bastd.ui.settings.remoteapp

Settings UI functionality related to the remote app.

  1# Released under the MIT License. See LICENSE for details.
  2#
  3"""Settings UI functionality related to the remote app."""
  4
  5from __future__ import annotations
  6
  7import ba
  8
  9
 10class RemoteAppSettingsWindow(ba.Window):
 11    """Window showing info/settings related to the remote app."""
 12
 13    def __init__(self) -> None:
 14        from ba.internal import get_remote_app_name
 15        self._r = 'connectMobileDevicesWindow'
 16        width = 700
 17        height = 390
 18        spacing = 40
 19        uiscale = ba.app.ui.uiscale
 20        super().__init__(root_widget=ba.containerwidget(
 21            size=(width, height),
 22            transition='in_right',
 23            scale=(1.85 if uiscale is ba.UIScale.SMALL else
 24                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0),
 25            stack_offset=(-10, 0) if uiscale is ba.UIScale.SMALL else (0, 0)))
 26        btn = ba.buttonwidget(parent=self._root_widget,
 27                              position=(40, height - 67),
 28                              size=(140, 65),
 29                              scale=0.8,
 30                              label=ba.Lstr(resource='backText'),
 31                              button_type='back',
 32                              text_scale=1.1,
 33                              autoselect=True,
 34                              on_activate_call=self._back)
 35        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 36
 37        ba.textwidget(parent=self._root_widget,
 38                      position=(width * 0.5, height - 42),
 39                      size=(0, 0),
 40                      text=ba.Lstr(resource=self._r + '.titleText'),
 41                      maxwidth=370,
 42                      color=ba.app.ui.title_color,
 43                      scale=0.8,
 44                      h_align='center',
 45                      v_align='center')
 46
 47        ba.buttonwidget(edit=btn,
 48                        button_type='backSmall',
 49                        size=(60, 60),
 50                        label=ba.charstr(ba.SpecialChar.BACK))
 51
 52        v = height - 70.0
 53        v -= spacing * 1.2
 54        ba.textwidget(parent=self._root_widget,
 55                      position=(15, v - 26),
 56                      size=(width - 30, 30),
 57                      maxwidth=width * 0.95,
 58                      color=(0.7, 0.9, 0.7, 1.0),
 59                      scale=0.8,
 60                      text=ba.Lstr(resource=self._r + '.explanationText',
 61                                   subs=[('${APP_NAME}',
 62                                          ba.Lstr(resource='titleText')),
 63                                         ('${REMOTE_APP_NAME}',
 64                                          get_remote_app_name())]),
 65                      max_height=100,
 66                      h_align='center',
 67                      v_align='center')
 68        v -= 90
 69
 70        # hmm the itms:// version doesnt bounce through safari but is kinda
 71        # apple-specific-ish
 72
 73        # Update: now we just show link to the remote webpage.
 74        ba.textwidget(parent=self._root_widget,
 75                      position=(width * 0.5, v + 5),
 76                      size=(0, 0),
 77                      color=(0.7, 0.9, 0.7, 1.0),
 78                      scale=1.4,
 79                      text='bombsquadgame.com/remote',
 80                      maxwidth=width * 0.95,
 81                      max_height=60,
 82                      h_align='center',
 83                      v_align='center')
 84        v -= 30
 85
 86        ba.textwidget(parent=self._root_widget,
 87                      position=(width * 0.5, v - 35),
 88                      size=(0, 0),
 89                      color=(0.7, 0.9, 0.7, 0.8),
 90                      scale=0.65,
 91                      text=ba.Lstr(resource=self._r + '.bestResultsText'),
 92                      maxwidth=width * 0.95,
 93                      max_height=height * 0.19,
 94                      h_align='center',
 95                      v_align='center')
 96
 97        ba.checkboxwidget(
 98            parent=self._root_widget,
 99            position=(width * 0.5 - 150, v - 116),
100            size=(300, 30),
101            maxwidth=300,
102            scale=0.8,
103            value=not ba.app.config.resolve('Enable Remote App'),
104            autoselect=True,
105            text=ba.Lstr(resource='disableRemoteAppConnectionsText'),
106            on_value_change_call=self._on_check_changed)
107
108    def _on_check_changed(self, value: bool) -> None:
109        cfg = ba.app.config
110        cfg['Enable Remote App'] = not value
111        cfg.apply_and_commit()
112
113    def _back(self) -> None:
114        from bastd.ui.settings import controls
115        ba.containerwidget(edit=self._root_widget, transition='out_right')
116        ba.app.ui.set_main_menu_window(
117            controls.ControlsSettingsWindow(
118                transition='in_left').get_root_widget())
class RemoteAppSettingsWindow(ba.ui.Window):
 11class RemoteAppSettingsWindow(ba.Window):
 12    """Window showing info/settings related to the remote app."""
 13
 14    def __init__(self) -> None:
 15        from ba.internal import get_remote_app_name
 16        self._r = 'connectMobileDevicesWindow'
 17        width = 700
 18        height = 390
 19        spacing = 40
 20        uiscale = ba.app.ui.uiscale
 21        super().__init__(root_widget=ba.containerwidget(
 22            size=(width, height),
 23            transition='in_right',
 24            scale=(1.85 if uiscale is ba.UIScale.SMALL else
 25                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0),
 26            stack_offset=(-10, 0) if uiscale is ba.UIScale.SMALL else (0, 0)))
 27        btn = ba.buttonwidget(parent=self._root_widget,
 28                              position=(40, height - 67),
 29                              size=(140, 65),
 30                              scale=0.8,
 31                              label=ba.Lstr(resource='backText'),
 32                              button_type='back',
 33                              text_scale=1.1,
 34                              autoselect=True,
 35                              on_activate_call=self._back)
 36        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 37
 38        ba.textwidget(parent=self._root_widget,
 39                      position=(width * 0.5, height - 42),
 40                      size=(0, 0),
 41                      text=ba.Lstr(resource=self._r + '.titleText'),
 42                      maxwidth=370,
 43                      color=ba.app.ui.title_color,
 44                      scale=0.8,
 45                      h_align='center',
 46                      v_align='center')
 47
 48        ba.buttonwidget(edit=btn,
 49                        button_type='backSmall',
 50                        size=(60, 60),
 51                        label=ba.charstr(ba.SpecialChar.BACK))
 52
 53        v = height - 70.0
 54        v -= spacing * 1.2
 55        ba.textwidget(parent=self._root_widget,
 56                      position=(15, v - 26),
 57                      size=(width - 30, 30),
 58                      maxwidth=width * 0.95,
 59                      color=(0.7, 0.9, 0.7, 1.0),
 60                      scale=0.8,
 61                      text=ba.Lstr(resource=self._r + '.explanationText',
 62                                   subs=[('${APP_NAME}',
 63                                          ba.Lstr(resource='titleText')),
 64                                         ('${REMOTE_APP_NAME}',
 65                                          get_remote_app_name())]),
 66                      max_height=100,
 67                      h_align='center',
 68                      v_align='center')
 69        v -= 90
 70
 71        # hmm the itms:// version doesnt bounce through safari but is kinda
 72        # apple-specific-ish
 73
 74        # Update: now we just show link to the remote webpage.
 75        ba.textwidget(parent=self._root_widget,
 76                      position=(width * 0.5, v + 5),
 77                      size=(0, 0),
 78                      color=(0.7, 0.9, 0.7, 1.0),
 79                      scale=1.4,
 80                      text='bombsquadgame.com/remote',
 81                      maxwidth=width * 0.95,
 82                      max_height=60,
 83                      h_align='center',
 84                      v_align='center')
 85        v -= 30
 86
 87        ba.textwidget(parent=self._root_widget,
 88                      position=(width * 0.5, v - 35),
 89                      size=(0, 0),
 90                      color=(0.7, 0.9, 0.7, 0.8),
 91                      scale=0.65,
 92                      text=ba.Lstr(resource=self._r + '.bestResultsText'),
 93                      maxwidth=width * 0.95,
 94                      max_height=height * 0.19,
 95                      h_align='center',
 96                      v_align='center')
 97
 98        ba.checkboxwidget(
 99            parent=self._root_widget,
100            position=(width * 0.5 - 150, v - 116),
101            size=(300, 30),
102            maxwidth=300,
103            scale=0.8,
104            value=not ba.app.config.resolve('Enable Remote App'),
105            autoselect=True,
106            text=ba.Lstr(resource='disableRemoteAppConnectionsText'),
107            on_value_change_call=self._on_check_changed)
108
109    def _on_check_changed(self, value: bool) -> None:
110        cfg = ba.app.config
111        cfg['Enable Remote App'] = not value
112        cfg.apply_and_commit()
113
114    def _back(self) -> None:
115        from bastd.ui.settings import controls
116        ba.containerwidget(edit=self._root_widget, transition='out_right')
117        ba.app.ui.set_main_menu_window(
118            controls.ControlsSettingsWindow(
119                transition='in_left').get_root_widget())

