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

Window showing info/settings related to the remote app.

Inherited Members
bauiv1._uitypes.Window
get_root_widget