bastd.ui.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 TYPE_CHECKING
 8
 9import ba
10from bastd.ui import popup
11
12if TYPE_CHECKING:
13    pass
14
15
16class GetBSRemoteWindow(popup.PopupWindow):
17    """Popup telling the user about BSRemote app."""
18
19    def __init__(self) -> None:
20        position = (0.0, 0.0)
21        uiscale = ba.app.ui.uiscale
22        scale = (
23            2.3
24            if uiscale is ba.UIScale.SMALL
25            else 1.65
26            if uiscale is ba.UIScale.MEDIUM
27            else 1.23
28        )
29        self._transitioning_out = False
30        self._width = 570
31        self._height = 350
32        bg_color = (0.5, 0.4, 0.6)
33        popup.PopupWindow.__init__(
34            self,
35            position=position,
36            size=(self._width, self._height),
37            scale=scale,
38            bg_color=bg_color,
39        )
40        self._cancel_button = ba.buttonwidget(
41            parent=self.root_widget,
42            position=(50, self._height - 30),
43            size=(50, 50),
44            scale=0.5,
45            label='',
46            color=bg_color,
47            on_activate_call=self._on_cancel_press,
48            autoselect=True,
49            icon=ba.gettexture('crossOut'),
50            iconscale=1.2,
51        )
52        ba.imagewidget(
53            parent=self.root_widget,
54            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
55            size=(220, 220),
56            texture=ba.gettexture('multiplayerExamples'),
57        )
58        ba.textwidget(
59            parent=self.root_widget,
60            size=(0, 0),
61            h_align='center',
62            v_align='center',
63            maxwidth=self._width * 0.9,
64            position=(self._width * 0.5, 60),
65            text=ba.Lstr(
66                resource='remoteAppInfoShortText',
67                subs=[
68                    ('${APP_NAME}', ba.Lstr(resource='titleText')),
69                    (
70                        '${REMOTE_APP_NAME}',
71                        ba.Lstr(resource='remote_app.app_name'),
72                    ),
73                ],
74            ),
75        )
76
77    def _on_cancel_press(self) -> None:
78        self._transition_out()
79
80    def _transition_out(self) -> None:
81        if not self._transitioning_out:
82            self._transitioning_out = True
83            ba.containerwidget(edit=self.root_widget, transition='out_scale')
84
85    def on_popup_cancel(self) -> None:
86        ba.playsound(ba.getsound('swish'))
87        self._transition_out()
class GetBSRemoteWindow(bastd.ui.popup.PopupWindow):
17class GetBSRemoteWindow(popup.PopupWindow):
18    """Popup telling the user about BSRemote app."""
19
20    def __init__(self) -> None:
21        position = (0.0, 0.0)
22        uiscale = ba.app.ui.uiscale
23        scale = (
24            2.3
25            if uiscale is ba.UIScale.SMALL
26            else 1.65
27            if uiscale is ba.UIScale.MEDIUM
28            else 1.23
29        )
30        self._transitioning_out = False
31        self._width = 570
32        self._height = 350
33        bg_color = (0.5, 0.4, 0.6)
34        popup.PopupWindow.__init__(
35            self,
36            position=position,
37            size=(self._width, self._height),
38            scale=scale,
39            bg_color=bg_color,
40        )
41        self._cancel_button = ba.buttonwidget(
42            parent=self.root_widget,
43            position=(50, self._height - 30),
44            size=(50, 50),
45            scale=0.5,
46            label='',
47            color=bg_color,
48            on_activate_call=self._on_cancel_press,
49            autoselect=True,
50            icon=ba.gettexture('crossOut'),
51            iconscale=1.2,
52        )
53        ba.imagewidget(
54            parent=self.root_widget,
55            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
56            size=(220, 220),
57            texture=ba.gettexture('multiplayerExamples'),
58        )
59        ba.textwidget(
60            parent=self.root_widget,
61            size=(0, 0),
62            h_align='center',
63            v_align='center',
64            maxwidth=self._width * 0.9,
65            position=(self._width * 0.5, 60),
66            text=ba.Lstr(
67                resource='remoteAppInfoShortText',
68                subs=[
69                    ('${APP_NAME}', ba.Lstr(resource='titleText')),
70                    (
71                        '${REMOTE_APP_NAME}',
72                        ba.Lstr(resource='remote_app.app_name'),
73                    ),
74                ],
75            ),
76        )
77
78    def _on_cancel_press(self) -> None:
79        self._transition_out()
80
81    def _transition_out(self) -> None:
82        if not self._transitioning_out:
83            self._transitioning_out = True
84            ba.containerwidget(edit=self.root_widget, transition='out_scale')
85
86    def on_popup_cancel(self) -> None:
87        ba.playsound(ba.getsound('swish'))
88        self._transition_out()

Popup telling the user about BSRemote app.

GetBSRemoteWindow()
20    def __init__(self) -> None:
21        position = (0.0, 0.0)
22        uiscale = ba.app.ui.uiscale
23        scale = (
24            2.3
25            if uiscale is ba.UIScale.SMALL
26            else 1.65
27            if uiscale is ba.UIScale.MEDIUM
28            else 1.23
29        )
30        self._transitioning_out = False
31        self._width = 570
32        self._height = 350
33        bg_color = (0.5, 0.4, 0.6)
34        popup.PopupWindow.__init__(
35            self,
36            position=position,
37            size=(self._width, self._height),
38            scale=scale,
39            bg_color=bg_color,
40        )
41        self._cancel_button = ba.buttonwidget(
42            parent=self.root_widget,
43            position=(50, self._height - 30),
44            size=(50, 50),
45            scale=0.5,
46            label='',
47            color=bg_color,
48            on_activate_call=self._on_cancel_press,
49            autoselect=True,
50            icon=ba.gettexture('crossOut'),
51            iconscale=1.2,
52        )
53        ba.imagewidget(
54            parent=self.root_widget,
55            position=(self._width * 0.5 - 110, self._height * 0.67 - 110),
56            size=(220, 220),
57            texture=ba.gettexture('multiplayerExamples'),
58        )
59        ba.textwidget(
60            parent=self.root_widget,
61            size=(0, 0),
62            h_align='center',
63            v_align='center',
64            maxwidth=self._width * 0.9,
65            position=(self._width * 0.5, 60),
66            text=ba.Lstr(
67                resource='remoteAppInfoShortText',
68                subs=[
69                    ('${APP_NAME}', ba.Lstr(resource='titleText')),
70                    (
71                        '${REMOTE_APP_NAME}',
72                        ba.Lstr(resource='remote_app.app_name'),
73                    ),
74                ],
75            ),
76        )
def on_popup_cancel(self) -> None:
86    def on_popup_cancel(self) -> None:
87        ba.playsound(ba.getsound('swish'))
88        self._transition_out()

Called when the popup is canceled.

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