bastd.ui.settings.xbox360controller

UI functionality related to using xbox360 controllers.

  1# Released under the MIT License. See LICENSE for details.
  2#
  3"""UI functionality related to using xbox360 controllers."""
  4
  5from __future__ import annotations
  6
  7from typing import TYPE_CHECKING
  8
  9import ba
 10import ba.internal
 11
 12if TYPE_CHECKING:
 13    pass
 14
 15
 16class XBox360ControllerSettingsWindow(ba.Window):
 17    """UI showing info about xbox 360 controllers."""
 18
 19    def __init__(self) -> None:
 20        self._r = 'xbox360ControllersWindow'
 21        width = 700
 22        height = 300 if ba.internal.is_running_on_fire_tv() else 485
 23        spacing = 40
 24        uiscale = ba.app.ui.uiscale
 25        super().__init__(
 26            root_widget=ba.containerwidget(
 27                size=(width, height),
 28                transition='in_right',
 29                scale=(
 30                    1.4
 31                    if uiscale is ba.UIScale.SMALL
 32                    else 1.4
 33                    if uiscale is ba.UIScale.MEDIUM
 34                    else 1.0
 35                ),
 36            )
 37        )
 38
 39        btn = ba.buttonwidget(
 40            parent=self._root_widget,
 41            position=(35, height - 65),
 42            size=(120, 60),
 43            scale=0.84,
 44            label=ba.Lstr(resource='backText'),
 45            button_type='back',
 46            autoselect=True,
 47            on_activate_call=self._back,
 48        )
 49        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 50
 51        ba.textwidget(
 52            parent=self._root_widget,
 53            position=(width * 0.5, height - 42),
 54            size=(0, 0),
 55            scale=0.85,
 56            text=ba.Lstr(
 57                resource=self._r + '.titleText',
 58                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
 59            ),
 60            color=ba.app.ui.title_color,
 61            maxwidth=400,
 62            h_align='center',
 63            v_align='center',
 64        )
 65
 66        ba.buttonwidget(
 67            edit=btn,
 68            button_type='backSmall',
 69            size=(60, 60),
 70            label=ba.charstr(ba.SpecialChar.BACK),
 71        )
 72
 73        v = height - 70
 74        v -= spacing
 75
 76        if ba.internal.is_running_on_fire_tv():
 77            ba.textwidget(
 78                parent=self._root_widget,
 79                position=(width * 0.5, height * 0.47),
 80                size=(0, 0),
 81                color=(0.7, 0.9, 0.7, 1.0),
 82                maxwidth=width * 0.95,
 83                max_height=height * 0.75,
 84                scale=0.7,
 85                text=ba.Lstr(resource=self._r + '.ouyaInstructionsText'),
 86                h_align='center',
 87                v_align='center',
 88            )
 89        else:
 90            ba.textwidget(
 91                parent=self._root_widget,
 92                position=(width * 0.5, v - 1),
 93                size=(0, 0),
 94                color=(0.7, 0.9, 0.7, 1.0),
 95                maxwidth=width * 0.95,
 96                max_height=height * 0.22,
 97                text=ba.Lstr(resource=self._r + '.macInstructionsText'),
 98                scale=0.7,
 99                h_align='center',
100                v_align='center',
101            )
102            v -= 90
103            b_width = 300
104            btn = ba.buttonwidget(
105                parent=self._root_widget,
106                position=((width - b_width) * 0.5, v - 10),
107                size=(b_width, 50),
108                label=ba.Lstr(resource=self._r + '.getDriverText'),
109                autoselect=True,
110                on_activate_call=ba.Call(
111                    ba.open_url,
112                    'https://github.com/360Controller/360Controller/releases',
113                ),
114            )
115            ba.containerwidget(edit=self._root_widget, start_button=btn)
116            v -= 60
117            ba.textwidget(
118                parent=self._root_widget,
119                position=(width * 0.5, v - 85),
120                size=(0, 0),
121                color=(0.7, 0.9, 0.7, 1.0),
122                maxwidth=width * 0.95,
123                max_height=height * 0.46,
124                scale=0.7,
125                text=ba.Lstr(resource=self._r + '.macInstructions2Text'),
126                h_align='center',
127                v_align='center',
128            )
129
130    def _back(self) -> None:
131        from bastd.ui.settings import controls
132
133        ba.containerwidget(edit=self._root_widget, transition='out_right')
134        ba.app.ui.set_main_menu_window(
135            controls.ControlsSettingsWindow(
136                transition='in_left'
137            ).get_root_widget()
138        )
class XBox360ControllerSettingsWindow(ba.ui.Window):
 17class XBox360ControllerSettingsWindow(ba.Window):
 18    """UI showing info about xbox 360 controllers."""
 19
 20    def __init__(self) -> None:
 21        self._r = 'xbox360ControllersWindow'
 22        width = 700
 23        height = 300 if ba.internal.is_running_on_fire_tv() else 485
 24        spacing = 40
 25        uiscale = ba.app.ui.uiscale
 26        super().__init__(
 27            root_widget=ba.containerwidget(
 28                size=(width, height),
 29                transition='in_right',
 30                scale=(
 31                    1.4
 32                    if uiscale is ba.UIScale.SMALL
 33                    else 1.4
 34                    if uiscale is ba.UIScale.MEDIUM
 35                    else 1.0
 36                ),
 37            )
 38        )
 39
 40        btn = ba.buttonwidget(
 41            parent=self._root_widget,
 42            position=(35, height - 65),
 43            size=(120, 60),
 44            scale=0.84,
 45            label=ba.Lstr(resource='backText'),
 46            button_type='back',
 47            autoselect=True,
 48            on_activate_call=self._back,
 49        )
 50        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 51
 52        ba.textwidget(
 53            parent=self._root_widget,
 54            position=(width * 0.5, height - 42),
 55            size=(0, 0),
 56            scale=0.85,
 57            text=ba.Lstr(
 58                resource=self._r + '.titleText',
 59                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
 60            ),
 61            color=ba.app.ui.title_color,
 62            maxwidth=400,
 63            h_align='center',
 64            v_align='center',
 65        )
 66
 67        ba.buttonwidget(
 68            edit=btn,
 69            button_type='backSmall',
 70            size=(60, 60),
 71            label=ba.charstr(ba.SpecialChar.BACK),
 72        )
 73
 74        v = height - 70
 75        v -= spacing
 76
 77        if ba.internal.is_running_on_fire_tv():
 78            ba.textwidget(
 79                parent=self._root_widget,
 80                position=(width * 0.5, height * 0.47),
 81                size=(0, 0),
 82                color=(0.7, 0.9, 0.7, 1.0),
 83                maxwidth=width * 0.95,
 84                max_height=height * 0.75,
 85                scale=0.7,
 86                text=ba.Lstr(resource=self._r + '.ouyaInstructionsText'),
 87                h_align='center',
 88                v_align='center',
 89            )
 90        else:
 91            ba.textwidget(
 92                parent=self._root_widget,
 93                position=(width * 0.5, v - 1),
 94                size=(0, 0),
 95                color=(0.7, 0.9, 0.7, 1.0),
 96                maxwidth=width * 0.95,
 97                max_height=height * 0.22,
 98                text=ba.Lstr(resource=self._r + '.macInstructionsText'),
 99                scale=0.7,
100                h_align='center',
101                v_align='center',
102            )
103            v -= 90
104            b_width = 300
105            btn = ba.buttonwidget(
106                parent=self._root_widget,
107                position=((width - b_width) * 0.5, v - 10),
108                size=(b_width, 50),
109                label=ba.Lstr(resource=self._r + '.getDriverText'),
110                autoselect=True,
111                on_activate_call=ba.Call(
112                    ba.open_url,
113                    'https://github.com/360Controller/360Controller/releases',
114                ),
115            )
116            ba.containerwidget(edit=self._root_widget, start_button=btn)
117            v -= 60
118            ba.textwidget(
119                parent=self._root_widget,
120                position=(width * 0.5, v - 85),
121                size=(0, 0),
122                color=(0.7, 0.9, 0.7, 1.0),
123                maxwidth=width * 0.95,
124                max_height=height * 0.46,
125                scale=0.7,
126                text=ba.Lstr(resource=self._r + '.macInstructions2Text'),
127                h_align='center',
128                v_align='center',
129            )
130
131    def _back(self) -> None:
132        from bastd.ui.settings import controls
133
134        ba.containerwidget(edit=self._root_widget, transition='out_right')
135        ba.app.ui.set_main_menu_window(
136            controls.ControlsSettingsWindow(
137                transition='in_left'
138            ).get_root_widget()
139        )

