mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-26 08:53:32 +08:00
updated playlist editing for MainWindow system
This commit is contained in:
parent
9b85768cd0
commit
b550866ed7
56
.efrocachemap
generated
56
.efrocachemap
generated
@ -4096,26 +4096,26 @@
|
||||
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
||||
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
||||
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "6f45d8d041a5c44d44e6da00ddd68983",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "fc5c2514f1773c91159fc8014e5f3e93",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "a8679f4c2a071af5f024c04fb2de5685",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "2d32e5d05331df1b4b6923ee241b630b",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "8d9d7a041a1d3e56aec39682821927f6",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "0d0405cb2e05629b0a23d6b8eca203ad",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "338528869c6fd8797b96cb875e3820cf",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "4428797051af1f7fde71fb638db52b17",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "c202858e8db64aebb88be04828ddfaa9",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "bd13e0e3edf0aac64609fb764921d7b1",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "f183757c9541262774adb1e0599f2001",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "85791e6585f4858517330e23834fc7b8",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "90b0d97ebaf7756824493b2fcee1e97e",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "955eef9f918e24c37e279db75ec6fca3",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "b42ae8f5896f850e72fc4c30b2b8c52b",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "dda8f5a5099d9b695c9ab5a148f5ff10",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "8389b61cf60dd2f4ebad8b0e2c376605",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "cce612fb88788b32b303a956cd6fd6f5",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "d54a451817bee9d4f8debd1fecf84ae9",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "e41c4795f5b6f7dd0cf61286e62e91ac",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "b4a141253c7e65acf25669015d739dc8",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "66dd516f011240f4bd89d960747f5306",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "7467a00e52c02904d385a9f03cb938c1",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "bff07f7aaba6de3994093450f6b7652e",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "e4264a74c5197c903ced0f9fad9f358f",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "0b2b7ffdcba7fce08115d60f46907dd3",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "2b6bedf49d78797be81a3a91a40faea4",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "8a83499d274108ac181c8709cfecebcc",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "ac51052669f94969d50c32c3bb5faa39",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "0de05110dc0d73c578f1ee90098d062f",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "29536a3ccaa1373662a9ad61d15ea311",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "56d6bd161d82ff248b1389c83dbc1a9e",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "8cfafd625e0744cc1cd6a825d4192d6b",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "5673525e6591eed323a574dbc4e053cd",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "fef949796918e90da2c867d212923fc5",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "2c5b61d0105dc5c2c0d69fee4de0b3bb",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "27084c4785c00b0b47348a7ea2121df4",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "b474ebbbd3498bfbbf7ade35bf4e3273",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "9d364f0f8023699a7f4c14ee4f1f80a2",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "e8b7846713d5aca5a9a472652b49bced",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "73ad3303fe1a82005918fbc5dae3446c",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "fa659b5d6119acba6570c92ce4d35ae2",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "73ad3303fe1a82005918fbc5dae3446c",
|
||||
@ -4132,14 +4132,14 @@
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "3e5c5fd0a09f55ba7b05ce1e2ec7171e",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "1659535e95e3047fda529543e265ac97",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "3e5c5fd0a09f55ba7b05ce1e2ec7171e",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "ccc8a569891e0e5541706ca21aa91a3e",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "f39ae9be9fe75e16f45ea78f2bd3147a",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "5b1eb9ecc0eaaa22fb0b838479515deb",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "41977e7f7bbd1baa587661e9c0daee85",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "92451c795510652611fdac035839f0eb",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "6b3215ddfb8bb3ff8149b380f829806a",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "1980c181a06f7355770d31499b7f9245",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "ce4592ab12f3954f62140365211c8eb4",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "8f7ffb5997d1601d57d71af95584d719",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "cacccdf999c17e285edfb89a830f2286",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "c39508091d106d9fb77fd676a14ae4b1",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "584298e65be570d131f7543744c28b47",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "79a0e0beb67caef006d3ef5d3afa3fae",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "a5520e9b3ba6556412381d179a9e3884",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "5ad1b6928cdb9fb4e0c29f399785f535",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "504cfbf0d946547c3c26bda13afe0833",
|
||||
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
||||
"src/assets/ba_data/python/babase/_mgen/enums.py": "cb299985623bbcc86015cb103a424ae6",
|
||||
"src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
### 1.7.37 (build 21978, api 9, 2024-09-03)
|
||||
### 1.7.37 (build 21980, api 9, 2024-09-03)
|
||||
- Bumping api version to 9. As you'll see below, there's some UI changes that
|
||||
will require a bit of work for any UI mods to adapt to. If your mods don't
|
||||
touch UI stuff at all you can simply bump your api version and call it a day.
|
||||
|
||||
@ -52,7 +52,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# Build number and version of the ballistica binary we expect to be
|
||||
# using.
|
||||
TARGET_BALLISTICA_BUILD = 21978
|
||||
TARGET_BALLISTICA_BUILD = 21980
|
||||
TARGET_BALLISTICA_VERSION = '1.7.37'
|
||||
|
||||
|
||||
|
||||
@ -64,43 +64,43 @@ class GameActivity(Activity[PlayerT, TeamT]):
|
||||
# (unless overridden by the map).
|
||||
default_music: bascenev1.MusicType | None = None
|
||||
|
||||
@classmethod
|
||||
def create_settings_ui(
|
||||
cls,
|
||||
sessiontype: type[bascenev1.Session],
|
||||
settings: dict | None,
|
||||
completion_call: Callable[[dict | None], None],
|
||||
) -> None:
|
||||
"""Launch an in-game UI to configure settings for a game type.
|
||||
# @classmethod
|
||||
# def create_settings_ui(
|
||||
# cls,
|
||||
# sessiontype: type[bascenev1.Session],
|
||||
# settings: dict | None,
|
||||
# completion_call: Callable[[dict | None], None],
|
||||
# ) -> None:
|
||||
# """Launch an in-game UI to configure settings for a game type.
|
||||
|
||||
'sessiontype' should be the bascenev1.Session class the game will
|
||||
be used in.
|
||||
# 'sessiontype' should be the bascenev1.Session class the game will
|
||||
# be used in.
|
||||
|
||||
'settings' should be an existing settings dict (implies 'edit'
|
||||
ui mode) or None (implies 'add' ui mode).
|
||||
# 'settings' should be an existing settings dict (implies 'edit'
|
||||
# ui mode) or None (implies 'add' ui mode).
|
||||
|
||||
'completion_call' will be called with a filled-out settings dict on
|
||||
success or None on cancel.
|
||||
# 'completion_call' will be called with a filled-out settings dict on
|
||||
# success or None on cancel.
|
||||
|
||||
Generally subclasses don't need to override this; if they override
|
||||
bascenev1.GameActivity.get_available_settings() and
|
||||
bascenev1.GameActivity.get_supported_maps() they can just rely on
|
||||
the default implementation here which calls those methods.
|
||||
"""
|
||||
# pylint: disable=cyclic-import
|
||||
from bauiv1lib.playlist.editgame import PlaylistEditGameWindow
|
||||
# Generally subclasses don't need to override this; if they override
|
||||
# bascenev1.GameActivity.get_available_settings() and
|
||||
# bascenev1.GameActivity.get_supported_maps() they can just rely on
|
||||
# the default implementation here which calls those methods.
|
||||
# """
|
||||
# # pylint: disable=cyclic-import
|
||||
# from bauiv1lib.playlist.editgame import PlaylistEditGameWindow
|
||||
|
||||
assert babase.app.classic is not None
|
||||
babase.app.ui_v1.clear_main_window()
|
||||
babase.app.ui_v1.set_main_window(
|
||||
PlaylistEditGameWindow(
|
||||
cls,
|
||||
sessiontype,
|
||||
settings,
|
||||
completion_call=completion_call,
|
||||
),
|
||||
from_window=False, # Disable check since we don't know.
|
||||
)
|
||||
# assert babase.app.classic is not None
|
||||
# babase.app.ui_v1.clear_main_window()
|
||||
# babase.app.ui_v1.set_main_window(
|
||||
# PlaylistEditGameWindow(
|
||||
# cls,
|
||||
# sessiontype,
|
||||
# settings,
|
||||
# completion_call=completion_call,
|
||||
# ),
|
||||
# from_window=False, # Disable check since we don't know.
|
||||
# )
|
||||
|
||||
@classmethod
|
||||
def getscoreconfig(cls) -> bascenev1.ScoreConfig:
|
||||
|
||||
@ -181,7 +181,8 @@ class CharacterPicker(PopupWindow):
|
||||
|
||||
def _on_store_press(self) -> None:
|
||||
from bauiv1lib.account import show_sign_in_prompt
|
||||
from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
# from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
plus = bui.app.plus
|
||||
assert plus is not None
|
||||
@ -189,12 +190,16 @@ class CharacterPicker(PopupWindow):
|
||||
if plus.get_v1_account_state() != 'signed_in':
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._transition_out()
|
||||
StoreBrowserWindow(
|
||||
modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.CHARACTERS,
|
||||
origin_widget=self._get_more_characters_button,
|
||||
)
|
||||
|
||||
bui.screenmessage('UNDER CONSTRUCTION')
|
||||
return
|
||||
|
||||
# self._transition_out()
|
||||
# StoreBrowserWindow(
|
||||
# modal=True,
|
||||
# show_tab=StoreBrowserWindow.TabID.CHARACTERS,
|
||||
# origin_widget=self._get_more_characters_button,
|
||||
# )
|
||||
|
||||
def _select_character(self, character: str) -> None:
|
||||
if self._delegate is not None:
|
||||
|
||||
@ -159,7 +159,8 @@ class IconPicker(PopupWindow):
|
||||
|
||||
def _on_store_press(self) -> None:
|
||||
from bauiv1lib.account import show_sign_in_prompt
|
||||
from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
# from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
plus = bui.app.plus
|
||||
assert plus is not None
|
||||
@ -167,12 +168,16 @@ class IconPicker(PopupWindow):
|
||||
if plus.get_v1_account_state() != 'signed_in':
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
self._transition_out()
|
||||
StoreBrowserWindow(
|
||||
modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.ICONS,
|
||||
origin_widget=self._get_more_icons_button,
|
||||
)
|
||||
# self._transition_out()
|
||||
|
||||
bui.screenmessage('UNDER CONSTRUCTION')
|
||||
return
|
||||
|
||||
# StoreBrowserWindow(
|
||||
# modal=True,
|
||||
# show_tab=StoreBrowserWindow.TabID.ICONS,
|
||||
# origin_widget=self._get_more_icons_button,
|
||||
# )
|
||||
|
||||
def _select_icon(self, icon: str) -> None:
|
||||
if self._delegate is not None:
|
||||
|
||||
@ -57,12 +57,10 @@ class PlaylistAddGameWindow(bui.MainWindow):
|
||||
self._back_button = bui.buttonwidget(
|
||||
parent=self._root_widget,
|
||||
position=(58 + x_inset, self._height - 53),
|
||||
size=(165, 70),
|
||||
scale=0.75,
|
||||
text_scale=1.2,
|
||||
label=bui.Lstr(resource='backText'),
|
||||
size=(60, 48),
|
||||
label=bui.charstr(bui.SpecialChar.BACK),
|
||||
autoselect=True,
|
||||
button_type='back',
|
||||
button_type='backSmall',
|
||||
on_activate_call=self.main_window_back,
|
||||
)
|
||||
self._select_button = select_button = bui.buttonwidget(
|
||||
@ -257,27 +255,37 @@ class PlaylistAddGameWindow(bui.MainWindow):
|
||||
from bauiv1lib.account import show_sign_in_prompt
|
||||
from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
# No-op if we're not in control.
|
||||
if self.main_window_has_control():
|
||||
return
|
||||
|
||||
plus = bui.app.plus
|
||||
assert plus is not None
|
||||
|
||||
if plus.get_v1_account_state() != 'signed_in':
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
StoreBrowserWindow(
|
||||
modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.MINIGAMES,
|
||||
on_close_call=self._on_store_close,
|
||||
origin_widget=self._get_more_games_button,
|
||||
|
||||
self.main_window_replace(
|
||||
StoreBrowserWindow(
|
||||
# modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.MINIGAMES,
|
||||
# on_close_call=self._on_store_close,
|
||||
origin_widget=self._get_more_games_button,
|
||||
minimal_toolbars=True,
|
||||
)
|
||||
)
|
||||
|
||||
def _on_store_close(self) -> None:
|
||||
self._refresh(select_get_more_games_button=True)
|
||||
# def _on_store_close(self) -> None:
|
||||
# self._refresh(select_get_more_games_button=True)
|
||||
|
||||
def _add(self) -> None:
|
||||
bui.lock_all_input() # Make sure no more commands happen.
|
||||
bui.apptimer(0.1, bui.unlock_all_input)
|
||||
assert self._selected_game_type is not None
|
||||
self._editcontroller.add_game_type_selected(self._selected_game_type)
|
||||
self._editcontroller.add_game_type_selected(
|
||||
self._selected_game_type, from_window=self
|
||||
)
|
||||
|
||||
def _set_selected_game_type(self, gametype: type[bs.GameActivity]) -> None:
|
||||
self._selected_game_type = gametype
|
||||
@ -290,6 +298,3 @@ class PlaylistAddGameWindow(bui.MainWindow):
|
||||
self._editcontroller.get_session_type()
|
||||
),
|
||||
)
|
||||
|
||||
# def _back(self) -> None:
|
||||
# self._editcontroller.add_game_cancelled()
|
||||
|
||||
@ -114,8 +114,6 @@ class PlaylistBrowserWindow(bui.MainWindow):
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
)
|
||||
# if uiscale is bui.UIScale.SMALL and bui.app.ui_v1.use_toolbars:
|
||||
# bui.textwidget(edit=txt, text='')
|
||||
|
||||
bui.buttonwidget(
|
||||
edit=self._back_button,
|
||||
@ -152,8 +150,8 @@ class PlaylistBrowserWindow(bui.MainWindow):
|
||||
self._config_name_full = self._pvars.config_name + ' Playlists'
|
||||
self._last_config = None
|
||||
|
||||
# Update now and once per second.
|
||||
# (this should do our initial refresh)
|
||||
# Update now and once per second (this should do our initial
|
||||
# refresh).
|
||||
self._update()
|
||||
self._update_timer = bui.AppTimer(
|
||||
1.0, bui.WeakCall(self._update), repeat=True
|
||||
@ -675,13 +673,12 @@ class PlaylistBrowserWindow(bui.MainWindow):
|
||||
# Launching a regular game session; simply get our window
|
||||
# transitioning out.
|
||||
self.main_window_close(transition='out_left')
|
||||
# bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
|
||||
def _on_playlist_select(self, playlist_name: str) -> None:
|
||||
self._selected_playlist = playlist_name
|
||||
|
||||
def _update(self) -> None:
|
||||
# make sure config exists
|
||||
# Make sure config exists.
|
||||
if self._config_name_full not in bui.app.config:
|
||||
bui.app.config[self._config_name_full] = {}
|
||||
|
||||
@ -725,7 +722,6 @@ class PlaylistBrowserWindow(bui.MainWindow):
|
||||
|
||||
self._save_state()
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
# assert bui.app.classic is not None
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistCustomizeBrowserWindow(
|
||||
origin_widget=self._customize_button,
|
||||
@ -756,15 +752,6 @@ class PlaylistBrowserWindow(bui.MainWindow):
|
||||
|
||||
self.main_window_back()
|
||||
|
||||
# self._save_state()
|
||||
# bui.containerwidget(
|
||||
# edit=self._root_widget, transition=self._transition_out
|
||||
# )
|
||||
# assert bui.app.classic is not None
|
||||
# bui.app.ui_v1.set_main_window(
|
||||
# PlayWindow(transition='in_left'), from_window=self, is_back=True
|
||||
# )
|
||||
|
||||
def _save_state(self) -> None:
|
||||
try:
|
||||
sel = self._root_widget.get_selected_child()
|
||||
|
||||
@ -6,19 +6,19 @@ from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import time
|
||||
import logging
|
||||
|
||||
# import logging
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
import bascenev1 as bs
|
||||
# import bascenev1 as bs
|
||||
import bauiv1 as bui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
|
||||
REQUIRE_PRO = False
|
||||
import bascenev1 as bs
|
||||
|
||||
# TEMP
|
||||
UNDER_CONSTRUCTION = True
|
||||
REQUIRE_PRO = False
|
||||
|
||||
|
||||
class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
@ -77,7 +77,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
if uiscale is bui.UIScale.SMALL:
|
||||
self._back_button = None
|
||||
bui.containerwidget(
|
||||
edit=self._root_widget, on_cancel_call=self._back
|
||||
edit=self._root_widget, on_cancel_call=self.main_window_back
|
||||
)
|
||||
else:
|
||||
self._back_button = bui.buttonwidget(
|
||||
@ -291,8 +291,8 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
right_widget=bui.get_special_widget('squad_button'),
|
||||
)
|
||||
|
||||
# make sure config exists
|
||||
self._config_name_full = self._pvars.config_name + ' Playlists'
|
||||
# Make sure config exists.
|
||||
self._config_name_full = f'{self._pvars.config_name} Playlists'
|
||||
|
||||
if self._config_name_full not in bui.app.config:
|
||||
bui.app.config[self._config_name_full] = {}
|
||||
@ -305,7 +305,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
|
||||
if self._back_button is not None:
|
||||
bui.buttonwidget(
|
||||
edit=self._back_button, on_activate_call=self._back
|
||||
edit=self._back_button, on_activate_call=self.main_window_back
|
||||
)
|
||||
bui.containerwidget(
|
||||
edit=self._root_widget, cancel_button=self._back_button
|
||||
@ -336,9 +336,14 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
)
|
||||
)
|
||||
|
||||
# @override
|
||||
# def on_main_window_close(self) -> None:
|
||||
# self._save_state()
|
||||
@override
|
||||
def on_main_window_close(self) -> None:
|
||||
if self._selected_playlist_name is not None:
|
||||
cfg = bui.app.config
|
||||
cfg[f'{self._pvars.config_name} Playlist Selection'] = (
|
||||
self._selected_playlist_name
|
||||
)
|
||||
cfg.commit()
|
||||
|
||||
def _update(self) -> None:
|
||||
assert bui.app.classic is not None
|
||||
@ -348,59 +353,10 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
edit=lock, opacity=0.0 if (have or not REQUIRE_PRO) else 1.0
|
||||
)
|
||||
|
||||
def _back(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
# from bauiv1lib.playlist import browser
|
||||
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
if not self._root_widget or self._root_widget.transitioning_out:
|
||||
return
|
||||
|
||||
if self._selected_playlist_name is not None:
|
||||
cfg = bui.app.config
|
||||
cfg[self._pvars.config_name + ' Playlist Selection'] = (
|
||||
self._selected_playlist_name
|
||||
)
|
||||
cfg.commit()
|
||||
|
||||
self.main_window_back()
|
||||
# bui.containerwidget(
|
||||
# edit=self._root_widget, transition=self._transition_out
|
||||
# )
|
||||
# assert bui.app.classic is not None
|
||||
# bui.app.ui_v1.set_main_window(
|
||||
# browser.PlaylistBrowserWindow(
|
||||
# transition='in_left', sessiontype=self._sessiontype
|
||||
# ),
|
||||
# from_window=self,
|
||||
# is_back=True,
|
||||
# )
|
||||
|
||||
def _select(self, name: str, index: int) -> None:
|
||||
self._selected_playlist_name = name
|
||||
self._selected_playlist_index = index
|
||||
|
||||
def _run_selected_playlist(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
bui.unlock_all_input()
|
||||
try:
|
||||
bs.new_host_session(self._sessiontype)
|
||||
except Exception:
|
||||
from bascenev1lib import mainmenu
|
||||
|
||||
logging.exception('Error running session %s.', self._sessiontype)
|
||||
|
||||
# Drop back into a main menu session.
|
||||
bs.new_host_session(mainmenu.MainMenuSession)
|
||||
|
||||
def _choose_playlist(self) -> None:
|
||||
if self._selected_playlist_name is None:
|
||||
return
|
||||
self._save_playlist_selection()
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
bui.fade_screen(False, endcall=self._run_selected_playlist)
|
||||
bui.lock_all_input()
|
||||
|
||||
def _refresh(self, select_playlist: str | None = None) -> None:
|
||||
from efro.util import asserttype
|
||||
|
||||
@ -451,7 +407,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
)
|
||||
bui.widget(edit=txtw, show_buffer_top=50, show_buffer_bottom=50)
|
||||
|
||||
# Hitting up from top widget should jump to 'back'
|
||||
# Hitting up from top widget should jump to 'back'.
|
||||
if index == 0:
|
||||
bui.widget(
|
||||
edit=txtw,
|
||||
@ -473,8 +429,8 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
visible_child=txtw,
|
||||
)
|
||||
else:
|
||||
# Select this one if it was previously selected.
|
||||
# Go by index if there's one.
|
||||
# Select this one if it was previously selected. Go by
|
||||
# index if there's one.
|
||||
if old_selection_index is not None:
|
||||
if index == old_selection_index:
|
||||
bui.columnwidget(
|
||||
@ -493,10 +449,10 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
index += 1
|
||||
|
||||
def _save_playlist_selection(self) -> None:
|
||||
# Store the selected playlist in prefs.
|
||||
# This serves dual purposes of letting us re-select it next time
|
||||
# if we want and also lets us pass it to the game (since we reset
|
||||
# the whole python environment that's not actually easy).
|
||||
# Store the selected playlist in prefs. This serves dual
|
||||
# purposes of letting us re-select it next time if we want and
|
||||
# also lets us pass it to the game (since we reset the whole
|
||||
# python environment that's not actually easy).
|
||||
cfg = bui.app.config
|
||||
cfg[self._pvars.config_name + ' Playlist Selection'] = (
|
||||
self._selected_playlist_name
|
||||
@ -511,8 +467,8 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
from bauiv1lib.playlist.editcontroller import PlaylistEditController
|
||||
from bauiv1lib.purchase import PurchaseWindow
|
||||
|
||||
if UNDER_CONSTRUCTION:
|
||||
bui.screenmessage('UNDER CONSTRUCTION')
|
||||
# No-op if we're not in control.
|
||||
if not self.main_window_has_control():
|
||||
return
|
||||
|
||||
assert bui.app.classic is not None
|
||||
@ -538,18 +494,13 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
self._save_playlist_selection()
|
||||
|
||||
# Kick off the edit UI.
|
||||
PlaylistEditController(sessiontype=self._sessiontype)
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
PlaylistEditController(sessiontype=self._sessiontype, from_window=self)
|
||||
|
||||
def _edit_playlist(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bauiv1lib.playlist.editcontroller import PlaylistEditController
|
||||
from bauiv1lib.purchase import PurchaseWindow
|
||||
|
||||
if UNDER_CONSTRUCTION:
|
||||
bui.screenmessage('UNDER CONSTRUCTION')
|
||||
return
|
||||
|
||||
assert bui.app.classic is not None
|
||||
if REQUIRE_PRO and not bui.app.classic.accounts.have_pro_options():
|
||||
PurchaseWindow(items=['pro'])
|
||||
@ -566,8 +517,8 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
PlaylistEditController(
|
||||
existing_playlist_name=self._selected_playlist_name,
|
||||
sessiontype=self._sessiontype,
|
||||
from_window=self,
|
||||
)
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
|
||||
def _do_delete_playlist(self) -> None:
|
||||
plus = bui.app.plus
|
||||
@ -732,7 +683,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
bui.getsound('error').play()
|
||||
return
|
||||
|
||||
# clamp at our max playlist number
|
||||
# Clamp at our max playlist number.
|
||||
if len(bui.app.config[self._config_name_full]) > self._max_playlists:
|
||||
bui.screenmessage(
|
||||
bui.Lstr(
|
||||
@ -747,10 +698,11 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow):
|
||||
return
|
||||
|
||||
copy_text = bui.Lstr(resource='copyOfText').evaluate()
|
||||
# get just 'Copy' or whatnot
|
||||
copy_word = copy_text.replace('${NAME}', '').strip()
|
||||
# find a valid dup name that doesn't exist
|
||||
|
||||
# Get just 'Copy' or whatnot.
|
||||
copy_word = copy_text.replace('${NAME}', '').strip()
|
||||
|
||||
# Find a valid dup name that doesn't exist.
|
||||
test_index = 1
|
||||
base_name = self._get_playlist_display_name(
|
||||
self._selected_playlist_name
|
||||
|
||||
@ -290,9 +290,6 @@ class PlaylistEditWindow(bui.MainWindow):
|
||||
self._editcontroller.set_edit_ui_selection(selection)
|
||||
|
||||
def _cancel(self) -> None:
|
||||
# from bauiv1lib.playlist.customizebrowser import (
|
||||
# PlaylistCustomizeBrowserWindow,
|
||||
# )
|
||||
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
if not self._root_widget or self._root_widget.transitioning_out:
|
||||
@ -301,38 +298,25 @@ class PlaylistEditWindow(bui.MainWindow):
|
||||
bui.getsound('powerdown01').play()
|
||||
self.main_window_back()
|
||||
|
||||
# bui.containerwidget(edit=self._root_widget, transition='out_right')
|
||||
# assert bui.app.classic is not None
|
||||
# bui.app.ui_v1.set_main_window(
|
||||
# PlaylistCustomizeBrowserWindow(
|
||||
# transition='in_left',
|
||||
# sessiontype=self._editcontroller.get_session_type(),
|
||||
# select_playlist=(
|
||||
# self._editcontroller.get_existing_playlist_name()
|
||||
# ),
|
||||
# ),
|
||||
# from_window=self,
|
||||
# is_back=True,
|
||||
# )
|
||||
|
||||
def _add(self) -> None:
|
||||
# Store list name then tell the session to perform an add.
|
||||
self._editcontroller.setname(
|
||||
cast(str, bui.textwidget(query=self._text_field))
|
||||
)
|
||||
self._editcontroller.add_game_pressed()
|
||||
self._editcontroller.add_game_pressed(from_window=self)
|
||||
|
||||
def _edit(self) -> None:
|
||||
# Store list name then tell the session to perform an add.
|
||||
self._editcontroller.setname(
|
||||
cast(str, bui.textwidget(query=self._text_field))
|
||||
)
|
||||
self._editcontroller.edit_game_pressed()
|
||||
self._editcontroller.edit_game_pressed(from_window=self)
|
||||
|
||||
def _save_press(self) -> None:
|
||||
from bauiv1lib.playlist.customizebrowser import (
|
||||
PlaylistCustomizeBrowserWindow,
|
||||
)
|
||||
|
||||
# No-op if we're not in control.
|
||||
if not self.main_window_has_control():
|
||||
return
|
||||
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
if not self._root_widget or self._root_widget.transitioning_out:
|
||||
@ -395,18 +379,9 @@ class PlaylistEditWindow(bui.MainWindow):
|
||||
)
|
||||
plus.run_v1_account_transactions()
|
||||
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_right')
|
||||
bui.getsound('gunCocking').play()
|
||||
assert bui.app.classic is not None
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistCustomizeBrowserWindow(
|
||||
transition='in_left',
|
||||
sessiontype=self._editcontroller.get_session_type(),
|
||||
select_playlist=new_name,
|
||||
),
|
||||
from_window=self,
|
||||
is_back=True,
|
||||
)
|
||||
|
||||
self.main_window_back()
|
||||
|
||||
def _save_press_with_sound(self) -> None:
|
||||
bui.getsound('swish').play()
|
||||
|
||||
@ -11,7 +11,7 @@ import bascenev1 as bs
|
||||
import bauiv1 as bui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
|
||||
class PlaylistEditController:
|
||||
@ -20,8 +20,8 @@ class PlaylistEditController:
|
||||
def __init__(
|
||||
self,
|
||||
sessiontype: type[bs.Session],
|
||||
from_window: bui.MainWindow,
|
||||
existing_playlist_name: str | None = None,
|
||||
transition: str = 'in_right',
|
||||
playlist: list[dict[str, Any]] | None = None,
|
||||
playlist_name: str | None = None,
|
||||
):
|
||||
@ -44,6 +44,9 @@ class PlaylistEditController:
|
||||
self._existing_playlist_name = existing_playlist_name
|
||||
self._config_name_full = self._pvars.config_name + ' Playlists'
|
||||
|
||||
self._pre_game_add_state: bui.MainWindowState | None = None
|
||||
self._pre_game_edit_state: bui.MainWindowState | None = None
|
||||
|
||||
# Make sure config exists.
|
||||
if self._config_name_full not in appconfig:
|
||||
appconfig[self._config_name_full] = {}
|
||||
@ -88,11 +91,12 @@ class PlaylistEditController:
|
||||
# and that's all they can do.
|
||||
self._edit_ui_selection = 'add_button'
|
||||
|
||||
assert bui.app.classic is not None
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistEditWindow(editcontroller=self, transition=transition),
|
||||
from_window=False, # Disable this check.
|
||||
)
|
||||
editwindow = PlaylistEditWindow(editcontroller=self)
|
||||
from_window.main_window_replace(editwindow)
|
||||
|
||||
# Once we've set our start window, store the back state. We'll
|
||||
# skip back to there once we're fully done.
|
||||
self._back_state = editwindow.main_window_back_state
|
||||
|
||||
def get_config_name(self) -> str:
|
||||
"""(internal)"""
|
||||
@ -142,83 +146,88 @@ class PlaylistEditController:
|
||||
"""Sets the selected playlist index."""
|
||||
self._selected_index = index
|
||||
|
||||
def add_game_pressed(self) -> None:
|
||||
def add_game_pressed(self, from_window: bui.MainWindow) -> None:
|
||||
"""(internal)"""
|
||||
from bauiv1lib.playlist.addgame import PlaylistAddGameWindow
|
||||
|
||||
assert bui.app.classic is not None
|
||||
bui.app.ui_v1.clear_main_window()
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistAddGameWindow(editcontroller=self), from_window=None
|
||||
)
|
||||
# assert bui.app.classic is not None
|
||||
|
||||
def edit_game_pressed(self) -> None:
|
||||
# No op if we're not in control.
|
||||
if not from_window.main_window_has_control():
|
||||
return
|
||||
|
||||
addwindow = PlaylistAddGameWindow(editcontroller=self)
|
||||
from_window.main_window_replace(addwindow)
|
||||
|
||||
# Once we're there, store the back state. We'll use that to jump
|
||||
# back to our current location once the edit is done.
|
||||
assert self._pre_game_add_state is None
|
||||
self._pre_game_add_state = addwindow.main_window_back_state
|
||||
|
||||
def edit_game_pressed(self, from_window: bui.MainWindow) -> None:
|
||||
"""Should be called by supplemental UIs when a game is to be edited."""
|
||||
|
||||
if not self._playlist:
|
||||
return
|
||||
|
||||
self._show_edit_ui(
|
||||
gametype=bui.getclass(
|
||||
self._playlist[self._selected_index]['type'],
|
||||
subclassof=bs.GameActivity,
|
||||
),
|
||||
settings=self._playlist[self._selected_index],
|
||||
from_window=from_window,
|
||||
)
|
||||
|
||||
# def add_game_cancelled(self) -> None:
|
||||
# """(internal)"""
|
||||
# from bauiv1lib.playlist.edit import PlaylistEditWindow
|
||||
|
||||
# assert bui.app.classic is not None
|
||||
# bui.app.ui_v1.clear_main_window(transition='out_right')
|
||||
# bui.app.ui_v1.set_main_window(
|
||||
# PlaylistEditWindow(editcontroller=self, transition='in_left'),
|
||||
# from_window=None,
|
||||
# is_back=True,
|
||||
# )
|
||||
|
||||
def _show_edit_ui(
|
||||
self, gametype: type[bs.GameActivity], settings: dict[str, Any] | None
|
||||
self,
|
||||
gametype: type[bs.GameActivity],
|
||||
settings: dict[str, Any] | None,
|
||||
from_window: bui.MainWindow,
|
||||
) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bauiv1lib.playlist.editgame import PlaylistEditGameWindow
|
||||
|
||||
if not from_window.main_window_has_control():
|
||||
return
|
||||
|
||||
self._editing_game = settings is not None
|
||||
self._editing_game_type = gametype
|
||||
assert self._sessiontype is not None
|
||||
gametype.create_settings_ui(
|
||||
self._sessiontype, copy.deepcopy(settings), self._edit_game_done
|
||||
|
||||
# Jump into an edit window.
|
||||
editwindow = PlaylistEditGameWindow(
|
||||
gametype,
|
||||
self._sessiontype,
|
||||
copy.deepcopy(settings),
|
||||
completion_call=self._edit_game_done,
|
||||
)
|
||||
from_window.main_window_replace(editwindow)
|
||||
|
||||
# Once we're there, store the back state. We'll use that to jump
|
||||
# back to our current location once the edit is done.
|
||||
assert self._pre_game_edit_state is None
|
||||
self._pre_game_edit_state = editwindow.main_window_back_state
|
||||
|
||||
def add_game_type_selected(
|
||||
self, gametype: type[bs.GameActivity], from_window: bui.MainWindow
|
||||
) -> None:
|
||||
"""(internal)"""
|
||||
self._show_edit_ui(
|
||||
gametype=gametype, settings=None, from_window=from_window
|
||||
)
|
||||
|
||||
def add_game_type_selected(self, gametype: type[bs.GameActivity]) -> None:
|
||||
"""(internal)"""
|
||||
self._show_edit_ui(gametype=gametype, settings=None)
|
||||
def _edit_game_done(
|
||||
self, config: dict[str, Any] | None, from_window: bui.MainWindow
|
||||
) -> None:
|
||||
|
||||
def _edit_game_done(self, config: dict[str, Any] | None) -> None:
|
||||
from bauiv1lib.playlist.edit import PlaylistEditWindow
|
||||
from bauiv1lib.playlist.addgame import PlaylistAddGameWindow
|
||||
# No-op if provided window isn't in charge.
|
||||
if not from_window.main_window_has_control():
|
||||
return
|
||||
|
||||
assert bui.app.classic is not None
|
||||
if config is None:
|
||||
# If we were editing, go back to our list.
|
||||
if self._editing_game:
|
||||
bui.getsound('powerdown01').play()
|
||||
bui.app.ui_v1.clear_main_window()
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistEditWindow(
|
||||
editcontroller=self, transition='in_left'
|
||||
),
|
||||
from_window=None,
|
||||
is_back=True,
|
||||
)
|
||||
|
||||
# Otherwise we were adding; go back to the add type choice list.
|
||||
else:
|
||||
bui.app.ui_v1.clear_main_window()
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistAddGameWindow(
|
||||
editcontroller=self, transition='in_left'
|
||||
),
|
||||
from_window=None,
|
||||
is_back=True,
|
||||
)
|
||||
bui.getsound('powerdown01').play()
|
||||
else:
|
||||
# Make sure type is in there.
|
||||
assert self._editing_game_type is not None
|
||||
@ -235,9 +244,17 @@ class PlaylistEditController:
|
||||
self._selected_index = insert_index
|
||||
|
||||
bui.getsound('gunCocking').play()
|
||||
bui.app.ui_v1.clear_main_window()
|
||||
bui.app.ui_v1.set_main_window(
|
||||
PlaylistEditWindow(editcontroller=self, transition='in_left'),
|
||||
from_window=None,
|
||||
is_back=True,
|
||||
)
|
||||
|
||||
# If we're adding, jump to before the add started.
|
||||
# Otherwise jump to before the edit started.
|
||||
assert (
|
||||
self._pre_game_edit_state is not None
|
||||
or self._pre_game_add_state is not None
|
||||
)
|
||||
if self._pre_game_add_state is not None:
|
||||
from_window.main_window_back_state = self._pre_game_add_state
|
||||
elif self._pre_game_edit_state is not None:
|
||||
from_window.main_window_back_state = self._pre_game_edit_state
|
||||
from_window.main_window_back()
|
||||
self._pre_game_edit_state = None
|
||||
self._pre_game_add_state = None
|
||||
|
||||
@ -24,7 +24,7 @@ class PlaylistEditGameWindow(bui.MainWindow):
|
||||
gametype: type[bs.GameActivity],
|
||||
sessiontype: type[bs.Session],
|
||||
config: dict[str, Any] | None,
|
||||
completion_call: Callable[[dict[str, Any] | None], Any],
|
||||
completion_call: Callable[[dict[str, Any] | None, bui.MainWindow], Any],
|
||||
default_selection: str | None = None,
|
||||
transition: str | None = 'in_right',
|
||||
origin_widget: bui.Widget | None = None,
|
||||
@ -141,15 +141,15 @@ class PlaylistEditGameWindow(bui.MainWindow):
|
||||
btn = bui.buttonwidget(
|
||||
parent=self._root_widget,
|
||||
position=(45 + x_inset, height - 82 + y_extra2),
|
||||
size=(180, 70) if is_add else (180, 65),
|
||||
size=(60, 48) if is_add else (180, 65),
|
||||
label=(
|
||||
bui.Lstr(resource='backText')
|
||||
bui.charstr(bui.SpecialChar.BACK)
|
||||
if is_add
|
||||
else bui.Lstr(resource='cancelText')
|
||||
),
|
||||
button_type='back' if is_add else None,
|
||||
button_type='backSmall' if is_add else None,
|
||||
autoselect=True,
|
||||
scale=0.75,
|
||||
scale=1.0 if is_add else 0.75,
|
||||
text_scale=1.3,
|
||||
on_activate_call=bui.Call(self._cancel),
|
||||
)
|
||||
@ -541,24 +541,41 @@ class PlaylistEditGameWindow(bui.MainWindow):
|
||||
# pylint: disable=cyclic-import
|
||||
from bauiv1lib.playlist.mapselect import PlaylistMapSelectWindow
|
||||
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
if not self._root_widget or self._root_widget.transitioning_out:
|
||||
# No-op if we're not in control.
|
||||
if not self.main_window_has_control():
|
||||
return
|
||||
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
# if not self._root_widget or self._root_widget.transitioning_out:
|
||||
# return
|
||||
|
||||
self._config = self._getconfig()
|
||||
|
||||
# Replace ourself with the map-select UI.
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
assert bui.app.classic is not None
|
||||
bui.app.ui_v1.set_main_window(
|
||||
self.main_window_replace(
|
||||
PlaylistMapSelectWindow(
|
||||
self._gametype,
|
||||
self._sessiontype,
|
||||
copy.deepcopy(self._getconfig()),
|
||||
# copy.deepcopy(self._getconfig()),
|
||||
self._config,
|
||||
self._edit_info,
|
||||
self._completion_call,
|
||||
),
|
||||
from_window=self,
|
||||
)
|
||||
)
|
||||
|
||||
# bui.containerwidget(edit=self._root_widget, transition='out_left')
|
||||
# assert bui.app.classic is not None
|
||||
# bui.app.ui_v1.set_main_window(
|
||||
# PlaylistMapSelectWindow(
|
||||
# self._gametype,
|
||||
# self._sessiontype,
|
||||
# copy.deepcopy(self._getconfig()),
|
||||
# self._edit_info,
|
||||
# self._completion_call,
|
||||
# ),
|
||||
# from_window=self,
|
||||
# )
|
||||
|
||||
def _choice_inc(
|
||||
self,
|
||||
setting_name: str,
|
||||
@ -586,7 +603,7 @@ class PlaylistEditGameWindow(bui.MainWindow):
|
||||
][1]
|
||||
|
||||
def _cancel(self) -> None:
|
||||
self._completion_call(None)
|
||||
self._completion_call(None, self)
|
||||
|
||||
def _check_value_change(
|
||||
self, setting_name: str, widget: bui.Widget, value: int
|
||||
@ -607,7 +624,7 @@ class PlaylistEditGameWindow(bui.MainWindow):
|
||||
return {'settings': settings}
|
||||
|
||||
def _add(self) -> None:
|
||||
self._completion_call(copy.deepcopy(self._getconfig()))
|
||||
self._completion_call(self._getconfig(), self)
|
||||
|
||||
def _inc(
|
||||
self,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
import bauiv1 as bui
|
||||
|
||||
@ -24,9 +24,10 @@ class PlaylistMapSelectWindow(bui.MainWindow):
|
||||
sessiontype: type[bs.Session],
|
||||
config: dict[str, Any],
|
||||
edit_info: dict[str, Any],
|
||||
completion_call: Callable[[dict[str, Any] | None], Any],
|
||||
completion_call: Callable[[dict[str, Any] | None, bui.MainWindow], Any],
|
||||
transition: str | None = 'in_right',
|
||||
origin_widget: bui.Widget | None = None,
|
||||
select_get_more_maps_button: bool = False,
|
||||
):
|
||||
# pylint: disable=too-many-locals
|
||||
|
||||
@ -38,6 +39,7 @@ class PlaylistMapSelectWindow(bui.MainWindow):
|
||||
self._completion_call = completion_call
|
||||
self._edit_info = edit_info
|
||||
self._maps: list[tuple[str, bui.Texture]] = []
|
||||
self._selected_get_more_maps = False
|
||||
try:
|
||||
self._previous_map = get_filtered_map_name(
|
||||
config['settings']['map']
|
||||
@ -114,7 +116,34 @@ class PlaylistMapSelectWindow(bui.MainWindow):
|
||||
bui.containerwidget(edit=self._scrollwidget, claims_left_right=True)
|
||||
|
||||
self._subcontainer: bui.Widget | None = None
|
||||
self._refresh()
|
||||
self._refresh(select_get_more_maps_button=select_get_more_maps_button)
|
||||
|
||||
@override
|
||||
def get_main_window_state(self) -> bui.MainWindowState:
|
||||
# Support recreating our window for back/refresh purposes.
|
||||
cls = type(self)
|
||||
|
||||
# Pull things out of self here; if we do it in the lambda we'll
|
||||
# keep ourself alive.
|
||||
gametype = self._gametype
|
||||
sessiontype = self._sessiontype
|
||||
config = self._config
|
||||
edit_info = self._edit_info
|
||||
completion_call = self._completion_call
|
||||
select_get_more_maps = self._selected_get_more_maps
|
||||
|
||||
return bui.BasicMainWindowState(
|
||||
create_call=lambda transition, origin_widget: cls(
|
||||
transition=transition,
|
||||
origin_widget=origin_widget,
|
||||
gametype=gametype,
|
||||
sessiontype=sessiontype,
|
||||
config=config,
|
||||
edit_info=edit_info,
|
||||
completion_call=completion_call,
|
||||
select_get_more_maps_button=select_get_more_maps,
|
||||
)
|
||||
)
|
||||
|
||||
def _refresh(self, select_get_more_maps_button: bool = False) -> None:
|
||||
# pylint: disable=too-many-statements
|
||||
@ -255,21 +284,32 @@ class PlaylistMapSelectWindow(bui.MainWindow):
|
||||
from bauiv1lib import account
|
||||
from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
# No-op if we're not in control.
|
||||
if not self.main_window_has_control():
|
||||
return
|
||||
|
||||
plus = bui.app.plus
|
||||
assert plus is not None
|
||||
|
||||
if plus.get_v1_account_state() != 'signed_in':
|
||||
account.show_sign_in_prompt()
|
||||
return
|
||||
StoreBrowserWindow(
|
||||
modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.MAPS,
|
||||
on_close_call=self._on_store_close,
|
||||
origin_widget=self._get_more_maps_button,
|
||||
|
||||
self._selected_get_more_maps = True
|
||||
|
||||
self.main_window_replace(
|
||||
StoreBrowserWindow(
|
||||
# modal=True,
|
||||
show_tab=StoreBrowserWindow.TabID.MAPS,
|
||||
# on_close_call=self._on_store_close,
|
||||
origin_widget=self._get_more_maps_button,
|
||||
minimal_toolbars=True,
|
||||
)
|
||||
)
|
||||
|
||||
def _on_store_close(self) -> None:
|
||||
self._refresh(select_get_more_maps_button=True)
|
||||
# def _on_store_close(self) -> None:
|
||||
# pass
|
||||
# self._refresh(select_get_more_maps_button=True)
|
||||
|
||||
def _select(self, map_name: str) -> None:
|
||||
# from bauiv1lib.playlist.editgame import PlaylistEditGameWindow
|
||||
|
||||
@ -41,11 +41,12 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
def __init__(
|
||||
self,
|
||||
transition: str | None = 'in_right',
|
||||
modal: bool = False,
|
||||
# modal: bool = False,
|
||||
show_tab: StoreBrowserWindow.TabID | None = None,
|
||||
on_close_call: Callable[[], Any] | None = None,
|
||||
back_location: str | None = None,
|
||||
# on_close_call: Callable[[], Any] | None = None,
|
||||
# back_location: str | None = None,
|
||||
origin_widget: bui.Widget | None = None,
|
||||
minimal_toolbars: bool = False,
|
||||
):
|
||||
# pylint: disable=too-many-statements
|
||||
# pylint: disable=too-many-locals
|
||||
@ -59,19 +60,19 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
bui.set_analytics_screen('Store Window')
|
||||
|
||||
# Need to store this ourself for modal mode.
|
||||
if origin_widget is not None:
|
||||
self._transition_out = 'out_scale'
|
||||
else:
|
||||
self._transition_out = 'out_right'
|
||||
# if origin_widget is not None:
|
||||
# self._transition_out = 'out_scale'
|
||||
# else:
|
||||
# self._transition_out = 'out_right'
|
||||
|
||||
self.button_infos: dict[str, dict[str, Any]] | None = None
|
||||
self.update_buttons_timer: bui.AppTimer | None = None
|
||||
self._status_textwidget_update_timer = None
|
||||
|
||||
self._back_location = back_location
|
||||
self._on_close_call = on_close_call
|
||||
# self._back_location = back_location
|
||||
# self._on_close_call = on_close_call
|
||||
self._show_tab = show_tab
|
||||
self._modal = modal
|
||||
# self._modal = modal
|
||||
self._width = 1670 if uiscale is bui.UIScale.SMALL else 1040
|
||||
self._x_inset = x_inset = 310 if uiscale is bui.UIScale.SMALL else 0
|
||||
self._height = (
|
||||
@ -91,7 +92,7 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
size=(self._width, self._height + extra_top),
|
||||
toolbar_visibility=(
|
||||
'menu_store'
|
||||
if uiscale is bui.UIScale.SMALL
|
||||
if (uiscale is bui.UIScale.SMALL or minimal_toolbars)
|
||||
else 'menu_full'
|
||||
),
|
||||
scale=(
|
||||
@ -115,15 +116,15 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
size=(140, 60),
|
||||
scale=1.1,
|
||||
autoselect=True,
|
||||
label=bui.Lstr(resource='doneText' if self._modal else 'backText'),
|
||||
button_type=None if self._modal else 'back',
|
||||
on_activate_call=self._back,
|
||||
label=bui.Lstr(resource='backText'),
|
||||
button_type='back',
|
||||
on_activate_call=self.main_window_back,
|
||||
)
|
||||
|
||||
if uiscale is bui.UIScale.SMALL:
|
||||
self._back_button.delete()
|
||||
bui.containerwidget(
|
||||
edit=self._root_widget, on_cancel_call=self._back
|
||||
edit=self._root_widget, on_cancel_call=self.main_window_back
|
||||
)
|
||||
backbuttonspecial = True
|
||||
else:
|
||||
@ -163,7 +164,7 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
maxwidth=290,
|
||||
)
|
||||
|
||||
if not self._modal and not backbuttonspecial:
|
||||
if not backbuttonspecial:
|
||||
bui.buttonwidget(
|
||||
edit=self._back_button,
|
||||
button_type='backSmall',
|
||||
@ -1251,23 +1252,23 @@ class StoreBrowserWindow(bui.MainWindow):
|
||||
except Exception:
|
||||
logging.exception('Error restoring state for %s.', self)
|
||||
|
||||
def _back(self) -> None:
|
||||
# def _back(self) -> None:
|
||||
|
||||
if self._modal:
|
||||
# no-op if our underlying widget is dead or on its way out.
|
||||
if not self._root_widget or self._root_widget.transitioning_out:
|
||||
return
|
||||
self._save_state()
|
||||
bui.containerwidget(
|
||||
edit=self._root_widget, transition=self._transition_out
|
||||
)
|
||||
else:
|
||||
# no-op if we're not currently in control.
|
||||
if not self.main_window_has_control():
|
||||
return
|
||||
self.main_window_back()
|
||||
if self._on_close_call is not None:
|
||||
self._on_close_call()
|
||||
# # if self._modal:
|
||||
# # # no-op if our underlying widget is dead or on its way out.
|
||||
# # if not self._root_widget or self._root_widget.transitioning_out:
|
||||
# # return
|
||||
# # self._save_state()
|
||||
# # bui.containerwidget(
|
||||
# # edit=self._root_widget, transition=self._transition_out
|
||||
# # )
|
||||
# # else:
|
||||
# # no-op if we're not currently in control.
|
||||
# if not self.main_window_has_control():
|
||||
# return
|
||||
# self.main_window_back()
|
||||
# # if self._on_close_call is not None:
|
||||
# # self._on_close_call()
|
||||
|
||||
|
||||
def _check_merch_availability_in_bg_thread() -> None:
|
||||
|
||||
@ -229,14 +229,18 @@ class StoreButton:
|
||||
def _default_on_activate_call(self) -> None:
|
||||
# pylint: disable=cyclic-import
|
||||
from bauiv1lib.account import show_sign_in_prompt
|
||||
from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
# from bauiv1lib.store.browser import StoreBrowserWindow
|
||||
|
||||
plus = bui.app.plus
|
||||
assert plus is not None
|
||||
if plus.get_v1_account_state() != 'signed_in':
|
||||
show_sign_in_prompt()
|
||||
return
|
||||
StoreBrowserWindow(modal=True, origin_widget=self._button)
|
||||
|
||||
raise RuntimeError('no longer wired up')
|
||||
|
||||
# StoreBrowserWindow(modal=True, origin_widget=self._button)
|
||||
|
||||
def get_button(self) -> bui.Widget:
|
||||
"""Return the underlying button widget."""
|
||||
|
||||
@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
|
||||
namespace ballistica {
|
||||
|
||||
// These are set automatically via script; don't modify them here.
|
||||
const int kEngineBuildNumber = 21978;
|
||||
const int kEngineBuildNumber = 21980;
|
||||
const char* kEngineVersion = "1.7.37";
|
||||
const int kEngineApiVersion = 9;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user