From b51bc29773c26a0baeae9e5fefe07fcb362e49ba Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 31 Aug 2023 09:12:03 -0700 Subject: [PATCH] tidying --- .efrocachemap | 88 +++++++++---------- .idea/dictionaries/ericf.xml | 3 +- CHANGELOG.md | 4 +- .../.idea/dictionaries/ericf.xml | 3 +- src/assets/ba_data/python/babase/_app.py | 11 +-- src/assets/ba_data/python/baenv.py | 4 +- .../ba_data/python/bauiv1/_subsystem.py | 1 - .../python/bauiv1lib/settings/controls.py | 1 - src/ballistica/base/base.cc | 3 +- src/ballistica/base/base.h | 6 ++ .../platform/apple/base_platform_apple.cc | 8 ++ .../base/platform/apple/base_platform_apple.h | 1 + src/ballistica/base/platform/base_platform.cc | 2 + src/ballistica/base/platform/base_platform.h | 3 + .../base/python/class/python_class_env.cc | 30 +++++-- .../base/python/class/python_class_env.h | 1 + src/ballistica/core/core.cc | 21 +++-- src/ballistica/core/core.h | 1 - .../platform/apple/core_platform_apple.cc | 8 -- .../core/platform/apple/core_platform_apple.h | 1 - src/ballistica/core/platform/core_platform.cc | 4 - src/ballistica/core/platform/core_platform.h | 5 -- src/ballistica/core/support/base_soft.h | 8 +- .../python/class/python_class_material.cc | 2 +- src/ballistica/scene_v1/scene_v1.h | 29 +++--- src/ballistica/shared/ballistica.cc | 9 +- src/ballistica/shared/ballistica.h | 31 ++++--- 27 files changed, 157 insertions(+), 131 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 478002a4..78afb51e 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4064,50 +4064,50 @@ "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": "d17c2ee21e1fb7845763e9ccc9e7966d", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "742d02168b023ef812b53fed2e581f7d", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "b41cfcdd17a4ce3a85707426c62144ee", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "a799400fd4b28b724a5cd7022c016a1c", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "0651c8caba1b5258acf06cf515829e94", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "c67d36bac8c20c59cf58fe67ff5aab6f", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "a932c27c89add5dd0b0b5054ccbc9c30", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "bcccf5b9506727ae7339d172946e9cba", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "ad79f1fb9a69488395dcb8e9909b18e2", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "1c4c72504904d6ac6003401cffef8550", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "3be75ed39f701ea673fdf4c41cc85fee", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "b6caf556a041fd297a42d022dd28bbbd", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "32bce4f3dc1068d13c7a8c13f6f65d39", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "633069c441e56f01cbe5a15d2a3202d4", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "02350d3de51cd2056d3144ff34fe24d2", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "562c39ba329fcd64b23d86a56cd5f7bb", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "a173972be3a16bc2637dabbe124aaea6", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "f0b9f9514c4da093c8720a89e54c069c", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "f7df321426c7add9f4ea31e266ed5c66", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "72435cbb4e1b80f31652950f32021464", - "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "cbb5ca4147284608ee43aaefe1f9bcfb", - "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "788b336518c767880ce7392d7f595852", - "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "cbb5ca4147284608ee43aaefe1f9bcfb", - "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "788b336518c767880ce7392d7f595852", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "cccb7895ed8f412f72ce04c676eae235", - "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "f792c55164f95f8b33f00e7d809c90f7", - "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "cccb7895ed8f412f72ce04c676eae235", - "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "f792c55164f95f8b33f00e7d809c90f7", - "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "460f8c445f95f1789820ab1d4556c03a", - "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "911f93f977b96774cfa3c82f5e5a4cc8", - "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "460f8c445f95f1789820ab1d4556c03a", - "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "911f93f977b96774cfa3c82f5e5a4cc8", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "8d7077f5e2b9ed0cf9dcf8cbb75ef696", - "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "016af4cf5eea1232e05db579bda8ee4b", - "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "5d848f38d9a8056de078a26f78538051", - "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "016af4cf5eea1232e05db579bda8ee4b", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "3dd5639a27b74c03e77e3ef706889466", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "c374e1187e51a6c7af83b3158e9ece34", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "92888461dc4f86381cfade96b43ca944", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "95c4b8c64bcfb62f782a4b3b74189b80", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "bb99cd26d290a01a90f538fc9dcc4af6", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "eb5316cfd1213ed4eb61f780ea9ad5ef", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "1c436928b8fdae376046661097a85851", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "b5e3f67b28943b3afe6e8d62811f2844", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "4542f7820b33b8f1f6719b17efa26453", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "c94898207acb63e3e09cb08b50ebd287", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "ad606ee2ee1367b906c9cbb18c53baf6", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "776e2461a852753010278d5b90ff32df", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "aefcfd8774114e7cebc418d0adad56f2", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "d21df3fc06db87786d68ccc1417d043e", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "7b218f79079e8e0d92b5f0a4afb0599d", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "94738f2f6fcbea9dad60af4bd6a7cd5d", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "033b39b34a10d5bce6e53572a816d0ef", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "f4eb1cc72a16eafcaba2d55c65f19a7b", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "fec5b1818aa97bc0dff1ddf127742574", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "76930acbbd2e8dd35f35639d85ce21ac", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "d5ab5ad85dd8d113125d15f03c221db3", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "29fbcf76221d71ea3ecb73d8ab353f7b", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "3d8b4b5d6ba376f2d280209e0aa3bcf2", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "fb9da4455aa7c0d8e5120a75ccaeabcb", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "056f8137ba8b1179b66eea59944aefb2", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "78f53224dd6052c93da31bda7ee1c84c", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "82128374a7eabc651061d778e099b923", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "2cd60cbebfbe25447791284b42c3caf9", + "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "a589af5b31246539eac3264c829c41a0", + "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "3dfaf945474294cb9f3808a835fb667c", + "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "a589af5b31246539eac3264c829c41a0", + "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "3dfaf945474294cb9f3808a835fb667c", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "47e08d2f265f4dda15b309fa67ba163b", + "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "c9a5225be07b4456e073014e1db2cafe", + "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "47e08d2f265f4dda15b309fa67ba163b", + "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "c9a5225be07b4456e073014e1db2cafe", + "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "f79382e5342db6f38f4c07170589d62d", + "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "b2d5386301891813a790f1a19d442022", + "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "f79382e5342db6f38f4c07170589d62d", + "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "b2d5386301891813a790f1a19d442022", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "899eda04958efce6903b7dd2abe6c76f", + "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "e98d76fe2d0af7e775801998d8591340", + "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "e9d551c0bfbb330470b1e0784028e4d3", + "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "e98d76fe2d0af7e775801998d8591340", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "77f25ad3348eb212969725c0ec7ebec8", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "df8038790ce73124950dc443c1e972ad", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "f184798b7973343cdc42d16e05aa335f", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "2e3ed4ea52261efd17d0927b21cf4075", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "1a5c374cfdd07ccbb2f1e9a44b886131", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "66da72816faa1d87d0b3fe677c6eb9c8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "fbef69c5fba9b7c94d37e233eb6c9642", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "c37e1dc4f95a8db0b5059dae0b5f5241", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318", "src/ballistica/base/mgen/pyembed/binding_base.inc": "ad347097a38e0d7ede9eb6dec6a80ee9", diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 351a93cf..993d45c3 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -1073,6 +1073,7 @@ flagnode flagpos flav + flavordir fldtypes flines floinkdingle @@ -3378,4 +3379,4 @@ zval - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 658f9967..101b2aa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -### 1.7.27 (build 21281, api 8, 2023-08-30) +### 1.7.28 (build 21289, api 8, 2023-08-31) + +### 1.7.27 (build 21282, api 8, 2023-08-30) - Fixed a rare crash that could occur if the app shuts down while a background thread is making a web request. The app will now try to wait for any such diff --git a/ballisticakit-cmake/.idea/dictionaries/ericf.xml b/ballisticakit-cmake/.idea/dictionaries/ericf.xml index 6d3915be..88a7f7dc 100644 --- a/ballisticakit-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticakit-cmake/.idea/dictionaries/ericf.xml @@ -654,6 +654,7 @@ fjco fjcoiwef flagindex + flavordir flipbit floinkdingle floooff @@ -1981,4 +1982,4 @@ zrot - + \ No newline at end of file diff --git a/src/assets/ba_data/python/babase/_app.py b/src/assets/ba_data/python/babase/_app.py index 093d3dda..9c1a2c6e 100644 --- a/src/assets/ba_data/python/babase/_app.py +++ b/src/assets/ba_data/python/babase/_app.py @@ -4,10 +4,10 @@ # pylint: disable=too-many-lines from __future__ import annotations +import os import logging -from enum import Enum - import warnings +from enum import Enum from typing import TYPE_CHECKING from concurrent.futures import ThreadPoolExecutor from functools import cached_property @@ -143,10 +143,11 @@ class App: the single shared instance. """ - self.env: babase.Env = _babase.Env() - if self.env.running_with_dummy_modules: + if os.environ.get('BA_RUNNING_WITH_DUMMY_MODULES') == '1': return + self.env: babase.Env = _babase.Env() + self.state = self.State.NOT_RUNNING # Controls which app-modes we use for handling given @@ -199,7 +200,7 @@ class App: def postinit(self) -> None: """Called after we've been inited and assigned to babase.app.""" - if self.env.running_with_dummy_modules: + if os.environ.get('BA_RUNNING_WITH_DUMMY_MODULES') == '1': return # NOTE: the reason we need a postinit here is that diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 04c61787..b16b7924 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -52,8 +52,8 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21281 -TARGET_BALLISTICA_VERSION = '1.7.27' +TARGET_BALLISTICA_BUILD = 21289 +TARGET_BALLISTICA_VERSION = '1.7.28' @dataclass diff --git a/src/assets/ba_data/python/bauiv1/_subsystem.py b/src/assets/ba_data/python/bauiv1/_subsystem.py index 2d5e8c3f..311650cb 100644 --- a/src/assets/ba_data/python/bauiv1/_subsystem.py +++ b/src/assets/ba_data/python/bauiv1/_subsystem.py @@ -56,7 +56,6 @@ class UIV1Subsystem(babase.AppSubsystem): self.cleanupchecks: list[UICleanupCheck] = [] self.upkeeptimer: babase.AppTimer | None = None self.use_toolbars = _bauiv1.toolbar_test() - # self.use_toolbars = env.get('toolbar_test', True) self.title_color = (0.72, 0.7, 0.75) self.heading_color = (0.72, 0.7, 0.75) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/controls.py b/src/assets/ba_data/python/bauiv1lib/settings/controls.py index 2d9e4c33..0b9abd39 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/controls.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/controls.py @@ -70,7 +70,6 @@ class ControlsSettingsWindow(bui.Window): show_space_1 = True height += space_height - print('hello') show_keyboard = False if bs.getinputdevice('Keyboard', '#1', doraise=False) is not None: show_keyboard = True diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index c757166c..e66d83e9 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -234,7 +234,7 @@ void BaseFeatureSet::OnAppShutdownComplete() { if (app_adapter->ManagesEventLoop()) { g_core->main_event_loop()->Quit(); } else { - g_core->platform->QuitApp(); + platform->QuitApp(); } } @@ -720,5 +720,6 @@ void BaseFeatureSet::ShutdownSuppressEnd() { shutdown_suppress_count_--; assert(shutdown_suppress_count_ >= 0); } +auto BaseFeatureSet::GetReturnValue() const -> int { return return_value(); } } // namespace ballistica::base diff --git a/src/ballistica/base/base.h b/src/ballistica/base/base.h index c142b604..34aab1d1 100644 --- a/src/ballistica/base/base.h +++ b/src/ballistica/base/base.h @@ -736,6 +736,11 @@ class BaseFeatureSet : public FeatureSetNativeComponent, // Non-const bits (fixme: clean up access to these). TouchInput* touch_input{}; + auto return_value() const { return return_value_; } + void set_return_value(int val) { return_value_ = val; } + + auto GetReturnValue() const -> int override; + private: BaseFeatureSet(); void LogVersionInfo_(); @@ -762,6 +767,7 @@ class BaseFeatureSet : public FeatureSetNativeComponent, bool base_native_import_completed_{}; bool basn_log_behavior_{}; bool server_wrapper_managed_{}; + int return_value_{}; }; } // namespace ballistica::base diff --git a/src/ballistica/base/platform/apple/base_platform_apple.cc b/src/ballistica/base/platform/apple/base_platform_apple.cc index 8486eb44..e955fdc9 100644 --- a/src/ballistica/base/platform/apple/base_platform_apple.cc +++ b/src/ballistica/base/platform/apple/base_platform_apple.cc @@ -63,6 +63,14 @@ void BasePlatformApple::DoOpenURL(const std::string& url) { #endif } +void BasePlatformApple::QuitApp() { +#if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD + core::AppleUtils::Quit(); // will post a cocoa terminate +#else + BasePlatform::QuitApp(); +#endif +} + } // namespace ballistica::base #endif // BA_OSTYPE_MACOS || BA_OSTYPE_IOS_TVOS diff --git a/src/ballistica/base/platform/apple/base_platform_apple.h b/src/ballistica/base/platform/apple/base_platform_apple.h index 50cf78cc..c885e052 100644 --- a/src/ballistica/base/platform/apple/base_platform_apple.h +++ b/src/ballistica/base/platform/apple/base_platform_apple.h @@ -16,6 +16,7 @@ class BasePlatformApple : public BasePlatform { void RestorePurchases() override; void PurchaseAck(const std::string& purchase, const std::string& order_id) override; + void QuitApp() override; void DoOpenURL(const std::string& url) override; diff --git a/src/ballistica/base/platform/base_platform.cc b/src/ballistica/base/platform/base_platform.cc index f3d3ff66..a17d09df 100644 --- a/src/ballistica/base/platform/base_platform.cc +++ b/src/ballistica/base/platform/base_platform.cc @@ -321,4 +321,6 @@ void BasePlatform::OnAppShutdown() { assert(g_base->InLogicThread()); } void BasePlatform::OnScreenSizeChange() { assert(g_base->InLogicThread()); } void BasePlatform::DoApplyAppConfig() { assert(g_base->InLogicThread()); } +void BasePlatform::QuitApp() { exit(g_base->return_value()); } + } // namespace ballistica::base diff --git a/src/ballistica/base/platform/base_platform.h b/src/ballistica/base/platform/base_platform.h index 61a2cc82..fc2c53a1 100644 --- a/src/ballistica/base/platform/base_platform.h +++ b/src/ballistica/base/platform/base_platform.h @@ -33,6 +33,9 @@ class BasePlatform { virtual void OnScreenSizeChange(); virtual void DoApplyAppConfig(); + /// Quit the app (can be immediate or via posting some high level event). + virtual void QuitApp(); + #pragma mark IN APP PURCHASES -------------------------------------------------- void Purchase(const std::string& item); diff --git a/src/ballistica/base/python/class/python_class_env.cc b/src/ballistica/base/python/class/python_class_env.cc index 666d50ff..af1cea48 100644 --- a/src/ballistica/base/python/class/python_class_env.cc +++ b/src/ballistica/base/python/class/python_class_env.cc @@ -170,10 +170,6 @@ void PythonClassEnv::SetupType(PyTypeObject* cls) { envs["demo"] = BoolEntry_(g_buildconfig.demo_build(), "Whether the app is targeting a demo experience."); - auto* envval = getenv("BA_RUNNING_WITH_DUMMY_MODULES"); - envs["running_with_dummy_modules"] = - BoolEntry_(envval && !strcmp(envval, "1"), "(internal)"); - bool first = true; for (auto&& entry : envs) { if (!first) { @@ -239,9 +235,33 @@ PythonClassEnv::PythonClassEnv() = default; PythonClassEnv::~PythonClassEnv() = default; +auto PythonClassEnv::Dir(PythonClassEnv* self) -> PyObject* { + BA_PYTHON_TRY; + + // Start with the standard Python dir listing. + PyObject* dir_list = Python::generic_dir(reinterpret_cast(self)); + assert(PyList_Check(dir_list)); + + assert(g_entries_); + + // ..and add in our custom attr names. + for (auto&& env : *g_entries_) { + PyList_Append(dir_list, PythonRef(PyUnicode_FromString(env.first.c_str()), + PythonRef::kSteal) + .Get()); + } + PyList_Sort(dir_list); + return dir_list; + + BA_PYTHON_CATCH; +} + PyTypeObject PythonClassEnv::type_obj; // Any methods for our class go here. -PyMethodDef PythonClassEnv::tp_methods[] = {{nullptr}}; +PyMethodDef PythonClassEnv::tp_methods[] = { + {"__dir__", (PyCFunction)Dir, METH_NOARGS, + "allows inclusion of our custom attrs in standard python dir()"}, + {nullptr}}; } // namespace ballistica::base diff --git a/src/ballistica/base/python/class/python_class_env.h b/src/ballistica/base/python/class/python_class_env.h index 087429c4..dcca64c5 100644 --- a/src/ballistica/base/python/class/python_class_env.h +++ b/src/ballistica/base/python/class/python_class_env.h @@ -37,6 +37,7 @@ class PythonClassEnv : public PythonClass { static auto tp_new(PyTypeObject* type, PyObject* args, PyObject* keywds) -> PyObject*; static void tp_dealloc(PythonClassEnv* self); + static auto Dir(PythonClassEnv* self) -> PyObject*; }; } // namespace ballistica::base diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index 7d421e0f..1374988e 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -148,6 +148,7 @@ auto CoreFeatureSet::core_config() const -> const CoreConfig& { } void CoreFeatureSet::ApplyBaEnvConfig() { + // Ask baenv for the config we should use. auto envcfg = python->objs().Get(core::CorePython::ObjID::kBaEnvGetConfigCall).Call(); BA_PRECONDITION_FATAL(envcfg.Exists()); @@ -155,7 +156,7 @@ void CoreFeatureSet::ApplyBaEnvConfig() { assert(!have_ba_env_vals_); have_ba_env_vals_ = true; - // Grab everything baenv shipped us. + // Pull everything we want out of it. ba_env_config_dir_ = envcfg.GetAttr("config_dir").ValueAsString(); ba_env_data_dir_ = envcfg.GetAttr("data_dir").ValueAsString(); ba_env_app_python_dir_ = @@ -173,7 +174,8 @@ void CoreFeatureSet::ApplyBaEnvConfig() { ba_env_app_python_dir_.has_value() && *ba_env_app_python_dir_ != standard_app_python_dir; - // Ok, now look for the existence of ba_data in the dir we've got. + // As a sanity check, die if the data dir we were given doesn't contain a + // 'ba_data' dir. auto fullpath = ba_env_data_dir_ + BA_DIRSLASH + "ba_data"; if (!platform->FilePathExists(fullpath)) { FatalError("ba_data directory not found at '" + fullpath + "'."); @@ -335,14 +337,15 @@ void CoreFeatureSet::UpdateAppTime() { std::scoped_lock lock(app_time_mutex_); microsecs_t passed = t - last_app_time_measure_microsecs_; - // The time calls we're using are supposed to be monotonic, but I've seen - // 'passed' equal -1 even when it is using std::chrono::steady_clock. Let's - // do our own filtering here to make 100% sure we don't go backwards. + // The time calls we're using are supposed to be monotonic, but I've + // seen 'passed' equal -1 even when it is using + // std::chrono::steady_clock. Let's do our own filtering here to make + // 100% sure we don't go backwards. if (passed < 0) { passed = 0; } else { - // Very large times-passed probably means we went to sleep or something; - // clamp to a reasonable value. + // Very large times-passed probably means we went to sleep or + // something; clamp to a reasonable value. if (passed > 250000) { passed = 250000; } @@ -355,8 +358,8 @@ void CoreFeatureSet::UpdateAppTime() { void CoreFeatureSet::UpdateMainThreadID() { auto current_id = std::this_thread::get_id(); - // This gets called a lot and it may happen before we are spun up, - // so just ignore it in that case.. + // This gets called a lot and it may happen before we are spun up, so just + // ignore it in that case. main_thread_id = current_id; main_event_loop_->set_thread_id(current_id); } diff --git a/src/ballistica/core/core.h b/src/ballistica/core/core.h index fc9fc856..49f0c342 100644 --- a/src/ballistica/core/core.h +++ b/src/ballistica/core/core.h @@ -164,7 +164,6 @@ class CoreFeatureSet { bool should_pause{}; bool reset_vr_orientation{}; bool user_ran_commands{}; - int return_value{}; std::thread::id main_thread_id{}; bool vr_mode; diff --git a/src/ballistica/core/platform/apple/core_platform_apple.cc b/src/ballistica/core/platform/apple/core_platform_apple.cc index c860e5ba..8bf1b07c 100644 --- a/src/ballistica/core/platform/apple/core_platform_apple.cc +++ b/src/ballistica/core/platform/apple/core_platform_apple.cc @@ -297,14 +297,6 @@ void CorePlatformApple::SetHardwareCursorVisible(bool visible) { #endif } -void CorePlatformApple::QuitApp() { -#if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD - AppleUtils::Quit(); // will post a cocoa terminate -#else - CorePlatform::QuitApp(); -#endif -} - void CorePlatformApple::OpenFileExternally(const std::string& path) { #if BA_XCODE_BUILD AppleUtils::EditTextFile(path.c_str()); diff --git a/src/ballistica/core/platform/apple/core_platform_apple.h b/src/ballistica/core/platform/apple/core_platform_apple.h index 23619a8c..52252761 100644 --- a/src/ballistica/core/platform/apple/core_platform_apple.h +++ b/src/ballistica/core/platform/apple/core_platform_apple.h @@ -50,7 +50,6 @@ class CorePlatformApple : public CorePlatform { void GameCenterLogin() override; auto IsOSPlayingMusic() -> bool override; void SetHardwareCursorVisible(bool visible) override; - void QuitApp() override; void OpenFileExternally(const std::string& path) override; void OpenDirExternally(const std::string& path) override; void MacMusicAppInit() override; diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index 52f59169..9f201691 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -470,8 +470,6 @@ void CorePlatform::SleepMillisecs(millisecs_t ms) { #pragma clang diagnostic push #pragma ide diagnostic ignored "NullDereferences" -void CorePlatform::WillExitMain(bool errored) {} - auto CorePlatform::GetUIScale() -> UIScale { // Handles mac/pc/linux cases. return UIScale::kLarge; @@ -810,8 +808,6 @@ void CorePlatform::SetHardwareCursorVisible(bool visible) { #endif } -void CorePlatform::QuitApp() { exit(g_core->return_value); } - void CorePlatform::OpenFileExternally(const std::string& path) { Log(LogLevel::kError, "OpenFileExternally() unimplemented"); } diff --git a/src/ballistica/core/platform/core_platform.h b/src/ballistica/core/platform/core_platform.h index c72efd0a..83d9e269 100644 --- a/src/ballistica/core/platform/core_platform.h +++ b/src/ballistica/core/platform/core_platform.h @@ -49,8 +49,6 @@ class CorePlatform { /// class versions can go here. virtual void PostInit(); - virtual void WillExitMain(bool errored); - virtual void OnScreenSizeChange(); virtual void StepDisplayTime(); @@ -430,9 +428,6 @@ class CorePlatform { /// Show/hide the hardware cursor. virtual void SetHardwareCursorVisible(bool visible); - /// Quit the app (can be immediate or via posting some high level event). - virtual void QuitApp(); - /// Open a file using the system default method (in another app, etc.) virtual void OpenFileExternally(const std::string& path); diff --git a/src/ballistica/core/support/base_soft.h b/src/ballistica/core/support/base_soft.h index 005d5291..22852448 100644 --- a/src/ballistica/core/support/base_soft.h +++ b/src/ballistica/core/support/base_soft.h @@ -8,10 +8,9 @@ namespace ballistica::core { -/// 'Soft' interface to the base feature-set. -/// Feature-sets listing base as a soft requirement must limit their use of -/// base to these methods and should be prepared to handle the not-present -/// case. +/// 'Soft' interface to the base feature-set. Feature-sets listing base as a +/// soft requirement must limit their use of base to these methods and +/// should be prepared to handle the not-present case. class BaseSoftInterface { public: virtual void ScreenMessage(const std::string& s, const Vector3f& color) = 0; @@ -44,6 +43,7 @@ class BaseSoftInterface { virtual void DoPushObjCall(const PythonObjectSetBase* objset, int id, const std::string& arg) = 0; virtual auto IsAppStarted() const -> bool = 0; + virtual auto GetReturnValue() const -> int = 0; }; } // namespace ballistica::core diff --git a/src/ballistica/scene_v1/python/class/python_class_material.cc b/src/ballistica/scene_v1/python/class/python_class_material.cc index b491f1fb..3ea51b8d 100644 --- a/src/ballistica/scene_v1/python/class/python_class_material.cc +++ b/src/ballistica/scene_v1/python/class/python_class_material.cc @@ -221,7 +221,7 @@ auto PythonClassMaterial::tp_setattro(PythonClassMaterial* self, PyObject* attr, auto PythonClassMaterial::Dir(PythonClassMaterial* self) -> PyObject* { BA_PYTHON_TRY; - // Start with the standard python dir listing. + // Start with the standard Python dir listing. PyObject* dir_list = Python::generic_dir(reinterpret_cast(self)); assert(PyList_Check(dir_list)); diff --git a/src/ballistica/scene_v1/scene_v1.h b/src/ballistica/scene_v1/scene_v1.h index f3f21011..63415c81 100644 --- a/src/ballistica/scene_v1/scene_v1.h +++ b/src/ballistica/scene_v1/scene_v1.h @@ -25,26 +25,25 @@ class BaseFeatureSet; namespace ballistica::scene_v1 { -// Protocol version we host games with and write replays to. -// This should be incremented whenever there are changes made to the -// session-commands layer (new/removed/changed nodes, attrs, data files, -// behavior, etc.) -// Note that the packet/gamepacket/message layer can vary more organically based -// on build-numbers of connected clients/servers since none of that data is -// stored; this just needs to be observed for all the scene stuff that -// goes into replays since a single stream can get played/replayed on different -// builds (as long as they support that protocol version). +// Protocol version we host games with and write replays to. This should be +// incremented whenever there are changes made to the session-commands layer +// (new/removed/changed nodes, attrs, data files, behavior, etc.) + +// Note that the packet/gamepacket/message layer can vary more organically +// based on build-numbers of connected clients/servers since none of that +// data is stored; this just needs to be observed for all the scene stuff +// that goes into replays since a single stream can get played/replayed on +// different builds (as long as they support that protocol version). const int kProtocolVersion = 33; -// Oldest protocol version we can act as a client to. -// This can generally be left as-is as long as only -// new nodes/attrs/commands are added and existing -// stuff is unchanged. +// Oldest protocol version we can act as a client to. This can generally be +// left as-is as long as only new nodes/attrs/commands are added and +// existing stuff is unchanged. const int kProtocolVersionMin = 24; // FIXME: We should separate out connection protocol from scene protocol. We -// want to be able to watch really old replays if possible but being able to -// connect to old clients is much less important (and slows progress). +// want to be able to watch really old replays if possible but being able +// to connect to old clients is much less important (and slows progress). // Protocol additions: // 25: added a few new achievement graphics and new node attrs for displaying diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 085df9a2..d8ce5baf 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,8 +39,8 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 21281; -const char* kEngineVersion = "1.7.27"; +const int kEngineBuildNumber = 21289; +const char* kEngineVersion = "1.7.28"; const int kEngineApiVersion = 8; #if BA_MONOLITHIC_BUILD @@ -156,9 +156,8 @@ auto MonolithicMain(const core::CoreConfig& core_config) -> int { } } } - if (l_core) { - l_core->platform->WillExitMain(false); - return l_core->return_value; + if (l_base) { + return l_base->GetReturnValue(); } return -1; // Didn't even get core; something clearly wrong. } diff --git a/src/ballistica/shared/ballistica.h b/src/ballistica/shared/ballistica.h index 2944c6db..83734735 100644 --- a/src/ballistica/shared/ballistica.h +++ b/src/ballistica/shared/ballistica.h @@ -18,8 +18,8 @@ #include "ballistica/shared/foundation/macros.h" #include "ballistica/shared/foundation/types.h" -// There are one or two places where we include this from regular C -// or Objective-C code so want to gracefully handle that case. +// There are one or two places where we include this from regular C or +// Objective-C code so want to gracefully handle that case. #ifdef __cplusplus namespace ballistica { @@ -40,10 +40,9 @@ const int kMaxPacketSize = 700; // Extra bytes added to message packets. const int kMessagePacketHeaderSize = 6; -// The screen, no matter what size/aspect, will always -// fit this virtual rectangle, so placing UI elements within -// these coords is always safe. -// (we currently match the screen ratio of an iPhone 5). +// The screen, no matter what size/aspect, will always fit this virtual +// rectangle, so placing UI elements within these coords is always safe. (we +// currently match the screen ratio of an iPhone 5). const int kBaseVirtualResX = 1207; const int kBaseVirtualResY = 680; @@ -60,13 +59,14 @@ namespace core { class CoreConfig; } -// The following is a smattering of convenience functions declared in our top -// level namespace. Functionality can be exposed here if it is used often -// enough that avoiding the extra class includes seems like an overall +// The following is a smattering of convenience functions declared in our +// top level namespace. Functionality can be exposed here if it is used +// often enough that avoiding the extra class includes seems like an overall // compile-time/convenience win. #if BA_MONOLITHIC_BUILD -/// Entry point for standard monolithic builds. Handles all initing and running. +/// Entry point for standard monolithic builds. Handles all initing and +/// running. auto MonolithicMain(const core::CoreConfig& config) -> int; #endif // BA_MONOLITHIC_BUILD @@ -80,12 +80,11 @@ auto CurrentThreadName() -> std::string; /// Convenient access to Logging::Log. void Log(LogLevel level, const std::string& msg); -/// Log a fatal error and kill the app. -/// Can be called from any thread at any time. -/// Provided message will be shown to the user if possible. -/// This will attempt to ship all accumulated logs to the master-server -/// so the standard Log() call can be used before this to include extra -/// info not relevant to the end user. +/// Log a fatal error and kill the app. Can be called from any thread at any +/// time. Provided message will be shown to the user if possible. This will +/// attempt to ship all accumulated logs to the master-server so the +/// standard Log() call can be used before this to include extra info not +/// relevant to the end user. void FatalError(const std::string& message = ""); } // namespace ballistica