bauiv1lib.playlist.addgame

Provides a window for selecting a game type to add to a playlist.

  1# Released under the MIT License. See LICENSE for details.
  2#
  3"""Provides a window for selecting a game type to add to a playlist."""
  4
  5from __future__ import annotations
  6
  7from typing import TYPE_CHECKING, override
  8
  9import bascenev1 as bs
 10import bauiv1 as bui
 11
 12if TYPE_CHECKING:
 13    from bauiv1lib.playlist.editcontroller import PlaylistEditController
 14
 15
 16class PlaylistAddGameWindow(bui.MainWindow):
 17    """Window for selecting a game type to add to a playlist."""
 18
 19    def __init__(
 20        self,
 21        editcontroller: PlaylistEditController,
 22        transition: str | None = 'in_right',
 23        origin_widget: bui.Widget | None = None,
 24    ):
 25        self._editcontroller = editcontroller
 26        self._r = 'addGameWindow'
 27        assert bui.app.classic is not None
 28        uiscale = bui.app.ui_v1.uiscale
 29        self._width = 750 if uiscale is bui.UIScale.SMALL else 650
 30        x_inset = 50 if uiscale is bui.UIScale.SMALL else 0
 31        self._height = (
 32            346
 33            if uiscale is bui.UIScale.SMALL
 34            else 380 if uiscale is bui.UIScale.MEDIUM else 440
 35        )
 36        top_extra = 30 if uiscale is bui.UIScale.SMALL else 20
 37        self._scroll_width = 210
 38
 39        super().__init__(
 40            root_widget=bui.containerwidget(
 41                size=(self._width, self._height + top_extra),
 42                scale=(
 43                    1.95
 44                    if uiscale is bui.UIScale.SMALL
 45                    else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0
 46                ),
 47                stack_offset=(0, 1) if uiscale is bui.UIScale.SMALL else (0, 0),
 48                toolbar_visibility='menu_minimal',
 49            ),
 50            transition=transition,
 51            origin_widget=origin_widget,
 52        )
 53
 54        if uiscale is bui.UIScale.SMALL:
 55            self._back_button = bui.get_special_widget('back_button')
 56        else:
 57            self._back_button = bui.buttonwidget(
 58                parent=self._root_widget,
 59                position=(58 + x_inset, self._height - 53),
 60                size=(165, 70),
 61                scale=0.75,
 62                text_scale=1.2,
 63                label=bui.Lstr(resource='backText'),
 64                autoselect=True,
 65                button_type='back',
 66                on_activate_call=self.main_window_back,
 67            )
 68        self._select_button = select_button = bui.buttonwidget(
 69            parent=self._root_widget,
 70            position=(self._width - (172 + x_inset), self._height - 50),
 71            autoselect=True,
 72            size=(160, 60),
 73            scale=0.75,
 74            text_scale=1.2,
 75            label=bui.Lstr(resource='selectText'),
 76            on_activate_call=self._add,
 77        )
 78
 79        bui.widget(
 80            edit=select_button,
 81            right_widget=bui.get_special_widget('squad_button'),
 82        )
 83
 84        bui.textwidget(
 85            parent=self._root_widget,
 86            position=(self._width * 0.5, self._height - 28),
 87            size=(0, 0),
 88            scale=1.0,
 89            text=bui.Lstr(resource=f'{self._r}.titleText'),
 90            h_align='center',
 91            color=bui.app.ui_v1.title_color,
 92            maxwidth=250,
 93            v_align='center',
 94        )
 95        v = self._height - 64
 96
 97        self._selected_title_text = bui.textwidget(
 98            parent=self._root_widget,
 99            position=(x_inset + self._scroll_width + 50 + 30, v - 15),
100            size=(0, 0),
101            scale=1.0,
102            color=(0.7, 1.0, 0.7, 1.0),
103            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
104            h_align='left',
105            v_align='center',
106        )
107        v -= 30
108
109        self._selected_description_text = bui.textwidget(
110            parent=self._root_widget,
111            position=(x_inset + self._scroll_width + 50 + 30, v),
112            size=(0, 0),
113            scale=0.7,
114            color=(0.5, 0.8, 0.5, 1.0),
115            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
116            h_align='left',
117        )
118
119        scroll_height = self._height - 100
120
121        v = self._height - 60
122
123        self._scrollwidget = bui.scrollwidget(
124            parent=self._root_widget,
125            position=(x_inset + 61, v - scroll_height),
126            size=(self._scroll_width, scroll_height),
127            highlight=False,
128        )
129        bui.widget(
130            edit=self._scrollwidget,
131            up_widget=self._back_button,
132            left_widget=self._back_button,
133            right_widget=select_button,
134        )
135        self._column: bui.Widget | None = None
136
137        v -= 35
138
139        if uiscale is bui.UIScale.SMALL:
140            bui.containerwidget(
141                edit=self._root_widget, on_cancel_call=self.main_window_back
142            )
143        else:
144            bui.containerwidget(
145                edit=self._root_widget,
146                cancel_button=self._back_button,
147            )
148        bui.containerwidget(edit=self._root_widget, start_button=select_button)
149
150        self._selected_game_type: type[bs.GameActivity] | None = None
151
152        bui.containerwidget(
153            edit=self._root_widget, selected_child=self._scrollwidget
154        )
155
156        self._game_types: list[type[bs.GameActivity]] = []
157
158        # Get actual games loading in the bg.
159        bui.app.meta.load_exported_classes(
160            bs.GameActivity,
161            self._on_game_types_loaded,
162            completion_cb_in_bg_thread=True,
163        )
164
165        # Refresh with our initial empty list. We'll refresh again once
166        # game loading is complete.
167        self._refresh()
168
169    @override
170    def get_main_window_state(self) -> bui.MainWindowState:
171        # Support recreating our window for back/refresh purposes.
172        cls = type(self)
173
174        # Avoid dereferencing self from the lambda or we'll keep
175        # ourself alive indefinitely.
176        editcontroller = self._editcontroller
177
178        return bui.BasicMainWindowState(
179            create_call=lambda transition, origin_widget: cls(
180                transition=transition,
181                origin_widget=origin_widget,
182                editcontroller=editcontroller,
183            )
184        )
185
186    def _on_game_types_loaded(
187        self, gametypes: list[type[bs.GameActivity]]
188    ) -> None:
189        assert bui.app.classic is not None
190        store = bui.app.classic.store
191
192        # We asked for a bg thread completion cb so we can do some
193        # filtering here in the bg thread where its not gonna cause hitches.
194        assert not bui.in_logic_thread()
195        sessiontype = self._editcontroller.get_session_type()
196        unowned = store.get_unowned_game_types()
197        self._game_types = [
198            gt
199            for gt in gametypes
200            if gt not in unowned and gt.supports_session_type(sessiontype)
201        ]
202
203        # Sort in the current language.
204        self._game_types.sort(key=lambda g: g.get_display_string().evaluate())
205
206        # Tell ourself to refresh back in the logic thread.
207        bui.pushcall(self._refresh, from_other_thread=True)
208
209    def _refresh(self, select_get_more_games_button: bool = False) -> None:
210        if self._column is not None:
211            self._column.delete()
212
213        self._column = bui.columnwidget(
214            parent=self._scrollwidget, border=2, margin=0
215        )
216
217        for i, gametype in enumerate(self._game_types):
218
219            def _doit() -> None:
220                if self._select_button:
221                    bui.apptimer(0.1, self._select_button.activate)
222
223            txt = bui.textwidget(
224                parent=self._column,
225                position=(0, 0),
226                size=(self._scroll_width * 1.1, 24),
227                text=gametype.get_display_string(),
228                h_align='left',
229                v_align='center',
230                color=(0.8, 0.8, 0.8, 1.0),
231                maxwidth=self._scroll_width * 0.8,
232                on_select_call=bui.Call(self._set_selected_game_type, gametype),
233                always_highlight=True,
234                selectable=True,
235                on_activate_call=_doit,
236            )
237            if i == 0:
238                bui.widget(edit=txt, up_widget=self._back_button)
239
240        self._get_more_games_button = bui.buttonwidget(
241            parent=self._column,
242            autoselect=True,
243            label=bui.Lstr(resource=f'{self._r}.getMoreGamesText'),
244            color=(0.54, 0.52, 0.67),
245            textcolor=(0.7, 0.65, 0.7),
246            on_activate_call=self._on_get_more_games_press,
247            size=(178, 50),
248        )
249        if select_get_more_games_button:
250            bui.containerwidget(
251                edit=self._column,
252                selected_child=self._get_more_games_button,
253                visible_child=self._get_more_games_button,
254            )
255
256    def _on_get_more_games_press(self) -> None:
257        from bauiv1lib.account import show_sign_in_prompt
258        from bauiv1lib.store.browser import StoreBrowserWindow
259
260        plus = bui.app.plus
261        assert plus is not None
262
263        if plus.get_v1_account_state() != 'signed_in':
264            show_sign_in_prompt()
265            return
266        StoreBrowserWindow(
267            modal=True,
268            show_tab=StoreBrowserWindow.TabID.MINIGAMES,
269            on_close_call=self._on_store_close,
270            origin_widget=self._get_more_games_button,
271        )
272
273    def _on_store_close(self) -> None:
274        self._refresh(select_get_more_games_button=True)
275
276    def _add(self) -> None:
277        bui.lock_all_input()  # Make sure no more commands happen.
278        bui.apptimer(0.1, bui.unlock_all_input)
279        assert self._selected_game_type is not None
280        self._editcontroller.add_game_type_selected(self._selected_game_type)
281
282    def _set_selected_game_type(self, gametype: type[bs.GameActivity]) -> None:
283        self._selected_game_type = gametype
284        bui.textwidget(
285            edit=self._selected_title_text, text=gametype.get_display_string()
286        )
287        bui.textwidget(
288            edit=self._selected_description_text,
289            text=gametype.get_description_display_string(
290                self._editcontroller.get_session_type()
291            ),
292        )
293
294    # def _back(self) -> None:
295    #     self._editcontroller.add_game_cancelled()
class PlaylistAddGameWindow(bauiv1._uitypes.MainWindow):
 17class PlaylistAddGameWindow(bui.MainWindow):
 18    """Window for selecting a game type to add to a playlist."""
 19
 20    def __init__(
 21        self,
 22        editcontroller: PlaylistEditController,
 23        transition: str | None = 'in_right',
 24        origin_widget: bui.Widget | None = None,
 25    ):
 26        self._editcontroller = editcontroller
 27        self._r = 'addGameWindow'
 28        assert bui.app.classic is not None
 29        uiscale = bui.app.ui_v1.uiscale
 30        self._width = 750 if uiscale is bui.UIScale.SMALL else 650
 31        x_inset = 50 if uiscale is bui.UIScale.SMALL else 0
 32        self._height = (
 33            346
 34            if uiscale is bui.UIScale.SMALL
 35            else 380 if uiscale is bui.UIScale.MEDIUM else 440
 36        )
 37        top_extra = 30 if uiscale is bui.UIScale.SMALL else 20
 38        self._scroll_width = 210
 39
 40        super().__init__(
 41            root_widget=bui.containerwidget(
 42                size=(self._width, self._height + top_extra),
 43                scale=(
 44                    1.95
 45                    if uiscale is bui.UIScale.SMALL
 46                    else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0
 47                ),
 48                stack_offset=(0, 1) if uiscale is bui.UIScale.SMALL else (0, 0),
 49                toolbar_visibility='menu_minimal',
 50            ),
 51            transition=transition,
 52            origin_widget=origin_widget,
 53        )
 54
 55        if uiscale is bui.UIScale.SMALL:
 56            self._back_button = bui.get_special_widget('back_button')
 57        else:
 58            self._back_button = bui.buttonwidget(
 59                parent=self._root_widget,
 60                position=(58 + x_inset, self._height - 53),
 61                size=(165, 70),
 62                scale=0.75,
 63                text_scale=1.2,
 64                label=bui.Lstr(resource='backText'),
 65                autoselect=True,
 66                button_type='back',
 67                on_activate_call=self.main_window_back,
 68            )
 69        self._select_button = select_button = bui.buttonwidget(
 70            parent=self._root_widget,
 71            position=(self._width - (172 + x_inset), self._height - 50),
 72            autoselect=True,
 73            size=(160, 60),
 74            scale=0.75,
 75            text_scale=1.2,
 76            label=bui.Lstr(resource='selectText'),
 77            on_activate_call=self._add,
 78        )
 79
 80        bui.widget(
 81            edit=select_button,
 82            right_widget=bui.get_special_widget('squad_button'),
 83        )
 84
 85        bui.textwidget(
 86            parent=self._root_widget,
 87            position=(self._width * 0.5, self._height - 28),
 88            size=(0, 0),
 89            scale=1.0,
 90            text=bui.Lstr(resource=f'{self._r}.titleText'),
 91            h_align='center',
 92            color=bui.app.ui_v1.title_color,
 93            maxwidth=250,
 94            v_align='center',
 95        )
 96        v = self._height - 64
 97
 98        self._selected_title_text = bui.textwidget(
 99            parent=self._root_widget,
100            position=(x_inset + self._scroll_width + 50 + 30, v - 15),
101            size=(0, 0),
102            scale=1.0,
103            color=(0.7, 1.0, 0.7, 1.0),
104            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
105            h_align='left',
106            v_align='center',
107        )
108        v -= 30
109
110        self._selected_description_text = bui.textwidget(
111            parent=self._root_widget,
112            position=(x_inset + self._scroll_width + 50 + 30, v),
113            size=(0, 0),
114            scale=0.7,
115            color=(0.5, 0.8, 0.5, 1.0),
116            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
117            h_align='left',
118        )
119
120        scroll_height = self._height - 100
121
122        v = self._height - 60
123
124        self._scrollwidget = bui.scrollwidget(
125            parent=self._root_widget,
126            position=(x_inset + 61, v - scroll_height),
127            size=(self._scroll_width, scroll_height),
128            highlight=False,
129        )
130        bui.widget(
131            edit=self._scrollwidget,
132            up_widget=self._back_button,
133            left_widget=self._back_button,
134            right_widget=select_button,
135        )
136        self._column: bui.Widget | None = None
137
138        v -= 35
139
140        if uiscale is bui.UIScale.SMALL:
141            bui.containerwidget(
142                edit=self._root_widget, on_cancel_call=self.main_window_back
143            )
144        else:
145            bui.containerwidget(
146                edit=self._root_widget,
147                cancel_button=self._back_button,
148            )
149        bui.containerwidget(edit=self._root_widget, start_button=select_button)
150
151        self._selected_game_type: type[bs.GameActivity] | None = None
152
153        bui.containerwidget(
154            edit=self._root_widget, selected_child=self._scrollwidget
155        )
156
157        self._game_types: list[type[bs.GameActivity]] = []
158
159        # Get actual games loading in the bg.
160        bui.app.meta.load_exported_classes(
161            bs.GameActivity,
162            self._on_game_types_loaded,
163            completion_cb_in_bg_thread=True,
164        )
165
166        # Refresh with our initial empty list. We'll refresh again once
167        # game loading is complete.
168        self._refresh()
169
170    @override
171    def get_main_window_state(self) -> bui.MainWindowState:
172        # Support recreating our window for back/refresh purposes.
173        cls = type(self)
174
175        # Avoid dereferencing self from the lambda or we'll keep
176        # ourself alive indefinitely.
177        editcontroller = self._editcontroller
178
179        return bui.BasicMainWindowState(
180            create_call=lambda transition, origin_widget: cls(
181                transition=transition,
182                origin_widget=origin_widget,
183                editcontroller=editcontroller,
184            )
185        )
186
187    def _on_game_types_loaded(
188        self, gametypes: list[type[bs.GameActivity]]
189    ) -> None:
190        assert bui.app.classic is not None
191        store = bui.app.classic.store
192
193        # We asked for a bg thread completion cb so we can do some
194        # filtering here in the bg thread where its not gonna cause hitches.
195        assert not bui.in_logic_thread()
196        sessiontype = self._editcontroller.get_session_type()
197        unowned = store.get_unowned_game_types()
198        self._game_types = [
199            gt
200            for gt in gametypes
201            if gt not in unowned and gt.supports_session_type(sessiontype)
202        ]
203
204        # Sort in the current language.
205        self._game_types.sort(key=lambda g: g.get_display_string().evaluate())
206
207        # Tell ourself to refresh back in the logic thread.
208        bui.pushcall(self._refresh, from_other_thread=True)
209
210    def _refresh(self, select_get_more_games_button: bool = False) -> None:
211        if self._column is not None:
212            self._column.delete()
213
214        self._column = bui.columnwidget(
215            parent=self._scrollwidget, border=2, margin=0
216        )
217
218        for i, gametype in enumerate(self._game_types):
219
220            def _doit() -> None:
221                if self._select_button:
222                    bui.apptimer(0.1, self._select_button.activate)
223
224            txt = bui.textwidget(
225                parent=self._column,
226                position=(0, 0),
227                size=(self._scroll_width * 1.1, 24),
228                text=gametype.get_display_string(),
229                h_align='left',
230                v_align='center',
231                color=(0.8, 0.8, 0.8, 1.0),
232                maxwidth=self._scroll_width * 0.8,
233                on_select_call=bui.Call(self._set_selected_game_type, gametype),
234                always_highlight=True,
235                selectable=True,
236                on_activate_call=_doit,
237            )
238            if i == 0:
239                bui.widget(edit=txt, up_widget=self._back_button)
240
241        self._get_more_games_button = bui.buttonwidget(
242            parent=self._column,
243            autoselect=True,
244            label=bui.Lstr(resource=f'{self._r}.getMoreGamesText'),
245            color=(0.54, 0.52, 0.67),
246            textcolor=(0.7, 0.65, 0.7),
247            on_activate_call=self._on_get_more_games_press,
248            size=(178, 50),
249        )
250        if select_get_more_games_button:
251            bui.containerwidget(
252                edit=self._column,
253                selected_child=self._get_more_games_button,
254                visible_child=self._get_more_games_button,
255            )
256
257    def _on_get_more_games_press(self) -> None:
258        from bauiv1lib.account import show_sign_in_prompt
259        from bauiv1lib.store.browser import StoreBrowserWindow
260
261        plus = bui.app.plus
262        assert plus is not None
263
264        if plus.get_v1_account_state() != 'signed_in':
265            show_sign_in_prompt()
266            return
267        StoreBrowserWindow(
268            modal=True,
269            show_tab=StoreBrowserWindow.TabID.MINIGAMES,
270            on_close_call=self._on_store_close,
271            origin_widget=self._get_more_games_button,
272        )
273
274    def _on_store_close(self) -> None:
275        self._refresh(select_get_more_games_button=True)
276
277    def _add(self) -> None:
278        bui.lock_all_input()  # Make sure no more commands happen.
279        bui.apptimer(0.1, bui.unlock_all_input)
280        assert self._selected_game_type is not None
281        self._editcontroller.add_game_type_selected(self._selected_game_type)
282
283    def _set_selected_game_type(self, gametype: type[bs.GameActivity]) -> None:
284        self._selected_game_type = gametype
285        bui.textwidget(
286            edit=self._selected_title_text, text=gametype.get_display_string()
287        )
288        bui.textwidget(
289            edit=self._selected_description_text,
290            text=gametype.get_description_display_string(
291                self._editcontroller.get_session_type()
292            ),
293        )
294
295    # def _back(self) -> None:
296    #     self._editcontroller.add_game_cancelled()

