bastd.ui.settings.audio
Provides audio settings UI.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Provides audio settings UI.""" 4 5from __future__ import annotations 6 7from typing import TYPE_CHECKING 8 9import _ba 10import ba 11 12if TYPE_CHECKING: 13 pass 14 15 16class AudioSettingsWindow(ba.Window): 17 """Window for editing audio settings.""" 18 19 def __init__(self, 20 transition: str = 'in_right', 21 origin_widget: ba.Widget | None = None): 22 # pylint: disable=too-many-statements 23 # pylint: disable=too-many-locals 24 # pylint: disable=cyclic-import 25 from bastd.ui.popup import PopupMenu 26 from bastd.ui.config import ConfigNumberEdit 27 28 music = ba.app.music 29 30 # If they provided an origin-widget, scale up from that. 31 scale_origin: tuple[float, float] | None 32 if origin_widget is not None: 33 self._transition_out = 'out_scale' 34 scale_origin = origin_widget.get_screen_space_center() 35 transition = 'in_scale' 36 else: 37 self._transition_out = 'out_right' 38 scale_origin = None 39 40 self._r = 'audioSettingsWindow' 41 42 spacing = 50.0 43 width = 460.0 44 height = 210.0 45 46 # Update: hard-coding head-relative audio to true now, 47 # so not showing options. 48 # show_vr_head_relative_audio = True if ba.app.vr_mode else False 49 show_vr_head_relative_audio = False 50 51 if show_vr_head_relative_audio: 52 height += 70 53 54 show_soundtracks = False 55 if music.have_music_player(): 56 show_soundtracks = True 57 height += spacing * 2.0 58 59 uiscale = ba.app.ui.uiscale 60 base_scale = (2.05 if uiscale is ba.UIScale.SMALL else 61 1.6 if uiscale is ba.UIScale.MEDIUM else 1.0) 62 popup_menu_scale = base_scale * 1.2 63 64 super().__init__(root_widget=ba.containerwidget( 65 size=(width, height), 66 transition=transition, 67 scale=base_scale, 68 scale_origin_stack_offset=scale_origin, 69 stack_offset=(0, -20) if uiscale is ba.UIScale.SMALL else (0, 0))) 70 71 self._back_button = back_button = btn = ba.buttonwidget( 72 parent=self._root_widget, 73 position=(35, height - 55), 74 size=(120, 60), 75 scale=0.8, 76 text_scale=1.2, 77 label=ba.Lstr(resource='backText'), 78 button_type='back', 79 on_activate_call=self._back, 80 autoselect=True) 81 ba.containerwidget(edit=self._root_widget, cancel_button=btn) 82 v = height - 60 83 v -= spacing * 1.0 84 ba.textwidget(parent=self._root_widget, 85 position=(width * 0.5, height - 32), 86 size=(0, 0), 87 text=ba.Lstr(resource=self._r + '.titleText'), 88 color=ba.app.ui.title_color, 89 maxwidth=180, 90 h_align='center', 91 v_align='center') 92 93 ba.buttonwidget(edit=self._back_button, 94 button_type='backSmall', 95 size=(60, 60), 96 label=ba.charstr(ba.SpecialChar.BACK)) 97 98 self._sound_volume_numedit = svne = ConfigNumberEdit( 99 parent=self._root_widget, 100 position=(40, v), 101 xoffset=10, 102 configkey='Sound Volume', 103 displayname=ba.Lstr(resource=self._r + '.soundVolumeText'), 104 minval=0.0, 105 maxval=1.0, 106 increment=0.1) 107 if ba.app.ui.use_toolbars: 108 ba.widget(edit=svne.plusbutton, 109 right_widget=_ba.get_special_widget('party_button')) 110 v -= spacing 111 self._music_volume_numedit = ConfigNumberEdit( 112 parent=self._root_widget, 113 position=(40, v), 114 xoffset=10, 115 configkey='Music Volume', 116 displayname=ba.Lstr(resource=self._r + '.musicVolumeText'), 117 minval=0.0, 118 maxval=1.0, 119 increment=0.1, 120 callback=music.music_volume_changed, 121 changesound=False) 122 123 v -= 0.5 * spacing 124 125 self._vr_head_relative_audio_button: ba.Widget | None 126 if show_vr_head_relative_audio: 127 v -= 40 128 ba.textwidget(parent=self._root_widget, 129 position=(40, v + 24), 130 size=(0, 0), 131 text=ba.Lstr(resource=self._r + 132 '.headRelativeVRAudioText'), 133 color=(0.8, 0.8, 0.8), 134 maxwidth=230, 135 h_align='left', 136 v_align='center') 137 138 popup = PopupMenu( 139 parent=self._root_widget, 140 position=(290, v), 141 width=120, 142 button_size=(135, 50), 143 scale=popup_menu_scale, 144 choices=['Auto', 'On', 'Off'], 145 choices_display=[ 146 ba.Lstr(resource='autoText'), 147 ba.Lstr(resource='onText'), 148 ba.Lstr(resource='offText') 149 ], 150 current_choice=ba.app.config.resolve('VR Head Relative Audio'), 151 on_value_change_call=self._set_vr_head_relative_audio) 152 self._vr_head_relative_audio_button = popup.get_button() 153 ba.textwidget(parent=self._root_widget, 154 position=(width * 0.5, v - 11), 155 size=(0, 0), 156 text=ba.Lstr(resource=self._r + 157 '.headRelativeVRAudioInfoText'), 158 scale=0.5, 159 color=(0.7, 0.8, 0.7), 160 maxwidth=400, 161 flatness=1.0, 162 h_align='center', 163 v_align='center') 164 v -= 30 165 else: 166 self._vr_head_relative_audio_button = None 167 168 self._soundtrack_button: ba.Widget | None 169 if show_soundtracks: 170 v -= 1.2 * spacing 171 self._soundtrack_button = ba.buttonwidget( 172 parent=self._root_widget, 173 position=((width - 310) / 2, v), 174 size=(310, 50), 175 autoselect=True, 176 label=ba.Lstr(resource=self._r + '.soundtrackButtonText'), 177 on_activate_call=self._do_soundtracks) 178 v -= spacing * 0.5 179 ba.textwidget(parent=self._root_widget, 180 position=(0, v), 181 size=(width, 20), 182 text=ba.Lstr(resource=self._r + 183 '.soundtrackDescriptionText'), 184 flatness=1.0, 185 h_align='center', 186 scale=0.5, 187 color=(0.7, 0.8, 0.7, 1.0), 188 maxwidth=400) 189 else: 190 self._soundtrack_button = None 191 192 # Tweak a few navigation bits. 193 try: 194 ba.widget(edit=back_button, down_widget=svne.minusbutton) 195 except Exception: 196 ba.print_exception('Error wiring AudioSettingsWindow.') 197 198 self._restore_state() 199 200 def _set_vr_head_relative_audio(self, val: str) -> None: 201 cfg = ba.app.config 202 cfg['VR Head Relative Audio'] = val 203 cfg.apply_and_commit() 204 205 def _do_soundtracks(self) -> None: 206 # pylint: disable=cyclic-import 207 from bastd.ui.soundtrack import browser as stb 208 209 # We require disk access for soundtracks; 210 # if we don't have it, request it. 211 if not _ba.have_permission(ba.Permission.STORAGE): 212 ba.playsound(ba.getsound('ding')) 213 ba.screenmessage(ba.Lstr(resource='storagePermissionAccessText'), 214 color=(0.5, 1, 0.5)) 215 ba.timer(1.0, 216 ba.Call(_ba.request_permission, ba.Permission.STORAGE), 217 timetype=ba.TimeType.REAL) 218 return 219 220 self._save_state() 221 ba.containerwidget(edit=self._root_widget, transition='out_left') 222 ba.app.ui.set_main_menu_window( 223 stb.SoundtrackBrowserWindow( 224 origin_widget=self._soundtrack_button).get_root_widget()) 225 226 def _back(self) -> None: 227 # pylint: disable=cyclic-import 228 from bastd.ui.settings import allsettings 229 self._save_state() 230 ba.containerwidget(edit=self._root_widget, 231 transition=self._transition_out) 232 ba.app.ui.set_main_menu_window( 233 allsettings.AllSettingsWindow( 234 transition='in_left').get_root_widget()) 235 236 def _save_state(self) -> None: 237 try: 238 sel = self._root_widget.get_selected_child() 239 if sel == self._sound_volume_numedit.minusbutton: 240 sel_name = 'SoundMinus' 241 elif sel == self._sound_volume_numedit.plusbutton: 242 sel_name = 'SoundPlus' 243 elif sel == self._music_volume_numedit.minusbutton: 244 sel_name = 'MusicMinus' 245 elif sel == self._music_volume_numedit.plusbutton: 246 sel_name = 'MusicPlus' 247 elif sel == self._soundtrack_button: 248 sel_name = 'Soundtrack' 249 elif sel == self._back_button: 250 sel_name = 'Back' 251 elif sel == self._vr_head_relative_audio_button: 252 sel_name = 'VRHeadRelative' 253 else: 254 raise ValueError(f'unrecognized selection \'{sel}\'') 255 ba.app.ui.window_states[type(self)] = sel_name 256 except Exception: 257 ba.print_exception(f'Error saving state for {self.__class__}.') 258 259 def _restore_state(self) -> None: 260 try: 261 sel_name = ba.app.ui.window_states.get(type(self)) 262 sel: ba.Widget | None 263 if sel_name == 'SoundMinus': 264 sel = self._sound_volume_numedit.minusbutton 265 elif sel_name == 'SoundPlus': 266 sel = self._sound_volume_numedit.plusbutton 267 elif sel_name == 'MusicMinus': 268 sel = self._music_volume_numedit.minusbutton 269 elif sel_name == 'MusicPlus': 270 sel = self._music_volume_numedit.plusbutton 271 elif sel_name == 'VRHeadRelative': 272 sel = self._vr_head_relative_audio_button 273 elif sel_name == 'Soundtrack': 274 sel = self._soundtrack_button 275 elif sel_name == 'Back': 276 sel = self._back_button 277 else: 278 sel = self._back_button 279 if sel: 280 ba.containerwidget(edit=self._root_widget, selected_child=sel) 281 except Exception: 282 ba.print_exception(f'Error restoring state for {self.__class__}.')
class
AudioSettingsWindow(ba.ui.Window):
17class AudioSettingsWindow(ba.Window): 18 """Window for editing audio settings.""" 19 20 def __init__(self, 21 transition: str = 'in_right', 22 origin_widget: ba.Widget | None = None): 23 # pylint: disable=too-many-statements 24 # pylint: disable=too-many-locals 25 # pylint: disable=cyclic-import 26 from bastd.ui.popup import PopupMenu 27 from bastd.ui.config import ConfigNumberEdit 28 29 music = ba.app.music 30 31 # If they provided an origin-widget, scale up from that. 32 scale_origin: tuple[float, float] | None 33 if origin_widget is not None: 34 self._transition_out = 'out_scale' 35 scale_origin = origin_widget.get_screen_space_center() 36 transition = 'in_scale' 37 else: 38 self._transition_out = 'out_right' 39 scale_origin = None 40 41 self._r = 'audioSettingsWindow' 42 43 spacing = 50.0 44 width = 460.0 45 height = 210.0 46 47 # Update: hard-coding head-relative audio to true now, 48 # so not showing options. 49 # show_vr_head_relative_audio = True if ba.app.vr_mode else False 50 show_vr_head_relative_audio = False 51 52 if show_vr_head_relative_audio: 53 height += 70 54 55 show_soundtracks = False 56 if music.have_music_player(): 57 show_soundtracks = True 58 height += spacing * 2.0 59 60 uiscale = ba.app.ui.uiscale 61 base_scale = (2.05 if uiscale is ba.UIScale.SMALL else 62 1.6 if uiscale is ba.UIScale.MEDIUM else 1.0) 63 popup_menu_scale = base_scale * 1.2 64 65 super().__init__(root_widget=ba.containerwidget( 66 size=(width, height), 67 transition=transition, 68 scale=base_scale, 69 scale_origin_stack_offset=scale_origin, 70 stack_offset=(0, -20) if uiscale is ba.UIScale.SMALL else (0, 0))) 71 72 self._back_button = back_button = btn = ba.buttonwidget( 73 parent=self._root_widget, 74 position=(35, height - 55), 75 size=(120, 60), 76 scale=0.8, 77 text_scale=1.2, 78 label=ba.Lstr(resource='backText'), 79 button_type='back', 80 on_activate_call=self._back, 81 autoselect=True) 82 ba.containerwidget(edit=self._root_widget, cancel_button=btn) 83 v = height - 60 84 v -= spacing * 1.0 85 ba.textwidget(parent=self._root_widget, 86 position=(width * 0.5, height - 32), 87 size=(0, 0), 88 text=ba.Lstr(resource=self._r + '.titleText'), 89 color=ba.app.ui.title_color, 90 maxwidth=180, 91 h_align='center', 92 v_align='center') 93 94 ba.buttonwidget(edit=self._back_button, 95 button_type='backSmall', 96 size=(60, 60), 97 label=ba.charstr(ba.SpecialChar.BACK)) 98 99 self._sound_volume_numedit = svne = ConfigNumberEdit( 100 parent=self._root_widget, 101 position=(40, v), 102 xoffset=10, 103 configkey='Sound Volume', 104 displayname=ba.Lstr(resource=self._r + '.soundVolumeText'), 105 minval=0.0, 106 maxval=1.0, 107 increment=0.1) 108 if ba.app.ui.use_toolbars: 109 ba.widget(edit=svne.plusbutton, 110 right_widget=_ba.get_special_widget('party_button')) 111 v -= spacing 112 self._music_volume_numedit = ConfigNumberEdit( 113 parent=self._root_widget, 114 position=(40, v), 115 xoffset=10, 116 configkey='Music Volume', 117 displayname=ba.Lstr(resource=self._r + '.musicVolumeText'), 118 minval=0.0, 119 maxval=1.0, 120 increment=0.1, 121 callback=music.music_volume_changed, 122 changesound=False) 123 124 v -= 0.5 * spacing 125 126 self._vr_head_relative_audio_button: ba.Widget | None 127 if show_vr_head_relative_audio: 128 v -= 40 129 ba.textwidget(parent=self._root_widget, 130 position=(40, v + 24), 131 size=(0, 0), 132 text=ba.Lstr(resource=self._r + 133 '.headRelativeVRAudioText'), 134 color=(0.8, 0.8, 0.8), 135 maxwidth=230, 136 h_align='left', 137 v_align='center') 138 139 popup = PopupMenu( 140 parent=self._root_widget, 141 position=(290, v), 142 width=120, 143 button_size=(135, 50), 144 scale=popup_menu_scale, 145 choices=['Auto', 'On', 'Off'], 146 choices_display=[ 147 ba.Lstr(resource='autoText'), 148 ba.Lstr(resource='onText'), 149 ba.Lstr(resource='offText') 150 ], 151 current_choice=ba.app.config.resolve('VR Head Relative Audio'), 152 on_value_change_call=self._set_vr_head_relative_audio) 153 self._vr_head_relative_audio_button = popup.get_button() 154 ba.textwidget(parent=self._root_widget, 155 position=(width * 0.5, v - 11), 156 size=(0, 0), 157 text=ba.Lstr(resource=self._r + 158 '.headRelativeVRAudioInfoText'), 159 scale=0.5, 160 color=(0.7, 0.8, 0.7), 161 maxwidth=400, 162 flatness=1.0, 163 h_align='center', 164 v_align='center') 165 v -= 30 166 else: 167 self._vr_head_relative_audio_button = None 168 169 self._soundtrack_button: ba.Widget | None 170 if show_soundtracks: 171 v -= 1.2 * spacing 172 self._soundtrack_button = ba.buttonwidget( 173 parent=self._root_widget, 174 position=((width - 310) / 2, v), 175 size=(310, 50), 176 autoselect=True, 177 label=ba.Lstr(resource=self._r + '.soundtrackButtonText'), 178 on_activate_call=self._do_soundtracks) 179 v -= spacing * 0.5 180 ba.textwidget(parent=self._root_widget, 181 position=(0, v), 182 size=(width, 20), 183 text=ba.Lstr(resource=self._r + 184 '.soundtrackDescriptionText'), 185 flatness=1.0, 186 h_align='center', 187 scale=0.5, 188 color=(0.7, 0.8, 0.7, 1.0), 189 maxwidth=400) 190 else: 191 self._soundtrack_button = None 192 193 # Tweak a few navigation bits. 194 try: 195 ba.widget(edit=back_button, down_widget=svne.minusbutton) 196 except Exception: 197 ba.print_exception('Error wiring AudioSettingsWindow.') 198 199 self._restore_state() 200 201 def _set_vr_head_relative_audio(self, val: str) -> None: 202 cfg = ba.app.config 203 cfg['VR Head Relative Audio'] = val 204 cfg.apply_and_commit() 205 206 def _do_soundtracks(self) -> None: 207 # pylint: disable=cyclic-import 208 from bastd.ui.soundtrack import browser as stb 209 210 # We require disk access for soundtracks; 211 # if we don't have it, request it. 212 if not _ba.have_permission(ba.Permission.STORAGE): 213 ba.playsound(ba.getsound('ding')) 214 ba.screenmessage(ba.Lstr(resource='storagePermissionAccessText'), 215 color=(0.5, 1, 0.5)) 216 ba.timer(1.0, 217 ba.Call(_ba.request_permission, ba.Permission.STORAGE), 218 timetype=ba.TimeType.REAL) 219 return 220 221 self._save_state() 222 ba.containerwidget(edit=self._root_widget, transition='out_left') 223 ba.app.ui.set_main_menu_window( 224 stb.SoundtrackBrowserWindow( 225 origin_widget=self._soundtrack_button).get_root_widget()) 226 227 def _back(self) -> None: 228 # pylint: disable=cyclic-import 229 from bastd.ui.settings import allsettings 230 self._save_state() 231 ba.containerwidget(edit=self._root_widget, 232 transition=self._transition_out) 233 ba.app.ui.set_main_menu_window( 234 allsettings.AllSettingsWindow( 235 transition='in_left').get_root_widget()) 236 237 def _save_state(self) -> None: 238 try: 239 sel = self._root_widget.get_selected_child() 240 if sel == self._sound_volume_numedit.minusbutton: 241 sel_name = 'SoundMinus' 242 elif sel == self._sound_volume_numedit.plusbutton: 243 sel_name = 'SoundPlus' 244 elif sel == self._music_volume_numedit.minusbutton: 245 sel_name = 'MusicMinus' 246 elif sel == self._music_volume_numedit.plusbutton: 247 sel_name = 'MusicPlus' 248 elif sel == self._soundtrack_button: 249 sel_name = 'Soundtrack' 250 elif sel == self._back_button: 251 sel_name = 'Back' 252 elif sel == self._vr_head_relative_audio_button: 253 sel_name = 'VRHeadRelative' 254 else: 255 raise ValueError(f'unrecognized selection \'{sel}\'') 256 ba.app.ui.window_states[type(self)] = sel_name 257 except Exception: 258 ba.print_exception(f'Error saving state for {self.__class__}.') 259 260 def _restore_state(self) -> None: 261 try: 262 sel_name = ba.app.ui.window_states.get(type(self)) 263 sel: ba.Widget | None 264 if sel_name == 'SoundMinus': 265 sel = self._sound_volume_numedit.minusbutton 266 elif sel_name == 'SoundPlus': 267 sel = self._sound_volume_numedit.plusbutton 268 elif sel_name == 'MusicMinus': 269 sel = self._music_volume_numedit.minusbutton 270 elif sel_name == 'MusicPlus': 271 sel = self._music_volume_numedit.plusbutton 272 elif sel_name == 'VRHeadRelative': 273 sel = self._vr_head_relative_audio_button 274 elif sel_name == 'Soundtrack': 275 sel = self._soundtrack_button 276 elif sel_name == 'Back': 277 sel = self._back_button 278 else: 279 sel = self._back_button 280 if sel: 281 ba.containerwidget(edit=self._root_widget, selected_child=sel) 282 except Exception: 283 ba.print_exception(f'Error restoring state for {self.__class__}.')
Window for editing audio settings.
AudioSettingsWindow( transition: str = 'in_right', origin_widget: _ba.Widget | None = None)
20 def __init__(self, 21 transition: str = 'in_right', 22 origin_widget: ba.Widget | None = None): 23 # pylint: disable=too-many-statements 24 # pylint: disable=too-many-locals 25 # pylint: disable=cyclic-import 26 from bastd.ui.popup import PopupMenu 27 from bastd.ui.config import ConfigNumberEdit 28 29 music = ba.app.music 30 31 # If they provided an origin-widget, scale up from that. 32 scale_origin: tuple[float, float] | None 33 if origin_widget is not None: 34 self._transition_out = 'out_scale' 35 scale_origin = origin_widget.get_screen_space_center() 36 transition = 'in_scale' 37 else: 38 self._transition_out = 'out_right' 39 scale_origin = None 40 41 self._r = 'audioSettingsWindow' 42 43 spacing = 50.0 44 width = 460.0 45 height = 210.0 46 47 # Update: hard-coding head-relative audio to true now, 48 # so not showing options. 49 # show_vr_head_relative_audio = True if ba.app.vr_mode else False 50 show_vr_head_relative_audio = False 51 52 if show_vr_head_relative_audio: 53 height += 70 54 55 show_soundtracks = False 56 if music.have_music_player(): 57 show_soundtracks = True 58 height += spacing * 2.0 59 60 uiscale = ba.app.ui.uiscale 61 base_scale = (2.05 if uiscale is ba.UIScale.SMALL else 62 1.6 if uiscale is ba.UIScale.MEDIUM else 1.0) 63 popup_menu_scale = base_scale * 1.2 64 65 super().__init__(root_widget=ba.containerwidget( 66 size=(width, height), 67 transition=transition, 68 scale=base_scale, 69 scale_origin_stack_offset=scale_origin, 70 stack_offset=(0, -20) if uiscale is ba.UIScale.SMALL else (0, 0))) 71 72 self._back_button = back_button = btn = ba.buttonwidget( 73 parent=self._root_widget, 74 position=(35, height - 55), 75 size=(120, 60), 76 scale=0.8, 77 text_scale=1.2, 78 label=ba.Lstr(resource='backText'), 79 button_type='back', 80 on_activate_call=self._back, 81 autoselect=True) 82 ba.containerwidget(edit=self._root_widget, cancel_button=btn) 83 v = height - 60 84 v -= spacing * 1.0 85 ba.textwidget(parent=self._root_widget, 86 position=(width * 0.5, height - 32), 87 size=(0, 0), 88 text=ba.Lstr(resource=self._r + '.titleText'), 89 color=ba.app.ui.title_color, 90 maxwidth=180, 91 h_align='center', 92 v_align='center') 93 94 ba.buttonwidget(edit=self._back_button, 95 button_type='backSmall', 96 size=(60, 60), 97 label=ba.charstr(ba.SpecialChar.BACK)) 98 99 self._sound_volume_numedit = svne = ConfigNumberEdit( 100 parent=self._root_widget, 101 position=(40, v), 102 xoffset=10, 103 configkey='Sound Volume', 104 displayname=ba.Lstr(resource=self._r + '.soundVolumeText'), 105 minval=0.0, 106 maxval=1.0, 107 increment=0.1) 108 if ba.app.ui.use_toolbars: 109 ba.widget(edit=svne.plusbutton, 110 right_widget=_ba.get_special_widget('party_button')) 111 v -= spacing 112 self._music_volume_numedit = ConfigNumberEdit( 113 parent=self._root_widget, 114 position=(40, v), 115 xoffset=10, 116 configkey='Music Volume', 117 displayname=ba.Lstr(resource=self._r + '.musicVolumeText'), 118 minval=0.0, 119 maxval=1.0, 120 increment=0.1, 121 callback=music.music_volume_changed, 122 changesound=False) 123 124 v -= 0.5 * spacing 125 126 self._vr_head_relative_audio_button: ba.Widget | None 127 if show_vr_head_relative_audio: 128 v -= 40 129 ba.textwidget(parent=self._root_widget, 130 position=(40, v + 24), 131 size=(0, 0), 132 text=ba.Lstr(resource=self._r + 133 '.headRelativeVRAudioText'), 134 color=(0.8, 0.8, 0.8), 135 maxwidth=230, 136 h_align='left', 137 v_align='center') 138 139 popup = PopupMenu( 140 parent=self._root_widget, 141 position=(290, v), 142 width=120, 143 button_size=(135, 50), 144 scale=popup_menu_scale, 145 choices=['Auto', 'On', 'Off'], 146 choices_display=[ 147 ba.Lstr(resource='autoText'), 148 ba.Lstr(resource='onText'), 149 ba.Lstr(resource='offText') 150 ], 151 current_choice=ba.app.config.resolve('VR Head Relative Audio'), 152 on_value_change_call=self._set_vr_head_relative_audio) 153 self._vr_head_relative_audio_button = popup.get_button() 154 ba.textwidget(parent=self._root_widget, 155 position=(width * 0.5, v - 11), 156 size=(0, 0), 157 text=ba.Lstr(resource=self._r + 158 '.headRelativeVRAudioInfoText'), 159 scale=0.5, 160 color=(0.7, 0.8, 0.7), 161 maxwidth=400, 162 flatness=1.0, 163 h_align='center', 164 v_align='center') 165 v -= 30 166 else: 167 self._vr_head_relative_audio_button = None 168 169 self._soundtrack_button: ba.Widget | None 170 if show_soundtracks: 171 v -= 1.2 * spacing 172 self._soundtrack_button = ba.buttonwidget( 173 parent=self._root_widget, 174 position=((width - 310) / 2, v), 175 size=(310, 50), 176 autoselect=True, 177 label=ba.Lstr(resource=self._r + '.soundtrackButtonText'), 178 on_activate_call=self._do_soundtracks) 179 v -= spacing * 0.5 180 ba.textwidget(parent=self._root_widget, 181 position=(0, v), 182 size=(width, 20), 183 text=ba.Lstr(resource=self._r + 184 '.soundtrackDescriptionText'), 185 flatness=1.0, 186 h_align='center', 187 scale=0.5, 188 color=(0.7, 0.8, 0.7, 1.0), 189 maxwidth=400) 190 else: 191 self._soundtrack_button = None 192 193 # Tweak a few navigation bits. 194 try: 195 ba.widget(edit=back_button, down_widget=svne.minusbutton) 196 except Exception: 197 ba.print_exception('Error wiring AudioSettingsWindow.') 198 199 self._restore_state()
Inherited Members
- ba.ui.Window
- get_root_widget