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_extensions 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
24            if uiscale is bui.UIScale.MEDIUM
25            else 1.23
26        )
27        self._transitioning_out = False
28        self._width = 570
29        self._height = 350
30        bg_color = (0.5, 0.4, 0.6)
31        super().__init__(
32            position=position,
33            size=(self._width, self._height),
34            scale=scale,
35            bg_color=bg_color,
36        )
37        self._cancel_button = bui.buttonwidget(
38            parent=self.root_widget,
39            position=(50, self._height - 30),
40            size=(50, 50),
41            scale=0.5,
42            label='',
43            color=bg_color,
44            on_activate_call=self._on_cancel_press,
45            autoselect=True,
46            icon=bui.gettexture('crossOut'),
47            iconscale=1.2,
48        )
49        bui.imagewidget(
50            parent=self.root_widget,
51            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
52            size=(220, 220),
53            texture=bui.gettexture('multiplayerExamples'),
54        )
55        bui.textwidget(
56            parent=self.root_widget,
57            size=(0, 0),
58            h_align='center',
59            v_align='center',
60            maxwidth=self._width * 0.9,
61            position=(self._width * 0.5, 60),
62            text=bui.Lstr(
63                resource='remoteAppInfoShortText',
64                subs=[
65                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
66                    (
67                        '${REMOTE_APP_NAME}',
68                        bui.Lstr(resource='remote_app.app_name'),
69                    ),
70                ],
71            ),
72        )
73
74    def _on_cancel_press(self) -> None:
75        self._transition_out()
76
77    def _transition_out(self) -> None:
78        if not self._transitioning_out:
79            self._transitioning_out = True
80            bui.containerwidget(edit=self.root_widget, transition='out_scale')
81
82    @override
83    def on_popup_cancel(self) -> None:
84        bui.getsound('swish').play()
85        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
25            if uiscale is bui.UIScale.MEDIUM
26            else 1.23
27        )
28        self._transitioning_out = False
29        self._width = 570
30        self._height = 350
31        bg_color = (0.5, 0.4, 0.6)
32        super().__init__(
33            position=position,
34            size=(self._width, self._height),
35            scale=scale,
36            bg_color=bg_color,
37        )
38        self._cancel_button = bui.buttonwidget(
39            parent=self.root_widget,
40            position=(50, self._height - 30),
41            size=(50, 50),
42            scale=0.5,
43            label='',
44            color=bg_color,
45            on_activate_call=self._on_cancel_press,
46            autoselect=True,
47            icon=bui.gettexture('crossOut'),
48            iconscale=1.2,
49        )
50        bui.imagewidget(
51            parent=self.root_widget,
52            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
53            size=(220, 220),
54            texture=bui.gettexture('multiplayerExamples'),
55        )
56        bui.textwidget(
57            parent=self.root_widget,
58            size=(0, 0),
59            h_align='center',
60            v_align='center',
61            maxwidth=self._width * 0.9,
62            position=(self._width * 0.5, 60),
63            text=bui.Lstr(
64                resource='remoteAppInfoShortText',
65                subs=[
66                    ('${APP_NAME}', bui.Lstr(resource='titleText')),
67                    (
68                        '${REMOTE_APP_NAME}',
69                        bui.Lstr(resource='remote_app.app_name'),
70                    ),
71                ],
72            ),
73        )
74
75    def _on_cancel_press(self) -> None:
76        self._transition_out()
77
78    def _transition_out(self) -> None:
79        if not self._transitioning_out:
80            self._transitioning_out = True
81            bui.containerwidget(edit=self.root_widget, transition='out_scale')
82
83    @override
84    def on_popup_cancel(self) -> None:
85        bui.getsound('swish').play()
86        self._transition_out()

Popup telling the user about BSRemote app.

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

Called when the popup is canceled.

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