bauiv1lib.getremote

Provides a popup telling the user about the BSRemote app.

 1# Released under the MIT License. See LICENSE for details.
 2#
 3"""Provides a popup telling the user about the BSRemote app."""
 4
 5from __future__ import annotations
 6
 7from typing import override
 8
 9from bauiv1lib.popup import PopupWindow
10import bauiv1 as bui
11
12
13class GetBSRemoteWindow(PopupWindow):
14    """Popup telling the user about BSRemote app."""
15
16    def __init__(self) -> None:
17        position = (0.0, 0.0)
18        assert bui.app.classic is not None
19        uiscale = bui.app.ui_v1.uiscale
20        scale = (
21            2.3
22            if uiscale is bui.UIScale.SMALL
23            else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23
24        )
25        self._transitioning_out = False
26        self._width = 570
27        self._height = 350
28        bg_color = (0.5, 0.4, 0.6)
29        super().__init__(
30            position=position,
31            size=(self._width, self._height),
32            scale=scale,
33            bg_color=bg_color,
34        )
35        self._cancel_button = bui.buttonwidget(
36            parent=self.root_widget,
37            position=(50, self._height - 30),
38            size=(50, 50),
39            scale=0.5,
40            label='',
41            color=bg_color,
42            on_activate_call=self._on_cancel_press,
43            autoselect=True,
44            icon=bui.gettexture('crossOut'),
45            iconscale=1.2,
46        )
47        bui.imagewidget(
48            parent=self.root_widget,
49            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
50            size=(220, 220),
51            texture=bui.gettexture('multiplayerExamples'),
52        )
53        bui.textwidget(
54            parent=self.root_widget,
55            size=(0, 0),
56            h_align='center',
57            v_align='center',
58            maxwidth=self._width * 0.9,
59            position=(self._width * 0.5, 60),
60            text=bui.Lstr(
61                resource='remoteAppInfoShortText',
62                subs=[
63                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
64                    (
65                        '${REMOTE_APP_NAME}',
66                        bui.Lstr(resource='remote_app.app_name'),
67                    ),
68                ],
69            ),
70        )
71
72    def _on_cancel_press(self) -> None:
73        self._transition_out()
74
75    def _transition_out(self) -> None:
76        if not self._transitioning_out:
77            self._transitioning_out = True
78            bui.containerwidget(edit=self.root_widget, transition='out_scale')
79
80    @override
81    def on_popup_cancel(self) -> None:
82        bui.getsound('swish').play()
83        self._transition_out()
class GetBSRemoteWindow(bauiv1lib.popup.PopupWindow):
14class GetBSRemoteWindow(PopupWindow):
15    """Popup telling the user about BSRemote app."""
16
17    def __init__(self) -> None:
18        position = (0.0, 0.0)
19        assert bui.app.classic is not None
20        uiscale = bui.app.ui_v1.uiscale
21        scale = (
22            2.3
23            if uiscale is bui.UIScale.SMALL
24            else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23
25        )
26        self._transitioning_out = False
27        self._width = 570
28        self._height = 350
29        bg_color = (0.5, 0.4, 0.6)
30        super().__init__(
31            position=position,
32            size=(self._width, self._height),
33            scale=scale,
34            bg_color=bg_color,
35        )
36        self._cancel_button = bui.buttonwidget(
37            parent=self.root_widget,
38            position=(50, self._height - 30),
39            size=(50, 50),
40            scale=0.5,
41            label='',
42            color=bg_color,
43            on_activate_call=self._on_cancel_press,
44            autoselect=True,
45            icon=bui.gettexture('crossOut'),
46            iconscale=1.2,
47        )
48        bui.imagewidget(
49            parent=self.root_widget,
50            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
51            size=(220, 220),
52            texture=bui.gettexture('multiplayerExamples'),
53        )
54        bui.textwidget(
55            parent=self.root_widget,
56            size=(0, 0),
57            h_align='center',
58            v_align='center',
59            maxwidth=self._width * 0.9,
60            position=(self._width * 0.5, 60),
61            text=bui.Lstr(
62                resource='remoteAppInfoShortText',
63                subs=[
64                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
65                    (
66                        '${REMOTE_APP_NAME}',
67                        bui.Lstr(resource='remote_app.app_name'),
68                    ),
69                ],
70            ),
71        )
72
73    def _on_cancel_press(self) -> None:
74        self._transition_out()
75
76    def _transition_out(self) -> None:
77        if not self._transitioning_out:
78            self._transitioning_out = True
79            bui.containerwidget(edit=self.root_widget, transition='out_scale')
80
81    @override
82    def on_popup_cancel(self) -> None:
83        bui.getsound('swish').play()
84        self._transition_out()

Popup telling the user about BSRemote app.

@override
def on_popup_cancel(self) -> None:
81    @override
82    def on_popup_cancel(self) -> None:
83        bui.getsound('swish').play()
84        self._transition_out()

Called when the popup is canceled.

Cancels can occur due to clicking outside the window, hitting escape, etc.