From e7f2368eec4edb152ef17990786972cc036bcedf Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 30 Aug 2024 15:44:49 -0700 Subject: [PATCH] fixed in-game settings menu --- .efrocachemap | 56 ++++++------- CHANGELOG.md | 2 +- src/assets/ba_data/python/babase/__init__.py | 2 + .../ba_data/python/baclassic/_appmode.py | 15 +++- src/assets/ba_data/python/baenv.py | 2 +- src/assets/ba_data/python/bauiv1/__init__.py | 2 + .../ba_data/python/bauiv1lib/ingamemenu.py | 6 +- src/ballistica/base/app_mode/app_mode.cc | 2 +- src/ballistica/base/app_mode/app_mode.h | 4 +- .../python/methods/python_methods_base_3.cc | 33 ++++++++ .../classic/support/classic_app_mode.cc | 2 +- .../classic/support/classic_app_mode.h | 2 +- src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/ui_v1/widget/root_widget.cc | 80 ++++++++++++------- 14 files changed, 142 insertions(+), 68 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 054c7cfe..690f2546 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": "6ca46255d87047834e9bceed2a572492", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "773786e74f514fc457797cf7c614cf23", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "45bbfb410e7b7913b7018984eb148cfd", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "8bd52a87787a7919f9380b9cb123025d", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "deee48c7d81d0cf451e5d38a4d5c1b52", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "2d9db97047c544f2f18cba20e5132b4f", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "eb1e5c208f95e89344729ca6d0d13d69", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "f3e81698bc42154c9a311ccdaa19502f", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "e6e76cea88f2dbd268197e26cebeec4d", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "93a91bb8c65b30288cb02c932108bbfb", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "517bad06f8f6761d7cd5c66a332e4796", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "df7fbf1c5e2d3485425d1061c09cc454", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "fe4463737ea11236062a9d73445e1d04", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "a4b2333e35a640793aad1a58d4a7da99", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "46ae66faca5b5dcedd8c45fab1de2d40", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "8e4b07dcffe24fd40245bfb141f21a33", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "2542ddef05c44ef98e8ce013d9d9d893", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "e742017f9a7163ce5c926dbabb0c1b2c", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "189eb8e10c5ce9304340ab3ca6ca1eb5", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "88427878171caad3f31c08c9c0f38422", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "c6d67ec79facefc5cad965530b23bcd8", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "3d66a0cd0dd6e11c7f0bc9bca7c32918", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "3b57ad3a4c258a38022ff6760fb99273", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "49494eff1ea0e26629b31d1962072f03", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "7ec96c9d86bd7ab6a8972c486421037b", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "8cfbdb28fcefb6746efcf45368e4d4c8", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "c4f03152366701177ac8df1b1216800e", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "9c2a644cffb13828706d3a62fc93bea1", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "82cb874a3aab2d3a86a446987686e50f", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "138da633cfcbc99d4a32632dfd20220e", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "7d26e8d3b9ca3ef030c31bd3219a81f6", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "7d50251a8c2a865868f55fef1b1e7bbe", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "e823ba47693a1fa0dabdad310e56aee5", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "8787b88ac1276d15a93685dd4d192a82", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "9e281fcbf8bdd498646646b3fed7257d", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "c6d5c81f924d607acc6c996989ba8726", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "d4ce0446eabed898120bb9306dbaae1c", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "4bab9b11091309039860c712305f14a0", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "a7ae68ea69d0cf32842ca7d4559fd719", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "667491d9323656d8112f7f8df86821ef", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "73ad3303fe1a82005918fbc5dae3446c", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "fa659b5d6119acba6570c92ce4d35ae2", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "73ad3303fe1a82005918fbc5dae3446c", @@ -4132,14 +4132,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "3e5c5fd0a09f55ba7b05ce1e2ec7171e", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "1659535e95e3047fda529543e265ac97", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "3e5c5fd0a09f55ba7b05ce1e2ec7171e", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "db87ff147063b23294144fa0ca838255", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "d70137eb08f7426fded9b0648b52cc42", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "852afacdebd25751185ce74d0e55c761", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "7f59022c28a769dc850285e76ffd0b1b", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "c700e22237f9f385645e8cb3993e43b2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "e92d8ce8707096f99d87e3579a18aaf6", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "cbbb6e764b847817a662f14404338bf2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "d2c5ad26fcc7699c53214a67c6a66a2a", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "8452c85e5970578ecf49d0b3c48a518a", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "1acf59d4e8e9267484e5635bee0730ea", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "65d344082b8282acb78193d3ddcd3751", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "57ad999dcdb7b2810276ef52f8da7c2e", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "ec35b5c459c74efb3bf0f9d1461a3936", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "14ecbf98f8ff91e6dc27220563e566a5", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "f8ac156a52ebf4a834f13b74cba4c260", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "c08e8ab8c1d1ccc533c1f44457cfe90e", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "cb299985623bbcc86015cb103a424ae6", "src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d", diff --git a/CHANGELOG.md b/CHANGELOG.md index 38611a87..0b054f57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 21972, api 9, 2024-08-30) +### 1.7.37 (build 21974, api 9, 2024-08-30) - 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. diff --git a/src/assets/ba_data/python/babase/__init__.py b/src/assets/ba_data/python/babase/__init__.py index 50a08100..aca78d41 100644 --- a/src/assets/ba_data/python/babase/__init__.py +++ b/src/assets/ba_data/python/babase/__init__.py @@ -62,6 +62,7 @@ from _babase import ( have_chars, have_permission, in_logic_thread, + in_main_menu, increment_analytics_count, invoke_main_menu, is_os_playing_music, @@ -262,6 +263,7 @@ __all__ = [ 'have_chars', 'have_permission', 'in_logic_thread', + 'in_main_menu', 'increment_analytics_count', 'InputDeviceNotFoundError', 'InputType', diff --git a/src/assets/ba_data/python/baclassic/_appmode.py b/src/assets/ba_data/python/baclassic/_appmode.py index bcb3b3c0..0bfed722 100644 --- a/src/assets/ba_data/python/baclassic/_appmode.py +++ b/src/assets/ba_data/python/baclassic/_appmode.py @@ -15,6 +15,7 @@ from babase import ( AppIntentDefault, invoke_main_menu, screenmessage, + in_main_menu, ) import _baclassic @@ -120,20 +121,28 @@ class ClassicAppMode(AppMode): 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): + + 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. + # Blow away the window stack and build a fresh one. ui.clear_main_window() ui.set_main_window( window, from_window=False, # Disable from-check. - back_state=MainMenuWindow.do_get_main_window_state(), + back_state=( + MainMenuWindow.do_get_main_window_state() + if in_main_menu() + else InGameMenuWindow.do_get_main_window_state() + ), ) def _root_ui_menu_press(self) -> None: diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 91c61af4..5beeb7dc 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 = 21972 +TARGET_BALLISTICA_BUILD = 21974 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/assets/ba_data/python/bauiv1/__init__.py b/src/assets/ba_data/python/bauiv1/__init__.py index bcaaec93..31b0de18 100644 --- a/src/assets/ba_data/python/bauiv1/__init__.py +++ b/src/assets/ba_data/python/bauiv1/__init__.py @@ -60,6 +60,7 @@ from babase import ( getclass, have_permission, in_logic_thread, + in_main_menu, increment_analytics_count, is_browser_likely_available, is_xcode_build, @@ -188,6 +189,7 @@ __all__ = [ 'hscrollwidget', 'imagewidget', 'in_logic_thread', + 'in_main_menu', 'increment_analytics_count', 'is_browser_likely_available', 'is_party_icon_visible', diff --git a/src/assets/ba_data/python/bauiv1lib/ingamemenu.py b/src/assets/ba_data/python/bauiv1lib/ingamemenu.py index abb04027..f72477f9 100644 --- a/src/assets/ba_data/python/bauiv1lib/ingamemenu.py +++ b/src/assets/ba_data/python/bauiv1lib/ingamemenu.py @@ -49,7 +49,11 @@ class InGameMenuWindow(bui.MainWindow): @override def get_main_window_state(self) -> bui.MainWindowState: # Support recreating our window for back/refresh purposes. - cls = type(self) + return self.do_get_main_window_state() + + @classmethod + def do_get_main_window_state(cls) -> bui.MainWindowState: + """Classmethod to gen a windowstate for the main menu.""" return bui.BasicMainWindowState( create_call=lambda transition, origin_widget: cls( transition=transition, origin_widget=origin_widget diff --git a/src/ballistica/base/app_mode/app_mode.cc b/src/ballistica/base/app_mode/app_mode.cc index 4f1650fc..b4361428 100644 --- a/src/ballistica/base/app_mode/app_mode.cc +++ b/src/ballistica/base/app_mode/app_mode.cc @@ -66,6 +66,6 @@ void AppMode::LanguageChanged() {} auto AppMode::LastClientJoinTime() const -> millisecs_t { return -1; } -auto AppMode::InClassicMainMenuSession() const -> bool { return false; } +auto AppMode::IsInMainMenu() const -> bool { return false; } } // namespace ballistica::base diff --git a/src/ballistica/base/app_mode/app_mode.h b/src/ballistica/base/app_mode/app_mode.h index 7f981b5a..5f848367 100644 --- a/src/ballistica/base/app_mode/app_mode.h +++ b/src/ballistica/base/app_mode/app_mode.h @@ -68,8 +68,8 @@ class AppMode { /// Called when language changes. virtual void LanguageChanged(); - /// Are we currently in a classic 'main menu' session? - virtual auto InClassicMainMenuSession() const -> bool; + /// Are we currently in a 'main menu' situation (as opposed to gameplay)? + virtual auto IsInMainMenu() const -> bool; /// Get current party size (for legacy parties). virtual auto GetPartySize() const -> int; diff --git a/src/ballistica/base/python/methods/python_methods_base_3.cc b/src/ballistica/base/python/methods/python_methods_base_3.cc index 831031dd..b0f79be9 100644 --- a/src/ballistica/base/python/methods/python_methods_base_3.cc +++ b/src/ballistica/base/python/methods/python_methods_base_3.cc @@ -6,6 +6,7 @@ #include #include "ballistica/base/app_adapter/app_adapter.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/assets/sound_asset.h" #include "ballistica/base/input/input.h" #include "ballistica/base/platform/base_platform.h" @@ -350,6 +351,37 @@ static PyMethodDef PyInLogicThreadDef = { "Returns whether or not the current thread is the logic thread.", }; +// ------------------------------ in_main_menu --------------------------------- + +static auto PyInMainMenu(PyObject* self, PyObject* args, + PyObject* keywds) -> PyObject* { + BA_PYTHON_TRY; + static const char* kwlist[] = {nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "", + const_cast(kwlist))) { + return nullptr; + } + BA_PRECONDITION(g_base->InLogicThread()); + if (g_base->app_mode()->IsInMainMenu()) { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; + BA_PYTHON_CATCH; +} + +static PyMethodDef PyInMainMenuDef = { + "in_main_menu", // name + (PyCFunction)PyInMainMenu, // method + METH_VARARGS | METH_KEYWORDS, // flags + + "in_main_menu() -> bool\n" + "\n" + "(internal)\n" + "\n" + "Returns whether or not the app-mode is currently in a main menu\n" + "situation (as opposed to gameplay).", +}; + // ----------------------------- set_thread_name ------------------------------- static auto PySetThreadName(PyObject* self, PyObject* args, @@ -1949,6 +1981,7 @@ auto PythonMoethodsBase3::GetMethods() -> std::vector { PyGetThreadNameDef, PySetThreadNameDef, PyInLogicThreadDef, + PyInMainMenuDef, PyRequestPermissionDef, PyHavePermissionDef, PyUnlockAllInputDef, diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index 364c03eb..17c4e31d 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -67,7 +67,7 @@ base::InputDeviceDelegate* ClassicAppMode::CreateInputDeviceDelegate( // Go with 5 minute ban. const int kKickBanSeconds = 5 * 60; -bool ClassicAppMode::InClassicMainMenuSession() const { +bool ClassicAppMode::IsInMainMenu() const { scene_v1::HostSession* hostsession = scene_v1::ContextRefSceneV1::FromAppForegroundContext().GetHostSession(); return (hostsession && hostsession->is_main_menu()); diff --git a/src/ballistica/classic/support/classic_app_mode.h b/src/ballistica/classic/support/classic_app_mode.h index 0fa75159..8e8e8d0b 100644 --- a/src/ballistica/classic/support/classic_app_mode.h +++ b/src/ballistica/classic/support/classic_app_mode.h @@ -155,7 +155,7 @@ class ClassicAppMode : public base::AppMode { void OnAppStart() override; void OnAppSuspend() override; void OnAppUnsuspend() override; - auto InClassicMainMenuSession() const -> bool override; + auto IsInMainMenu() const -> bool override; auto CreateInputDeviceDelegate(base::InputDevice* device) -> base::InputDeviceDelegate* override; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 3742e32d..6d729243 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 = 21972; +const int kEngineBuildNumber = 21974; 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 06b50a56..dafac229 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -45,6 +45,8 @@ struct RootWidget::ButtonDef { uint32_t visibility_mask{}; bool selectable{true}; bool enable_sound{true}; + bool allow_in_main_menu{true}; + bool allow_in_game{true}; float h_align{}; float x{}; float y{}; @@ -83,6 +85,8 @@ struct RootWidget::Button { bool selectable{true}; bool fully_offscreen{}; bool enabled{}; + bool allow_in_main_menu{true}; + bool allow_in_game{true}; uint32_t visibility_mask{}; }; @@ -224,6 +228,8 @@ void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); + bd.allow_in_game = false; + // Show some in store mode. if (type == MeterType::kLevel || type == MeterType::kTickets) { bd.visibility_mask |= @@ -493,6 +499,8 @@ void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, } bd.pre_buffer = -10.0f; + bd.allow_in_game = false; + Button* btn = AddButton_(bd); if (type == MeterType::kTokens) { get_tokens_button_ = btn; @@ -664,11 +672,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); - // on desktop, stick this in the top left corner - // if (g_ui->scale() == UIScale::kLarge) { - // bd.h_align = 0.0f; - // bd.x = 120.0f; - // } + bd.allow_in_game = false; Button* b = account_button_ = AddButton_(bd); top_left_buttons_.push_back(b); @@ -677,9 +681,9 @@ void RootWidget::Setup() { { TextDef td; td.button = b; - td.y = 9.0f; - td.width = bd.width * 0.9f; - td.text = "Player Name"; + td.y = 0.0f; + td.width = bd.width * 0.8f; + td.text = "PlayerName"; td.scale = 1.2f; td.depth_min = 0.3f; td.color_r = 0.5f; @@ -690,19 +694,19 @@ void RootWidget::Setup() { } // Clan. - { - TextDef td; - td.button = b; - td.y = -12.0f; - td.width = bd.width * 0.9f; - td.depth_min = 0.3f; - td.text = "Clan Name"; - td.color_a = 0.6f; - td.scale = 0.6f; - td.flatness = 1.0f; - td.shadow = 0.0f; - AddText_(td); - } + // { + // TextDef td; + // td.button = b; + // td.y = -12.0f; + // td.width = bd.width * 0.9f; + // td.depth_min = 0.3f; + // td.text = "Clan Name"; + // td.color_a = 0.6f; + // td.scale = 0.6f; + // td.flatness = 1.0f; + // td.shadow = 0.0f; + // AddText_(td); + // } } // float anchorx = 0.0f; @@ -739,6 +743,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); b.pre_buffer = 5.0f; b.enable_sound = false; + b.allow_in_main_menu = false; menu_button_ = AddButton_(b); top_right_buttons_.push_back(menu_button_); } @@ -797,6 +802,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); b.pre_buffer = 20.0f; + b.allow_in_game = false; inbox_button_ = AddButton_(b); bottom_left_buttons_.push_back(inbox_button_); } @@ -821,6 +827,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); b.pre_buffer = 20.0f; + b.allow_in_game = false; achievements_button_ = AddButton_(b); bottom_left_buttons_.push_back(achievements_button_); bx += 80.0f; @@ -1009,7 +1016,7 @@ void RootWidget::Setup() { (static_cast(Widget::ToolbarVisibility::kMenuFull) | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); - + bd.allow_in_game = false; AddButton_(bd); } @@ -1028,6 +1035,7 @@ void RootWidget::Setup() { float spacing = 130.0f; b.x = -1.5f * spacing; b.call = UIV1Python::ObjID::kRootUIChestSlot1PressCall; + b.allow_in_game = false; AddButton_(b); b.x = -0.5f * spacing; @@ -1092,6 +1100,7 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); b.disable_offset_scale = 1.5f; b.pre_buffer = 20.0f; + b.allow_in_game = false; inventory_button_ = AddButton_(b); bottom_right_buttons_.push_back(inventory_button_); } @@ -1111,6 +1120,8 @@ void RootWidget::Setup() { | static_cast(Widget::ToolbarVisibility::kMenuFullNoBack) | static_cast(Widget::ToolbarVisibility::kMenuFullRoot)); b.pre_buffer = 20.0f; + b.allow_in_game = false; + store_button_ = AddButton_(b); bottom_right_buttons_.push_back(store_button_); } @@ -1149,6 +1160,8 @@ auto RootWidget::AddButton_(const ButtonDef& def) -> RootWidget::Button* { b.h_align = def.h_align; b.v_align = def.v_align; b.selectable = def.selectable; + b.allow_in_game = def.allow_in_game; + b.allow_in_main_menu = def.allow_in_main_menu; b.widget = Object::New(); b.widget->SetColor(def.color_r, def.color_g, def.color_b); b.widget->set_opacity(def.opacity); @@ -1248,11 +1261,8 @@ void RootWidget::UpdateForFocusedWindow() { } void RootWidget::UpdateForFocusedWindow_(Widget* widget) { - // Take note if the current session is the main menu; we do a few things - // differently there. - // - // FIXME - need a more generalized way to determine this. - in_main_menu_ = g_base->app_mode()->InClassicMainMenuSession(); + // Take note whether we're currently in a main menu vs gameplay. + in_main_menu_ = g_base->app_mode()->IsInMainMenu(); if (widget == nullptr) { toolbar_visibility_ = ToolbarVisibility::kInGame; @@ -1280,9 +1290,23 @@ void RootWidget::StepPositions_(float dt) { // When we're in the main menu, always disable the menu button and // shift the party button a bit to the right if (in_main_menu_) { - if (&b == menu_button_) { + if (!b.allow_in_main_menu) { enable_button = false; } + // Disallow menu button in the main menu. + // if (&b == menu_button_) { + // enable_button = false; + // } + } else { + if (!b.allow_in_game) { + enable_button = false; + } + // Disallow most buttons in-game. + // if (&b == inbox_button_ || &b == achievements_button_ + // || &b == account_button_ || &b == level_meter_button_ + // || &b == trophy_meter_button_ || &b == store_button_ || &b == ) { + // enable_button = false; + // } } if (&b == back_button_) { // Back button is always disabled in medium/large UI.