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 # Update: now we just show link to the remote webpage. 89 bui.textwidget( 90 parent=self._root_widget, 91 position=(width * 0.5, v + 5), 92 size=(0, 0), 93 color=(0.7, 0.9, 0.7, 1.0), 94 scale=1.4, 95 text='bombsquadgame.com/remote', 96 maxwidth=width * 0.95, 97 max_height=60, 98 h_align='center', 99 v_align='center', 100 ) 101 v -= 30 102 103 bui.textwidget( 104 parent=self._root_widget, 105 position=(width * 0.5, v - 35), 106 size=(0, 0), 107 color=(0.7, 0.9, 0.7, 0.8), 108 scale=0.65, 109 text=bui.Lstr(resource=self._r + '.bestResultsText'), 110 maxwidth=width * 0.95, 111 max_height=height * 0.19, 112 h_align='center', 113 v_align='center', 114 ) 115 116 bui.checkboxwidget( 117 parent=self._root_widget, 118 position=(width * 0.5 - 150, v - 116), 119 size=(300, 30), 120 maxwidth=300, 121 scale=0.8, 122 value=not bui.app.config.resolve('Enable Remote App'), 123 autoselect=True, 124 text=bui.Lstr(resource='disableRemoteAppConnectionsText'), 125 on_value_change_call=self._on_check_changed, 126 ) 127 128 def _on_check_changed(self, value: bool) -> None: 129 cfg = bui.app.config 130 cfg['Enable Remote App'] = not value 131 cfg.apply_and_commit() 132 133 def _back(self) -> None: 134 from bauiv1lib.settings import controls 135 136 # no-op if our underlying widget is dead or on its way out. 137 if not self._root_widget or self._root_widget.transitioning_out: 138 return 139 140 bui.containerwidget(edit=self._root_widget, transition='out_right') 141 assert bui.app.classic is not None 142 bui.app.ui_v1.set_main_menu_window( 143 controls.ControlsSettingsWindow( 144 transition='in_left' 145 ).get_root_widget(), 146 from_window=self._root_widget, 147 )
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 # Update: now we just show link to the remote webpage. 90 bui.textwidget( 91 parent=self._root_widget, 92 position=(width * 0.5, v + 5), 93 size=(0, 0), 94 color=(0.7, 0.9, 0.7, 1.0), 95 scale=1.4, 96 text='bombsquadgame.com/remote', 97 maxwidth=width * 0.95, 98 max_height=60, 99 h_align='center', 100 v_align='center', 101 ) 102 v -= 30 103 104 bui.textwidget( 105 parent=self._root_widget, 106 position=(width * 0.5, v - 35), 107 size=(0, 0), 108 color=(0.7, 0.9, 0.7, 0.8), 109 scale=0.65, 110 text=bui.Lstr(resource=self._r + '.bestResultsText'), 111 maxwidth=width * 0.95, 112 max_height=height * 0.19, 113 h_align='center', 114 v_align='center', 115 ) 116 117 bui.checkboxwidget( 118 parent=self._root_widget, 119 position=(width * 0.5 - 150, v - 116), 120 size=(300, 30), 121 maxwidth=300, 122 scale=0.8, 123 value=not bui.app.config.resolve('Enable Remote App'), 124 autoselect=True, 125 text=bui.Lstr(resource='disableRemoteAppConnectionsText'), 126 on_value_change_call=self._on_check_changed, 127 ) 128 129 def _on_check_changed(self, value: bool) -> None: 130 cfg = bui.app.config 131 cfg['Enable Remote App'] = not value 132 cfg.apply_and_commit() 133 134 def _back(self) -> None: 135 from bauiv1lib.settings import controls 136 137 # no-op if our underlying widget is dead or on its way out. 138 if not self._root_widget or self._root_widget.transitioning_out: 139 return 140 141 bui.containerwidget(edit=self._root_widget, transition='out_right') 142 assert bui.app.classic is not None 143 bui.app.ui_v1.set_main_menu_window( 144 controls.ControlsSettingsWindow( 145 transition='in_left' 146 ).get_root_widget(), 147 from_window=self._root_widget, 148 )
Window showing info/settings related to the remote app.
Inherited Members
- bauiv1._uitypes.Window
- get_root_widget