From 9f4690b5a570b262fb744e60d89e2b0777e45968 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Wed, 18 Dec 2024 13:33:40 -0800 Subject: [PATCH] tokens meter now properly reflects gold-pass ownership --- .efrocachemap | 48 +++++++++---------- CHANGELOG.md | 2 +- .../ba_data/python/baclassic/_appmode.py | 2 + src/assets/ba_data/python/baenv.py | 2 +- .../python/methods/python_methods_classic.cc | 14 ++++-- .../classic/support/classic_app_mode.cc | 24 +++++++++- .../classic/support/classic_app_mode.h | 4 +- src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/ui_v1/widget/root_widget.cc | 21 +++++++- src/ballistica/ui_v1/widget/root_widget.h | 3 +- tools/efro/util.py | 15 +++++- 11 files changed, 98 insertions(+), 39 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 3784d481..1edb879f 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4103,22 +4103,22 @@ "build/assets/windows/Win32/ucrtbased.dll": "bfd1180c269d3950b76f35a63655e9e1", "build/assets/windows/Win32/vc_redist.x86.exe": "15a5f1f876503885adbdf5b3989b3718", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "3dd66dfcf706962c87c5316e04ec3f31", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "490a8c49e02a4191c30e6ed60d6f4d9f", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "4bf9630c25094e26b55f21728df761aa", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "932ab6ca24fa629f37a6ac0d017eb5af", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "cf4fc2e014a1a704ee512444fe9d364a", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "1a37cd3bebb37683e24e72b9b702e686", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "e3d75d506d866cf41b43608a367683a4", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "8fb682964be158cd645331516ed61440", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "a3317c2c62a6de8f35043afa292cdd04", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "97b41a461f9f71e8e093dd71d1c13ad5", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "a6ec7deb4beacc26ac7399994451605f", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "aa576dc1f944f7300958f95e5cc86984", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "5ae7d93eeb81f265087986579ffa9f11", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "ef8b5ca5e0877b9c0367913b18cba08c", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "e9c42b8a249557bb3b0cee18fbe254c6", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "48677d1e015369fe564f339785d167d7", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "f9803c96c92f7d4dd345603076b3ae72", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "759dc34f67f5d03b90b8aa282f6fe4e4", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "a07cb32525e62f3c608f97cd055c40fa", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "981086385bca1e94252e4840ea9e54a4", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "2e3e7b291de093fe1b90054770b22677", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "1524792f23cb310c22dff77fab4bf44c", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "6ac767ac37d32016240344895cb6974d", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "7bd189a692b78bb9e965a5ca567e316c", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "38d28b24348a815c91ed939e9e92e3af", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "0fa5c2ac8b4d00e41c489c8c8e477690", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "141a7e706c53a56cb266106a8506113b", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "f83f3c9f75266ee12871a4617abeaf4c", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "741045af91f2086f9477fbc0fc41b8dc", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "bba009880748eec4e98dc4f0053de041", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "9664c41727f66a5abbc8ee6d8c894707", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "63b99b77bb6c032f95e01660492a60b7", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "8e0d4fe40c9d3f78dc353b855c36033d", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "7a523edeaea9e8e222e3d9daafd53d3a", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "8e0d4fe40c9d3f78dc353b855c36033d", @@ -4131,14 +4131,14 @@ "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "b57964942b8ca52efdf51582adc26aee", "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "3516e46d80d01cab8b93d3c50a5947bc", "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "b57964942b8ca52efdf51582adc26aee", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "92f4e8a1a7a02d67371021e4322fe64e", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "bb65d468a59720259979daa18faed3c4", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "6b7b8ca64ed2e9b0a93a9e3999192ff3", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "d662741332c1face1dd2635959a140dc", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "5c24a04029507fd79add85739e1be722", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "1bb1d8f2be67329d66557a55946a99a2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "e7de0956d9215dde33ea9f0e487bd092", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "2475fa5570783ac4ab8c8c2360bc11e4", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "14d6093a5de1c5d862b4b7586b8ab7b4", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "5050be44e2391c60654d99a81accf28e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "763f1f32df0092cded564856ccaa5eee", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "c7904ea044dd0b11510d4f52aae48c1c", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "bdd683789643cef7d01c186ab8d767a2", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "bcd2cc9ae3baa73a7a72f82cbb2aabb8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "ac256750318d76da7d9fcee90e9bc808", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "f103638e32e70b08af0e79e604cf055d", "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": "06042d31df0ff9af96b99477162e2a91", diff --git a/CHANGELOG.md b/CHANGELOG.md index 067c6bd3..cbfd08c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22136, api 9, 2024-12-17) +### 1.7.37 (build 22137, api 9, 2024-12-18) - 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/baclassic/_appmode.py b/src/assets/ba_data/python/baclassic/_appmode.py index 23cbbee1..a2262305 100644 --- a/src/assets/ba_data/python/baclassic/_appmode.py +++ b/src/assets/ba_data/python/baclassic/_appmode.py @@ -188,6 +188,7 @@ class ClassicAppMode(babase.AppMode): level_text='-', xp_text='-', inbox_count_text='', + gold_pass=False, ) else: @@ -222,6 +223,7 @@ class ClassicAppMode(babase.AppMode): level_text=str(val.level), xp_text=f'{val.xp}/{val.xpmax}', inbox_count_text=ibc, + gold_pass=val.gold_pass, ) 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 17710f31..9a08d772 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -53,7 +53,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 22136 +TARGET_BALLISTICA_BUILD = 22137 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/ballistica/classic/python/methods/python_methods_classic.cc b/src/ballistica/classic/python/methods/python_methods_classic.cc index 4539f86a..bca26086 100644 --- a/src/ballistica/classic/python/methods/python_methods_classic.cc +++ b/src/ballistica/classic/python/methods/python_methods_classic.cc @@ -303,6 +303,7 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) const char* level_text; const char* xp_text; const char* inbox_count_text; + int gold_pass{}; static const char* kwlist[] = {"tickets_text", "tokens_text", @@ -312,12 +313,13 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) "level_text", "xp_text", "inbox_count_text", + "gold_pass", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssssssss", - const_cast(kwlist), &tickets_text, - &tokens_text, &league_rank_text, - &league_type, &achievements_percent_text, - &level_text, &xp_text, &inbox_count_text)) { + if (!PyArg_ParseTupleAndKeywords( + args, keywds, "ssssssssp", const_cast(kwlist), &tickets_text, + &tokens_text, &league_rank_text, &league_type, + &achievements_percent_text, &level_text, &xp_text, &inbox_count_text, + &gold_pass)) { return nullptr; } BA_PRECONDITION(g_base->InLogicThread()); @@ -334,6 +336,7 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) appmode->SetRootUILevelText(level_text); appmode->SetRootUIXPText(xp_text); appmode->SetRootUIInboxCountText(inbox_count_text); + appmode->SetRootUIGoldPass(gold_pass); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -352,6 +355,7 @@ static PyMethodDef PySetRootUIValuesDef = { " level_text: str,\n" " xp_text: str,\n" " inbox_count_text: str,\n" + " gold_pass: bool,\n" ") -> None\n" "\n" "(internal)", diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index 5d0c26cf..ab6b2778 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -150,7 +150,8 @@ void ClassicAppMode::Reset_() { // current values for everything. if (auto* root_widget = uiv1_->root_widget()) { root_widget->SetTicketsMeterText(root_ui_tickets_meter_text_); - root_widget->SetTokensMeterText(root_ui_tokens_meter_text_); + root_widget->SetTokensMeterText(root_ui_tokens_meter_text_, + root_ui_gold_pass_); root_widget->SetLeagueRankText(root_ui_league_rank_text_); root_widget->SetLeagueType(root_ui_league_type_); root_widget->SetAchievementPercentText(root_ui_achievement_percent_text_); @@ -1572,7 +1573,8 @@ void ClassicAppMode::SetRootUITokensMeterText(const std::string text) { // Apply it to any existing UI. if (uiv1_) { if (auto* root_widget = uiv1_->root_widget()) { - root_widget->SetTokensMeterText(root_ui_tokens_meter_text_); + root_widget->SetTokensMeterText(root_ui_tokens_meter_text_, + root_ui_gold_pass_); } } } @@ -1676,6 +1678,24 @@ void ClassicAppMode::SetRootUIInboxCountText(const std::string text) { } } +void ClassicAppMode::SetRootUIGoldPass(bool enabled) { + BA_PRECONDITION(g_base->InLogicThread()); + if (enabled == root_ui_gold_pass_) { + return; + } + + // Store the value. + root_ui_gold_pass_ = enabled; + + // Apply it to any existing UI. + if (uiv1_) { + if (auto* root_widget = uiv1_->root_widget()) { + root_widget->SetTokensMeterText(root_ui_tokens_meter_text_, + root_ui_gold_pass_); + } + } +} + auto ClassicAppMode::GetBottomLeftEdgeHeight() -> float { assert(g_base->InLogicThread()); if (uiv1_) { diff --git a/src/ballistica/classic/support/classic_app_mode.h b/src/ballistica/classic/support/classic_app_mode.h index bfc64390..3a14956a 100644 --- a/src/ballistica/classic/support/classic_app_mode.h +++ b/src/ballistica/classic/support/classic_app_mode.h @@ -223,6 +223,7 @@ class ClassicAppMode : public base::AppMode { void SetRootUILevelText(const std::string text); void SetRootUIXPText(const std::string text); void SetRootUIInboxCountText(const std::string text); + void SetRootUIGoldPass(bool enabled); private: ClassicAppMode(); @@ -260,7 +261,8 @@ class ClassicAppMode : public base::AppMode { bool game_roster_dirty_{}; bool kick_vote_in_progress_{}; bool kick_voting_enabled_{true}; - bool replay_paused_{false}; + bool replay_paused_{}; + bool root_ui_gold_pass_{}; ui_v1::UIV1FeatureSet* uiv1_{}; cJSON* game_roster_{}; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 509dafae..db38d18c 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 = 22136; +const int kEngineBuildNumber = 22137; 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 74b5e8b0..45aa5097 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -10,6 +10,7 @@ #include "ballistica/base/graphics/renderer/render_pass.h" #include "ballistica/base/graphics/support/frame_def.h" #include "ballistica/base/support/context.h" +#include "ballistica/shared/buildconfig/buildconfig_common.h" #include "ballistica/shared/foundation/inline.h" #include "ballistica/ui_v1/python/ui_v1_python.h" #include "ballistica/ui_v1/widget/button_widget.h" @@ -78,6 +79,7 @@ struct RootWidget::Button { bool selectable{true}; bool fully_offscreen{}; bool enabled{}; + bool force_hide{}; bool allow_in_main_menu{true}; bool allow_in_game{true}; uint32_t visibility_mask{}; @@ -1061,6 +1063,9 @@ void RootWidget::StepChildWidgets_(float dt) { if (&b == back_button_ && !is_small) { enable_button = false; } + if (b.force_hide) { + enable_button = false; + } b.enabled = enable_button; } @@ -1375,9 +1380,21 @@ void RootWidget::SetTicketsMeterText(const std::string& val) { tickets_meter_text_->widget->SetText(val); } -void RootWidget::SetTokensMeterText(const std::string& val) { +void RootWidget::SetTokensMeterText(const std::string& val, bool gold_pass) { assert(tokens_meter_text_); - tokens_meter_text_->widget->SetText(val); + assert(get_tokens_button_); + if (gold_pass) { + get_tokens_button_->force_hide = true; + // Use the infinity symbol if we have full unicode support. + tokens_meter_text_->widget->SetText( + g_buildconfig.enable_os_font_rendering() ? "\xE2\x88\x9E" : "inf"); + tokens_meter_text_->widget->set_color(1.0f, 0.6f, 0.1f, 0.6f); + } else { + get_tokens_button_->force_hide = false; + tokens_meter_text_->widget->SetText(val); + tokens_meter_text_->widget->set_color(1.0f, 1.0f, 1.0f, 1.0f); + } + MarkForUpdate(); } void RootWidget::SetLeagueRankText(const std::string& val) { diff --git a/src/ballistica/ui_v1/widget/root_widget.h b/src/ballistica/ui_v1/widget/root_widget.h index 4000376a..a8ba6b7a 100644 --- a/src/ballistica/ui_v1/widget/root_widget.h +++ b/src/ballistica/ui_v1/widget/root_widget.h @@ -40,7 +40,7 @@ class RootWidget : public ContainerWidget { void SetAccountState(bool signed_in, const std::string& name); void SetTicketsMeterText(const std::string& val); - void SetTokensMeterText(const std::string& val); + void SetTokensMeterText(const std::string& val, bool gold_pass); void SetLeagueRankText(const std::string& val); void SetLeagueType(const std::string& val); void SetAchievementPercentText(const std::string& val); @@ -51,6 +51,7 @@ class RootWidget : public ContainerWidget { auto bottom_left_height() const { return bottom_left_height_; } private: + void UpdateTokensMeterText_(); struct ButtonDef; struct Button; struct TextDef; diff --git a/tools/efro/util.py b/tools/efro/util.py index 0aa02d23..16acc167 100644 --- a/tools/efro/util.py +++ b/tools/efro/util.py @@ -118,11 +118,24 @@ def utc_now_naive() -> datetime.datetime: This can be used to replace datetime.utcnow(), which is now deprecated. Most all code should migrate to use timezone-aware times instead of - this. + relying on this. """ return datetime.datetime.now(datetime.UTC).replace(tzinfo=None) +def utc_from_timestamp_naive(timestamp: float) -> datetime.datetime: + """Get a naive utc time from a timestamp. + + This can be used to replace datetime.utcfromtimestamp(), which is now + deprecated. Most all code should migrate to use timezone-aware times + instead of relying on this. + """ + + return datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC).replace( + tzinfo=None + ) + + def utc_today() -> datetime.datetime: """Get offset-aware midnight in the utc time zone.""" now = datetime.datetime.now(datetime.UTC)