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

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