Window showing info/settings related to the remote app.

RemoteAppSettingsWindow()
 14    def __init__(self) -> None:
 15        from ba.internal import get_remote_app_name
 16        self._r = 'connectMobileDevicesWindow'
 17        width = 700
 18        height = 390
 19        spacing = 40
 20        uiscale = ba.app.ui.uiscale
 21        super().__init__(root_widget=ba.containerwidget(
 22            size=(width, height),
 23            transition='in_right',
 24            scale=(1.85 if uiscale is ba.UIScale.SMALL else
 25                   1.3 if uiscale is ba.UIScale.MEDIUM else 1.0),
 26            stack_offset=(-10, 0) if uiscale is ba.UIScale.SMALL else (0, 0)))
 27        btn = ba.buttonwidget(parent=self._root_widget,
 28                              position=(40, height - 67),
 29                              size=(140, 65),
 30                              scale=0.8,
 31                              label=ba.Lstr(resource='backText'),
 32                              button_type='back',
 33                              text_scale=1.1,
 34                              autoselect=True,
 35                              on_activate_call=self._back)
 36        ba.containerwidget(edit=self._root_widget, cancel_button=btn)
 37
 38        ba.textwidget(parent=self._root_widget,
 39                      position=(width * 0.5, height - 42),
 40                      size=(0, 0),
 41                      text=ba.Lstr(resource=self._r + '.titleText'),
 42                      maxwidth=370,
 43                      color=ba.app.ui.title_color,
 44                      scale=0.8,
 45                      h_align='center',
 46                      v_align='center')
 47
 48        ba.buttonwidget(edit=btn,
 49                        button_type='backSmall',
 50                        size=(60, 60),
 51                        label=ba.charstr(ba.SpecialChar.BACK))
 52
 53        v = height - 70.0
 54        v -= spacing * 1.2
 55        ba.textwidget(parent=self._root_widget,
 56                      position=(15, v - 26),
 57                      size=(width - 30, 30),
 58                      maxwidth=width * 0.95,
 59                      color=(0.7, 0.9, 0.7, 1.0),
 60                      scale=0.8,
 61                      text=ba.Lstr(resource=self._r + '.explanationText',
 62                                   subs=[('${APP_NAME}',
 63                                          ba.Lstr(resource='titleText')),
 64                                         ('${REMOTE_APP_NAME}',
 65                                          get_remote_app_name())]),
 66                      max_height=100,
 67                      h_align='center',
 68                      v_align='center')
 69        v -= 90
 70
 71        # hmm the itms:// version doesnt bounce through safari but is kinda
 72        # apple-specific-ish
 73
 74        # Update: now we just show link to the remote webpage.
 75        ba.textwidget(parent=self._root_widget,
 76                      position=(width * 0.5, v + 5),
 77                      size=(0, 0),
 78                      color=(0.7, 0.9, 0.7, 1.0),
 79                      scale=1.4,
 80                      text='bombsquadgame.com/remote',
 81                      maxwidth=width * 0.95,
 82                      max_height=60,
 83                      h_align='center',
 84                      v_align='center')
 85        v -= 30
 86
 87        ba.textwidget(parent=self._root_widget,
 88                      position=(width * 0.5, v - 35),
 89                      size=(0, 0),
 90                      color=(0.7, 0.9, 0.7, 0.8),
 91                      scale=0.65,
 92                      text=ba.Lstr(resource=self._r + '.bestResultsText'),
 93                      maxwidth=width * 0.95,
 94                      max_height=height * 0.19,
 95                      h_align='center',
 96                      v_align='center')
 97
 98        ba.checkboxwidget(
 99            parent=self._root_widget,
100            position=(width * 0.5 - 150, v - 116),
101            size=(300, 30),
102            maxwidth=300,
103            scale=0.8,
104            value=not ba.app.config.resolve('Enable Remote App'),
105            autoselect=True,
106            text=ba.Lstr(resource='disableRemoteAppConnectionsText'),
107            on_value_change_call=self._on_check_changed)
Inherited Members
ba.ui.Window
get_root_widget