def __init__( self, gamepad: ba.InputDevice, button: str, callback: Callable[[str, Dict[str, Any], AwaitGamepadInputWindow], Any], message: ba.Lstr = None, message2: ba.Lstr = None): if message is None: print('AwaitGamepadInputWindow message is None!') # Shouldn't get here. message = ba.Lstr(value='Press any button...') self._callback = callback self._input = gamepad self._capture_button = button width = 400 height = 150 uiscale = ba.app.ui.uiscale super().__init__(root_widget=ba.containerwidget( scale=(2.0 if uiscale is ba.UIScale.SMALL else 1.9 if uiscale is ba.UIScale.MEDIUM else 1.0), size=(width, height), transition='in_scale'), ) ba.textwidget(parent=self._root_widget, position=(0, (height - 60) if message2 is None else (height - 50)), size=(width, 25), text=message, maxwidth=width * 0.9, h_align='center', v_align='center') if message2 is not None: ba.textwidget(parent=self._root_widget, position=(width * 0.5, height - 60), size=(0, 0), text=message2, maxwidth=width * 0.9, scale=0.47, color=(0.7, 1.0, 0.7, 0.6), h_align='center', v_align='center') self._counter = 5 self._count_down_text = ba.textwidget(parent=self._root_widget, h_align='center', position=(0, height - 110), size=(width, 25), color=(1, 1, 1, 0.3), text=str(self._counter)) self._decrement_timer: Optional[ba.Timer] = ba.Timer( 1.0, ba.Call(self._decrement), repeat=True, timetype=ba.TimeType.REAL) _ba.capture_gamepad_input(ba.WeakCall(self._event_callback))
def __init__(self) -> None: from typing import cast width = 480 height = 170 spacing = 40 self._r = 'configGamepadSelectWindow' uiscale = ba.app.uiscale super().__init__(root_widget=ba.containerwidget( scale=(2.3 if uiscale is ba.UIScale.SMALL else 1.5 if uiscale is ba.UIScale.MEDIUM else 1.0), size=(width, height), transition='in_right', )) btn = ba.buttonwidget(parent=self._root_widget, position=(20, height - 60), size=(130, 60), label=ba.Lstr(resource='backText'), button_type='back', scale=0.8, on_activate_call=self._back) # Let's not have anything selected by default; its misleading looking # for the controller getting configured. ba.containerwidget(edit=self._root_widget, cancel_button=btn, selected_child=cast(ba.Widget, 0)) ba.textwidget(parent=self._root_widget, position=(20, height - 50), size=(width, 25), text=ba.Lstr(resource=self._r + '.titleText'), maxwidth=250, color=ba.app.title_color, h_align='center', v_align='center') ba.buttonwidget(edit=btn, button_type='backSmall', size=(60, 60), label=ba.charstr(ba.SpecialChar.BACK)) v: float = height - 60 v -= spacing ba.textwidget(parent=self._root_widget, position=(15, v), size=(width - 30, 30), scale=0.8, text=ba.Lstr(resource=self._r + '.pressAnyButtonText'), maxwidth=width * 0.95, color=ba.app.infotextcolor, h_align='center', v_align='top') v -= spacing * 1.24 if ba.app.platform == 'android': ba.textwidget(parent=self._root_widget, position=(15, v), size=(width - 30, 30), scale=0.46, text=ba.Lstr(resource=self._r + '.androidNoteText'), maxwidth=width * 0.95, color=(0.7, 0.9, 0.7, 0.5), h_align='center', v_align='top') _ba.capture_gamepad_input(gamepad_configure_callback)