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

Called when the popup is canceled.

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