UI showing info about xbox 360 controllers.

XBox360ControllerSettingsWindow()
 20    def __init__(self) -> None:
 21        self._r = 'xbox360ControllersWindow'
 22        width = 700
 23        height = 300 if ba.internal.is_running_on_fire_tv() else 485
 24        spacing = 40
 25        uiscale = ba.app.ui.uiscale
 26        super().__init__(
 27            root_widget=ba.containerwidget(
 28                size=(width, height),
 29                transition='in_right',
 30                scale=(
 31                    1.4
 32                    if uiscale is ba.UIScale.SMALL
 33                    else 1.4
 34                    if uiscale is ba.UIScale.MEDIUM
 35                    else 1.0
 36                ),
 37            )
 38        )
 39
 40        btn = ba.buttonwidget(
 41            parent=self._root_widget,
 42            position=(35, height - 65),
 43            size=(120, 60),
 44            scale=0.84,
 45            label=ba.Lstr(resource='backText'),
 46            button_type='back',
 47            autoselect=True,
 48            on_activate_call=self._back,
 49        )
 50        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 51
 52        ba.textwidget(
 53            parent=self._root_widget,
 54            position=(width * 0.5, height - 42),
 55            size=(0, 0),
 56            scale=0.85,
 57            text=ba.Lstr(
 58                resource=self._r + '.titleText',
 59                subs=[('${APP_NAME}', ba.Lstr(resource='titleText'))],
 60            ),
 61            color=ba.app.ui.title_color,
 62            maxwidth=400,
 63            h_align='center',
 64            v_align='center',
 65        )
 66
 67        ba.buttonwidget(
 68            edit=btn,
 69            button_type='backSmall',
 70            size=(60, 60),
 71            label=ba.charstr(ba.SpecialChar.BACK),
 72        )
 73
 74        v = height - 70
 75        v -= spacing
 76
 77        if ba.internal.is_running_on_fire_tv():
 78            ba.textwidget(
 79                parent=self._root_widget,
 80                position=(width * 0.5, height * 0.47),
 81                size=(0, 0),
 82                color=(0.7, 0.9, 0.7, 1.0),
 83                maxwidth=width * 0.95,
 84                max_height=height * 0.75,
 85                scale=0.7,
 86                text=ba.Lstr(resource=self._r + '.ouyaInstructionsText'),
 87                h_align='center',
 88                v_align='center',
 89            )
 90        else:
 91            ba.textwidget(
 92                parent=self._root_widget,
 93                position=(width * 0.5, v - 1),
 94                size=(0, 0),
 95                color=(0.7, 0.9, 0.7, 1.0),
 96                maxwidth=width * 0.95,
 97                max_height=height * 0.22,
 98                text=ba.Lstr(resource=self._r + '.macInstructionsText'),
 99                scale=0.7,
100                h_align='center',
101                v_align='center',
102            )
103            v -= 90
104            b_width = 300
105            btn = ba.buttonwidget(
106                parent=self._root_widget,
107                position=((width - b_width) * 0.5, v - 10),
108                size=(b_width, 50),
109                label=ba.Lstr(resource=self._r + '.getDriverText'),
110                autoselect=True,
111                on_activate_call=ba.Call(
112                    ba.open_url,
113                    'https://github.com/360Controller/360Controller/releases',
114                ),
115            )
116            ba.containerwidget(edit=self._root_widget, start_button=btn)
117            v -= 60
118            ba.textwidget(
119                parent=self._root_widget,
120                position=(width * 0.5, v - 85),
121                size=(0, 0),
122                color=(0.7, 0.9, 0.7, 1.0),
123                maxwidth=width * 0.95,
124                max_height=height * 0.46,
125                scale=0.7,
126                text=ba.Lstr(resource=self._r + '.macInstructions2Text'),
127                h_align='center',
128                v_align='center',
129            )
Inherited Members
ba.ui.Window
get_root_widget