Window for selecting a game type to add to a playlist.

PlaylistAddGameWindow( editcontroller: bauiv1lib.playlist.editcontroller.PlaylistEditController, transition: str | None = 'in_right', origin_widget: _bauiv1.Widget | None = None)
 20    def __init__(
 21        self,
 22        editcontroller: PlaylistEditController,
 23        transition: str | None = 'in_right',
 24        origin_widget: bui.Widget | None = None,
 25    ):
 26        self._editcontroller = editcontroller
 27        self._r = 'addGameWindow'
 28        assert bui.app.classic is not None
 29        uiscale = bui.app.ui_v1.uiscale
 30        self._width = 750 if uiscale is bui.UIScale.SMALL else 650
 31        x_inset = 50 if uiscale is bui.UIScale.SMALL else 0
 32        self._height = (
 33            346
 34            if uiscale is bui.UIScale.SMALL
 35            else 380 if uiscale is bui.UIScale.MEDIUM else 440
 36        )
 37        top_extra = 30 if uiscale is bui.UIScale.SMALL else 20
 38        self._scroll_width = 210
 39
 40        super().__init__(
 41            root_widget=bui.containerwidget(
 42                size=(self._width, self._height + top_extra),
 43                scale=(
 44                    1.95
 45                    if uiscale is bui.UIScale.SMALL
 46                    else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0
 47                ),
 48                stack_offset=(0, 1) if uiscale is bui.UIScale.SMALL else (0, 0),
 49                toolbar_visibility='menu_minimal',
 50            ),
 51            transition=transition,
 52            origin_widget=origin_widget,
 53        )
 54
 55        if uiscale is bui.UIScale.SMALL:
 56            self._back_button = bui.get_special_widget('back_button')
 57        else:
 58            self._back_button = bui.buttonwidget(
 59                parent=self._root_widget,
 60                position=(58 + x_inset, self._height - 53),
 61                size=(165, 70),
 62                scale=0.75,
 63                text_scale=1.2,
 64                label=bui.Lstr(resource='backText'),
 65                autoselect=True,
 66                button_type='back',
 67                on_activate_call=self.main_window_back,
 68            )
 69        self._select_button = select_button = bui.buttonwidget(
 70            parent=self._root_widget,
 71            position=(self._width - (172 + x_inset), self._height - 50),
 72            autoselect=True,
 73            size=(160, 60),
 74            scale=0.75,
 75            text_scale=1.2,
 76            label=bui.Lstr(resource='selectText'),
 77            on_activate_call=self._add,
 78        )
 79
 80        bui.widget(
 81            edit=select_button,
 82            right_widget=bui.get_special_widget('squad_button'),
 83        )
 84
 85        bui.textwidget(
 86            parent=self._root_widget,
 87            position=(self._width * 0.5, self._height - 28),
 88            size=(0, 0),
 89            scale=1.0,
 90            text=bui.Lstr(resource=f'{self._r}.titleText'),
 91            h_align='center',
 92            color=bui.app.ui_v1.title_color,
 93            maxwidth=250,
 94            v_align='center',
 95        )
 96        v = self._height - 64
 97
 98        self._selected_title_text = bui.textwidget(
 99            parent=self._root_widget,
100            position=(x_inset + self._scroll_width + 50 + 30, v - 15),
101            size=(0, 0),
102            scale=1.0,
103            color=(0.7, 1.0, 0.7, 1.0),
104            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
105            h_align='left',
106            v_align='center',
107        )
108        v -= 30
109
110        self._selected_description_text = bui.textwidget(
111            parent=self._root_widget,
112            position=(x_inset + self._scroll_width + 50 + 30, v),
113            size=(0, 0),
114            scale=0.7,
115            color=(0.5, 0.8, 0.5, 1.0),
116            maxwidth=self._width - self._scroll_width - 150 - x_inset * 2,
117            h_align='left',
118        )
119
120        scroll_height = self._height - 100
121
122        v = self._height - 60
123
124        self._scrollwidget = bui.scrollwidget(
125            parent=self._root_widget,
126            position=(x_inset + 61, v - scroll_height),
127            size=(self._scroll_width, scroll_height),
128            highlight=False,
129        )
130        bui.widget(
131            edit=self._scrollwidget,
132            up_widget=self._back_button,
133            left_widget=self._back_button,
134            right_widget=select_button,
135        )
136        self._column: bui.Widget | None = None
137
138        v -= 35
139
140        if uiscale is bui.UIScale.SMALL:
141            bui.containerwidget(
142                edit=self._root_widget, on_cancel_call=self.main_window_back
143            )
144        else:
145            bui.containerwidget(
146                edit=self._root_widget,
147                cancel_button=self._back_button,
148            )
149        bui.containerwidget(edit=self._root_widget, start_button=select_button)
150
151        self._selected_game_type: type[bs.GameActivity] | None = None
152
153        bui.containerwidget(
154            edit=self._root_widget, selected_child=self._scrollwidget
155        )
156
157        self._game_types: list[type[bs.GameActivity]] = []
158
159        # Get actual games loading in the bg.
160        bui.app.meta.load_exported_classes(
161            bs.GameActivity,
162            self._on_game_types_loaded,
163            completion_cb_in_bg_thread=True,
164        )
165
166        # Refresh with our initial empty list. We'll refresh again once
167        # game loading is complete.
168        self._refresh()

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.

@override
def get_main_window_state(self) -> bauiv1.MainWindowState:
170    @override
171    def get_main_window_state(self) -> bui.MainWindowState:
172        # Support recreating our window for back/refresh purposes.
173        cls = type(self)
174
175        # Avoid dereferencing self from the lambda or we'll keep
176        # ourself alive indefinitely.
177        editcontroller = self._editcontroller
178
179        return bui.BasicMainWindowState(
180            create_call=lambda transition, origin_widget: cls(
181                transition=transition,
182                origin_widget=origin_widget,
183                editcontroller=editcontroller,
184            )
185        )

Return a WindowState to recreate this window, if supported.

Inherited Members
bauiv1._uitypes.MainWindow
main_window_back_state
main_window_close
can_change_main_window
main_window_back
main_window_replace
on_main_window_close
bauiv1._uitypes.Window
get_root_widget