def _build_gui(self) -> None: from bastd.ui import config as cfgui from bastd.ui import radiogroup # clear anything already there children = self._subcontainer.get_children() for child in children: child.delete() h = 30 v = self._sub_height - 85 clr = (0.8, 0.8, 0.8, 1.0) clr2 = (0.8, 0.8, 0.8) ba.textwidget(parent=self._subcontainer, position=(-10, v + 43), size=(self._sub_width, 25), text=ba.Lstr(resource=self._r + '.swipeInfoText'), flatness=1.0, color=(0, 0.9, 0.1, 0.7), maxwidth=self._sub_width * 0.9, scale=0.55, h_align='center', v_align='center') cur_val = ba.app.config.get('Touch Movement Control Type', 'swipe') ba.textwidget(parent=self._subcontainer, position=(h, v - 2), size=(0, 30), text=ba.Lstr(resource=self._r + '.movementText'), maxwidth=190, color=clr, v_align='center') cb1 = ba.checkboxwidget(parent=self._subcontainer, position=(h + 220, v), size=(170, 30), text=ba.Lstr(resource=self._r + '.joystickText'), maxwidth=100, textcolor=clr2, scale=0.9) cb2 = ba.checkboxwidget(parent=self._subcontainer, position=(h + 357, v), size=(170, 30), text=ba.Lstr(resource=self._r + '.swipeText'), maxwidth=100, textcolor=clr2, value=False, scale=0.9) radiogroup.make_radio_group((cb1, cb2), ('joystick', 'swipe'), cur_val, self._movement_changed) v -= 50 cfgui.ConfigNumberEdit( parent=self._subcontainer, position=(h, v), xoffset=65, configkey='Touch Controls Scale Movement', displayname=ba.Lstr(resource=self._r + '.movementControlScaleText'), changesound=False, minval=0.1, maxval=4.0, increment=0.1) v -= 50 cur_val = ba.app.config.get('Touch Action Control Type', 'buttons') ba.textwidget(parent=self._subcontainer, position=(h, v - 2), size=(0, 30), text=ba.Lstr(resource=self._r + '.actionsText'), maxwidth=190, color=clr, v_align='center') cb1 = ba.checkboxwidget(parent=self._subcontainer, position=(h + 220, v), size=(170, 30), text=ba.Lstr(resource=self._r + '.buttonsText'), maxwidth=100, textcolor=clr2, scale=0.9) cb2 = ba.checkboxwidget(parent=self._subcontainer, position=(h + 357, v), size=(170, 30), text=ba.Lstr(resource=self._r + '.swipeText'), maxwidth=100, textcolor=clr2, scale=0.9) radiogroup.make_radio_group((cb1, cb2), ('buttons', 'swipe'), cur_val, self._actions_changed) v -= 50 cfgui.ConfigNumberEdit(parent=self._subcontainer, position=(h, v), xoffset=65, configkey='Touch Controls Scale Actions', displayname=ba.Lstr(resource=self._r + '.actionControlScaleText'), changesound=False, minval=0.1, maxval=4.0, increment=0.1) v -= 50 cfgui.ConfigCheckBox(parent=self._subcontainer, position=(h, v), size=(400, 30), maxwidth=400, configkey='Touch Controls Swipe Hidden', displayname=ba.Lstr(resource=self._r + '.swipeControlsHiddenText')) v -= 65 ba.buttonwidget(parent=self._subcontainer, position=(self._sub_width * 0.5 - 70, v), size=(170, 60), label=ba.Lstr(resource=self._r + '.resetText'), scale=0.75, on_activate_call=self._reset) ba.textwidget(parent=self._root_widget, position=(self._width * 0.5, 38), size=(0, 0), h_align='center', text=ba.Lstr(resource=self._r + '.dragControlsText'), maxwidth=self._width * 0.8, scale=0.65, color=(1, 1, 1, 0.4))
def __init__(self, transition: str = 'in_right', origin_widget: ba.Widget = None): # pylint: disable=too-many-statements # pylint: disable=too-many-locals # pylint: disable=cyclic-import from ba.internal import have_music_player, music_volume_changed from bastd.ui import popup as popup_ui from bastd.ui import config as cfgui # If they provided an origin-widget, scale up from that. scale_origin: Optional[Tuple[float, float]] if origin_widget is not None: self._transition_out = 'out_scale' scale_origin = origin_widget.get_screen_space_center() transition = 'in_scale' else: self._transition_out = 'out_right' scale_origin = None self._r = 'audioSettingsWindow' spacing = 50.0 width = 460.0 height = 210.0 # Update: hard-coding head-relative audio to true now, so not showing # options. # show_vr_head_relative_audio = True if ba.app.vr_mode else False show_vr_head_relative_audio = False if show_vr_head_relative_audio: height += 70 show_soundtracks = False if have_music_player(): show_soundtracks = True height += spacing * 2.0 base_scale = (2.05 if ba.app.small_ui else 1.6 if ba.app.med_ui else 1.0) popup_menu_scale = base_scale * 1.2 super().__init__(root_widget=ba.containerwidget( size=(width, height), transition=transition, scale=base_scale, scale_origin_stack_offset=scale_origin, stack_offset=(0, -20) if ba.app.small_ui else (0, 0))) self._back_button = back_button = btn = ba.buttonwidget( parent=self._root_widget, position=(35, height - 55), size=(120, 60), scale=0.8, text_scale=1.2, label=ba.Lstr(resource='backText'), button_type='back', on_activate_call=self._back, autoselect=True) ba.containerwidget(edit=self._root_widget, cancel_button=btn) v = height - 60 v -= spacing * 1.0 ba.textwidget(parent=self._root_widget, position=(width * 0.5, height - 32), size=(0, 0), text=ba.Lstr(resource=self._r + '.titleText'), color=ba.app.title_color, maxwidth=180, h_align="center", v_align="center") ba.buttonwidget(edit=self._back_button, button_type='backSmall', size=(60, 60), label=ba.charstr(ba.SpecialChar.BACK)) self._sound_volume_numedit = svne = cfgui.ConfigNumberEdit( parent=self._root_widget, position=(40, v), xoffset=10, configkey="Sound Volume", displayname=ba.Lstr(resource=self._r + '.soundVolumeText'), minval=0.0, maxval=1.0, increment=0.1) if ba.app.toolbars: ba.widget(edit=svne.plusbutton, right_widget=_ba.get_special_widget('party_button')) v -= spacing self._music_volume_numedit = cfgui.ConfigNumberEdit( parent=self._root_widget, position=(40, v), xoffset=10, configkey="Music Volume", displayname=ba.Lstr(resource=self._r + '.musicVolumeText'), minval=0.0, maxval=1.0, increment=0.1, callback=music_volume_changed, changesound=False) v -= 0.5 * spacing self._vr_head_relative_audio_button: Optional[ba.Widget] if show_vr_head_relative_audio: v -= 40 ba.textwidget(parent=self._root_widget, position=(40, v + 24), size=(0, 0), text=ba.Lstr(resource=self._r + '.headRelativeVRAudioText'), color=(0.8, 0.8, 0.8), maxwidth=230, h_align="left", v_align="center") popup = popup_ui.PopupMenu( parent=self._root_widget, position=(290, v), width=120, button_size=(135, 50), scale=popup_menu_scale, choices=['Auto', 'On', 'Off'], choices_display=[ ba.Lstr(resource='autoText'), ba.Lstr(resource='onText'), ba.Lstr(resource='offText') ], current_choice=ba.app.config.resolve('VR Head Relative Audio'), on_value_change_call=self._set_vr_head_relative_audio) self._vr_head_relative_audio_button = popup.get_button() ba.textwidget(parent=self._root_widget, position=(width * 0.5, v - 11), size=(0, 0), text=ba.Lstr(resource=self._r + '.headRelativeVRAudioInfoText'), scale=0.5, color=(0.7, 0.8, 0.7), maxwidth=400, flatness=1.0, h_align="center", v_align="center") v -= 30 else: self._vr_head_relative_audio_button = None self._soundtrack_button: Optional[ba.Widget] if show_soundtracks: v -= 1.2 * spacing self._soundtrack_button = ba.buttonwidget( parent=self._root_widget, position=((width - 310) / 2, v), size=(310, 50), autoselect=True, label=ba.Lstr(resource=self._r + '.soundtrackButtonText'), on_activate_call=self._do_soundtracks) v -= spacing * 0.5 ba.textwidget(parent=self._root_widget, position=(0, v), size=(width, 20), text=ba.Lstr(resource=self._r + '.soundtrackDescriptionText'), flatness=1.0, h_align='center', scale=0.5, color=(0.7, 0.8, 0.7, 1.0), maxwidth=400) else: self._soundtrack_button = None # tweak a few navigation bits try: ba.widget(edit=back_button, down_widget=svne.minusbutton) except Exception: ba.print_exception('error wiring AudioSettingsWindow') self._restore_state()