diff --git a/.efrocachemap b/.efrocachemap index 51c316f7..0d10b9e2 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -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": "21a16533b62c491d0581609132c22dd5", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "fd60f24823b5fd2951acf06ad92d124b", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "87bba2b52609ee3ae31c2b1255218d93", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "bb123af5ef4bdede5248e4d0e086d623", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "78e44932b961f079ddf15fae69fed639", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "49210bd0982bf5eda8dd1074b0b26152", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "85fcee6b23abbf1c5a8e64fd95567b6e", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "6c881b22460cb58f93249bc9f7a95724", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "625390166d0eac624f14fc1688c638e7", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "66cfb48fb1975ca32a750754d16055eb", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "b459b77672b95838742903e0afd1d9ae", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "f17dd55c15904f515e53fc676658194f", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "b1a493c944b9e60a80482e0097699695", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "018ca530ee4e8eaf78c2ea50059f2da4", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "83ef6001e1ef561a33207c396a7dc8b0", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "a00d2cff684ae4df75e52159ead85824", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "775c7f67370eff8d333eda82a626531f", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "1fa9c1e758e790c263b45315b016fe11", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "8b9e532091efbf224cb410ebf66cfbcf", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "7fbbd61ecdcbb4a8e162b6045d2dcf53", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "855a05f0dde692555dcd240456c63397", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "46b1d1929707bd20d50509c53c406f80", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "8f0f4ed6508328a4a75c95450ecae525", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "14d5f4e4cdaa859100b6e247f713f23b", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "586cdec51141ee2c2553450b917ccf13", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "cb68c967d6cc12fb98865bd391b630c7", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "8ba734f236f8b3d76a0f3a634d088ef1", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "59a854138d18b814e0913a4608b7fe87", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "cfa3a2f7ef36c88736a88c8229a7389d", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "27677f0f0d72c4b487070dada1e494dd", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "02124d81c73f4212be27028c97bca2b2", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "81297de9661e18bf6c67c20927a6d6b8", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "99e2c966b4855f712fb383a167ae2bb5", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "fc534000c33ad4db9cc0d7756e171947", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "753846937971a4353045178dacc9fd76", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "6ea4ace6e74840ae2534d7df1ebe4b1c", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "c25040a973dbbbe0c51b51934bd13df9", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "8db99aef1dd403903f6d433314d1ca66", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "af04c5cbfad31760865ae59079ee32a4", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "ec2bd6cc16ae27771271eb250634d6b1", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "ad908b297b41c2fdf13582e34c434245", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "086a2ce72497e44079ad6b747fc5439f", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "ad908b297b41c2fdf13582e34c434245", @@ -4132,14 +4132,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "d7a1d4deb51b0792d083737477e6833b", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "4c11b81a574aa9af593f54db4d998e61", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "d7a1d4deb51b0792d083737477e6833b", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "564675e2f00a311387a6e621f3b67332", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "93395e2263f9ed10160dd8e80811be77", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "24445c70a851b691690803c87af33c81", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "cf286af8eb7762893ee935e08975eb60", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "33b5f0f70ad2d8775dee1fd810f319e5", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "74a2c3fa9e709ca034a106d56c3b3e36", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "8d97d249be1218c6277dc1de54e5c6b8", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "892e10ddcf3b8f1dd83e5d0303594273", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "8eea688090f6d2be7b003c1469afc244", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "9409dfcaf0598768143e06690d33ce65", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "a85fb3ac57086dc5f271b3afea90b489", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "30b60a444fba031a67c96ed9193050da", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "b06998159410ed4b02591ca2998b9c38", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "51553d3162f0af5acfd5e55880e454c9", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "215dbbb47e8def7b1f63448275b4d33b", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "52dd9b73e6d72412ca6b273fb342368e", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad", "src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d", diff --git a/CHANGELOG.md b/CHANGELOG.md index f2adaa5b..b614e532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22010, api 9, 2024-09-24) +### 1.7.37 (build 22015, api 9, 2024-09-25) - 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. @@ -101,6 +101,11 @@ - There is now a `ba*.app.classic.save_ui_state()` method that should be called right before jumping into a game/replay/etc. This will save a state that will automatically be restored the next time the main menu activity is entered. +- (build 22010) Added the concept of 'auxiliary' windows and used them to make + various window navigation more intuitive. Example: previously, if you were on + the co-op screen and pressed the trophy toolbar icon to see your league rank + and then pressed back, you would be taken back to the top level main menu. Now + it will take you back to the co-op screen. ### 1.7.36 (build 21944, api 8, 2024-07-26) - Wired up Tokens, BombSquad's new purchasable currency. The first thing these diff --git a/config/requirements.txt b/config/requirements.txt index 75a8e8ab..816a0d45 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -6,7 +6,7 @@ mypy==1.11.2 pbxproj==4.2.1 pdoc==14.7.0 pur==7.3.2 -pylint==3.3.0 +pylint==3.3.1 pylsp-mypy==0.6.9 pytest==8.3.3 python-daemon==3.0.1 diff --git a/src/assets/.asset_manifest_public.json b/src/assets/.asset_manifest_public.json index efae5d4a..2e5060b0 100644 --- a/src/assets/.asset_manifest_public.json +++ b/src/assets/.asset_manifest_public.json @@ -367,7 +367,6 @@ "ba_data/python/bauiv1lib/__pycache__/__init__.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/achievements.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/appinvite.cpython-312.opt-1.pyc", - "ba_data/python/bauiv1lib/__pycache__/benchmarks.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/characterpicker.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/colorpicker.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/config.cpython-312.opt-1.pyc", @@ -380,7 +379,7 @@ "ba_data/python/bauiv1lib/__pycache__/fileselector.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/getremote.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/gettokens.cpython-312.opt-1.pyc", - "ba_data/python/bauiv1lib/__pycache__/helpui.cpython-312.opt-1.pyc", + "ba_data/python/bauiv1lib/__pycache__/help.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/iconpicker.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/inbox.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/__pycache__/ingamemenu.cpython-312.opt-1.pyc", @@ -421,7 +420,6 @@ "ba_data/python/bauiv1lib/account/viewer.py", "ba_data/python/bauiv1lib/achievements.py", "ba_data/python/bauiv1lib/appinvite.py", - "ba_data/python/bauiv1lib/benchmarks.py", "ba_data/python/bauiv1lib/characterpicker.py", "ba_data/python/bauiv1lib/colorpicker.py", "ba_data/python/bauiv1lib/config.py", @@ -456,7 +454,7 @@ "ba_data/python/bauiv1lib/gather/publictab.py", "ba_data/python/bauiv1lib/getremote.py", "ba_data/python/bauiv1lib/gettokens.py", - "ba_data/python/bauiv1lib/helpui.py", + "ba_data/python/bauiv1lib/help.py", "ba_data/python/bauiv1lib/iconpicker.py", "ba_data/python/bauiv1lib/inbox.py", "ba_data/python/bauiv1lib/ingamemenu.py", @@ -516,6 +514,7 @@ "ba_data/python/bauiv1lib/settings/__pycache__/advanced.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/settings/__pycache__/allsettings.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/settings/__pycache__/audio.cpython-312.opt-1.pyc", + "ba_data/python/bauiv1lib/settings/__pycache__/benchmarks.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/settings/__pycache__/controls.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/settings/__pycache__/devtools.cpython-312.opt-1.pyc", "ba_data/python/bauiv1lib/settings/__pycache__/gamepad.cpython-312.opt-1.pyc", @@ -533,6 +532,7 @@ "ba_data/python/bauiv1lib/settings/advanced.py", "ba_data/python/bauiv1lib/settings/allsettings.py", "ba_data/python/bauiv1lib/settings/audio.py", + "ba_data/python/bauiv1lib/settings/benchmarks.py", "ba_data/python/bauiv1lib/settings/controls.py", "ba_data/python/bauiv1lib/settings/devtools.py", "ba_data/python/bauiv1lib/settings/gamepad.py", diff --git a/src/assets/Makefile b/src/assets/Makefile index 5440f665..81619ca9 100644 --- a/src/assets/Makefile +++ b/src/assets/Makefile @@ -341,7 +341,6 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/account/viewer.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/achievements.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/appinvite.py \ - $(BUILD_DIR)/ba_data/python/bauiv1lib/benchmarks.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/characterpicker.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/colorpicker.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/config.py \ @@ -365,7 +364,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/gather/publictab.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/getremote.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/gettokens.py \ - $(BUILD_DIR)/ba_data/python/bauiv1lib/helpui.py \ + $(BUILD_DIR)/ba_data/python/bauiv1lib/help.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/iconpicker.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/inbox.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/ingamemenu.py \ @@ -406,6 +405,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/advanced.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/allsettings.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/audio.py \ + $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/benchmarks.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/controls.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/devtools.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/gamepad.py \ @@ -619,7 +619,6 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/account/__pycache__/viewer.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/achievements.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/appinvite.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/benchmarks.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/characterpicker.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/colorpicker.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/config.cpython-312.opt-1.pyc \ @@ -643,7 +642,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/gather/__pycache__/publictab.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/getremote.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/gettokens.cpython-312.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/helpui.cpython-312.opt-1.pyc \ + $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/help.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/iconpicker.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/inbox.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/ingamemenu.cpython-312.opt-1.pyc \ @@ -684,6 +683,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/advanced.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/allsettings.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/audio.cpython-312.opt-1.pyc \ + $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/benchmarks.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/controls.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/devtools.cpython-312.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/settings/__pycache__/gamepad.cpython-312.opt-1.pyc \ diff --git a/src/assets/ba_data/python/baclassic/_appmode.py b/src/assets/ba_data/python/baclassic/_appmode.py index 07bc250b..7d130394 100644 --- a/src/assets/ba_data/python/baclassic/_appmode.py +++ b/src/assets/ba_data/python/baclassic/_appmode.py @@ -15,14 +15,16 @@ from babase import ( AppIntentDefault, invoke_main_menu, screenmessage, - in_main_menu, + # in_main_menu, ) import _baclassic if TYPE_CHECKING: + from typing import Callable + from babase import AppIntent - from bauiv1 import UIV1AppSubsystem, MainWindow + from bauiv1 import UIV1AppSubsystem, MainWindow, MainWindowState class ClassicAppMode(AppMode): @@ -124,38 +126,6 @@ class ClassicAppMode(AppMode): if not app.active: invoke_main_menu() - def _jump_to_main_window(self, window: MainWindow) -> None: - """Jump to a window with the main menu as its parent.""" - from bauiv1lib.mainmenu import MainMenuWindow - from bauiv1lib.ingamemenu import InGameMenuWindow - - ui = app.ui_v1 - - old_window = ui.get_main_window() - - if isinstance(old_window, (MainMenuWindow, InGameMenuWindow)): - # If we're currently in the top level menu window, just push - # our mainwindow on to the end. - old_window.main_window_replace(window) - else: - # Blow away the window stack and build a fresh one. - ui.clear_main_window() - - back_state = ( - MainMenuWindow.do_get_main_window_state() - if in_main_menu() - else InGameMenuWindow.do_get_main_window_state() - ) - # set_main_window() needs this to be set. - back_state.is_top_level = True - - ui.set_main_window( - window, - from_window=False, # Disable from-check. - back_state=back_state, - suppress_warning=True, - ) - def _root_ui_menu_press(self) -> None: from babase import push_back_press @@ -173,18 +143,11 @@ class ClassicAppMode(AppMode): import bauiv1 from bauiv1lib.account.settings import AccountSettingsWindow - ui = app.ui_v1 - - # If the window is already showing, back out of it. - current_main_window = ui.get_main_window() - if isinstance(current_main_window, AccountSettingsWindow): - current_main_window.main_window_back() - return - - self._jump_to_main_window( - AccountSettingsWindow( + self._auxiliary_window_nav( + win_type=AccountSettingsWindow, + win_create_call=lambda: AccountSettingsWindow( origin_widget=bauiv1.get_special_widget('account_button') - ) + ), ) def _root_ui_squad_press(self) -> None: @@ -201,52 +164,133 @@ class ClassicAppMode(AppMode): import bauiv1 from bauiv1lib.settings.allsettings import AllSettingsWindow + self._auxiliary_window_nav( + win_type=AllSettingsWindow, + win_create_call=lambda: AllSettingsWindow( + origin_widget=bauiv1.get_special_widget('settings_button') + ), + ) + + def _auxiliary_window_nav( + self, + win_type: type[MainWindow], + win_create_call: Callable[[], MainWindow], + ) -> None: + """Navigate to or away from a particular type of Auxiliary window.""" + # pylint: disable=unidiomatic-typecheck + ui = app.ui_v1 - # If the window is already showing, back out of it. current_main_window = ui.get_main_window() - if isinstance(current_main_window, AllSettingsWindow): + + # Scan our ancestors for auxiliary states matching our type as + # well as auxiliary states in general. + aux_matching_state: MainWindowState | None = None + aux_state: MainWindowState | None = None + + if current_main_window is None: + raise RuntimeError( + 'Not currently handling no-top-level-window case.' + ) + + state = current_main_window.main_window_back_state + while state is not None: + assert state.window_type is not None + if state.is_auxiliary: + if state.window_type is win_type: + aux_matching_state = state + else: + aux_state = state + + state = state.parent + + # If there's an ancestor auxiliary window-state matching our + # type, back out past it (example: poking settings, navigating + # down a level or two, and then poking settings again should + # back out of settings). + if aux_matching_state is not None: + current_main_window.main_window_back_state = ( + aux_matching_state.parent + ) current_main_window.main_window_back() return - self._jump_to_main_window( - AllSettingsWindow( - origin_widget=bauiv1.get_special_widget('settings_button') + # If there's an ancestory auxiliary state *not* matching our + # type, crop the state and swap in our new auxiliary UI + # (example: poking settings, then poking account, then poking + # back should end up where things were before the settings + # poke). + if aux_state is not None: + # Blow away the window stack and build a fresh one. + ui.clear_main_window() + ui.set_main_window( + win_create_call(), + from_window=False, # Disable from-check. + back_state=aux_state.parent, + suppress_warning=True, + is_auxiliary=True, ) + return + + # Ok, no auxiliary states found. Now if current window is auxiliary + # and the type matches, simply do a back. + if ( + current_main_window.main_window_is_auxiliary + and type(current_main_window) is win_type + ): + current_main_window.main_window_back() + return + + # If current window is auxiliary but type doesn't match, + # swap it out for our new auxiliary UI. + if current_main_window.main_window_is_auxiliary: + ui.clear_main_window() + ui.set_main_window( + win_create_call(), + from_window=False, # Disable from-check. + back_state=current_main_window.main_window_back_state, + suppress_warning=True, + is_auxiliary=True, + ) + return + + # Ok, no existing auxiliary stuff was found period. Just + # navigate forward to this UI. + current_main_window.main_window_replace( + win_create_call(), is_auxiliary=True ) def _root_ui_achievements_press(self) -> None: import bauiv1 from bauiv1lib.achievements import AchievementsWindow - btn = bauiv1.get_special_widget('achievements_button') - - AchievementsWindow(position=btn.get_screen_space_center()) + self._auxiliary_window_nav( + win_type=AchievementsWindow, + win_create_call=lambda: AchievementsWindow( + origin_widget=bauiv1.get_special_widget('achievements_button') + ), + ) def _root_ui_inbox_press(self) -> None: import bauiv1 from bauiv1lib.inbox import InboxWindow - btn = bauiv1.get_special_widget('inbox_button') - - InboxWindow(position=btn.get_screen_space_center()) + self._auxiliary_window_nav( + win_type=InboxWindow, + win_create_call=lambda: InboxWindow( + origin_widget=bauiv1.get_special_widget('inbox_button') + ), + ) def _root_ui_store_press(self) -> None: import bauiv1 from bauiv1lib.store.browser import StoreBrowserWindow - ui = app.ui_v1 - - # If the window is already showing, back out of it. - current_main_window = ui.get_main_window() - if isinstance(current_main_window, StoreBrowserWindow): - current_main_window.main_window_back() - return - - self._jump_to_main_window( - StoreBrowserWindow( + self._auxiliary_window_nav( + win_type=StoreBrowserWindow, + win_create_call=lambda: StoreBrowserWindow( origin_widget=bauiv1.get_special_widget('store_button') - ) + ), ) def _root_ui_tickets_meter_press(self) -> None: @@ -270,25 +314,17 @@ class ClassicAppMode(AppMode): from bauiv1lib.account import show_sign_in_prompt from bauiv1lib.league.rankwindow import LeagueRankWindow - ui = app.ui_v1 - - # If the window is already showing, back out of it. - current_main_window = ui.get_main_window() - if isinstance(current_main_window, LeagueRankWindow): - current_main_window.main_window_back() - return - plus = bauiv1.app.plus assert plus is not None - if plus.get_v1_account_state() != 'signed_in': show_sign_in_prompt() return - self._jump_to_main_window( - LeagueRankWindow( + self._auxiliary_window_nav( + win_type=LeagueRankWindow, + win_create_call=lambda: LeagueRankWindow( origin_widget=bauiv1.get_special_widget('trophy_meter') - ) + ), ) def _root_ui_level_meter_press(self) -> None: @@ -303,26 +339,22 @@ class ClassicAppMode(AppMode): import bauiv1 from bauiv1lib.inventory import InventoryWindow - ui = app.ui_v1 - - # If the window is already showing, back out of it. - current_main_window = ui.get_main_window() - if isinstance(current_main_window, InventoryWindow): - current_main_window.main_window_back() - return - - self._jump_to_main_window( - InventoryWindow( + self._auxiliary_window_nav( + win_type=InventoryWindow, + win_create_call=lambda: InventoryWindow( origin_widget=bauiv1.get_special_widget('inventory_button') - ) + ), ) def _root_ui_get_tokens_press(self) -> None: import bauiv1 from bauiv1lib.gettokens import GetTokensWindow - GetTokensWindow( - origin_widget=bauiv1.get_special_widget('get_tokens_button') + self._auxiliary_window_nav( + win_type=GetTokensWindow, + win_create_call=lambda: GetTokensWindow( + origin_widget=bauiv1.get_special_widget('get_tokens_button') + ), ) def _root_ui_chest_slot_pressed(self, index: int) -> None: diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 4886940b..ddc1b45d 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -52,7 +52,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 22010 +TARGET_BALLISTICA_BUILD = 22015 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/assets/ba_data/python/bauiv1/_appsubsystem.py b/src/assets/ba_data/python/bauiv1/_appsubsystem.py index 9eeb6755..9711c51b 100644 --- a/src/assets/ba_data/python/bauiv1/_appsubsystem.py +++ b/src/assets/ba_data/python/bauiv1/_appsubsystem.py @@ -181,8 +181,10 @@ class UIV1AppSubsystem(babase.AppSubsystem): f' cannot use auto-back.' ) - # Valid states should have a value here. + # Valid states should have values here. assert back_state.is_top_level is not None + assert back_state.is_auxiliary is not None + assert back_state.window_type is not None backwin = back_state.create_window(transition='in_left') @@ -205,6 +207,7 @@ class UIV1AppSubsystem(babase.AppSubsystem): from_window: bauiv1.MainWindow | None | bool = True, is_back: bool = False, is_top_level: bool = False, + is_auxiliary: bool = False, back_state: MainWindowState | None = None, suppress_warning: bool = False, ) -> None: @@ -214,6 +217,7 @@ class UIV1AppSubsystem(babase.AppSubsystem): MainWindow methods main_window_replace() and main_window_back() should be used when possible for navigation. """ + # pylint: disable=too-many-locals # pylint: disable=too-many-branches # pylint: disable=too-many-statements from bauiv1._uitypes import MainWindow @@ -254,9 +258,13 @@ class UIV1AppSubsystem(babase.AppSubsystem): # If they passed a back-state, make sure it is fully filled out. if back_state is not None: - if back_state.is_top_level is None: + if ( + back_state.is_top_level is None + or back_state.is_auxiliary is None + or back_state.window_type is None + ): raise RuntimeError( - 'back_state.is_top_level has not been set.' + 'Provided back_state is incomplete.' ' Make sure to only pass fully-filled-out MainWindowStates.' ) # If a top-level main-window is being set, complain if there already @@ -309,18 +317,24 @@ class UIV1AppSubsystem(babase.AppSubsystem): logging.exception('Error checking from_window') if is_back: - # is_top_level should never be True here (only applies forward). + # These values should only be passed for forward navigation. assert not is_top_level - # Always should have back_state in this case. + assert not is_auxiliary + # Make sure back state is complete. assert back_state is not None assert back_state.is_top_level is not None + assert back_state.is_auxiliary is not None + assert back_state.window_type is type(window) window.main_window_back_state = back_state.parent window.main_window_is_top_level = back_state.is_top_level + window.main_window_is_auxiliary = back_state.is_auxiliary else: # Store if the window is top-level so we won't complain later if # we go back from it and there's nowhere to go to. window.main_window_is_top_level = is_top_level + window.main_window_is_auxiliary = is_auxiliary + # When navigating forward, generate a back-window-state from # the outgoing window. if is_top_level: @@ -386,6 +400,8 @@ class UIV1AppSubsystem(babase.AppSubsystem): # Store some common window stuff on its state. winstate.parent = window.main_window_back_state winstate.is_top_level = window.main_window_is_top_level + winstate.is_auxiliary = window.main_window_is_auxiliary + winstate.window_type = type(window) return winstate @@ -397,12 +413,15 @@ class UIV1AppSubsystem(babase.AppSubsystem): # Valid states should have a value here. assert state.is_top_level is not None + assert state.is_auxiliary is not None + assert state.window_type is not None win = state.create_window(transition=None) self.set_main_window( win, from_window=False, # disable check is_top_level=state.is_top_level, + is_auxiliary=state.is_auxiliary, back_state=state.parent, suppress_warning=True, ) diff --git a/src/assets/ba_data/python/bauiv1/_uitypes.py b/src/assets/ba_data/python/bauiv1/_uitypes.py index 00edc4cb..9158e7c8 100644 --- a/src/assets/ba_data/python/bauiv1/_uitypes.py +++ b/src/assets/ba_data/python/bauiv1/_uitypes.py @@ -65,6 +65,13 @@ class MainWindow(Window): self.main_window_is_top_level: bool = False + # Windows can be flagged as auxiliary when not related to the + # main UI task at hand. UI code may choose to handle auxiliary + # windows in special ways, such as by implicitly replacing + # existing auxiliary windows with new ones instead of keeping + # old ones as back targets. + self.main_window_is_auxiliary: bool = False + self._main_window_transition = transition self._main_window_origin_widget = origin_widget super().__init__(root_widget, cleanupcheck) @@ -147,7 +154,10 @@ class MainWindow(Window): self.main_window_close() def main_window_replace( - self, new_window: MainWindow, back_state: MainWindowState | None = None + self, + new_window: MainWindow, + back_state: MainWindowState | None = None, + is_auxiliary: bool = False, ) -> None: """Replace ourself with a new MainWindow.""" @@ -177,6 +187,7 @@ class MainWindow(Window): new_window, from_window=self, back_state=back_state, + is_auxiliary=is_auxiliary, suppress_warning=True, ) @@ -203,6 +214,8 @@ class MainWindowState: # The window that back/cancel navigation should take us to. self.parent: MainWindowState | None = None self.is_top_level: bool | None = None + self.is_auxiliary: bool | None = None + self.window_type: type[MainWindow] | None = None def create_window( self, @@ -314,10 +327,10 @@ def ui_upkeep() -> None: print( 'WARNING:', obj, - 'is still alive 5 second after its widget died;' + 'is still alive 5 second after its Widget died;' ' you might have a memory leak. Look for circular' - ' references or outside things referencing your window' - ' instance. See efro.debug module' + ' references or outside things referencing your Window' + ' class instance. See efro.debug module' ' for tools that can help debug this sort of thing.', ) else: diff --git a/src/assets/ba_data/python/bauiv1lib/account/settings.py b/src/assets/ba_data/python/bauiv1lib/account/settings.py index 0a16d8c4..eb4bdc4f 100644 --- a/src/assets/ba_data/python/bauiv1lib/account/settings.py +++ b/src/assets/ba_data/python/bauiv1lib/account/settings.py @@ -334,20 +334,6 @@ class AccountSettingsWindow(bui.MainWindow): ) linked_accounts_text_space = 60.0 - # Always show achievements except in the game-center case where - # its unified UI covers them. - # show_achievements_button = - # self._v1_signed_in and not game_center_active - - # Update: No longer showing this since its visible on main - # toolbar. - show_achievements_button = False - achievements_button_space = 60.0 - - # show_achievements_text = ( - # self._v1_signed_in and not show_achievements_button - # ) - # Update: No longer showing this since its visible on main # toolbar. show_achievements_text = False @@ -422,8 +408,6 @@ class AccountSettingsWindow(bui.MainWindow): self._sub_height += linked_accounts_text_space if show_achievements_text: self._sub_height += achievements_text_space - if show_achievements_button: - self._sub_height += achievements_button_space if show_leaderboards_button: self._sub_height += leaderboards_button_space if show_campaign_progress: @@ -876,43 +860,7 @@ class AccountSettingsWindow(bui.MainWindow): else: self._achievements_text = None - self._achievements_button: bui.Widget | None - if show_achievements_button: - button_width = 300 - v -= achievements_button_space * 0.85 - self._achievements_button = btn = bui.buttonwidget( - parent=self._subcontainer, - position=((self._sub_width - button_width) * 0.5, v), - color=(0.55, 0.5, 0.6), - textcolor=(0.75, 0.7, 0.8), - autoselect=True, - icon=bui.gettexture( - 'googlePlayAchievementsIcon' - if gpgs_active - else 'achievementsIcon' - ), - icon_color=( - (0.8, 0.95, 0.7) if gpgs_active else (0.85, 0.8, 0.9) - ), - on_activate_call=( - self._on_custom_achievements_press - if gpgs_active - else self._on_achievements_press - ), - size=(button_width, 50), - label='', - ) - if first_selectable is None: - first_selectable = btn - bui.widget( - edit=btn, right_widget=bui.get_special_widget('squad_button') - ) - bui.widget(edit=btn, left_widget=bbtn) - v -= achievements_button_space * 0.15 - else: - self._achievements_button = None - - if show_achievements_text or show_achievements_button: + if show_achievements_text: self._refresh_achievements() self._leaderboards_button: bui.Widget | None @@ -1212,15 +1160,6 @@ class AccountSettingsWindow(bui.MainWindow): else: logging.warning('show_game_service_ui requires plus feature-set.') - def _on_achievements_press(self) -> None: - # pylint: disable=cyclic-import - from bauiv1lib import achievements - - assert self._achievements_button is not None - achievements.AchievementsWindow( - position=self._achievements_button.get_screen_space_center() - ) - def _on_manage_account_press(self) -> None: self._do_manage_account_press(WebLocation.ACCOUNT_EDITOR) @@ -1401,10 +1340,7 @@ class AccountSettingsWindow(bui.MainWindow): def _refresh_achievements(self) -> None: assert bui.app.classic is not None - if ( - self._achievements_text is None - and self._achievements_button is None - ): + if self._achievements_text is None: return complete = sum( 1 if a.complete else 0 for a in bui.app.classic.ach.achievements @@ -1417,8 +1353,6 @@ class AccountSettingsWindow(bui.MainWindow): if self._achievements_text is not None: bui.textwidget(edit=self._achievements_text, text=txt_final) - if self._achievements_button is not None: - bui.buttonwidget(edit=self._achievements_button, label=txt_final) def _link_accounts_press(self) -> None: # pylint: disable=cyclic-import diff --git a/src/assets/ba_data/python/bauiv1lib/achievements.py b/src/assets/ba_data/python/bauiv1lib/achievements.py index 00744b3b..94f17750 100644 --- a/src/assets/ba_data/python/bauiv1lib/achievements.py +++ b/src/assets/ba_data/python/bauiv1lib/achievements.py @@ -6,55 +6,70 @@ from __future__ import annotations from typing import override -from bauiv1lib.popup import PopupWindow import bauiv1 as bui -class AchievementsWindow(PopupWindow): +class AchievementsWindow(bui.MainWindow): """Popup window to view achievements.""" def __init__( - self, position: tuple[float, float], scale: float | None = None + self, + transition: str | None = 'in_right', + origin_widget: bui.Widget | None = None, ): # pylint: disable=too-many-locals assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale - if scale is None: - scale = ( - 2.3 - if uiscale is bui.UIScale.SMALL - else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 - ) - self._transitioning_out = False - self._width = 450 + self._width = 600 if uiscale is bui.UIScale.SMALL else 450 self._height = ( - 300 + 380 if uiscale is bui.UIScale.SMALL else 370 if uiscale is bui.UIScale.MEDIUM else 450 ) - bg_color = (0.5, 0.4, 0.6) + yoffs = -45 if uiscale is bui.UIScale.SMALL else 0 - # creates our _root_widget super().__init__( - position=position, - size=(self._width, self._height), - scale=scale, - bg_color=bg_color, - edge_buffer_scale=4.0, # Try to keep button unobscured. + root_widget=bui.containerwidget( + size=(self._width, self._height), + toolbar_visibility=( + 'menu_minimal' + if uiscale is bui.UIScale.SMALL + else 'menu_full' + ), + scale=( + 2.3 + if uiscale is bui.UIScale.SMALL + else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 + ), + stack_offset=( + (0, 0) + if uiscale is bui.UIScale.SMALL + else (0, 0) if uiscale is bui.UIScale.MEDIUM else (0, 0) + ), + ), + transition=transition, + origin_widget=origin_widget, ) - self._cancel_button = bui.buttonwidget( - parent=self.root_widget, - position=(50, self._height - 30), - size=(50, 50), - scale=0.5, - label='', - color=bg_color, - on_activate_call=self._on_cancel_press, - autoselect=True, - icon=bui.gettexture('crossOut'), - iconscale=1.2, - ) + if uiscale is bui.UIScale.SMALL: + bui.containerwidget( + edit=self._root_widget, on_cancel_call=self.main_window_back + ) + self._back_button = None + else: + self._back_button = bui.buttonwidget( + parent=self._root_widget, + autoselect=True, + position=(50, self._height - 38 + yoffs), + size=(60, 60), + scale=0.6, + label=bui.charstr(bui.SpecialChar.BACK), + button_type='backSmall', + on_activate_call=self.main_window_back, + ) + bui.containerwidget( + edit=self._root_widget, cancel_button=self._back_button + ) achievements = bui.app.classic.ach.achievements num_complete = len([a for a in achievements if a.complete]) @@ -67,8 +82,13 @@ class AchievementsWindow(PopupWindow): ], ) self._title_text = bui.textwidget( - parent=self.root_widget, - position=(self._width * 0.5, self._height - 20), + parent=self._root_widget, + position=( + self._width * 0.5, + self._height + - (27 if uiscale is bui.UIScale.SMALL else 20) + + yoffs, + ), size=(0, 0), h_align='center', v_align='center', @@ -79,16 +99,27 @@ class AchievementsWindow(PopupWindow): ) self._scrollwidget = bui.scrollwidget( - parent=self.root_widget, - size=(self._width - 60, self._height - 70), - position=(30, 30), + parent=self._root_widget, + size=( + self._width - 60, + self._height - (150 if uiscale is bui.UIScale.SMALL else 70), + ), + position=( + 30, + (110 if uiscale is bui.UIScale.SMALL else 30) + yoffs, + ), capture_arrows=True, simple_culling_v=10, ) bui.widget(edit=self._scrollwidget, autoselect=True) + if uiscale is bui.UIScale.SMALL: + bui.widget( + edit=self._scrollwidget, + left_widget=bui.get_special_widget('back_button'), + ) bui.containerwidget( - edit=self.root_widget, cancel_button=self._cancel_button + edit=self._root_widget, cancel_button=self._back_button ) incr = 36 @@ -224,15 +255,12 @@ class AchievementsWindow(PopupWindow): v_align='center', ) - def _on_cancel_press(self) -> None: - self._transition_out() - - def _transition_out(self) -> None: - if not self._transitioning_out: - self._transitioning_out = True - bui.containerwidget(edit=self.root_widget, transition='out_scale') - @override - def on_popup_cancel(self) -> None: - bui.getsound('swish').play() - self._transition_out() + def get_main_window_state(self) -> bui.MainWindowState: + # Support recreating our window for back/refresh purposes. + cls = type(self) + return bui.BasicMainWindowState( + create_call=lambda transition, origin_widget: cls( + transition=transition, origin_widget=origin_widget + ) + ) diff --git a/src/assets/ba_data/python/bauiv1lib/characterpicker.py b/src/assets/ba_data/python/bauiv1lib/characterpicker.py index 2d5e413a..cd8286b4 100644 --- a/src/assets/ba_data/python/bauiv1lib/characterpicker.py +++ b/src/assets/ba_data/python/bauiv1lib/characterpicker.py @@ -195,8 +195,6 @@ class CharacterPicker(PopupWindow): def _on_store_press(self) -> None: from bauiv1lib.account import show_sign_in_prompt - # from bauiv1lib.store.browser import StoreBrowserWindow - plus = bui.app.plus assert plus is not None @@ -209,15 +207,6 @@ class CharacterPicker(PopupWindow): self._transition_out() - # bui.screenmessage('UNDER CONSTRUCTION') - # return - - # 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: self._delegate.on_character_picker_pick(character) diff --git a/src/assets/ba_data/python/bauiv1lib/coop/browser.py b/src/assets/ba_data/python/bauiv1lib/coop/browser.py index 7a04aeb7..b3571047 100644 --- a/src/assets/ba_data/python/bauiv1lib/coop/browser.py +++ b/src/assets/ba_data/python/bauiv1lib/coop/browser.py @@ -47,7 +47,7 @@ class CoopBrowserWindow(bui.MainWindow): # Quick note to players that tourneys won't work in ballistica # core builds. (need to split the word so it won't get subbed # out) - if 'ballistica' + 'kit' == bui.appname(): + if 'ballistica' + 'kit' == bui.appname() and bui.do_once(): bui.apptimer( 1.0, lambda: bui.screenmessage( @@ -77,12 +77,12 @@ class CoopBrowserWindow(bui.MainWindow): self._width = 1520 if uiscale is bui.UIScale.SMALL else 1120 self._x_inset = x_inset = 200 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 565 + 600 if uiscale is bui.UIScale.SMALL else 730 if uiscale is bui.UIScale.MEDIUM else 800 ) self._r = 'coopSelectWindow' - top_extra = 20 if uiscale is bui.UIScale.SMALL else 0 + top_extra = 0 if uiscale is bui.UIScale.SMALL else 0 self._tourney_data_up_to_date = False @@ -109,7 +109,7 @@ class CoopBrowserWindow(bui.MainWindow): size=(self._width, self._height + top_extra), toolbar_visibility='menu_full', stack_offset=( - (0, -17) + (0, -8) if uiscale is bui.UIScale.SMALL else (0, 0) if uiscale is bui.UIScale.MEDIUM else (0, 0) ), @@ -256,7 +256,7 @@ class CoopBrowserWindow(bui.MainWindow): self._scroll_width = self._width - (130 + 2 * x_inset) self._scroll_height = self._height - ( - 185 if uiscale is bui.UIScale.SMALL else 160 + 219 if uiscale is bui.UIScale.SMALL else 160 ) self._subcontainerwidth = 800.0 diff --git a/src/assets/ba_data/python/bauiv1lib/credits.py b/src/assets/ba_data/python/bauiv1lib/credits.py index 5c735e49..a3dc4e08 100644 --- a/src/assets/ba_data/python/bauiv1lib/credits.py +++ b/src/assets/ba_data/python/bauiv1lib/credits.py @@ -32,7 +32,7 @@ class CreditsWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale width = 990 if uiscale is bui.UIScale.SMALL else 670 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 - height = 398 if uiscale is bui.UIScale.SMALL else 500 + height = 450 if uiscale is bui.UIScale.SMALL else 500 self._r = 'creditsWindow' super().__init__( @@ -86,7 +86,7 @@ class CreditsWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, height - (65 if uiscale is bui.UIScale.SMALL else 54)), + position=(0, height - (93 if uiscale is bui.UIScale.SMALL else 54)), size=(width, 30), scale=0.8 if uiscale is bui.UIScale.SMALL else 1.0, text=bui.Lstr( @@ -101,8 +101,11 @@ class CreditsWindow(bui.MainWindow): scroll = bui.scrollwidget( parent=self._root_widget, - position=(40 + x_inset, 35), - size=(width - (80 + 2 * x_inset), height - 100), + position=(40 + x_inset, 62 if uiscale is bui.UIScale.SMALL else 35), + size=( + width - (80 + 2 * x_inset), + height - (160 if uiscale is bui.UIScale.SMALL else 100), + ), capture_arrows=True, ) diff --git a/src/assets/ba_data/python/bauiv1lib/gather/__init__.py b/src/assets/ba_data/python/bauiv1lib/gather/__init__.py index f3f01e32..d80218b3 100644 --- a/src/assets/ba_data/python/bauiv1lib/gather/__init__.py +++ b/src/assets/ba_data/python/bauiv1lib/gather/__init__.py @@ -90,8 +90,9 @@ class GatherWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale self._width = 1640 if uiscale is bui.UIScale.SMALL else 1040 x_offs = 200 if uiscale is bui.UIScale.SMALL else 0 + y_offs = -65 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 550 + 650 if uiscale is bui.UIScale.SMALL else 680 if uiscale is bui.UIScale.MEDIUM else 800 ) @@ -113,7 +114,7 @@ class GatherWindow(bui.MainWindow): else 0.95 if uiscale is bui.UIScale.MEDIUM else 0.7 ), stack_offset=( - (0, -20) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) if uiscale is bui.UIScale.MEDIUM else (0, 0) ), @@ -130,7 +131,7 @@ class GatherWindow(bui.MainWindow): else: self._back_button = btn = bui.buttonwidget( parent=self._root_widget, - position=(70 + x_offs, self._height - 74), + position=(70 + x_offs, self._height - 74 + y_offs), size=(140, 60), scale=1.1, autoselect=True, @@ -153,7 +154,7 @@ class GatherWindow(bui.MainWindow): ) bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 42 + t_offs_y), + position=(self._width * 0.5, self._height - 42 + t_offs_y + y_offs), size=(0, 0), color=bui.app.ui_v1.title_color, scale=( @@ -197,7 +198,10 @@ class GatherWindow(bui.MainWindow): self._tab_row = TabRow( self._root_widget, tabdefs, - pos=(tab_buffer_h * 0.5, self._height - 130 + tabs_top_extra), + pos=( + tab_buffer_h * 0.5, + self._height - 130 + tabs_top_extra + y_offs, + ), size=(self._width - tab_buffer_h, 50), on_select_call=bui.WeakCall(self._set_tab), ) @@ -227,11 +231,20 @@ class GatherWindow(bui.MainWindow): ) self._scroll_width = self._width - scroll_buffer_h - self._scroll_height = self._height - 180.0 + tabs_top_extra + self._scroll_height = ( + self._height + - (270.0 if uiscale is bui.UIScale.SMALL else 180.0) + + tabs_top_extra + ) self._scroll_left = (self._width - self._scroll_width) * 0.5 self._scroll_bottom = ( - self._height - self._scroll_height - 79 - 48 + tabs_top_extra + self._height + - self._scroll_height + - 79 + - 48 + + tabs_top_extra + + y_offs ) buffer_h = 10 buffer_v = 4 diff --git a/src/assets/ba_data/python/bauiv1lib/gather/privatetab.py b/src/assets/ba_data/python/bauiv1lib/gather/privatetab.py index d4492bf9..dc185f2d 100644 --- a/src/assets/ba_data/python/bauiv1lib/gather/privatetab.py +++ b/src/assets/ba_data/python/bauiv1lib/gather/privatetab.py @@ -24,7 +24,7 @@ from bacommon.net import ( from bauiv1lib.gather import GatherTab from bauiv1lib.play import PlaylistSelectContext -from bauiv1lib.gettokens import GetTokensWindow, show_get_tokens_prompt +from bauiv1lib.gettokens import show_get_tokens_prompt import bascenev1 as bs import bauiv1 as bui @@ -551,13 +551,13 @@ class PrivateGatherTab(GatherTab): edit=self._join_party_code_text, on_return_press_call=btn.activate ) - def _on_get_tokens_press(self) -> None: - if self._waiting_for_start_stop_response: - return + # def _on_get_tokens_press(self) -> None: + # if self._waiting_for_start_stop_response: + # return - # Bring up get-tickets window and then kill ourself (we're on - # the overlay layer so we'd show up above it). - GetTokensWindow(origin_widget=self._get_tokens_button) + # # Bring up get-tickets window and then kill ourself (we're on + # # the overlay layer so we'd show up above it). + # GetTokensWindow(origin_widget=self._get_tokens_button) def _build_host_tab(self) -> None: # pylint: disable=too-many-branches diff --git a/src/assets/ba_data/python/bauiv1lib/gettokens.py b/src/assets/ba_data/python/bauiv1lib/gettokens.py index 0c3baeb8..c923ae18 100644 --- a/src/assets/ba_data/python/bauiv1lib/gettokens.py +++ b/src/assets/ba_data/python/bauiv1lib/gettokens.py @@ -8,7 +8,7 @@ import time from enum import Enum from functools import partial from dataclasses import dataclass -from typing import TYPE_CHECKING, assert_never +from typing import TYPE_CHECKING, assert_never, override import bacommon.cloud import bauiv1 as bui @@ -54,7 +54,7 @@ class _TxtDef: rotate: float | None = None -class GetTokensWindow(bui.Window): +class GetTokensWindow(bui.MainWindow): """Window for purchasing/acquiring classic tickets.""" class State(Enum): @@ -67,12 +67,10 @@ class GetTokensWindow(bui.Window): def __init__( self, - transition: str = 'in_right', + transition: str | None = 'in_right', origin_widget: bui.Widget | None = None, - restore_previous_call: Callable[[bui.Widget], None] | None = None, + # restore_previous_call: Callable[[bui.Widget], None] | None = None, ): - # pylint: disable=too-many-locals - bwidthstd = 170 bwidthwide = 300 ycolor = (0, 0, 0.3) @@ -304,7 +302,7 @@ class GetTokensWindow(bui.Window): ] self._transitioning_out = False - self._restore_previous_call = restore_previous_call + # self._restore_previous_call = restore_previous_call self._textcolor = (0.92, 0.92, 2.0) self._query_in_flight = False @@ -314,14 +312,14 @@ class GetTokensWindow(bui.Window): ) # If they provided an origin-widget, scale up from that. - scale_origin: tuple[float, float] | None - if origin_widget is not None: - self._transition_out = 'out_scale' - scale_origin = origin_widget.get_screen_space_center() - transition = 'in_scale' - else: - self._transition_out = 'out_right' - scale_origin = None + # scale_origin: tuple[float, float] | None + # if origin_widget is not None: + # self._transition_out = 'out_scale' + # scale_origin = origin_widget.get_screen_space_center() + # transition = 'in_scale' + # else: + # self._transition_out = 'out_right' + # scale_origin = None uiscale = bui.app.ui_v1.uiscale self._width = 1000.0 if uiscale is bui.UIScale.SMALL else 800.0 @@ -334,8 +332,8 @@ class GetTokensWindow(bui.Window): super().__init__( root_widget=bui.containerwidget( size=(self._width, self._height), - transition=transition, - scale_origin_stack_offset=scale_origin, + # transition=transition, + # scale_origin_stack_offset=scale_origin, color=(0.3, 0.23, 0.36), scale=( 1.5 @@ -346,13 +344,19 @@ class GetTokensWindow(bui.Window): (0, -3) if uiscale is bui.UIScale.SMALL else (0, 0) ), # toolbar_visibility='menu_minimal', - toolbar_visibility='get_tokens', - ) + toolbar_visibility=( + 'get_tokens' + if uiscale is bui.UIScale.SMALL + else 'menu_full' + ), + ), + transition=transition, + origin_widget=origin_widget, ) if uiscale is bui.UIScale.SMALL: bui.containerwidget( - edit=self._root_widget, on_cancel_call=self._back + edit=self._root_widget, on_cancel_call=self.main_window_back ) self._back_button = bui.get_special_widget('back_button') else: @@ -363,23 +367,26 @@ class GetTokensWindow(bui.Window): self._height - 80 + self._y_offset, ), size=( - (140, 60) - if self._restore_previous_call is None - else (60, 60) + # (140, 60) + # if self._restore_previous_call is None + # else + (60, 60) ), scale=1.0, autoselect=True, label=( - bui.Lstr(resource='doneText') - if self._restore_previous_call is None - else bui.charstr(bui.SpecialChar.BACK) + # bui.Lstr(resource='doneText') + # if self._restore_previous_call is None + # else + bui.charstr(bui.SpecialChar.BACK) ), button_type=( - 'regular' - if self._restore_previous_call is None - else 'backSmall' + # 'regular' + # if self._restore_previous_call is None + # else + 'backSmall' ), - on_activate_call=self._back, + on_activate_call=self.main_window_back, ) # if uiscale is bui.UIScale.SMALL: # bui.widget( @@ -446,6 +453,16 @@ class GetTokensWindow(bui.Window): # self._ticking_sound.stop() # self._ticking_sound = None + @override + def get_main_window_state(self) -> bui.MainWindowState: + # Support recreating our window for back/refresh purposes. + cls = type(self) + return bui.BasicMainWindowState( + create_call=lambda transition, origin_widget: cls( + transition=transition, origin_widget=origin_widget + ) + ) + def _update(self) -> None: # No-op if our underlying widget is dead or on its way out. if not self._root_widget or self._root_widget.transitioning_out: @@ -815,17 +832,18 @@ class GetTokensWindow(bui.Window): # self._ticking_sound = None # bui.getsound('cashRegister2').play() - def _back(self) -> None: + # def _back(self) -> None: - # 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.main_ + # 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 - bui.containerwidget( - edit=self._root_widget, transition=self._transition_out - ) - if self._restore_previous_call is not None: - self._restore_previous_call(self._root_widget) + # bui.containerwidget( + # edit=self._root_widget, transition=self._transition_out + # ) + # if self._restore_previous_call is not None: + # self._restore_previous_call(self._root_widget) def _on_learn_more_press(self, url: str) -> None: bui.open_url(url) diff --git a/src/assets/ba_data/python/bauiv1lib/helpui.py b/src/assets/ba_data/python/bauiv1lib/help.py similarity index 96% rename from src/assets/ba_data/python/bauiv1lib/helpui.py rename to src/assets/ba_data/python/bauiv1lib/help.py index ea4e8722..d0652d59 100644 --- a/src/assets/ba_data/python/bauiv1lib/helpui.py +++ b/src/assets/ba_data/python/bauiv1lib/help.py @@ -26,13 +26,14 @@ class HelpWindow(bui.MainWindow): getres = bui.app.lang.get_resource - # self._main_menu = main_menu assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale width = 1050 if uiscale is bui.UIScale.SMALL else 750 - x_offs = 70 if uiscale is bui.UIScale.SMALL else 0 + xoffs = 70 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -33 if uiscale is bui.UIScale.SMALL else 0 + height = ( - 460 + 500 if uiscale is bui.UIScale.SMALL else 530 if uiscale is bui.UIScale.MEDIUM else 600 ) @@ -51,7 +52,7 @@ class HelpWindow(bui.MainWindow): else 1.15 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -24) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0) ), @@ -62,7 +63,10 @@ class HelpWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, height - (50 if uiscale is bui.UIScale.SMALL else 45)), + position=( + 0, + height - (50 if uiscale is bui.UIScale.SMALL else 45) + yoffs, + ), size=(width, 25), text=bui.Lstr( resource=f'{self._r}.titleText', @@ -75,11 +79,14 @@ class HelpWindow(bui.MainWindow): self._scrollwidget = bui.scrollwidget( parent=self._root_widget, - position=(44 + x_offs, 55 if uiscale is bui.UIScale.SMALL else 55), + position=( + 44 + xoffs, + (92 if uiscale is bui.UIScale.SMALL else 55) + yoffs, + ), simple_culling_v=100.0, size=( - width - (88 + 2 * x_offs), - height - 120 + (5 if uiscale is bui.UIScale.SMALL else 0), + width - (88 + 2 * xoffs), + height - (150 if uiscale is bui.UIScale.SMALL else 120), ), capture_arrows=True, ) @@ -105,7 +112,7 @@ class HelpWindow(bui.MainWindow): else: btn = bui.buttonwidget( parent=self._root_widget, - position=(x_offs + 50, height - 55), + position=(xoffs + 50, height - 55), size=(60, 55), scale=0.8, label=bui.charstr(bui.SpecialChar.BACK), diff --git a/src/assets/ba_data/python/bauiv1lib/iconpicker.py b/src/assets/ba_data/python/bauiv1lib/iconpicker.py index 779100cd..4f186b41 100644 --- a/src/assets/ba_data/python/bauiv1lib/iconpicker.py +++ b/src/assets/ba_data/python/bauiv1lib/iconpicker.py @@ -14,6 +14,18 @@ if TYPE_CHECKING: from typing import Any, Sequence +class IconPickerDelegate: + """Delegate for character-picker.""" + + def on_icon_picker_pick(self, icon: str) -> None: + """Called when a character is selected.""" + raise NotImplementedError() + + def on_icon_picker_get_more_press(self) -> None: + """Called when the 'get more characters' button is pressed.""" + raise NotImplementedError() + + class IconPicker(PopupWindow): """Picker for icons.""" @@ -21,7 +33,7 @@ class IconPicker(PopupWindow): self, parent: bui.Widget, position: tuple[float, float] = (0.0, 0.0), - delegate: Any = None, + delegate: IconPickerDelegate | None = None, scale: float | None = None, *, offset: tuple[float, float] = (0.0, 0.0), @@ -161,24 +173,17 @@ class IconPicker(PopupWindow): def _on_store_press(self) -> None: from bauiv1lib.account import show_sign_in_prompt - # 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 - # self._transition_out() - bui.screenmessage('UNDER CONSTRUCTION') - return + if self._delegate is not None: + self._delegate.on_icon_picker_get_more_press() - # StoreBrowserWindow( - # modal=True, - # show_tab=StoreBrowserWindow.TabID.ICONS, - # origin_widget=self._get_more_icons_button, - # ) + self._transition_out() def _select_icon(self, icon: str) -> None: if self._delegate is not None: diff --git a/src/assets/ba_data/python/bauiv1lib/inbox.py b/src/assets/ba_data/python/bauiv1lib/inbox.py index ee4b4108..d5c73000 100644 --- a/src/assets/ba_data/python/bauiv1lib/inbox.py +++ b/src/assets/ba_data/python/bauiv1lib/inbox.py @@ -6,58 +6,79 @@ from __future__ import annotations from typing import override -from bauiv1lib.popup import PopupWindow +# from bauiv1lib.popup import PopupWindow import bauiv1 as bui -class InboxWindow(PopupWindow): +class InboxWindow(bui.MainWindow): """Popup window to show account messages.""" def __init__( - self, position: tuple[float, float], scale: float | None = None + self, + transition: str | None = 'in_right', + origin_widget: bui.Widget | None = None, ): assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale - if scale is None: - scale = ( - 2.3 - if uiscale is bui.UIScale.SMALL - else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 - ) - self._transitioning_out = False - self._width = 450 + self._width = 600 if uiscale is bui.UIScale.SMALL else 450 self._height = ( - 300 + 380 if uiscale is bui.UIScale.SMALL else 370 if uiscale is bui.UIScale.MEDIUM else 450 ) - bg_color = (0.5, 0.4, 0.6) + yoffs = -45 if uiscale is bui.UIScale.SMALL else 0 - # creates our _root_widget super().__init__( - position=position, - size=(self._width, self._height), - scale=scale, - bg_color=bg_color, - edge_buffer_scale=4.0, # Try to keep button unobscured. + root_widget=bui.containerwidget( + size=(self._width, self._height), + toolbar_visibility=( + 'menu_minimal' + if uiscale is bui.UIScale.SMALL + else 'menu_full' + ), + scale=( + 2.3 + if uiscale is bui.UIScale.SMALL + else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 + ), + stack_offset=( + (0, 0) + if uiscale is bui.UIScale.SMALL + else (0, 0) if uiscale is bui.UIScale.MEDIUM else (0, 0) + ), + ), + transition=transition, + origin_widget=origin_widget, ) - self._cancel_button = bui.buttonwidget( - parent=self.root_widget, - position=(50, self._height - 30), - size=(50, 50), - scale=0.5, - label='', - color=bg_color, - on_activate_call=self._on_cancel_press, - autoselect=True, - icon=bui.gettexture('crossOut'), - iconscale=1.2, - ) + if uiscale is bui.UIScale.SMALL: + bui.containerwidget( + edit=self._root_widget, on_cancel_call=self.main_window_back + ) + self._back_button = None + else: + self._back_button = bui.buttonwidget( + parent=self._root_widget, + autoselect=True, + position=(50, self._height - 38 + yoffs), + size=(60, 60), + scale=0.6, + label=bui.charstr(bui.SpecialChar.BACK), + button_type='backSmall', + on_activate_call=self.main_window_back, + ) + bui.containerwidget( + edit=self._root_widget, cancel_button=self._back_button + ) self._title_text = bui.textwidget( - parent=self.root_widget, - position=(self._width * 0.5, self._height - 20), + parent=self._root_widget, + position=( + self._width * 0.5, + self._height + - (27 if uiscale is bui.UIScale.SMALL else 20) + + yoffs, + ), size=(0, 0), h_align='center', v_align='center', @@ -68,16 +89,27 @@ class InboxWindow(PopupWindow): ) self._scrollwidget = bui.scrollwidget( - parent=self.root_widget, - size=(self._width - 60, self._height - 70), - position=(30, 30), + parent=self._root_widget, + size=( + self._width - 60, + self._height - (150 if uiscale is bui.UIScale.SMALL else 70), + ), + position=( + 30, + (110 if uiscale is bui.UIScale.SMALL else 30) + yoffs, + ), capture_arrows=True, simple_culling_v=10, ) bui.widget(edit=self._scrollwidget, autoselect=True) + if uiscale is bui.UIScale.SMALL: + bui.widget( + edit=self._scrollwidget, + left_widget=bui.get_special_widget('back_button'), + ) bui.containerwidget( - edit=self.root_widget, cancel_button=self._cancel_button + edit=self._root_widget, cancel_button=self._back_button ) entries: list[str] = [] @@ -105,15 +137,26 @@ class InboxWindow(PopupWindow): v_align='center', ) - def _on_cancel_press(self) -> None: - self._transition_out() - - def _transition_out(self) -> None: - if not self._transitioning_out: - self._transitioning_out = True - bui.containerwidget(edit=self.root_widget, transition='out_scale') - @override - def on_popup_cancel(self) -> None: - bui.getsound('swish').play() - self._transition_out() + def get_main_window_state(self) -> bui.MainWindowState: + # Support recreating our window for back/refresh purposes. + cls = type(self) + return bui.BasicMainWindowState( + create_call=lambda transition, origin_widget: cls( + transition=transition, origin_widget=origin_widget + ) + ) + + # def _on_cancel_press(self) -> None: + # self._transition_out() + + # def _transition_out(self) -> None: + # if not self._transitioning_out: + # self._transitioning_out = True + # bui.containerwidget( + # edit=self._root_widget, transition='out_scale') + + # @override + # def on_popup_cancel(self) -> None: + # bui.getsound('swish').play() + # self._transition_out() diff --git a/src/assets/ba_data/python/bauiv1lib/inventory.py b/src/assets/ba_data/python/bauiv1lib/inventory.py index 6297f3aa..508ccfba 100644 --- a/src/assets/ba_data/python/bauiv1lib/inventory.py +++ b/src/assets/ba_data/python/bauiv1lib/inventory.py @@ -24,11 +24,12 @@ class InventoryWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale width = 1050 if uiscale is bui.UIScale.SMALL else 750 height = ( - 460 + 500 if uiscale is bui.UIScale.SMALL else 530 if uiscale is bui.UIScale.MEDIUM else 600 ) x_offs = 70 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -45 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( @@ -44,7 +45,7 @@ class InventoryWindow(bui.MainWindow): else 1.15 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -24) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0) ), @@ -55,7 +56,7 @@ class InventoryWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, height - (50 if uiscale is bui.UIScale.SMALL else 45)), + position=(0, height - 45 + yoffs), size=(width, 25), text='INVENTORY', color=bui.app.ui_v1.title_color, @@ -70,7 +71,7 @@ class InventoryWindow(bui.MainWindow): else: btn = bui.buttonwidget( parent=self._root_widget, - position=(x_offs + 50, height - 55), + position=(x_offs + 50, height - 55 + yoffs), size=(60, 55), scale=0.8, label=bui.charstr(bui.SpecialChar.BACK), @@ -83,7 +84,7 @@ class InventoryWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, height - 120), + position=(0, height - 120 + yoffs), size=(width, 25), text='(under construction)', scale=0.7, @@ -94,7 +95,7 @@ class InventoryWindow(bui.MainWindow): button_width = 300 self._player_profiles_button = btn = bui.buttonwidget( parent=self._root_widget, - position=((width - button_width) * 0.5, height - 200), + position=((width - button_width) * 0.5, height - 200 + yoffs), autoselect=True, size=(button_width, 60), label=bui.Lstr(resource='playerProfilesWindow.titleText'), diff --git a/src/assets/ba_data/python/bauiv1lib/league/rankwindow.py b/src/assets/ba_data/python/bauiv1lib/league/rankwindow.py index 97078465..a4a1fb67 100644 --- a/src/assets/ba_data/python/bauiv1lib/league/rankwindow.py +++ b/src/assets/ba_data/python/bauiv1lib/league/rankwindow.py @@ -186,16 +186,14 @@ class LeagueRankWindow(bui.MainWindow): self._update(show=info is None) def _on_achievements_press(self) -> None: - from bauiv1lib import achievements + from bauiv1lib.achievements import AchievementsWindow # only allow this for all-time or the current season # (we currently don't keep specific achievement data for old seasons) if self._season == 'a' or self._is_current_season: prab = self._power_ranking_achievements_button assert prab is not None - achievements.AchievementsWindow( - position=prab.get_screen_space_center() - ) + self.main_window_replace(AchievementsWindow(origin_widget=prab)) else: bui.screenmessage( bui.Lstr( diff --git a/src/assets/ba_data/python/bauiv1lib/mainmenu.py b/src/assets/ba_data/python/bauiv1lib/mainmenu.py index 496da734..278d5019 100644 --- a/src/assets/ba_data/python/bauiv1lib/mainmenu.py +++ b/src/assets/ba_data/python/bauiv1lib/mainmenu.py @@ -91,7 +91,7 @@ class MainMenuWindow(bui.MainWindow): import bauiv1lib.account.settings as _unused5 import bauiv1lib.store.browser as _unused6 import bauiv1lib.credits as _unused7 - import bauiv1lib.helpui as _unused8 + import bauiv1lib.help as _unused8 import bauiv1lib.settings.allsettings as _unused9 import bauiv1lib.gather as _unused10 import bauiv1lib.watch as _unused11 @@ -524,7 +524,7 @@ class MainMenuWindow(bui.MainWindow): def _howtoplay(self) -> None: # pylint: disable=cyclic-import - from bauiv1lib.helpui import HelpWindow + from bauiv1lib.help import HelpWindow # no-op if we're not currently in control. if not self.main_window_has_control(): diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/addgame.py b/src/assets/ba_data/python/bauiv1lib/playlist/addgame.py index 54b54914..7e064d1f 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/addgame.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/addgame.py @@ -28,17 +28,18 @@ class PlaylistAddGameWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale self._width = 750 if uiscale is bui.UIScale.SMALL else 650 x_inset = 50 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -44 if uiscale is bui.UIScale.SMALL else 0 + self._height = ( - 346 + 400 if uiscale is bui.UIScale.SMALL - else 380 if uiscale is bui.UIScale.MEDIUM else 440 + else 400 if uiscale is bui.UIScale.MEDIUM else 460 ) - top_extra = 30 if uiscale is bui.UIScale.SMALL else 20 self._scroll_width = 210 super().__init__( root_widget=bui.containerwidget( - size=(self._width, self._height + top_extra), + size=(self._width, self._height), scale=( 1.95 if uiscale is bui.UIScale.SMALL @@ -56,7 +57,7 @@ class PlaylistAddGameWindow(bui.MainWindow): else: self._back_button = bui.buttonwidget( parent=self._root_widget, - position=(58 + x_inset, self._height - 53), + position=(58 + x_inset, self._height - 53 + yoffs), size=(60, 48), label=bui.charstr(bui.SpecialChar.BACK), autoselect=True, @@ -65,7 +66,7 @@ class PlaylistAddGameWindow(bui.MainWindow): ) self._select_button = select_button = bui.buttonwidget( parent=self._root_widget, - position=(self._width - (172 + x_inset), self._height - 50), + position=(self._width - (172 + x_inset), self._height - 50 + yoffs), autoselect=True, size=(160, 60), scale=0.75, @@ -81,7 +82,7 @@ class PlaylistAddGameWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 28), + position=(self._width * 0.5, self._height - 28 + yoffs), size=(0, 0), scale=1.0, text=bui.Lstr(resource=f'{self._r}.titleText'), @@ -90,7 +91,7 @@ class PlaylistAddGameWindow(bui.MainWindow): maxwidth=250, v_align='center', ) - v = self._height - 64 + v = self._height - 64 + yoffs self._selected_title_text = bui.textwidget( parent=self._root_widget, @@ -114,9 +115,11 @@ class PlaylistAddGameWindow(bui.MainWindow): h_align='left', ) - scroll_height = self._height - 100 + scroll_height = self._height - ( + 160 if uiscale is bui.UIScale.SMALL else 100 + ) - v = self._height - 60 + v = self._height - 60 + yoffs self._scrollwidget = bui.scrollwidget( parent=self._root_widget, diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/browser.py b/src/assets/ba_data/python/bauiv1lib/playlist/browser.py index 65721765..0792f59a 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/browser.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/browser.py @@ -61,7 +61,7 @@ class PlaylistBrowserWindow(bui.MainWindow): else 510 if uiscale is bui.UIScale.MEDIUM else 580 ) - top_extra = 20 if uiscale is bui.UIScale.SMALL else 0 + top_extra = 30 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( @@ -80,7 +80,7 @@ class PlaylistBrowserWindow(bui.MainWindow): else 1.05 if uiscale is bui.UIScale.MEDIUM else 0.9 ), stack_offset=( - (0, -56) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, -46) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/customizebrowser.py b/src/assets/ba_data/python/bauiv1lib/playlist/customizebrowser.py index f9c777fd..559998cf 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/customizebrowser.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/customizebrowser.py @@ -45,20 +45,20 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale self._width = 970.0 if uiscale is bui.UIScale.SMALL else 650.0 x_inset = 100.0 if uiscale is bui.UIScale.SMALL else 0.0 + yoffs = -51 if uiscale is bui.UIScale.SMALL else 0.0 self._height = ( - 380.0 + 440.0 if uiscale is bui.UIScale.SMALL else 420.0 if uiscale is bui.UIScale.MEDIUM else 500.0 ) - top_extra = 20.0 if uiscale is bui.UIScale.SMALL else 0.0 super().__init__( root_widget=bui.containerwidget( - size=(self._width, self._height + top_extra), + size=(self._width, self._height), scale=( - 1.83 + 1.8 if uiscale is bui.UIScale.SMALL - else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0 + else 1.4 if uiscale is bui.UIScale.MEDIUM else 1.0 ), toolbar_visibility=( 'menu_minimal' @@ -66,7 +66,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): else 'menu_full' ), stack_offset=( - (0, -10) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -82,7 +82,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): else: self._back_button = bui.buttonwidget( parent=self._root_widget, - position=(43 + x_inset, self._height - 60), + position=(43 + x_inset, self._height - 60 + yoffs), size=(160, 68), scale=0.77, autoselect=True, @@ -99,7 +99,12 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, self._height - 47), + position=( + 0, + self._height + - (47 if uiscale is bui.UIScale.SMALL else 47) + + yoffs, + ), size=(self._width, 25), text=bui.Lstr( resource=f'{self._r}.titleText', @@ -111,7 +116,7 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): v_align='center', ) - v = self._height - 59.0 + v = self._height - 59.0 + yoffs h = 41 + x_inset b_color = (0.6, 0.53, 0.63) b_textcolor = (0.75, 0.7, 0.8) @@ -260,8 +265,10 @@ class PlaylistCustomizeBrowserWindow(bui.MainWindow): ) ) - v = self._height - 75 - self._scroll_height = self._height - 119 + v = self._height - 75 + yoffs + self._scroll_height = self._height - ( + 180 if uiscale is bui.UIScale.SMALL else 119 + ) scrollwidget = bui.scrollwidget( parent=self._root_widget, position=(140 + x_inset, v - self._scroll_height), diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/edit.py b/src/assets/ba_data/python/bauiv1lib/playlist/edit.py index 0a1b68f4..eb7c1d35 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/edit.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/edit.py @@ -35,22 +35,22 @@ class PlaylistEditWindow(bui.MainWindow): self._width = 870 if uiscale is bui.UIScale.SMALL else 670 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 400 + 500 if uiscale is bui.UIScale.SMALL else 470 if uiscale is bui.UIScale.MEDIUM else 540 ) + yoffs = -68 if uiscale is bui.UIScale.SMALL else 0 - top_extra = 20 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( - size=(self._width, self._height + top_extra), + size=(self._width, self._height), scale=( - 1.8 + 1.76 if uiscale is bui.UIScale.SMALL else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -16) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -58,7 +58,7 @@ class PlaylistEditWindow(bui.MainWindow): ) cancel_button = bui.buttonwidget( parent=self._root_widget, - position=(35 + x_inset, self._height - 60), + position=(35 + x_inset, self._height - 60 + yoffs), scale=0.8, size=(175, 60), autoselect=True, @@ -67,7 +67,7 @@ class PlaylistEditWindow(bui.MainWindow): ) save_button = btn = bui.buttonwidget( parent=self._root_widget, - position=(self._width - (195 + x_inset), self._height - 60), + position=(self._width - (195 + x_inset), self._height - 60 + yoffs), scale=0.8, size=(190, 60), autoselect=True, @@ -89,7 +89,7 @@ class PlaylistEditWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(-10, self._height - 50), + position=(-10, self._height - 50 + yoffs), size=(self._width, 25), text=bui.Lstr(resource=f'{self._r}.titleText'), color=bui.app.ui_v1.title_color, @@ -99,7 +99,7 @@ class PlaylistEditWindow(bui.MainWindow): maxwidth=270, ) - v = self._height - 115.0 + v = self._height - 115.0 + yoffs self._scroll_width = self._width - (205 + 2 * x_inset) @@ -136,7 +136,7 @@ class PlaylistEditWindow(bui.MainWindow): self._list_widgets: list[bui.Widget] = [] h = 40 + x_inset - v = self._height - 172.0 + v = self._height - 172.0 + yoffs b_color = (0.6, 0.53, 0.63) b_textcolor = (0.75, 0.7, 0.8) @@ -222,8 +222,10 @@ class PlaylistEditWindow(bui.MainWindow): repeat=True, ) - v = self._height - 100 - scroll_height = self._height - 155 + v = self._height - 100 + yoffs + scroll_height = self._height - ( + 250 if uiscale is bui.UIScale.SMALL else 155 + ) scrollwidget = bui.scrollwidget( parent=self._root_widget, position=(160 + x_inset, v - scroll_height), diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/editgame.py b/src/assets/ba_data/python/bauiv1lib/playlist/editgame.py index fa18b1e9..1dd46eda 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/editgame.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/editgame.py @@ -109,13 +109,14 @@ class PlaylistEditGameWindow(bui.MainWindow): width = 820 if uiscale is bui.UIScale.SMALL else 620 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 height = ( - 365 + 400 if uiscale is bui.UIScale.SMALL else 460 if uiscale is bui.UIScale.MEDIUM else 550 ) spacing = 52 y_extra = 15 y_extra2 = 21 + yoffs = -30 if uiscale is bui.UIScale.SMALL else 0 map_tex_name = get_map_class(self._map).get_preview_texture_name() if map_tex_name is None: @@ -132,7 +133,7 @@ class PlaylistEditGameWindow(bui.MainWindow): else 1.35 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -17) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -141,7 +142,7 @@ class PlaylistEditGameWindow(bui.MainWindow): btn = bui.buttonwidget( parent=self._root_widget, - position=(45 + x_inset, height - 82 + y_extra2), + position=(45 + x_inset, height - 82 + y_extra2 + yoffs), size=(60, 48) if is_add else (180, 65), label=( bui.charstr(bui.SpecialChar.BACK) @@ -158,7 +159,7 @@ class PlaylistEditGameWindow(bui.MainWindow): add_button = bui.buttonwidget( parent=self._root_widget, - position=(width - (193 + x_inset), height - 82 + y_extra2), + position=(width - (193 + x_inset), height - 82 + y_extra2 + yoffs), size=(200, 65), scale=0.75, text_scale=1.3, @@ -174,7 +175,7 @@ class PlaylistEditGameWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(-8, height - 70 + y_extra2), + position=(-8, height - 70 + y_extra2 + yoffs), size=(width, 25), text=gametype.get_display_string(), color=bui.app.ui_v1.title_color, @@ -194,8 +195,14 @@ class PlaylistEditGameWindow(bui.MainWindow): scroll_width = width - (86 + 2 * x_inset) self._scrollwidget = bui.scrollwidget( parent=self._root_widget, - position=(44 + x_inset, 35 + y_extra), - size=(scroll_width, height - 116), + position=( + 44 + x_inset, + (80 if uiscale is bui.UIScale.SMALL else 35) + y_extra + yoffs, + ), + size=( + scroll_width, + height - (166 if uiscale is bui.UIScale.SMALL else 116), + ), highlight=False, claims_left_right=True, claims_tab=True, diff --git a/src/assets/ba_data/python/bauiv1lib/playlist/mapselect.py b/src/assets/ba_data/python/bauiv1lib/playlist/mapselect.py index 65690a0f..603cd97a 100644 --- a/src/assets/ba_data/python/bauiv1lib/playlist/mapselect.py +++ b/src/assets/ba_data/python/bauiv1lib/playlist/mapselect.py @@ -53,22 +53,22 @@ class PlaylistMapSelectWindow(bui.MainWindow): width = 815 if uiscale is bui.UIScale.SMALL else 615 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 height = ( - 400 + 420 if uiscale is bui.UIScale.SMALL else 480 if uiscale is bui.UIScale.MEDIUM else 600 ) + yoffs = -37 if uiscale is bui.UIScale.SMALL else 0 - top_extra = 20 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( - size=(width, height + top_extra), + size=(width, height), scale=( 1.95 if uiscale is bui.UIScale.SMALL else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -27) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -77,7 +77,7 @@ class PlaylistMapSelectWindow(bui.MainWindow): self._cancel_button = btn = bui.buttonwidget( parent=self._root_widget, - position=(38 + x_inset, height - 67), + position=(38 + x_inset, height - 67 + yoffs), size=(140, 50), scale=0.9, text_scale=1.0, @@ -89,7 +89,7 @@ class PlaylistMapSelectWindow(bui.MainWindow): bui.containerwidget(edit=self._root_widget, cancel_button=btn) bui.textwidget( parent=self._root_widget, - position=(width * 0.5, height - 46), + position=(width * 0.5, height - 46 + yoffs), size=(0, 0), maxwidth=260, scale=1.1, @@ -101,9 +101,11 @@ class PlaylistMapSelectWindow(bui.MainWindow): h_align='center', v_align='center', ) - v = height - 70 + v = height - 70 + yoffs self._scroll_width = width - (80 + 2 * x_inset) - self._scroll_height = height - 140 + self._scroll_height = height - ( + 170 if uiscale is bui.UIScale.SMALL else 140 + ) self._scrollwidget = bui.scrollwidget( parent=self._root_widget, diff --git a/src/assets/ba_data/python/bauiv1lib/profile/edit.py b/src/assets/ba_data/python/bauiv1lib/profile/edit.py index 4bf5be4d..447bbb72 100644 --- a/src/assets/ba_data/python/bauiv1lib/profile/edit.py +++ b/src/assets/ba_data/python/bauiv1lib/profile/edit.py @@ -9,11 +9,14 @@ from typing import cast, override from bauiv1lib.colorpicker import ColorPicker from bauiv1lib.characterpicker import CharacterPickerDelegate +from bauiv1lib.iconpicker import IconPickerDelegate import bauiv1 as bui import bascenev1 as bs -class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): +class EditProfileWindow( + bui.MainWindow, CharacterPickerDelegate, IconPickerDelegate +): """Window for editing a player profile.""" def reload_window(self) -> None: @@ -30,10 +33,12 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): back_state=self.main_window_back_state, ) + # def __del__(self) -> None: + # print(f'~EditProfileWindow({id(self)})') + def __init__( self, existing_profile: str | None, - # in_main_menu: bool, transition: str | None = 'in_right', origin_widget: bui.Widget | None = None, ): @@ -41,12 +46,13 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): # pylint: disable=too-many-branches # pylint: disable=too-many-statements # pylint: disable=too-many-locals + assert bui.app.classic is not None + # print(f'EditProfileWindow({id(self)})') plus = bui.app.plus assert plus is not None - # self._in_main_menu = in_main_menu self._existing_profile = existing_profile self._r = 'editProfileWindow' self._spazzes: list[str] = [] @@ -62,10 +68,11 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): self._width = width = 880.0 if uiscale is bui.UIScale.SMALL else 680.0 self._x_inset = x_inset = 100.0 if uiscale is bui.UIScale.SMALL else 0.0 self._height = height = ( - 450.0 + 500.0 if uiscale is bui.UIScale.SMALL else 400.0 if uiscale is bui.UIScale.MEDIUM else 450.0 ) + yoffs = -42 if uiscale is bui.UIScale.SMALL else 0 spacing = 40 self._base_scale = ( 1.6 @@ -78,13 +85,10 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): size=(width, height + top_extra), scale=self._base_scale, stack_offset=( - (0, -40) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), toolbar_visibility=( - # 'menu_minimal' - None - if uiscale is bui.UIScale.SMALL - else 'menu_full' + None if uiscale is bui.UIScale.SMALL else 'menu_full' ), ), transition=transition, @@ -92,7 +96,7 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): ) cancel_button = btn = bui.buttonwidget( parent=self._root_widget, - position=(52 + x_inset, height - 60), + position=(52 + x_inset, height - 60 + yoffs), size=(155, 60), scale=0.8, autoselect=True, @@ -102,7 +106,7 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): bui.containerwidget(edit=self._root_widget, cancel_button=btn) save_button = btn = bui.buttonwidget( parent=self._root_widget, - position=(width - (177 + x_inset), height - 60), + position=(width - (177 + x_inset), height - 60 + yoffs), size=(155, 60), autoselect=True, scale=0.8, @@ -113,7 +117,7 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): bui.containerwidget(edit=self._root_widget, start_button=btn) bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, height - 38), + position=(self._width * 0.5, height - 38 + yoffs), size=(0, 0), text=( bui.Lstr(resource=f'{self._r}.titleNewText') @@ -163,7 +167,7 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): self._icon_index = icon_index bui.buttonwidget(edit=save_button, on_activate_call=self.save) - v = height - 115.0 + v = height - 115.0 + yoffs self._name = ( '' if self._existing_profile is None else self._existing_profile ) @@ -522,12 +526,16 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): 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 within the lambda + # we'll keep ourself alive which is bad. + + existing_profile = self._existing_profile return bui.BasicMainWindowState( create_call=lambda transition, origin_widget: cls( transition=transition, origin_widget=origin_widget, - existing_profile=self._existing_profile, - # in_main_menu=self._in_main_menu, + existing_profile=existing_profile, ) ) @@ -637,18 +645,35 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): for s in self._spazzes ] + @override def on_icon_picker_pick(self, icon: str) -> None: """An icon has been selected by the picker.""" self._icon = icon self._update_icon() + @override + def on_icon_picker_get_more_press(self) -> None: + """User wants to get more icons.""" + from bauiv1lib.store.browser import StoreBrowserWindow + + if not self.main_window_has_control(): + return + + self.main_window_replace( + StoreBrowserWindow( + minimal_toolbars=True, + show_tab=StoreBrowserWindow.TabID.ICONS, + ) + ) + @override def on_character_picker_pick(self, character: str) -> None: """A character has been selected by the picker.""" if not self._root_widget: return - # The player could have bought a new one while the picker was up. + # The player could have bought a new one while the picker was + # up. self.refresh_characters() self._icon_index = ( self._spazzes.index(character) if character in self._spazzes else 0 @@ -847,8 +872,8 @@ class EditProfileWindow(bui.MainWindow, CharacterPickerDelegate): } ) - # Also lets be aware we're no longer global if we're taking a - # new name (will need to re-request it). + # Also lets be aware we're no longer global if we're taking + # a new name (will need to re-request it). self._global = False plus.add_v1_account_transaction( diff --git a/src/assets/ba_data/python/bauiv1lib/profile/upgrade.py b/src/assets/ba_data/python/bauiv1lib/profile/upgrade.py index eadc9903..a9139a3c 100644 --- a/src/assets/ba_data/python/bauiv1lib/profile/upgrade.py +++ b/src/assets/ba_data/python/bauiv1lib/profile/upgrade.py @@ -34,13 +34,14 @@ class ProfileUpgradeWindow(bui.Window): uiscale = bui.app.ui_v1.uiscale self._width = 750 if uiscale is bui.UIScale.SMALL else 680 - self._height = 350 + self._height = 450 if uiscale is bui.UIScale.SMALL else 350 assert bui.app.classic is not None self._base_scale = ( 1.9 if uiscale is bui.UIScale.SMALL else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.2 ) + yoffs = -60.0 if uiscale is bui.UIScale.SMALL else 0 self._upgrade_start_time: float | None = None self._name = edit_profile_window.getname() self._edit_profile_window = weakref.ref(edit_profile_window) @@ -53,13 +54,13 @@ class ProfileUpgradeWindow(bui.Window): transition=transition, scale=self._base_scale, stack_offset=( - (0, -30) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ) ) cancel_button = bui.buttonwidget( parent=self._root_widget, - position=(52, 60), + position=(52, self._height - 290 + yoffs), size=(155, 60), scale=0.8, autoselect=True, @@ -68,7 +69,7 @@ class ProfileUpgradeWindow(bui.Window): ) self._upgrade_button = bui.buttonwidget( parent=self._root_widget, - position=(self._width - 190, 60), + position=(self._width - 190, self._height - 290 + yoffs), size=(155, 60), scale=0.8, autoselect=True, @@ -85,7 +86,7 @@ class ProfileUpgradeWindow(bui.Window): assert bui.app.classic is not None bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 38), + position=(self._width * 0.5, self._height - 38 + yoffs), size=(0, 0), text=bui.Lstr(resource=f'{self._r}.upgradeToGlobalProfileText'), color=bui.app.ui_v1.title_color, @@ -98,7 +99,7 @@ class ProfileUpgradeWindow(bui.Window): assert bui.app.classic is not None bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 100), + position=(self._width * 0.5, self._height - 100 + yoffs), size=(0, 0), text=bui.Lstr(resource=f'{self._r}.upgradeProfileInfoText'), color=bui.app.ui_v1.infotextcolor, @@ -110,7 +111,7 @@ class ProfileUpgradeWindow(bui.Window): self._status_text = bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 160), + position=(self._width * 0.5, self._height - 160 + yoffs), size=(0, 0), text=bui.Lstr( resource=f'{self._r}.checkingAvailabilityText', @@ -125,7 +126,7 @@ class ProfileUpgradeWindow(bui.Window): self._price_text = bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 230), + position=(self._width * 0.5, self._height - 230 + yoffs), size=(0, 0), text='', color=(0.2, 1, 0.2), @@ -135,22 +136,6 @@ class ProfileUpgradeWindow(bui.Window): v_align='center', ) - self._tickets_text: bui.Widget | None - # if not bui.app.ui_v1.use_toolbars: - # self._tickets_text = bui.textwidget( - # parent=self._root_widget, - # position=(self._width * 0.9 - 5, self._height - 30), - # size=(0, 0), - # text=bui.charstr(bui.SpecialChar.TICKET) + '123', - # color=(0.2, 1, 0.2), - # maxwidth=100, - # scale=0.5, - # h_align='right', - # v_align='center', - # ) - # else: - self._tickets_text = None - bui.app.classic.master_server_v1_get( 'bsGlobalProfileCheck', {'name': self._name, 'b': bui.app.env.engine_build_number}, @@ -161,7 +146,7 @@ class ProfileUpgradeWindow(bui.Window): ) self._status: str | None = 'waiting' self._update_timer = bui.AppTimer( - 1.0, bui.WeakCall(self._update), repeat=True + 1.023, bui.WeakCall(self._update), repeat=True ) self._update() @@ -256,23 +241,11 @@ class ProfileUpgradeWindow(bui.Window): plus = bui.app.plus assert plus is not None - try: - t_str = str(plus.get_v1_account_ticket_count()) - except Exception: - t_str = '?' - if self._tickets_text is not None: - bui.textwidget( - edit=self._tickets_text, - text=bui.Lstr( - resource='getTicketsWindow.youHaveShortText', - subs=[ - ( - '${COUNT}', - bui.charstr(bui.SpecialChar.TICKET) + t_str, - ) - ], - ), - ) + # If our originating window dies at any point, cancel. + edit_profile_window = self._edit_profile_window() + if edit_profile_window is None: + self._cancel() + return # Once we've kicked off an upgrade attempt and all transactions go # through, we're done. diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index d3915c32..245621f7 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -81,7 +81,9 @@ class AdvancedSettingsWindow(bui.MainWindow): self._show_always_use_internal_keyboard = not app.env.vr self._scroll_width = self._width - (100 + 2 * x_inset) - self._scroll_height = self._height - 115.0 + self._scroll_height = self._height - ( + 125.0 if uiscale is bui.UIScale.SMALL else 115.0 + ) self._sub_width = self._scroll_width * 0.95 self._sub_height = 870.0 @@ -129,10 +131,10 @@ class AdvancedSettingsWindow(bui.MainWindow): parent=self._root_widget, position=( self._width * 0.5, - self._height - (57 if uiscale is bui.UIScale.SMALL else 40), + self._height - (61 if uiscale is bui.UIScale.SMALL else 40), ), size=(0, 0), - scale=0.65 if uiscale is bui.UIScale.SMALL else 1.0, + scale=0.85 if uiscale is bui.UIScale.SMALL else 1.0, text=bui.Lstr(resource=f'{self._r}.titleText'), color=app.ui_v1.title_color, h_align='center', @@ -201,7 +203,7 @@ class AdvancedSettingsWindow(bui.MainWindow): from bauiv1lib import appinvite as _unused5 from bauiv1lib import account as _unused6 from bauiv1lib import sendinfo as _unused7 - from bauiv1lib import benchmarks as _unused8 + from bauiv1lib.settings import benchmarks as _unused8 from bauiv1lib.settings import plugins as _unused9 from bauiv1lib.settings import devtools as _unused10 @@ -783,7 +785,7 @@ class AdvancedSettingsWindow(bui.MainWindow): ) def _on_benchmark_press(self) -> None: - from bauiv1lib.benchmarks import BenchmarksAndStressTestsWindow + from bauiv1lib.settings.benchmarks import BenchmarksAndStressTestsWindow # no-op if we're not in control. if not self.main_window_has_control(): diff --git a/src/assets/ba_data/python/bauiv1lib/settings/allsettings.py b/src/assets/ba_data/python/bauiv1lib/settings/allsettings.py index 9c7c81a3..395e9efb 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/allsettings.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/allsettings.py @@ -33,9 +33,10 @@ class AllSettingsWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale width = 1000 if uiscale is bui.UIScale.SMALL else 580 x_inset = 125 if uiscale is bui.UIScale.SMALL else 0 - height = 435 + height = 500 if uiscale is bui.UIScale.SMALL else 435 self._r = 'settingsWindow' top_extra = 20 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -30 if uiscale is bui.UIScale.SMALL else 0 uiscale = bui.app.ui_v1.uiscale super().__init__( @@ -68,7 +69,7 @@ class AllSettingsWindow(bui.MainWindow): self._back_button = btn = bui.buttonwidget( parent=self._root_widget, autoselect=True, - position=(40 + x_inset, height - 55), + position=(40 + x_inset, height - 55 + yoffs), size=(130, 60), scale=0.8, text_scale=1.2, @@ -80,7 +81,7 @@ class AllSettingsWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(0, height - 44), + position=(0, height - 44 + yoffs), size=(width, 25), text=bui.Lstr(resource=f'{self._r}.titleText'), color=bui.app.ui_v1.title_color, @@ -97,7 +98,7 @@ class AllSettingsWindow(bui.MainWindow): label=bui.charstr(bui.SpecialChar.BACK), ) - v = height - 80 + v = height - 80 + yoffs v -= 145 basew = 280 if uiscale is bui.UIScale.SMALL else 230 diff --git a/src/assets/ba_data/python/bauiv1lib/settings/controls.py b/src/assets/ba_data/python/bauiv1lib/settings/controls.py index 38678056..562c7e9f 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/controls.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/controls.py @@ -150,7 +150,7 @@ class ControlsSettingsWindow(bui.MainWindow): parent=self._root_widget, position=( 0, - height + yoffs - (75 if uiscale is bui.UIScale.SMALL else 50), + height + yoffs - (53 if uiscale is bui.UIScale.SMALL else 50), ), size=(width, 25), text=bui.Lstr(resource=f'{self._r}.titleText'), @@ -159,7 +159,7 @@ class ControlsSettingsWindow(bui.MainWindow): v_align='top', ) - v = height - 75 + yoffs + v = height - (85 if uiscale is bui.UIScale.SMALL else 75) + yoffs v -= spacing if show_touch: diff --git a/src/assets/ba_data/python/bauiv1lib/settings/devtools.py b/src/assets/ba_data/python/bauiv1lib/settings/devtools.py index 80d924ca..ea817002 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/devtools.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/devtools.py @@ -92,7 +92,7 @@ class DevToolsWindow(bui.MainWindow): self._height - (64 if uiscale is bui.UIScale.SMALL else 48), ), size=(0, 25), - scale=(0.6 if uiscale is bui.UIScale.SMALL else 1.0), + scale=(0.8 if uiscale is bui.UIScale.SMALL else 1.0), maxwidth=self._width - 200, text=bui.Lstr(resource='settingsWindowAdvanced.devToolsText'), color=app.ui_v1.title_color, diff --git a/src/assets/ba_data/python/bauiv1lib/settings/nettesting.py b/src/assets/ba_data/python/bauiv1lib/settings/nettesting.py index 23a6142f..b8e25808 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/nettesting.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/nettesting.py @@ -32,7 +32,9 @@ class NetTestingWindow(bui.MainWindow): ): uiscale = bui.app.ui_v1.uiscale self._width = 820 - self._height = 400 if uiscale is bui.UIScale.SMALL else 500 + self._height = 500 if uiscale is bui.UIScale.SMALL else 500 + yoffs = -50 if uiscale is bui.UIScale.SMALL else 0 + self._printed_lines: list[str] = [] assert bui.app.classic is not None super().__init__( @@ -53,23 +55,33 @@ class NetTestingWindow(bui.MainWindow): transition=transition, origin_widget=origin_widget, ) - self._done_button: bui.Widget | None = bui.buttonwidget( - parent=self._root_widget, - position=(46, self._height - 77), - size=(60, 60), - scale=0.9, - label=bui.charstr(bui.SpecialChar.BACK), - button_type='backSmall', - autoselect=True, - on_activate_call=self.main_window_back, - ) + self._done_button: bui.Widget | None + if uiscale is bui.UIScale.SMALL: + bui.containerwidget( + edit=self._root_widget, on_cancel_call=self.main_window_back + ) + self._done_button = None + else: + self._done_button = bui.buttonwidget( + parent=self._root_widget, + position=(46, self._height - 77 + yoffs), + size=(60, 60), + scale=0.9, + label=bui.charstr(bui.SpecialChar.BACK), + button_type='backSmall', + autoselect=True, + on_activate_call=self.main_window_back, + ) + bui.containerwidget( + edit=self._root_widget, cancel_button=self._done_button + ) # Avoid squads button on small mode. xinset = -50 if uiscale is bui.UIScale.SMALL else 0 self._copy_button = bui.buttonwidget( parent=self._root_widget, - position=(self._width - 200 + xinset, self._height - 77), + position=(self._width - 200 + xinset, self._height - 77 + yoffs), size=(100, 60), scale=0.8, autoselect=True, @@ -79,7 +91,7 @@ class NetTestingWindow(bui.MainWindow): self._settings_button = bui.buttonwidget( parent=self._root_widget, - position=(self._width - 100 + xinset, self._height - 77), + position=(self._width - 100 + xinset, self._height - 77 + yoffs), size=(60, 60), scale=0.8, autoselect=True, @@ -90,7 +102,7 @@ class NetTestingWindow(bui.MainWindow): twidth = self._width - 540 bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 55), + position=(self._width * 0.5, self._height - 55 + yoffs), size=(0, 0), text=bui.Lstr(resource='settingsWindowAdvanced.netTestingText'), color=(0.8, 0.8, 0.8, 1.0), @@ -101,24 +113,19 @@ class NetTestingWindow(bui.MainWindow): self._scroll = bui.scrollwidget( parent=self._root_widget, - position=(50, 50), - size=(self._width - 100, self._height - 140), + position=( + 50, + (140 if uiscale is bui.UIScale.SMALL else 50) + yoffs, + ), + size=( + self._width - 100, + self._height - (220 if uiscale is bui.UIScale.SMALL else 140), + ), capture_arrows=True, autoselect=True, ) self._rows = bui.columnwidget(parent=self._scroll) - if uiscale is bui.UIScale.SMALL: - bui.containerwidget( - edit=self._root_widget, on_cancel_call=self.main_window_back - ) - self._done_button.delete() - self._done_button = None - else: - bui.containerwidget( - edit=self._root_widget, cancel_button=self._done_button - ) - # Now kick off the tests. # Pass a weak-ref to this window so we don't keep it alive # if we back out before it completes. Also set is as daemon @@ -169,7 +176,7 @@ class NetTestingWindow(bui.MainWindow): if not self.main_window_has_control(): return - self.main_window_replace(NetValTestingWindow()) + self.main_window_replace(get_net_val_testing_window()) def _run_diagnostics(weakwin: weakref.ref[NetTestingWindow]) -> None: @@ -461,26 +468,48 @@ def _test_nearby_zone_ping(nearest_zone: tuple[str, float] | None) -> None: raise RuntimeError('Ping too high.') -class NetValTestingWindow(TestingWindow): - """Window to test network related settings.""" +def get_net_val_testing_window() -> TestingWindow: + """Create a window for testing net values.""" + entries = [ + {'name': 'bufferTime', 'label': 'Buffer Time', 'increment': 1.0}, + { + 'name': 'delaySampling', + 'label': 'Delay Sampling', + 'increment': 1.0, + }, + { + 'name': 'dynamicsSyncTime', + 'label': 'Dynamics Sync Time', + 'increment': 10, + }, + {'name': 'showNetInfo', 'label': 'Show Net Info', 'increment': 1}, + ] + return TestingWindow( + title=bui.Lstr(resource='settingsWindowAdvanced.netTestingText'), + entries=entries, + ) - def __init__(self, transition: str = 'in_right'): - entries = [ - {'name': 'bufferTime', 'label': 'Buffer Time', 'increment': 1.0}, - { - 'name': 'delaySampling', - 'label': 'Delay Sampling', - 'increment': 1.0, - }, - { - 'name': 'dynamicsSyncTime', - 'label': 'Dynamics Sync Time', - 'increment': 10, - }, - {'name': 'showNetInfo', 'label': 'Show Net Info', 'increment': 1}, - ] - super().__init__( - title=bui.Lstr(resource='settingsWindowAdvanced.netTestingText'), - entries=entries, - transition=transition, - ) + +# class NetValTestingWindow(TestingWindow): +# """Window to test network related settings.""" + +# def __init__(self, transition: str = 'in_right'): +# entries = [ +# {'name': 'bufferTime', 'label': 'Buffer Time', 'increment': 1.0}, +# { +# 'name': 'delaySampling', +# 'label': 'Delay Sampling', +# 'increment': 1.0, +# }, +# { +# 'name': 'dynamicsSyncTime', +# 'label': 'Dynamics Sync Time', +# 'increment': 10, +# }, +# {'name': 'showNetInfo', 'label': 'Show Net Info', 'increment': 1}, +# ] +# super().__init__( +# title=bui.Lstr(resource='settingsWindowAdvanced.netTestingText'), +# entries=entries, +# transition=transition, +# ) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/plugins.py b/src/assets/ba_data/python/bauiv1lib/settings/plugins.py index 6c12907d..40d2f26c 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/plugins.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/plugins.py @@ -44,12 +44,13 @@ class PluginWindow(bui.MainWindow): uiscale = bui.app.ui_v1.uiscale self._width = 870.0 if uiscale is bui.UIScale.SMALL else 670.0 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -55.0 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 370.0 + 450.0 if uiscale is bui.UIScale.SMALL else 450.0 if uiscale is bui.UIScale.MEDIUM else 520.0 ) - top_extra = 10 if uiscale is bui.UIScale.SMALL else 0 + top_extra = 0 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( size=(self._width, self._height + top_extra), @@ -64,7 +65,7 @@ class PluginWindow(bui.MainWindow): else 1.4 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -25) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -72,7 +73,9 @@ class PluginWindow(bui.MainWindow): ) self._scroll_width = self._width - (100 + 2 * x_inset) - self._scroll_height = self._height - 115.0 + self._scroll_height = self._height - ( + 200.0 if uiscale is bui.UIScale.SMALL else 115.0 + ) self._sub_width = self._scroll_width * 0.95 self._sub_height = 724.0 @@ -85,7 +88,7 @@ class PluginWindow(bui.MainWindow): else: self._back_button = bui.buttonwidget( parent=self._root_widget, - position=(53 + x_inset, self._height - 60), + position=(53 + x_inset, self._height - 60 + yoffs), size=(140, 60), scale=0.8, autoselect=True, @@ -99,7 +102,7 @@ class PluginWindow(bui.MainWindow): self._title_text = bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 41), + position=(self._width * 0.5, self._height - 41 + yoffs), size=(0, 0), text=bui.Lstr(resource='pluginsText'), color=app.ui_v1.title_color, @@ -120,7 +123,7 @@ class PluginWindow(bui.MainWindow): self._num_plugins_text = bui.textwidget( parent=self._root_widget, - position=(settings_button_x - 130, self._height - 41), + position=(settings_button_x - 130, self._height - 41 + yoffs), size=(0, 0), text='', h_align='center', @@ -130,7 +133,7 @@ class PluginWindow(bui.MainWindow): self._category_button = bui.buttonwidget( parent=self._root_widget, scale=0.7, - position=(settings_button_x - 105, self._height - 60), + position=(settings_button_x - 105, self._height - 60 + yoffs), size=(130, 60), label=bui.Lstr(resource='allText'), autoselect=True, @@ -141,7 +144,7 @@ class PluginWindow(bui.MainWindow): self._settings_button = bui.buttonwidget( parent=self._root_widget, - position=(settings_button_x, self._height - 58), + position=(settings_button_x, self._height - 58 + yoffs), size=(40, 40), label='', on_activate_call=self._open_settings, @@ -149,7 +152,7 @@ class PluginWindow(bui.MainWindow): bui.imagewidget( parent=self._root_widget, - position=(settings_button_x + 3, self._height - 57), + position=(settings_button_x + 3, self._height - 57 + yoffs), draw_controller=self._settings_button, size=(35, 35), texture=bui.gettexture('settingsIcon'), @@ -163,7 +166,10 @@ class PluginWindow(bui.MainWindow): self._scrollwidget = bui.scrollwidget( parent=self._root_widget, - position=(50 + x_inset, 50), + position=( + 50 + x_inset, + (135 if uiscale is bui.UIScale.SMALL else 50) + yoffs, + ), simple_culling_v=20.0, highlight=False, size=(self._scroll_width, self._scroll_height), diff --git a/src/assets/ba_data/python/bauiv1lib/settings/pluginsettings.py b/src/assets/ba_data/python/bauiv1lib/settings/pluginsettings.py index 1f3aefda..19024b6b 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/pluginsettings.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/pluginsettings.py @@ -21,17 +21,13 @@ class PluginSettingsWindow(bui.MainWindow): assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale - width = 670.0 if uiscale is bui.UIScale.SMALL else 470.0 - height = ( - 365.0 - if uiscale is bui.UIScale.SMALL - else 300.0 if uiscale is bui.UIScale.MEDIUM else 370.0 - ) - top_extra = 10 if uiscale is bui.UIScale.SMALL else 0 + width = 750.0 if uiscale is bui.UIScale.SMALL else 470.0 + height = 400.0 if uiscale is bui.UIScale.SMALL else 300.0 + yoffs = -20 if uiscale is bui.UIScale.SMALL else 0 super().__init__( root_widget=bui.containerwidget( - size=(width, height + top_extra), + size=(width, height), toolbar_visibility=( 'menu_minimal' if uiscale is bui.UIScale.SMALL @@ -43,7 +39,7 @@ class PluginSettingsWindow(bui.MainWindow): else 1.4 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -25) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -51,7 +47,7 @@ class PluginSettingsWindow(bui.MainWindow): ) if uiscale is bui.UIScale.SMALL: - xoffs = 90 + xoffs = 135 self._back_button = bui.get_special_widget('back_button') bui.containerwidget( edit=self._root_widget, on_cancel_call=self.main_window_back @@ -60,7 +56,7 @@ class PluginSettingsWindow(bui.MainWindow): xoffs = 0 self._back_button = bui.buttonwidget( parent=self._root_widget, - position=(53, height - 60), + position=(53, height - 60 + yoffs), size=(60, 60), scale=0.8, autoselect=True, @@ -76,7 +72,7 @@ class PluginSettingsWindow(bui.MainWindow): parent=self._root_widget, position=( width * 0.5, - height - (45 if uiscale is bui.UIScale.SMALL else 35), + height - (55 if uiscale is bui.UIScale.SMALL else 35) + yoffs, ), size=(0, 0), text=bui.Lstr(resource='pluginSettingsText'), @@ -85,10 +81,10 @@ class PluginSettingsWindow(bui.MainWindow): v_align='center', ) - self._y_position = 170 if uiscale is bui.UIScale.MEDIUM else 205 + self._y_position = height - 140 + yoffs self._enable_plugins_button = bui.buttonwidget( parent=self._root_widget, - position=(xoffs + 65, self._y_position), + position=(xoffs + 65, self._y_position + yoffs), size=(350, 60), autoselect=True, label=bui.Lstr(resource='pluginsEnableAllText'), @@ -101,7 +97,7 @@ class PluginSettingsWindow(bui.MainWindow): self._y_position -= 70 self._disable_plugins_button = bui.buttonwidget( parent=self._root_widget, - position=(xoffs + 65, self._y_position), + position=(xoffs + 65, self._y_position + yoffs), size=(350, 60), autoselect=True, label=bui.Lstr(resource='pluginsDisableAllText'), @@ -114,7 +110,7 @@ class PluginSettingsWindow(bui.MainWindow): self._y_position -= 70 self._enable_new_plugins_check_box = bui.checkboxwidget( parent=self._root_widget, - position=(xoffs + 65, self._y_position), + position=(xoffs + 65, self._y_position + yoffs), size=(350, 60), value=bui.app.config.get( bui.app.plugins.AUTO_ENABLE_NEW_PLUGINS_CONFIG_KEY, diff --git a/src/assets/ba_data/python/bauiv1lib/settings/remoteapp.py b/src/assets/ba_data/python/bauiv1lib/settings/remoteapp.py index 97af8c44..d9719b3c 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/remoteapp.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/remoteapp.py @@ -21,7 +21,8 @@ class RemoteAppSettingsWindow(bui.MainWindow): app = bui.app uiscale = app.ui_v1.uiscale width = 800 if uiscale is bui.UIScale.SMALL else 700 - height = 390 + height = 480 if uiscale is bui.UIScale.SMALL else 390 + yoffs = -48 if uiscale is bui.UIScale.SMALL else 0 spacing = 40 assert bui.app.classic is not None super().__init__( @@ -33,12 +34,12 @@ class RemoteAppSettingsWindow(bui.MainWindow): else 'menu_full' ), scale=( - 1.76 + 1.75 if uiscale is bui.UIScale.SMALL else 1.3 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (-10, 0) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -52,7 +53,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): else: btn = bui.buttonwidget( parent=self._root_widget, - position=(40, height - 67), + position=(40, height - 67 + yoffs), size=(140, 65), scale=0.8, label=bui.Lstr(resource='backText'), @@ -71,7 +72,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(width * 0.5, height - 42), + position=(width * 0.5, height - 42 + yoffs), size=(0, 0), text=bui.Lstr(resource=f'{self._r}.titleText'), maxwidth=370, @@ -85,7 +86,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): v -= spacing * 1.2 bui.textwidget( parent=self._root_widget, - position=(15, v - 26), + position=(15, v - 26 + yoffs), size=(width - 30, 30), maxwidth=width * 0.95, color=(0.7, 0.9, 0.7, 1.0), @@ -106,7 +107,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): # Update: now we just show link to the remote webpage. bui.textwidget( parent=self._root_widget, - position=(width * 0.5, v + 5), + position=(width * 0.5, v + 5 + yoffs), size=(0, 0), color=(0.7, 0.9, 0.7, 1.0), scale=1.4, @@ -120,7 +121,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): bui.textwidget( parent=self._root_widget, - position=(width * 0.5, v - 35), + position=(width * 0.5, v - 35 + yoffs), size=(0, 0), color=(0.7, 0.9, 0.7, 0.8), scale=0.65, @@ -133,7 +134,7 @@ class RemoteAppSettingsWindow(bui.MainWindow): bui.checkboxwidget( parent=self._root_widget, - position=(width * 0.5 - 150, v - 116), + position=(width * 0.5 - 150, v - 116 + yoffs), size=(300, 30), maxwidth=300, scale=0.8, diff --git a/src/assets/ba_data/python/bauiv1lib/settings/testing.py b/src/assets/ba_data/python/bauiv1lib/settings/testing.py index de396332..00c48124 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/testing.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/testing.py @@ -5,7 +5,7 @@ from __future__ import annotations import copy -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, override import bauiv1 as bui @@ -25,9 +25,12 @@ class TestingWindow(bui.MainWindow): ): assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale - self._width = 700 if uiscale is bui.UIScale.SMALL else 600 - self._height = 324 if uiscale is bui.UIScale.SMALL else 400 + self._width = 690 if uiscale is bui.UIScale.SMALL else 600 + self._height = 400 if uiscale is bui.UIScale.SMALL else 400 + self._entries_orig = copy.deepcopy(entries) self._entries = copy.deepcopy(entries) + yoffs = -50 if uiscale is bui.UIScale.SMALL else 0 + super().__init__( root_widget=bui.containerwidget( size=(self._width, self._height), @@ -37,7 +40,7 @@ class TestingWindow(bui.MainWindow): else 1.2 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -20) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), toolbar_visibility=( 'menu_minimal' @@ -58,7 +61,7 @@ class TestingWindow(bui.MainWindow): self._back_button = btn = bui.buttonwidget( parent=self._root_widget, autoselect=True, - position=(65, self._height - 59), + position=(65, self._height - 59 + yoffs), size=(130, 60), scale=0.8, text_scale=1.2, @@ -74,25 +77,30 @@ class TestingWindow(bui.MainWindow): ) bui.containerwidget(edit=self._root_widget, cancel_button=btn) + self.title = title bui.textwidget( parent=self._root_widget, position=( self._width * 0.5, - self._height - (42 if uiscale is bui.UIScale.SMALL else 35), + self._height + - (42 if uiscale is bui.UIScale.SMALL else 35) + + yoffs, ), size=(0, 0), color=bui.app.ui_v1.title_color, h_align='center', v_align='center', maxwidth=245, - text=title, + text=self.title, ) bui.textwidget( parent=self._root_widget, position=( self._width * 0.5, - self._height - (80 if uiscale is bui.UIScale.SMALL else 80), + self._height + - (80 if uiscale is bui.UIScale.SMALL else 80) + + yoffs, ), size=(0, 0), color=bui.app.ui_v1.infotextcolor, @@ -102,12 +110,17 @@ class TestingWindow(bui.MainWindow): text=bui.Lstr(resource='settingsWindowAdvanced.forTestingText'), ) self._scroll_width = self._width - 130 - self._scroll_height = self._height - 140 + self._scroll_height = self._height - ( + 220 if uiscale is bui.UIScale.SMALL else 140 + ) self._scrollwidget = bui.scrollwidget( parent=self._root_widget, size=(self._scroll_width, self._scroll_height), highlight=False, - position=((self._width - self._scroll_width) * 0.5, 40), + position=( + (self._width - self._scroll_width) * 0.5, + (120 if uiscale is bui.UIScale.SMALL else 40) + yoffs, + ), ) bui.containerwidget(edit=self._scrollwidget, claims_left_right=True) @@ -226,3 +239,22 @@ class TestingWindow(bui.MainWindow): edit=entry['widget'], text='%.4g' % bui.app.classic.value_test(entry['name']), ) + + @override + def get_main_window_state(self) -> bui.MainWindowState: + # Support recreating our window for back/refresh purposes. + cls = type(self) + + # Pull values from self here; if we do it in the lambda we'll keep + # self alive which we don't want. + title = self.title + entries = self._entries_orig + + return bui.BasicMainWindowState( + create_call=lambda transition, origin_widget: cls( + title=title, + entries=entries, + transition=transition, + origin_widget=origin_widget, + ) + ) diff --git a/src/assets/ba_data/python/bauiv1lib/soundtrack/browser.py b/src/assets/ba_data/python/bauiv1lib/soundtrack/browser.py index 315ee998..371662b8 100644 --- a/src/assets/ba_data/python/bauiv1lib/soundtrack/browser.py +++ b/src/assets/ba_data/python/bauiv1lib/soundtrack/browser.py @@ -25,19 +25,21 @@ class SoundtrackBrowserWindow(bui.MainWindow): origin_widget: bui.Widget | None = None, ): # pylint: disable=too-many-statements + # pylint: disable=too-many-locals self._r = 'editSoundtrackWindow' assert bui.app.classic is not None uiscale = bui.app.ui_v1.uiscale self._width = 800 if uiscale is bui.UIScale.SMALL else 600 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 + yoffs = -30 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 340 + 400 if uiscale is bui.UIScale.SMALL else 370 if uiscale is bui.UIScale.MEDIUM else 440 ) spacing = 40.0 - v = self._height - 40.0 + v = self._height - 40.0 + yoffs v -= spacing * 1.0 super().__init__( @@ -54,7 +56,7 @@ class SoundtrackBrowserWindow(bui.MainWindow): else 1.6 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -18) if uiscale is bui.UIScale.SMALL else (0, 0) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 0) ), ), transition=transition, @@ -67,7 +69,7 @@ class SoundtrackBrowserWindow(bui.MainWindow): else: self._back_button = bui.buttonwidget( parent=self._root_widget, - position=(45 + x_inset, self._height - 60), + position=(45 + x_inset, self._height - 60 + yoffs), size=(120, 60), scale=0.8, label=bui.Lstr(resource='backText'), @@ -82,7 +84,12 @@ class SoundtrackBrowserWindow(bui.MainWindow): ) bui.textwidget( parent=self._root_widget, - position=(self._width * 0.5, self._height - 35), + position=( + self._width * 0.5, + self._height + - (46 if uiscale is bui.UIScale.SMALL else 35) + + yoffs, + ), size=(0, 0), maxwidth=300, text=bui.Lstr(resource=f'{self._r}.titleText'), @@ -92,7 +99,7 @@ class SoundtrackBrowserWindow(bui.MainWindow): ) h = 43 + x_inset - v = self._height - 60 + v = self._height - 60 + yoffs b_color = (0.6, 0.53, 0.63) b_textcolor = (0.75, 0.7, 0.8) lock_tex = bui.gettexture('lock') @@ -222,8 +229,10 @@ class SoundtrackBrowserWindow(bui.MainWindow): ) self._update() - v = self._height - 65 - scroll_height = self._height - 105 + v = self._height - 65 + yoffs + scroll_height = self._height - ( + 160 if uiscale is bui.UIScale.SMALL else 105 + ) v -= scroll_height self._scrollwidget = scrollwidget = bui.scrollwidget( parent=self._root_widget, diff --git a/src/assets/ba_data/python/bauiv1lib/soundtrack/edit.py b/src/assets/ba_data/python/bauiv1lib/soundtrack/edit.py index 27fb5c1b..1edbe8fe 100644 --- a/src/assets/ba_data/python/bauiv1lib/soundtrack/edit.py +++ b/src/assets/ba_data/python/bauiv1lib/soundtrack/edit.py @@ -35,10 +35,12 @@ class SoundtrackEditWindow(bui.MainWindow): self._width = 900 if uiscale is bui.UIScale.SMALL else 648 x_inset = 100 if uiscale is bui.UIScale.SMALL else 0 self._height = ( - 395 + 450 if uiscale is bui.UIScale.SMALL else 450 if uiscale is bui.UIScale.MEDIUM else 560 ) + yoffs = -48 if uiscale is bui.UIScale.SMALL else 0 + super().__init__( root_widget=bui.containerwidget( size=(self._width, self._height), @@ -48,7 +50,7 @@ class SoundtrackEditWindow(bui.MainWindow): else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0 ), stack_offset=( - (0, -37) + (0, 0) if uiscale is bui.UIScale.SMALL else (0, 15) if uiscale is bui.UIScale.MEDIUM else (0, 0) ), @@ -58,7 +60,7 @@ class SoundtrackEditWindow(bui.MainWindow): ) cancel_button = bui.buttonwidget( parent=self._root_widget, - position=(38 + x_inset, self._height - 60), + position=(38 + x_inset, self._height - 60 + yoffs), size=(160, 60), autoselect=True, label=bui.Lstr(resource='cancelText'), @@ -66,7 +68,7 @@ class SoundtrackEditWindow(bui.MainWindow): ) save_button = bui.buttonwidget( parent=self._root_widget, - position=(self._width - (168 + x_inset), self._height - 60), + position=(self._width - (168 + x_inset), self._height - 60 + yoffs), autoselect=True, size=(160, 60), label=bui.Lstr(resource='saveText'), @@ -76,7 +78,7 @@ class SoundtrackEditWindow(bui.MainWindow): bui.widget(edit=cancel_button, right_widget=save_button) bui.textwidget( parent=self._root_widget, - position=(0, self._height - 50), + position=(0, self._height - 50 + yoffs), size=(self._width, 25), text=bui.Lstr( resource=self._r @@ -91,7 +93,7 @@ class SoundtrackEditWindow(bui.MainWindow): v_align='center', maxwidth=280, ) - v = self._height - 110 + v = self._height - 110 + yoffs if 'Soundtracks' not in appconfig: appconfig['Soundtracks'] = {} @@ -165,7 +167,9 @@ class SoundtrackEditWindow(bui.MainWindow): on_return_press_call=self._do_it_with_sound, ) - scroll_height = self._height - 180 + scroll_height = self._height - ( + 230 if uiscale is bui.UIScale.SMALL else 180 + ) self._scrollwidget = scrollwidget = bui.scrollwidget( parent=self._root_widget, highlight=False, diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 7500892e..9a6a509d 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -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 = 22010; +const int kEngineBuildNumber = 22015; const char* kEngineVersion = "1.7.37"; const int kEngineApiVersion = 9; diff --git a/src/ballistica/ui_v1/widget/root_widget.cc b/src/ballistica/ui_v1/widget/root_widget.cc index bf8132f6..0f37e62c 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -54,6 +54,7 @@ struct RootWidget::ButtonDef { float h_align{}; float x{}; float y{}; + float y_offs_small{}; float width{100.0f}; float height{30.0f}; float scale{1.0f}; @@ -74,12 +75,13 @@ struct RootWidget::Button { Object::Ref widget; float h_align{}; VAlign v_align{VAlign::kTop}; - float x{}; // user provided x - float y{}; // user provided y - float x_target{}; // final target x (accounting for visibility, etc) - float y_target{}; // final target y (accounting for visibility, etc) - float x_smoothed{}; // current x (on way to target) - float y_smoothed{}; // current y (on way to target) + float x{}; // user provided x + float y{}; // user provided y + float y_offs_small{}; // user provided y offset for small uiscale + float x_target{}; // final target x (accounting for visibility, etc) + float y_target{}; // final target y (accounting for visibility, etc) + float x_smoothed{}; // current x (on way to target) + float y_smoothed{}; // current y (on way to target) float width{100.0f}; float height{30.0f}; float scale{1.0f}; @@ -178,10 +180,10 @@ auto RootWidget::AddCover_(float h_align, VAlign v_align, float x, float y, // phone-size; for other sizes we always draw a backing. // // UPDATE: We no longer do backings, so ignore that. - if (g_base->ui->scale() != UIScale::kSmall) { - bd.visibility_mask |= - static_cast(Widget::ToolbarVisibility::kMenuFull); - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // bd.visibility_mask |= + // static_cast(Widget::ToolbarVisibility::kMenuFull); + // } Button* b = AddButton_(bd); return b; @@ -189,7 +191,9 @@ auto RootWidget::AddCover_(float h_align, VAlign v_align, float x, float y, void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, float b, bool plus, const std::string& s) { - float yoffs = (g_base->ui->scale() == UIScale::kSmall) ? 0.0f : -7.0f; + // float yoffs = (g_base->ui->scale() == UIScale::kSmall) ? 0.0f : -7.0f; + + float y_offs_small{7.0f}; float width = (type == MeterType::kTrophy) ? 80.0f : 110.0f; width = 110.0f; @@ -202,7 +206,8 @@ void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, bd.width = width; bd.height = 36.0f; // bd.x = x; - bd.y = -36.0f + 10.0f + yoffs; + bd.y = -36.0f + 10.0f - y_offs_small; + bd.y_offs_small = y_offs_small; bd.img = "uiAtlas2"; bd.mesh_transparent = "currencyMeter"; bd.selectable = true; @@ -466,17 +471,18 @@ void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, bd.v_align = VAlign::kTop; bd.width = bd.height = 45.0f; // bd.x = x - 68; - bd.y = -36.0f + 11.0f + yoffs; + bd.y = -36.0f + 11.0f - y_offs_small; + bd.y_offs_small = y_offs_small; bd.img = "uiAtlas2"; bd.mesh_transparent = "currencyPlusButton"; bd.color_r = 0.35f; bd.color_g = 0.35f; bd.color_b = 0.55f; - if (g_base->ui->scale() != UIScale::kSmall) { - // bd.color_r *= TOOLBAR_COLOR_R; - // bd.color_g *= TOOLBAR_COLOR_G; - // bd.color_b *= TOOLBAR_COLOR_B; - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // bd.color_r *= TOOLBAR_COLOR_R; + // bd.color_g *= TOOLBAR_COLOR_G; + // bd.color_b *= TOOLBAR_COLOR_B; + // } bd.depth_min = 0.3f; switch (type) { case MeterType::kTokens: @@ -615,9 +621,9 @@ void RootWidget::Setup() { bd.h_align = 0.5f; bd.v_align = VAlign::kTop; bd.width = 850.0f; - if (g_base->ui->scale() != UIScale::kSmall) { - bd.width = 850.0f; - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // bd.width = 850.0f; + // } bd.height = 90.0f; bd.x = 0.0f; bd.y = -20.0f; @@ -628,14 +634,14 @@ void RootWidget::Setup() { bd.color_g = 0.41f; bd.color_b = 0.56f; bd.opacity = 1.0f; - if (g_base->ui->scale() != UIScale::kSmall) { - bd.color_r *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R; - bd.color_g *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G; - bd.color_b *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B; - bd.opacity *= TOOLBAR_OPACITY; - } else { - bd.opacity *= TOOLBAR_OPACITY_2; - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // bd.color_r *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R; + // bd.color_g *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G; + // bd.color_b *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B; + // bd.opacity *= TOOLBAR_OPACITY; + // } else { + // bd.opacity *= TOOLBAR_OPACITY_2; + // } bd.depth_min = 0.2f; // bd.call = ""; bd.call = UIV1Python::ObjID::kEmptyCall; @@ -649,7 +655,7 @@ void RootWidget::Setup() { } // float xoffs = (g_base->ui->scale() == UIScale::kSmall) ? 90.0f : 0.0f; - float yoffs = (g_base->ui->scale() == UIScale::kSmall) ? 0.0f : -10.0f; + // float yoffs = (g_base->ui->scale() == UIScale::kSmall) ? 0.0f : -10.0f; // Account Button { @@ -660,16 +666,18 @@ void RootWidget::Setup() { bd.height = 60.0f; bd.depth_min = 0.3f; // bd.x = 110.0f + xoffs; - bd.y = -24.0f + yoffs; + // bd.y = -24.0f + yoffs; + bd.y = -34.0f; + bd.y_offs_small = 10.0f; bd.color_r = 0.56f; bd.color_g = 0.5f; bd.color_b = 0.73f; bd.call = UIV1Python::ObjID::kRootUIAccountButtonPressCall; - if (g_base->ui->scale() != UIScale::kSmall) { - // bd.color_r *= TOOLBAR_COLOR_R; - // bd.color_g *= TOOLBAR_COLOR_G; - // bd.color_b *= TOOLBAR_COLOR_B; - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // bd.color_r *= TOOLBAR_COLOR_R; + // bd.color_g *= TOOLBAR_COLOR_G; + // bd.color_b *= TOOLBAR_COLOR_B; + // } bd.pre_buffer = 10.0f; bd.visibility_mask = (static_cast(Widget::ToolbarVisibility::kMenuFull) @@ -752,7 +760,7 @@ void RootWidget::Setup() { top_right_buttons_.push_back(menu_button_); } - // Party button. + // Squad button. { ButtonDef b; b.h_align = 1.0f; @@ -786,16 +794,16 @@ void RootWidget::Setup() { // Bot-left cover // AddCover(0.0f, VAlign::kBottom, 0.0f, -210.0f, 600.0f, 600.0f, 0.25f); - float bx = 55.0f; + // float bx = 55.0f; // Inbox button. { ButtonDef b; b.h_align = 0.0f; b.v_align = VAlign::kBottom; - b.width = b.height = 55.0f; + b.width = b.height = 60.0f; // b.x = bx; - b.y = b.height * 0.5f + 5; + b.y = b.height * 0.5f + 2.0f; b.color_r = BOT_LEFT_COLOR_R; b.color_g = BOT_LEFT_COLOR_G; b.color_b = BOT_LEFT_COLOR_B; @@ -805,22 +813,22 @@ void RootWidget::Setup() { (static_cast(Widget::ToolbarVisibility::kMenuFull) | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); - b.pre_buffer = 20.0f; + b.pre_buffer = 25.0f; b.allow_in_game = false; inbox_button_ = AddButton_(b); bottom_left_buttons_.push_back(inbox_button_); } - bx += 80.0f; + // bx += 80.0f; // Achievements button. if (explicit_bool(true)) { ButtonDef b; b.h_align = 0.0f; b.v_align = VAlign::kBottom; - b.width = b.height = 55.0f; + b.width = b.height = 60.0f; // b.x = bx; - b.y = b.height * 0.5f + 5; + b.y = b.height * 0.5f + 2.0f; b.color_r = BOT_LEFT_COLOR_R; b.color_g = BOT_LEFT_COLOR_G; b.color_b = BOT_LEFT_COLOR_B; @@ -830,11 +838,11 @@ void RootWidget::Setup() { (static_cast(Widget::ToolbarVisibility::kMenuFull) | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); - b.pre_buffer = 20.0f; + b.pre_buffer = 25.0f; b.allow_in_game = false; achievements_button_ = AddButton_(b); bottom_left_buttons_.push_back(achievements_button_); - bx += 80.0f; + // bx += 80.0f; // Achievement count. // { @@ -928,9 +936,9 @@ void RootWidget::Setup() { ButtonDef b; b.h_align = 0.0f; b.v_align = VAlign::kBottom; - b.width = b.height = 50.0f; + b.width = b.height = 60.0f; // b.x = bx; - b.y = b.height * 0.5f + 5; + b.y = b.height * 0.5f + 2.0f; b.color_r = BOT_LEFT_COLOR_R; b.color_g = BOT_LEFT_COLOR_G; b.color_b = BOT_LEFT_COLOR_B; @@ -940,7 +948,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); AddButton_(b); - bx += 70.0f; + // bx += 70.0f; } // Settings button. @@ -948,9 +956,9 @@ void RootWidget::Setup() { ButtonDef b; b.h_align = 0.0f; b.v_align = VAlign::kBottom; - b.width = b.height = 55.0f; + b.width = b.height = 60.0f; // b.x = bx; - b.y = b.height * 0.58f; + b.y = b.height * 0.58f - 2.0f; b.color_r = BOT_LEFT_COLOR_R; b.color_g = BOT_LEFT_COLOR_G; b.color_b = BOT_LEFT_COLOR_B; @@ -961,7 +969,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot) | static_cast(Widget::ToolbarVisibility::kMenuInGame)); - b.pre_buffer = 20.0f; + b.pre_buffer = 25.0f; settings_button_ = AddButton_(b); bottom_left_buttons_.push_back(settings_button_); } @@ -981,23 +989,23 @@ void RootWidget::Setup() { float backing_cover_g = backing_g; float backing_cover_b = backing_b; float backingA = 1.0f; - if (g_base->ui->scale() != UIScale::kSmall) { - backing_r *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R; - backing_g *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G; - backing_b *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B; - backing_cover_r *= TOOLBAR_COLOR_R; - backing_cover_g *= TOOLBAR_COLOR_G; - backing_cover_b *= TOOLBAR_COLOR_B; - backingA *= TOOLBAR_OPACITY; - } else { - backing_r *= 1.1f; - backing_g *= 1.1f; - backing_b *= 1.1f; - backing_cover_r *= 1.1f; - backing_cover_g *= 1.1f; - backing_cover_b *= 1.1f; - backingA *= TOOLBAR_OPACITY_2; - } + // if (g_base->ui->scale() != UIScale::kSmall) { + // backing_r *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R; + // backing_g *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G; + // backing_b *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B; + // backing_cover_r *= TOOLBAR_COLOR_R; + // backing_cover_g *= TOOLBAR_COLOR_G; + // backing_cover_b *= TOOLBAR_COLOR_B; + // backingA *= TOOLBAR_OPACITY; + // } else { + backing_r *= 1.1f; + backing_g *= 1.1f; + backing_b *= 1.1f; + backing_cover_r *= 1.1f; + backing_cover_g *= 1.1f; + backing_cover_b *= 1.1f; + backingA *= TOOLBAR_OPACITY_2; + // } // Bar backing. { @@ -1161,6 +1169,7 @@ auto RootWidget::AddButton_(const ButtonDef& def) -> RootWidget::Button* { Button& b(buttons_.back()); b.x = b.x_smoothed = b.x_target = def.x; b.y = b.y_smoothed = b.y_target = def.y; + b.y_offs_small = def.y_offs_small; b.visibility_mask = def.visibility_mask; b.disable_offset_scale = def.disable_offset_scale; b.pre_buffer = def.pre_buffer; @@ -1293,6 +1302,8 @@ void RootWidget::StepPositions_(float dt) { return; } + bool is_small{g_base->ui->scale() == UIScale::kSmall}; + // Update enabled-state for all buttons. for (Button& b : buttons_) { bool enable_button = @@ -1319,11 +1330,9 @@ void RootWidget::StepPositions_(float dt) { // enable_button = false; // } } - if (&b == back_button_) { - // Back button is always disabled in medium/large UI. - if (g_base->ui->scale() != UIScale::kSmall) { - enable_button = false; - } + // Back button is always disabled in medium/large UI. + if (&b == back_button_ && !is_small) { + enable_button = false; } b.enabled = enable_button; } @@ -1385,7 +1394,7 @@ void RootWidget::StepPositions_(float dt) { for (Button& b : buttons_) { // Update our target position. b.x_target = b.x; - b.y_target = b.y; + b.y_target = b.y + (is_small ? b.y_offs_small : 0.0f); float disable_offset = b.disable_offset_scale * 110.0f * ((b.v_align == VAlign::kTop) ? 1.0f : -1.0f); // float top_right_offset = 100.0f;