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

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