diff --git a/.efrocachemap b/.efrocachemap index 2a37afdb..9b48d154 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": "fd2ccd57c412479ed03996a5e74a1ce4", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "6a04d9c28b5d13fe33363e930aedd022", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "e1e84f99447ecf5aa6c33d0780ae70f5", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "98b55a2dbbaf1fd91b4f8dd1ac5249bd", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "49e65d07d4d1c50a2c5aa670fb3fdc54", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "a3b68c610903acc54e9cf595cb9c22e1", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "e79806597b55297c2b6c39a0c0a89a9b", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "af551c6316f51da5a768b12c2f970662", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "b8d1821cadc35df59bfe89d8fa1bde56", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "710532ecdf5162725223b3416ca1ca29", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "afa36ce15429556c3b6ac972fa2e5245", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "39e494cef6c263d793d81e99a1e51496", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "e77092b692df532a19b7fd203cf8bb75", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "75c02b6cfa892fbcfae8d55313fa3ac5", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "f8e7cf715c1666c6cd367018c4187aeb", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "9af412f7bfe3ac120de9d033e868b6b5", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "3182401e9b600638c78f3bb849da4588", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "c357f68d5e01e6caef1ac2eab2b81750", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "ee2e732ddf920f3da89c2e46fe3fec5f", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "5cbbbf35e5c3c5f71ad35ab3cb4e93e1", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "5dc626488240419a7fccd2e11e4e4fdc", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "9ee005e3df40528efc090d879917bec2", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "d554d33e3923e544b9b31dcc261230fb", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "764db7c11f7448c2c1dde96d7ec799b5", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "dd6fe4f7cc89a93a50a9693587bf511a", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "cf203b66bb7bd718dbcb43c19d2c45bd", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "317ec48fe589393847a7b0c0a6d602d1", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "59dd77ef407875ff7af0628e05a45ae7", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "c3f17815f34c6947eda16fdb850ed64c", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "6169a8b0c55aec2aa8e2ebd618d379a2", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "a1596b9b8425ab0a8531c7f1f4acf3b8", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "e674b261174e9b06a34f90c626856aa6", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "d14b5f0693440239fd056d831441a53a", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "3584cd1db78d6b68c8436eaa86bc6d21", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "b7242358f3d1bb04a414e4b7dfbc4311", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "11fe178ab9c93eb0f5d32a27895ea811", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "413f092eb584ba15edc1a1b48a63d760", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "35b37b4a67815a91df7b77ea2fac9f26", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "102b5af73a4ebce8ac475ed960ead4b4", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "f46a78e101f8c2c73654dfc982295748", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "0b5f8bdbe8221c4642d9f7f8584645ce", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "e94dd06863796f17b9cfcbb5f79edd32", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "0b5f8bdbe8221c4642d9f7f8584645ce", @@ -4132,14 +4132,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "381953df0ba482ef485e4da3fd8e9e69", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "3b706f71d9a4fd3e5e5ecae88c6087ee", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "381953df0ba482ef485e4da3fd8e9e69", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "9a5a41db9a2aa0f6fdc84bbc4d2a8ff7", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "12673b3a3699fae399e6129da992e9e6", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "659f4ce5759c8d7c910eec4a5e05b52d", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "83cfa6f843dad450f9c3a173e9717a3a", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "f50dfe45998077e38c808057b4a1d547", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "b059a1b92c6c093b54e48669564bdf1a", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "9b81340df4e2a4cb0ae7a1bd807ed7ec", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "6649f9be5b801b90ee692a1612c62e7b", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "1706a7dc691b033e20d3861e9b16861d", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "259cbea25d8aa9d53e61f2f1c7af2ff6", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "fd51dd1b9a75c053ba91ed521fd72fe1", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "3bb33d27b717ab731f43f44c443d1504", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "930c75164e229b2f9e3aa042100b1911", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "329d5a560c7dd3a9bef54ec9db9aaf27", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "51175094ecad6e8bea39103bb927e449", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "abf57a7d6c2df8bc3829060039bf7c19", "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 e729366a..a529e969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22019, api 9, 2024-09-30) +### 1.7.37 (build 22021, api 9, 2024-09-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/baenv.py b/src/assets/ba_data/python/baenv.py index bcbf67e8..2f7b3e53 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 = 22019 +TARGET_BALLISTICA_BUILD = 22021 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/ballistica/base/input/device/joystick_input.cc b/src/ballistica/base/input/device/joystick_input.cc index d7b88910..5a529ce4 100644 --- a/src/ballistica/base/input/device/joystick_input.cc +++ b/src/ballistica/base/input/device/joystick_input.cc @@ -3,19 +3,14 @@ #include "ballistica/base/input/device/joystick_input.h" #include "ballistica/base/app_adapter/app_adapter.h" -#include "ballistica/base/app_mode/app_mode.h" -#include "ballistica/base/audio/audio.h" -#include "ballistica/base/graphics/renderer/renderer.h" +#include "ballistica/base/assets/assets.h" #include "ballistica/base/input/input.h" #include "ballistica/base/python/base_python.h" #include "ballistica/base/support/classic_soft.h" #include "ballistica/base/support/repeater.h" #include "ballistica/base/ui/ui.h" #include "ballistica/core/core.h" -#include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/foundation/macros.h" -#include "ballistica/shared/python/python.h" -#include "ballistica/shared/python/python_command.h" namespace ballistica::base { diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index eeec38f9..61b16b5a 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -214,6 +214,12 @@ void UI::ActivatePartyIcon() { } } +void UI::SetPartyIconNumber(int val) { + if (auto* ui_delegate = g_base->ui->delegate()) { + ui_delegate->SetPartyIconNumber(val); + } +} + auto UI::PartyWindowOpen() -> bool { if (auto* ui_delegate = g_base->ui->delegate()) { return ui_delegate->PartyWindowOpen(); @@ -349,7 +355,7 @@ void UI::Reset() { // Reset and then deactivate any current delegate. if (auto* ui_delegate = g_base->ui->delegate()) { ui_delegate->Reset(); - g_base->ui->set_ui_delegate(nullptr); + g_base->ui->SetUIDelegate(nullptr); } } @@ -586,7 +592,7 @@ void UI::ShowURL(const std::string& url) { } } -void UI::set_ui_delegate(base::UIDelegateInterface* delegate) { +void UI::SetUIDelegate(base::UIDelegateInterface* delegate) { assert(g_base->InLogicThread()); if (delegate == delegate_) { diff --git a/src/ballistica/base/ui/ui.h b/src/ballistica/base/ui/ui.h index 00d41a5f..d16e6622 100644 --- a/src/ballistica/base/ui/ui.h +++ b/src/ballistica/base/ui/ui.h @@ -46,7 +46,7 @@ class UI { /// switching app-modes or when resetting things within an app mode. void Reset(); - void set_ui_delegate(base::UIDelegateInterface* delegate); + void SetUIDelegate(base::UIDelegateInterface* delegate); /// Pop up an in-app window to display a URL (NOT to open the URL in a /// browser). Can be called from any thread. @@ -59,6 +59,7 @@ class UI { auto PartyIconVisible() -> bool; auto PartyWindowOpen() -> bool; void ActivatePartyIcon(); + void SetPartyIconNumber(int val); auto HandleMouseDown(int button, float x, float y, bool double_click) -> bool; void HandleMouseUp(int button, float x, float y); diff --git a/src/ballistica/base/ui/ui_delegate.h b/src/ballistica/base/ui/ui_delegate.h index a668f78f..e82e7095 100644 --- a/src/ballistica/base/ui/ui_delegate.h +++ b/src/ballistica/base/ui/ui_delegate.h @@ -16,6 +16,8 @@ namespace ballistica::base { class UIDelegateInterface { public: + virtual void Reset() = 0; + /// Called when this delegate is becoming the active one. virtual void OnActivate() = 0; @@ -34,14 +36,11 @@ class UIDelegateInterface { virtual auto MainMenuVisible() -> bool = 0; virtual auto PartyIconVisible() -> bool = 0; virtual void ActivatePartyIcon() = 0; - // virtual void HandleLegacyRootUIMouseMotion(float x, float y) = 0; - // virtual auto HandleLegacyRootUIMouseDown(float x, float y) -> bool = 0; - // virtual void HandleLegacyRootUIMouseUp(float x, float y) = 0; virtual void Draw(FrameDef* frame_def) = 0; virtual auto PartyWindowOpen() -> bool = 0; - virtual void Reset() = 0; virtual auto GetRootWidget() -> ui_v1::Widget* = 0; virtual auto SendWidgetMessage(const WidgetMessage& m) -> int = 0; + virtual void SetPartyIconNumber(int num) = 0; /// Should return true if this app mode can confirm quitting the app. virtual auto HasQuitConfirmDialog() -> bool = 0; diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index 1549e91c..b99f7229 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -7,11 +7,11 @@ #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/graphics/support/frame_def.h" #include "ballistica/base/networking/network_writer.h" -#include "ballistica/base/python/base_python.h" +#include "ballistica/base/networking/networking.h" #include "ballistica/base/support/app_config.h" #include "ballistica/base/support/plus_soft.h" #include "ballistica/scene_v1/connection/connection_set.h" -#include "ballistica/scene_v1/connection/connection_to_client_udp.h" +#include "ballistica/scene_v1/connection/connection_to_client.h" #include "ballistica/scene_v1/connection/connection_to_host.h" #include "ballistica/scene_v1/node/globals_node.h" #include "ballistica/scene_v1/python/scene_v1_python.h" @@ -23,6 +23,7 @@ #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/generic/json.h" #include "ballistica/shared/generic/utils.h" +#include "ballistica/shared/networking/sockaddr.h" #include "ballistica/ui_v1/ui_v1.h" namespace ballistica::classic { @@ -92,6 +93,7 @@ void ClassicAppMode::OnActivate() { // callbacks. DoApplyAppConfig(); LanguageChanged(); + OnGameRosterChanged_(); } void ClassicAppMode::OnAppStart() { assert(g_base->InLogicThread()); } @@ -131,7 +133,7 @@ void ClassicAppMode::Reset_() { // Import UIV1 and wire it up for UI duty. if (!g_core->HeadlessMode()) { - g_base->ui->set_ui_delegate(ui_v1::UIV1FeatureSet::Import()); + g_base->ui->SetUIDelegate(ui_v1::UIV1FeatureSet::Import()); } // Fade in if we currently aren't. @@ -441,10 +443,17 @@ auto ClassicAppMode::HandleJSONPing(const std::string& data_str) } void ClassicAppMode::SetGameRoster(cJSON* r) { + assert(g_base->InLogicThread()); if (game_roster_ != nullptr) { cJSON_Delete(game_roster_); } game_roster_ = r; + OnGameRosterChanged_(); +} + +void ClassicAppMode::OnGameRosterChanged_() { + assert(g_base->InLogicThread()); + g_base->ui->SetPartyIconNumber(GetPartySize()); } auto ClassicAppMode::GetPartySize() const -> int { @@ -687,6 +696,8 @@ void ClassicAppMode::UpdateGameRoster() { } } + OnGameRosterChanged_(); + // Keep the Python layer informed on our number of connections; it may want // to pass the info along to the master server if we're hosting a public // party. diff --git a/src/ballistica/classic/support/classic_app_mode.h b/src/ballistica/classic/support/classic_app_mode.h index 8e8e8d0b..223ffe74 100644 --- a/src/ballistica/classic/support/classic_app_mode.h +++ b/src/ballistica/classic/support/classic_app_mode.h @@ -137,6 +137,7 @@ class ClassicAppMode : public base::AppMode { auto public_party_stats_url() const -> const std::string& { return public_party_stats_url_; } + void SetPublicPartyMaxSize(int count); void SetPublicPartyName(const std::string& name); void SetPublicPartyStatsURL(const std::string& name); @@ -211,6 +212,7 @@ class ClassicAppMode : public base::AppMode { private: ClassicAppMode(); + void OnGameRosterChanged_(); void PruneScanResults_(); void UpdateKickVote_(); auto GetGameRosterMessage_() -> std::vector; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 04476a7a..921de124 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 = 22019; +const int kEngineBuildNumber = 22021; const char* kEngineVersion = "1.7.37"; const int kEngineApiVersion = 9; diff --git a/src/ballistica/shared/foundation/exception.h b/src/ballistica/shared/foundation/exception.h index b0a0d544..e4447ad0 100644 --- a/src/ballistica/shared/foundation/exception.h +++ b/src/ballistica/shared/foundation/exception.h @@ -48,9 +48,6 @@ auto GetShortExceptionDescription(const std::exception& exc) -> const char*; class Exception : public std::exception { public: - // NOTE: When adding exception types here, add a corresponding - // handler in Python::SetPythonException. - explicit Exception(std::string message = "", PyExcType python_type = PyExcType::kRuntime); explicit Exception(PyExcType python_type); diff --git a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc index 0edfcf5b..5e4d4d9b 100644 --- a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc +++ b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc @@ -2501,13 +2501,6 @@ static auto PySetPartyWindowOpen(PyObject* self, PyObject* args, BA_PRECONDITION(g_base->InLogicThread()); assert(g_base->input); assert(g_ui_v1); - printf("FIXME SET PARTY WINDOW OPEN\n"); - // auto* root_ui = g_ui_v1->root_ui(); - // if (root_ui == nullptr) { - // throw Exception("ui-v1 root ui not found."); - // } - - // root_ui->set_party_window_open(static_cast(value)); g_ui_v1->set_party_window_open(static_cast(value)); Py_RETURN_NONE; BA_PYTHON_CATCH; diff --git a/src/ballistica/ui_v1/ui_v1.cc b/src/ballistica/ui_v1/ui_v1.cc index b0709536..c0be5304 100644 --- a/src/ballistica/ui_v1/ui_v1.cc +++ b/src/ballistica/ui_v1/ui_v1.cc @@ -50,10 +50,6 @@ void UIV1FeatureSet::OnModuleExec(PyObject* module) { assert(g_base == nullptr); // Should be getting set once here. g_base = base::BaseFeatureSet::Import(); - // Let base know we exist. - // (save it the trouble of trying to load us if it uses us passively). - // g_base->set_ui_v1(g_ui_v1); - g_core->LifecycleLog("_bauiv1 exec end"); } @@ -80,30 +76,25 @@ bool UIV1FeatureSet::MainMenuVisible() { } bool UIV1FeatureSet::PartyIconVisible() { - printf("FIXME HANDLE PARTY ICON VISIBLE\n"); - return false; - // int party_size = g_base->app_mode()->GetPartySize(); - // if (party_size > 1 || g_base->app_mode()->HasConnectionToHost() - // || root_ui()->always_draw_party_icon()) { - // return true; - // } - // return false; + // Currently this is always visible. + return true; +} + +void UIV1FeatureSet::SetPartyIconNumber(int num) { + // Store the value and plug it in if we've got a live widget. + party_icon_number_ = num; + if (auto* r = root_widget()) { + root_widget_->SetSquadSizeLabel(num); + } } void UIV1FeatureSet::ActivatePartyIcon() { - printf("FIXME HANDLE ACTIVATE PARTY ICON\n"); - // if (auto* r = root_ui()) { - // r->ActivatePartyIcon(); - // } + if (auto* r = root_widget()) { + root_widget_->SquadPress(); + } } -bool UIV1FeatureSet::PartyWindowOpen() { - printf("FIXME HANDLE PARTY WINDOW OPEN\n"); - // if (auto* r = root_ui()) { - // return r->party_window_open(); - // } - return party_window_open_; -} +bool UIV1FeatureSet::PartyWindowOpen() { return party_window_open_; } void UIV1FeatureSet::Draw(base::FrameDef* frame_def) { base::RenderPass* overlay_flat_pass = frame_def->GetOverlayFlatPass(); @@ -188,6 +179,9 @@ void UIV1FeatureSet::Reset() { rw->Setup(); rw->SetOverlayWidget(ow.Get()); + // Plug in current values for everything. + rw->SetSquadSizeLabel(party_icon_number_); + sw->GlobalSelect(); } diff --git a/src/ballistica/ui_v1/ui_v1.h b/src/ballistica/ui_v1/ui_v1.h index 9338a3d5..5298d7f4 100644 --- a/src/ballistica/ui_v1/ui_v1.h +++ b/src/ballistica/ui_v1/ui_v1.h @@ -80,12 +80,14 @@ class UIV1FeatureSet : public FeatureSetNativeComponent, /// Called when our associated Python module is instantiated. static void OnModuleExec(PyObject* module); + void DoHandleDeviceMenuPress(base::InputDevice* device) override; void DoShowURL(const std::string& url) override; auto MainMenuVisible() -> bool override; auto PartyIconVisible() -> bool override; void ActivatePartyIcon() override; void Draw(base::FrameDef* frame_def) override; + void SetPartyIconNumber(int num) override; UIV1Python* const python; @@ -135,10 +137,11 @@ class UIV1FeatureSet : public FeatureSetNativeComponent, Object::Ref screen_root_widget_; Object::Ref overlay_root_widget_; Object::Ref root_widget_; - bool always_use_internal_on_screen_keyboard_{}; - bool party_window_open_{false}; int ui_lock_count_{}; int language_state_{}; + int party_icon_number_{}; + bool always_use_internal_on_screen_keyboard_{}; + bool party_window_open_{}; }; } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/root_widget.cc b/src/ballistica/ui_v1/widget/root_widget.cc index 0503380c..538fc3d0 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -133,35 +133,6 @@ RootWidget::RootWidget() { RootWidget::~RootWidget() = default; -auto RootWidget::AddCover_(float h_align, VAlign v_align, float x, float y, - float w, float h, float o) -> RootWidget::Button* { - // Currently just not doing these in vr mode. - if (g_core->vr_mode()) { - return nullptr; - } - - ButtonDef bd; - bd.h_align = h_align; - bd.v_align = v_align; - bd.width = w; - bd.height = h; - bd.x = x; - bd.y = y; - bd.img = "softRect"; - bd.selectable = false; - bd.color_r = 0.0f; - bd.color_g = 0.0f; - bd.color_b = 0.0f; - bd.opacity = o; - bd.call = UIV1Python::ObjID::kEmptyCall; - - bd.visibility_mask = - static_cast(Widget::ToolbarVisibility::kMenuFullRoot); - - Button* b = AddButton_(bd); - return b; -} - void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, float b, bool plus, const std::string& s) { float y_offs_small{7.0f}; @@ -585,6 +556,24 @@ void RootWidget::Setup() { b.enable_sound = false; squad_button_ = AddButton_(b); top_right_buttons_.push_back(squad_button_); + + { + TextDef td; + td.button = squad_button_; + td.width = 70.0f; + td.text = "0"; + td.x = -2.0f; + td.y = -10.0f; + td.scale = 1.0f; + td.flatness = 1.0f; + td.shadow = 1.0f; + td.depth_min = 0.3f; + td.color_r = 0.0f; + td.color_g = 1.0f; + td.color_b = 0.0f; + td.color_a = 0.5f; + squad_size_text_ = AddText_(td); + } } AddMeter_(MeterType::kTokens, 1.0f, 1.0f, 1.0f, 1.0f, true, "123"); @@ -1211,6 +1200,13 @@ auto RootWidget::HandleMessage(const base::WidgetMessage& m) -> bool { return ContainerWidget::HandleMessage(m); } } +void RootWidget::SquadPress() { + assert(g_base->InLogicThread()); + if (squad_button_) { + squad_button_->widget->Activate(); + } +} + void RootWidget::BackPress() { assert(g_base->InLogicThread()); screen_stack_widget_->HandleMessage( @@ -1266,4 +1262,17 @@ auto RootWidget::GetSpecialWidget(const std::string& s) const -> Widget* { return nullptr; } +void RootWidget::SetSquadSizeLabel(int val) { + if (squad_size_text_) { + auto* w{squad_size_text_->widget.Get()}; + assert(w); + w->SetText(std::to_string(val)); + if (val > 0) { + w->set_color(0.0f, 1.0f, 0.0f, 1.0f); + } else { + w->set_color(0.0f, 1.0f, 0.0f, 0.5f); + } + } +} + } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/root_widget.h b/src/ballistica/ui_v1/widget/root_widget.h index 29b96978..e964dbbb 100644 --- a/src/ballistica/ui_v1/widget/root_widget.h +++ b/src/ballistica/ui_v1/widget/root_widget.h @@ -29,11 +29,13 @@ class RootWidget : public ContainerWidget { auto overlay_window_stack() const -> StackWidget* { return overlay_stack_widget_; } + void SquadPress(); /// Called when UIScale or screen dimensions change. void OnUIScaleChange(); void UpdateLayout() override; + void SetSquadSizeLabel(int val); private: struct ButtonDef; @@ -51,8 +53,6 @@ class RootWidget : public ContainerWidget { void StepPositions_(float dt); void AddMeter_(MeterType type, float h_align, float r, float g, float b, bool plus, const std::string& s); - auto AddCover_(float h_align, VAlign v_align, float x, float y, float w, - float h, float o) -> Button*; ToolbarVisibility toolbar_visibility_{ToolbarVisibility::kInGame}; StackWidget* screen_stack_widget_{}; StackWidget* overlay_stack_widget_{}; @@ -83,6 +83,7 @@ class RootWidget : public ContainerWidget { Button* level_icon_{}; Button* level_meter_button_{}; Button* trophy_icon_{}; + Text* squad_size_text_{}; }; } // namespace ballistica::ui_v1