bauiv1lib.playlist.mapselect
Provides UI for selecting maps in playlists.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Provides UI for selecting maps in playlists.""" 4 5from __future__ import annotations 6 7import math 8from typing import TYPE_CHECKING, override 9 10import bauiv1 as bui 11 12if TYPE_CHECKING: 13 from typing import Any, Callable 14 15 import bascenev1 as bs 16 17 18class PlaylistMapSelectWindow(bui.MainWindow): 19 """Window to select a map.""" 20 21 def __init__( 22 self, 23 gametype: type[bs.GameActivity], 24 sessiontype: type[bs.Session], 25 config: dict[str, Any], 26 edit_info: dict[str, Any], 27 completion_call: Callable[[dict[str, Any] | None, bui.MainWindow], Any], 28 transition: str | None = 'in_right', 29 origin_widget: bui.Widget | None = None, 30 select_get_more_maps_button: bool = False, 31 ): 32 # pylint: disable=too-many-locals 33 # pylint: disable=too-many-positional-arguments 34 35 from bascenev1 import get_filtered_map_name 36 37 self._gametype = gametype 38 self._sessiontype = sessiontype 39 self._config = config 40 self._completion_call = completion_call 41 self._edit_info = edit_info 42 self._maps: list[tuple[str, bui.Texture]] = [] 43 self._selected_get_more_maps = False 44 try: 45 self._previous_map = get_filtered_map_name( 46 config['settings']['map'] 47 ) 48 except Exception: 49 self._previous_map = '' 50 51 assert bui.app.classic is not None 52 uiscale = bui.app.ui_v1.uiscale 53 width = 815 if uiscale is bui.UIScale.SMALL else 615 54 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 55 height = ( 56 420 57 if uiscale is bui.UIScale.SMALL 58 else 480 if uiscale is bui.UIScale.MEDIUM else 600 59 ) 60 yoffs = -37 if uiscale is bui.UIScale.SMALL else 0 61 62 super().__init__( 63 root_widget=bui.containerwidget( 64 size=(width, height), 65 scale=( 66 1.95 67 if uiscale is bui.UIScale.SMALL 68 else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 69 ), 70 stack_offset=( 71 (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) 72 ), 73 ), 74 transition=transition, 75 origin_widget=origin_widget, 76 ) 77 78 self._cancel_button = btn = bui.buttonwidget( 79 parent=self._root_widget, 80 position=(38 + x_inset, height - 67 + yoffs), 81 size=(140, 50), 82 scale=0.9, 83 text_scale=1.0, 84 autoselect=True, 85 label=bui.Lstr(resource='cancelText'), 86 on_activate_call=self.main_window_back, 87 ) 88 89 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 90 bui.textwidget( 91 parent=self._root_widget, 92 position=(width * 0.5, height - 46 + yoffs), 93 size=(0, 0), 94 maxwidth=260, 95 scale=1.1, 96 text=bui.Lstr( 97 resource='mapSelectTitleText', 98 subs=[('${GAME}', self._gametype.get_display_string())], 99 ), 100 color=bui.app.ui_v1.title_color, 101 h_align='center', 102 v_align='center', 103 ) 104 v = height - 70 + yoffs 105 self._scroll_width = width - (80 + 2 * x_inset) 106 self._scroll_height = height - ( 107 170 if uiscale is bui.UIScale.SMALL else 140 108 ) 109 110 self._scrollwidget = bui.scrollwidget( 111 parent=self._root_widget, 112 position=(40 + x_inset, v - self._scroll_height), 113 size=(self._scroll_width, self._scroll_height), 114 ) 115 bui.containerwidget( 116 edit=self._root_widget, selected_child=self._scrollwidget 117 ) 118 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 119 120 self._subcontainer: bui.Widget | None = None 121 self._refresh(select_get_more_maps_button=select_get_more_maps_button) 122 123 @override 124 def get_main_window_state(self) -> bui.MainWindowState: 125 # Support recreating our window for back/refresh purposes. 126 cls = type(self) 127 128 # Pull things out of self here; if we do it in the lambda we'll 129 # keep ourself alive. 130 gametype = self._gametype 131 sessiontype = self._sessiontype 132 config = self._config 133 edit_info = self._edit_info 134 completion_call = self._completion_call 135 select_get_more_maps = self._selected_get_more_maps 136 137 return bui.BasicMainWindowState( 138 create_call=lambda transition, origin_widget: cls( 139 transition=transition, 140 origin_widget=origin_widget, 141 gametype=gametype, 142 sessiontype=sessiontype, 143 config=config, 144 edit_info=edit_info, 145 completion_call=completion_call, 146 select_get_more_maps_button=select_get_more_maps, 147 ) 148 ) 149 150 def _refresh(self, select_get_more_maps_button: bool = False) -> None: 151 # pylint: disable=too-many-statements 152 # pylint: disable=too-many-branches 153 # pylint: disable=too-many-locals 154 from bascenev1 import ( 155 get_map_class, 156 get_map_display_string, 157 ) 158 159 assert bui.app.classic is not None 160 store = bui.app.classic.store 161 # Kill old. 162 if self._subcontainer is not None: 163 self._subcontainer.delete() 164 165 mesh_opaque = bui.getmesh('level_select_button_opaque') 166 mesh_transparent = bui.getmesh('level_select_button_transparent') 167 168 self._maps = [] 169 map_list = self._gametype.get_supported_maps(self._sessiontype) 170 map_list_sorted = list(map_list) 171 map_list_sorted.sort() 172 unowned_maps = store.get_unowned_maps() 173 174 for mapname in map_list_sorted: 175 # Disallow ones we don't own. 176 if mapname in unowned_maps: 177 continue 178 map_tex_name = get_map_class(mapname).get_preview_texture_name() 179 if map_tex_name is not None: 180 try: 181 map_tex = bui.gettexture(map_tex_name) 182 self._maps.append((mapname, map_tex)) 183 except Exception: 184 print(f'Invalid map preview texture: "{map_tex_name}".') 185 else: 186 print('Error: no map preview texture for map:', mapname) 187 188 count = len(self._maps) 189 columns = 2 190 rows = int(math.ceil(float(count) / columns)) 191 button_width = 220 192 button_height = button_width * 0.5 193 button_buffer_h = 16 194 button_buffer_v = 19 195 self._sub_width = self._scroll_width * 0.95 196 self._sub_height = ( 197 5 + rows * (button_height + 2 * button_buffer_v) + 100 198 ) 199 self._subcontainer = bui.containerwidget( 200 parent=self._scrollwidget, 201 size=(self._sub_width, self._sub_height), 202 background=False, 203 ) 204 index = 0 205 mask_texture = bui.gettexture('mapPreviewMask') 206 h_offs = 130 if len(self._maps) == 1 else 0 207 for y in range(rows): 208 for x in range(columns): 209 pos = ( 210 x * (button_width + 2 * button_buffer_h) 211 + button_buffer_h 212 + h_offs, 213 self._sub_height 214 - (y + 1) * (button_height + 2 * button_buffer_v) 215 + 12, 216 ) 217 btn = bui.buttonwidget( 218 parent=self._subcontainer, 219 button_type='square', 220 size=(button_width, button_height), 221 autoselect=True, 222 texture=self._maps[index][1], 223 mask_texture=mask_texture, 224 mesh_opaque=mesh_opaque, 225 mesh_transparent=mesh_transparent, 226 label='', 227 color=(1, 1, 1), 228 on_activate_call=bui.Call( 229 self._select_with_delay, self._maps[index][0] 230 ), 231 position=pos, 232 ) 233 if x == 0: 234 bui.widget(edit=btn, left_widget=self._cancel_button) 235 if y == 0: 236 bui.widget(edit=btn, up_widget=self._cancel_button) 237 if x == columns - 1: 238 bui.widget( 239 edit=btn, 240 right_widget=bui.get_special_widget('squad_button'), 241 ) 242 243 bui.widget(edit=btn, show_buffer_top=60, show_buffer_bottom=60) 244 if self._maps[index][0] == self._previous_map: 245 bui.containerwidget( 246 edit=self._subcontainer, 247 selected_child=btn, 248 visible_child=btn, 249 ) 250 name = get_map_display_string(self._maps[index][0]) 251 bui.textwidget( 252 parent=self._subcontainer, 253 text=name, 254 position=(pos[0] + button_width * 0.5, pos[1] - 12), 255 size=(0, 0), 256 scale=0.5, 257 maxwidth=button_width, 258 draw_controller=btn, 259 h_align='center', 260 v_align='center', 261 color=(0.8, 0.8, 0.8, 0.8), 262 ) 263 index += 1 264 265 if index >= count: 266 break 267 if index >= count: 268 break 269 self._get_more_maps_button = btn = bui.buttonwidget( 270 parent=self._subcontainer, 271 size=(self._sub_width * 0.8, 60), 272 position=(self._sub_width * 0.1, 30), 273 label=bui.Lstr(resource='mapSelectGetMoreMapsText'), 274 on_activate_call=self._on_store_press, 275 color=(0.6, 0.53, 0.63), 276 textcolor=(0.75, 0.7, 0.8), 277 autoselect=True, 278 ) 279 bui.widget(edit=btn, show_buffer_top=30, show_buffer_bottom=30) 280 if select_get_more_maps_button: 281 bui.containerwidget( 282 edit=self._subcontainer, selected_child=btn, visible_child=btn 283 ) 284 285 def _on_store_press(self) -> None: 286 from bauiv1lib import account 287 from bauiv1lib.store.browser import StoreBrowserWindow 288 289 # No-op if we're not in control. 290 if not self.main_window_has_control(): 291 return 292 293 plus = bui.app.plus 294 assert plus is not None 295 296 if plus.get_v1_account_state() != 'signed_in': 297 account.show_sign_in_prompt() 298 return 299 300 self._selected_get_more_maps = True 301 302 self.main_window_replace( 303 StoreBrowserWindow( 304 show_tab=StoreBrowserWindow.TabID.MAPS, 305 origin_widget=self._get_more_maps_button, 306 minimal_toolbars=True, 307 ) 308 ) 309 310 def _select(self, map_name: str) -> None: 311 312 # no-op if our underlying widget is dead or on its way out. 313 if not self.main_window_has_control(): 314 return 315 316 self._config['settings']['map'] = map_name 317 self.main_window_back() 318 319 def _select_with_delay(self, map_name: str) -> None: 320 bui.lock_all_input() 321 bui.apptimer(0.1, bui.unlock_all_input) 322 bui.apptimer(0.1, bui.WeakCall(self._select, map_name))
class
PlaylistMapSelectWindow(bauiv1._uitypes.MainWindow):
19class PlaylistMapSelectWindow(bui.MainWindow): 20 """Window to select a map.""" 21 22 def __init__( 23 self, 24 gametype: type[bs.GameActivity], 25 sessiontype: type[bs.Session], 26 config: dict[str, Any], 27 edit_info: dict[str, Any], 28 completion_call: Callable[[dict[str, Any] | None, bui.MainWindow], Any], 29 transition: str | None = 'in_right', 30 origin_widget: bui.Widget | None = None, 31 select_get_more_maps_button: bool = False, 32 ): 33 # pylint: disable=too-many-locals 34 # pylint: disable=too-many-positional-arguments 35 36 from bascenev1 import get_filtered_map_name 37 38 self._gametype = gametype 39 self._sessiontype = sessiontype 40 self._config = config 41 self._completion_call = completion_call 42 self._edit_info = edit_info 43 self._maps: list[tuple[str, bui.Texture]] = [] 44 self._selected_get_more_maps = False 45 try: 46 self._previous_map = get_filtered_map_name( 47 config['settings']['map'] 48 ) 49 except Exception: 50 self._previous_map = '' 51 52 assert bui.app.classic is not None 53 uiscale = bui.app.ui_v1.uiscale 54 width = 815 if uiscale is bui.UIScale.SMALL else 615 55 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 56 height = ( 57 420 58 if uiscale is bui.UIScale.SMALL 59 else 480 if uiscale is bui.UIScale.MEDIUM else 600 60 ) 61 yoffs = -37 if uiscale is bui.UIScale.SMALL else 0 62 63 super().__init__( 64 root_widget=bui.containerwidget( 65 size=(width, height), 66 scale=( 67 1.95 68 if uiscale is bui.UIScale.SMALL 69 else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 70 ), 71 stack_offset=( 72 (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) 73 ), 74 ), 75 transition=transition, 76 origin_widget=origin_widget, 77 ) 78 79 self._cancel_button = btn = bui.buttonwidget( 80 parent=self._root_widget, 81 position=(38 + x_inset, height - 67 + yoffs), 82 size=(140, 50), 83 scale=0.9, 84 text_scale=1.0, 85 autoselect=True, 86 label=bui.Lstr(resource='cancelText'), 87 on_activate_call=self.main_window_back, 88 ) 89 90 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 91 bui.textwidget( 92 parent=self._root_widget, 93 position=(width * 0.5, height - 46 + yoffs), 94 size=(0, 0), 95 maxwidth=260, 96 scale=1.1, 97 text=bui.Lstr( 98 resource='mapSelectTitleText', 99 subs=[('${GAME}', self._gametype.get_display_string())], 100 ), 101 color=bui.app.ui_v1.title_color, 102 h_align='center', 103 v_align='center', 104 ) 105 v = height - 70 + yoffs 106 self._scroll_width = width - (80 + 2 * x_inset) 107 self._scroll_height = height - ( 108 170 if uiscale is bui.UIScale.SMALL else 140 109 ) 110 111 self._scrollwidget = bui.scrollwidget( 112 parent=self._root_widget, 113 position=(40 + x_inset, v - self._scroll_height), 114 size=(self._scroll_width, self._scroll_height), 115 ) 116 bui.containerwidget( 117 edit=self._root_widget, selected_child=self._scrollwidget 118 ) 119 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 120 121 self._subcontainer: bui.Widget | None = None 122 self._refresh(select_get_more_maps_button=select_get_more_maps_button) 123 124 @override 125 def get_main_window_state(self) -> bui.MainWindowState: 126 # Support recreating our window for back/refresh purposes. 127 cls = type(self) 128 129 # Pull things out of self here; if we do it in the lambda we'll 130 # keep ourself alive. 131 gametype = self._gametype 132 sessiontype = self._sessiontype 133 config = self._config 134 edit_info = self._edit_info 135 completion_call = self._completion_call 136 select_get_more_maps = self._selected_get_more_maps 137 138 return bui.BasicMainWindowState( 139 create_call=lambda transition, origin_widget: cls( 140 transition=transition, 141 origin_widget=origin_widget, 142 gametype=gametype, 143 sessiontype=sessiontype, 144 config=config, 145 edit_info=edit_info, 146 completion_call=completion_call, 147 select_get_more_maps_button=select_get_more_maps, 148 ) 149 ) 150 151 def _refresh(self, select_get_more_maps_button: bool = False) -> None: 152 # pylint: disable=too-many-statements 153 # pylint: disable=too-many-branches 154 # pylint: disable=too-many-locals 155 from bascenev1 import ( 156 get_map_class, 157 get_map_display_string, 158 ) 159 160 assert bui.app.classic is not None 161 store = bui.app.classic.store 162 # Kill old. 163 if self._subcontainer is not None: 164 self._subcontainer.delete() 165 166 mesh_opaque = bui.getmesh('level_select_button_opaque') 167 mesh_transparent = bui.getmesh('level_select_button_transparent') 168 169 self._maps = [] 170 map_list = self._gametype.get_supported_maps(self._sessiontype) 171 map_list_sorted = list(map_list) 172 map_list_sorted.sort() 173 unowned_maps = store.get_unowned_maps() 174 175 for mapname in map_list_sorted: 176 # Disallow ones we don't own. 177 if mapname in unowned_maps: 178 continue 179 map_tex_name = get_map_class(mapname).get_preview_texture_name() 180 if map_tex_name is not None: 181 try: 182 map_tex = bui.gettexture(map_tex_name) 183 self._maps.append((mapname, map_tex)) 184 except Exception: 185 print(f'Invalid map preview texture: "{map_tex_name}".') 186 else: 187 print('Error: no map preview texture for map:', mapname) 188 189 count = len(self._maps) 190 columns = 2 191 rows = int(math.ceil(float(count) / columns)) 192 button_width = 220 193 button_height = button_width * 0.5 194 button_buffer_h = 16 195 button_buffer_v = 19 196 self._sub_width = self._scroll_width * 0.95 197 self._sub_height = ( 198 5 + rows * (button_height + 2 * button_buffer_v) + 100 199 ) 200 self._subcontainer = bui.containerwidget( 201 parent=self._scrollwidget, 202 size=(self._sub_width, self._sub_height), 203 background=False, 204 ) 205 index = 0 206 mask_texture = bui.gettexture('mapPreviewMask') 207 h_offs = 130 if len(self._maps) == 1 else 0 208 for y in range(rows): 209 for x in range(columns): 210 pos = ( 211 x * (button_width + 2 * button_buffer_h) 212 + button_buffer_h 213 + h_offs, 214 self._sub_height 215 - (y + 1) * (button_height + 2 * button_buffer_v) 216 + 12, 217 ) 218 btn = bui.buttonwidget( 219 parent=self._subcontainer, 220 button_type='square', 221 size=(button_width, button_height), 222 autoselect=True, 223 texture=self._maps[index][1], 224 mask_texture=mask_texture, 225 mesh_opaque=mesh_opaque, 226 mesh_transparent=mesh_transparent, 227 label='', 228 color=(1, 1, 1), 229 on_activate_call=bui.Call( 230 self._select_with_delay, self._maps[index][0] 231 ), 232 position=pos, 233 ) 234 if x == 0: 235 bui.widget(edit=btn, left_widget=self._cancel_button) 236 if y == 0: 237 bui.widget(edit=btn, up_widget=self._cancel_button) 238 if x == columns - 1: 239 bui.widget( 240 edit=btn, 241 right_widget=bui.get_special_widget('squad_button'), 242 ) 243 244 bui.widget(edit=btn, show_buffer_top=60, show_buffer_bottom=60) 245 if self._maps[index][0] == self._previous_map: 246 bui.containerwidget( 247 edit=self._subcontainer, 248 selected_child=btn, 249 visible_child=btn, 250 ) 251 name = get_map_display_string(self._maps[index][0]) 252 bui.textwidget( 253 parent=self._subcontainer, 254 text=name, 255 position=(pos[0] + button_width * 0.5, pos[1] - 12), 256 size=(0, 0), 257 scale=0.5, 258 maxwidth=button_width, 259 draw_controller=btn, 260 h_align='center', 261 v_align='center', 262 color=(0.8, 0.8, 0.8, 0.8), 263 ) 264 index += 1 265 266 if index >= count: 267 break 268 if index >= count: 269 break 270 self._get_more_maps_button = btn = bui.buttonwidget( 271 parent=self._subcontainer, 272 size=(self._sub_width * 0.8, 60), 273 position=(self._sub_width * 0.1, 30), 274 label=bui.Lstr(resource='mapSelectGetMoreMapsText'), 275 on_activate_call=self._on_store_press, 276 color=(0.6, 0.53, 0.63), 277 textcolor=(0.75, 0.7, 0.8), 278 autoselect=True, 279 ) 280 bui.widget(edit=btn, show_buffer_top=30, show_buffer_bottom=30) 281 if select_get_more_maps_button: 282 bui.containerwidget( 283 edit=self._subcontainer, selected_child=btn, visible_child=btn 284 ) 285 286 def _on_store_press(self) -> None: 287 from bauiv1lib import account 288 from bauiv1lib.store.browser import StoreBrowserWindow 289 290 # No-op if we're not in control. 291 if not self.main_window_has_control(): 292 return 293 294 plus = bui.app.plus 295 assert plus is not None 296 297 if plus.get_v1_account_state() != 'signed_in': 298 account.show_sign_in_prompt() 299 return 300 301 self._selected_get_more_maps = True 302 303 self.main_window_replace( 304 StoreBrowserWindow( 305 show_tab=StoreBrowserWindow.TabID.MAPS, 306 origin_widget=self._get_more_maps_button, 307 minimal_toolbars=True, 308 ) 309 ) 310 311 def _select(self, map_name: str) -> None: 312 313 # no-op if our underlying widget is dead or on its way out. 314 if not self.main_window_has_control(): 315 return 316 317 self._config['settings']['map'] = map_name 318 self.main_window_back() 319 320 def _select_with_delay(self, map_name: str) -> None: 321 bui.lock_all_input() 322 bui.apptimer(0.1, bui.unlock_all_input) 323 bui.apptimer(0.1, bui.WeakCall(self._select, map_name))
Window to select a map.
PlaylistMapSelectWindow( gametype: type[bascenev1.GameActivity], sessiontype: type[bascenev1.Session], config: dict[str, typing.Any], edit_info: dict[str, typing.Any], completion_call: Callable[[dict[str, Any] | None, bauiv1.MainWindow], Any], transition: str | None = 'in_right', origin_widget: _bauiv1.Widget | None = None, select_get_more_maps_button: bool = False)
22 def __init__( 23 self, 24 gametype: type[bs.GameActivity], 25 sessiontype: type[bs.Session], 26 config: dict[str, Any], 27 edit_info: dict[str, Any], 28 completion_call: Callable[[dict[str, Any] | None, bui.MainWindow], Any], 29 transition: str | None = 'in_right', 30 origin_widget: bui.Widget | None = None, 31 select_get_more_maps_button: bool = False, 32 ): 33 # pylint: disable=too-many-locals 34 # pylint: disable=too-many-positional-arguments 35 36 from bascenev1 import get_filtered_map_name 37 38 self._gametype = gametype 39 self._sessiontype = sessiontype 40 self._config = config 41 self._completion_call = completion_call 42 self._edit_info = edit_info 43 self._maps: list[tuple[str, bui.Texture]] = [] 44 self._selected_get_more_maps = False 45 try: 46 self._previous_map = get_filtered_map_name( 47 config['settings']['map'] 48 ) 49 except Exception: 50 self._previous_map = '' 51 52 assert bui.app.classic is not None 53 uiscale = bui.app.ui_v1.uiscale 54 width = 815 if uiscale is bui.UIScale.SMALL else 615 55 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 56 height = ( 57 420 58 if uiscale is bui.UIScale.SMALL 59 else 480 if uiscale is bui.UIScale.MEDIUM else 600 60 ) 61 yoffs = -37 if uiscale is bui.UIScale.SMALL else 0 62 63 super().__init__( 64 root_widget=bui.containerwidget( 65 size=(width, height), 66 scale=( 67 1.95 68 if uiscale is bui.UIScale.SMALL 69 else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 70 ), 71 stack_offset=( 72 (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) 73 ), 74 ), 75 transition=transition, 76 origin_widget=origin_widget, 77 ) 78 79 self._cancel_button = btn = bui.buttonwidget( 80 parent=self._root_widget, 81 position=(38 + x_inset, height - 67 + yoffs), 82 size=(140, 50), 83 scale=0.9, 84 text_scale=1.0, 85 autoselect=True, 86 label=bui.Lstr(resource='cancelText'), 87 on_activate_call=self.main_window_back, 88 ) 89 90 bui.containerwidget(edit=self._root_widget, cancel_button=btn) 91 bui.textwidget( 92 parent=self._root_widget, 93 position=(width * 0.5, height - 46 + yoffs), 94 size=(0, 0), 95 maxwidth=260, 96 scale=1.1, 97 text=bui.Lstr( 98 resource='mapSelectTitleText', 99 subs=[('${GAME}', self._gametype.get_display_string())], 100 ), 101 color=bui.app.ui_v1.title_color, 102 h_align='center', 103 v_align='center', 104 ) 105 v = height - 70 + yoffs 106 self._scroll_width = width - (80 + 2 * x_inset) 107 self._scroll_height = height - ( 108 170 if uiscale is bui.UIScale.SMALL else 140 109 ) 110 111 self._scrollwidget = bui.scrollwidget( 112 parent=self._root_widget, 113 position=(40 + x_inset, v - self._scroll_height), 114 size=(self._scroll_width, self._scroll_height), 115 ) 116 bui.containerwidget( 117 edit=self._root_widget, selected_child=self._scrollwidget 118 ) 119 bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) 120 121 self._subcontainer: bui.Widget | None = None 122 self._refresh(select_get_more_maps_button=select_get_more_maps_button)
Create a MainWindow given a root widget and transition info.
Automatically handles in and out transitions on the provided widget, so there is no need to set transitions when creating it.
124 @override 125 def get_main_window_state(self) -> bui.MainWindowState: 126 # Support recreating our window for back/refresh purposes. 127 cls = type(self) 128 129 # Pull things out of self here; if we do it in the lambda we'll 130 # keep ourself alive. 131 gametype = self._gametype 132 sessiontype = self._sessiontype 133 config = self._config 134 edit_info = self._edit_info 135 completion_call = self._completion_call 136 select_get_more_maps = self._selected_get_more_maps 137 138 return bui.BasicMainWindowState( 139 create_call=lambda transition, origin_widget: cls( 140 transition=transition, 141 origin_widget=origin_widget, 142 gametype=gametype, 143 sessiontype=sessiontype, 144 config=config, 145 edit_info=edit_info, 146 completion_call=completion_call, 147 select_get_more_maps_button=select_get_more_maps, 148 ) 149 )
Return a WindowState to recreate this window, if supported.
Inherited Members
- bauiv1._uitypes.MainWindow
- main_window_back_state
- main_window_is_top_level
- main_window_is_auxiliary
- main_window_close
- main_window_has_control
- main_window_back
- main_window_replace
- on_main_window_close
- bauiv1._uitypes.Window
- get_root_widget