From 16ef618a93f7d375f5394f7880328306c866baa9 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 21 Aug 2023 16:08:48 -0700 Subject: [PATCH] tidying and work on cleaner shutdown --- .efrocachemap | 56 ++++---- CHANGELOG.md | 2 +- ballisticakit-cmake/CMakeLists.txt | 20 +-- .../Generic/BallisticaKitGeneric.vcxproj | 20 +-- .../BallisticaKitGeneric.vcxproj.filters | 45 +++---- .../Headless/BallisticaKitHeadless.vcxproj | 20 +-- .../BallisticaKitHeadless.vcxproj.filters | 45 +++---- src/assets/ba_data/python/babase/_app.py | 101 ++++++++------ src/assets/ba_data/python/babase/_hooks.py | 2 +- src/assets/ba_data/python/baenv.py | 9 +- src/ballistica/base/app/app.cc | 23 ++-- src/ballistica/base/app/app.h | 74 +++++------ .../base/app/{sdl_app.cc => app_sdl.cc} | 48 +++---- .../base/app/{sdl_app.h => app_sdl.h} | 20 +-- src/ballistica/base/app/app_vr.cc | 20 +-- .../base/{app => app_mode}/app_mode.cc | 2 +- .../base/{app => app_mode}/app_mode.h | 12 +- .../base/{app => app_mode}/app_mode_empty.cc | 10 +- .../base/{app => app_mode}/app_mode_empty.h | 11 +- src/ballistica/base/assets/assets.cc | 2 +- src/ballistica/base/audio/audio.cc | 2 +- src/ballistica/base/base.cc | 8 +- src/ballistica/base/base.h | 5 +- .../base/dynamics/collision_cache.cc | 4 +- .../base/dynamics/collision_cache.h | 8 +- src/ballistica/base/graphics/gl/gl_sys.cc | 6 +- src/ballistica/base/graphics/graphics.cc | 8 +- .../base/graphics/graphics_server.cc | 6 +- .../base/input/device/input_device.cc | 2 +- .../base/input/device/joystick_input.cc | 2 +- .../base/input/device/touch_input.cc | 2 +- src/ballistica/base/input/input.cc | 24 ++-- src/ballistica/base/input/input.h | 2 +- src/ballistica/base/logic/logic.cc | 123 +++++++++--------- src/ballistica/base/logic/logic.h | 1 + .../base/networking/network_reader.cc | 2 +- src/ballistica/base/networking/networking.cc | 2 +- src/ballistica/base/platform/base_platform.cc | 8 +- .../base/python/methods/python_methods_app.cc | 4 +- .../python/methods/python_methods_misc.cc | 2 +- .../base/{app => support}/app_config.cc | 2 +- .../base/{app => support}/app_config.h | 6 +- src/ballistica/base/support/stdio_console.cc | 2 +- .../base/{app => support}/stress_test.cc | 2 +- .../base/{app => support}/stress_test.h | 6 +- src/ballistica/base/ui/console.cc | 2 +- src/ballistica/base/ui/ui.cc | 8 +- src/ballistica/base/ui/ui.h | 38 +++--- src/ballistica/classic/README.md | 4 +- src/ballistica/core/README.md | 17 +-- src/ballistica/core/core.h | 1 + src/ballistica/plus/README.md | 10 +- src/ballistica/scene_v1/README.md | 3 +- .../scene_v1/support/scene_v1_app_mode.cc | 2 +- .../scene_v1/support/scene_v1_app_mode.h | 2 +- .../scene_v1/support/scene_v1_context.cc | 2 +- src/ballistica/shared/ballistica.cc | 2 +- .../python/methods/python_methods_ui_v1.cc | 2 +- src/ballistica/ui_v1/support/root_ui.cc | 2 +- src/ballistica/ui_v1/ui_v1.cc | 4 +- src/ballistica/ui_v1/widget/root_widget.cc | 2 +- 61 files changed, 456 insertions(+), 426 deletions(-) rename src/ballistica/base/app/{sdl_app.cc => app_sdl.cc} (94%) rename src/ballistica/base/app/{sdl_app.h => app_sdl.h} (78%) rename src/ballistica/base/{app => app_mode}/app_mode.cc (97%) rename src/ballistica/base/{app => app_mode}/app_mode.h (92%) rename src/ballistica/base/{app => app_mode}/app_mode_empty.cc (88%) rename src/ballistica/base/{app => app_mode}/app_mode_empty.h (55%) rename src/ballistica/base/{app => support}/app_config.cc (99%) rename src/ballistica/base/{app => support}/app_config.h (96%) rename src/ballistica/base/{app => support}/stress_test.cc (98%) rename src/ballistica/base/{app => support}/stress_test.h (75%) diff --git a/.efrocachemap b/.efrocachemap index ce80c073..8a640be6 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4068,26 +4068,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": "e90f3bcd2f94dd910220e15a42550966", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "969a2f87c4e7863dac65b26269101099", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "5514b6c86406ddddf5b651f8f3f55fe7", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "1aae03c6da0ba129356a2cad35a7f662", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "927adc17b55984179e79c513dd02f255", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "c14f956a37c6c4b854528431f69d97a3", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "fd57912de1a8c12d23b9f19729b963d8", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "3e21f3f57cd594dcd4e4b4ed14546cd8", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "205aca87311597d93946d2002c20b886", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "f3d980a36605c34dca3b12184326163a", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "50288dc0a0949cd8dacf30a2a7b2f616", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "badf5f08cbcb64742114ca048c6b7727", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "b8d0fc747eaf3ee018197debe08070be", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "8977914f6658821d8f2e4bd5ddd01072", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "3f8030273ba43450ece98a32f49535fb", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "f8b4ac0346f70ff11ede342cc411f488", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "6ca8a627e66d8afaafa8a4bfe86e6611", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "6cb944d5071845f6c1a08df540001f0d", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "d6c5b9a6526a3eddb9db427510e228e6", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "a2b9d7f28f1292dd57c428721ecc0db3", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "60b5c6ab04b194345ff6257b70d69a5c", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "b9c878e7396fd1426c2a99fffd600aab", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "6619693fb688c49e3fd87ef9c9c5211a", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "a1f18844189de4fe40a56f345b33ef62", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "f04b028c0bdfbc84ce1d646977d0c06a", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "8e96e29356cc8157e5aa1cb30e597c78", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "d4cc2f2ed1648c310aba235b30b43c79", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "2c246e46c453d94e60be71f3f0d5eefe", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "7b25f37a94583dfdf277d5d55d4c8ee2", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "2ce3e00ae6d5ff8e65697b68438e213e", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "9a26cab66c09e657c0ac3233b1ecf0d7", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "b20ad6abed43e7bec2de8fa04bff71e2", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "29999f55a9ccb252c621e714a1d15c9c", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "3f75965547ef911e2ad85a7b1786eb43", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "7257acfca19121cc25be53e698c73d9c", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "8b45af314375a63d939a906d9f211bda", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "736b5398e8396be443695e8b2bd572d9", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "56e73294a44f2d1f5bff3f4a9f973c2e", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "5630f2dd810cf19d1c309a579a0febde", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "4c5506d6eb64252f0fb7275e13e3912c", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "85ba4e81a1f7ae2cff4b1355eb49904f", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "498921f7eb2afd327d4b900cb70e31f9", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "85ba4e81a1f7ae2cff4b1355eb49904f", @@ -4104,14 +4104,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "0ab638b6602610bdaf432e3cc2464080", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "92394eb19387c363471ce134ac9e6a1b", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "0ab638b6602610bdaf432e3cc2464080", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "5d9be2a7f56e5ceff27dad1ac61b9cbe", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "457d66c8095b9730be34a6882ccd9fb4", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "c4dccb80b2697860a86867d7a0ab83a7", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "4f847c6193dedac5c22f51790d4673b6", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "bff441f8f95a256aa8d425bb2511b4be", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "6512b8d9980e7ce3367c71ca7f6787a3", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "1c2dda04a2e3c3a408dafce8a052bffa", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "0b973869db3eff21bbcd566511675f46", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "ac1e455123d1c71aa09a16f1e6c4ecad", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "68323b0304b2158b09d1af9573fc6d85", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "0f9b59502d1faf0b783420f78ee383f0", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "e5df1b61f11ec0e2b7a1b28b22390574", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "4d097132b48f21c218b7129ad4d5f9a4", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "6dc492eb1c9bf2e9e9fb591ea81fa253", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "ad53f8041a683789e5f16d762a3d3b2c", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "5d161b0abe97805381be809c0b5da828", "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": "eeddad968b176000e31c65be6206a2bc", diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f77e7a0..06c21f28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.26 (build 21215, api 8, 2023-08-18) +### 1.7.26 (build 21221, api 8, 2023-08-21) - Various general improvements to the pcommand (project command) system. - Modules containing pcommand functions are now named with an 's' - so diff --git a/ballisticakit-cmake/CMakeLists.txt b/ballisticakit-cmake/CMakeLists.txt index 1f577141..062e8a15 100644 --- a/ballisticakit-cmake/CMakeLists.txt +++ b/ballisticakit-cmake/CMakeLists.txt @@ -205,20 +205,16 @@ set(BALLISTICA_SOURCES # AUTOGENERATED_PUBLIC_BEGIN (this section is managed by the "update_project" tool) ${BA_SRC_ROOT}/ballistica/base/app/app.cc ${BA_SRC_ROOT}/ballistica/base/app/app.h - ${BA_SRC_ROOT}/ballistica/base/app/app_config.cc - ${BA_SRC_ROOT}/ballistica/base/app/app_config.h ${BA_SRC_ROOT}/ballistica/base/app/app_headless.cc ${BA_SRC_ROOT}/ballistica/base/app/app_headless.h - ${BA_SRC_ROOT}/ballistica/base/app/app_mode.cc - ${BA_SRC_ROOT}/ballistica/base/app/app_mode.h - ${BA_SRC_ROOT}/ballistica/base/app/app_mode_empty.cc - ${BA_SRC_ROOT}/ballistica/base/app/app_mode_empty.h + ${BA_SRC_ROOT}/ballistica/base/app/app_sdl.cc + ${BA_SRC_ROOT}/ballistica/base/app/app_sdl.h ${BA_SRC_ROOT}/ballistica/base/app/app_vr.cc ${BA_SRC_ROOT}/ballistica/base/app/app_vr.h - ${BA_SRC_ROOT}/ballistica/base/app/sdl_app.cc - ${BA_SRC_ROOT}/ballistica/base/app/sdl_app.h - ${BA_SRC_ROOT}/ballistica/base/app/stress_test.cc - ${BA_SRC_ROOT}/ballistica/base/app/stress_test.h + ${BA_SRC_ROOT}/ballistica/base/app_mode/app_mode.cc + ${BA_SRC_ROOT}/ballistica/base/app_mode/app_mode.h + ${BA_SRC_ROOT}/ballistica/base/app_mode/app_mode_empty.cc + ${BA_SRC_ROOT}/ballistica/base/app_mode/app_mode_empty.h ${BA_SRC_ROOT}/ballistica/base/assets/asset.cc ${BA_SRC_ROOT}/ballistica/base/assets/asset.h ${BA_SRC_ROOT}/ballistica/base/assets/assets.cc @@ -412,6 +408,8 @@ set(BALLISTICA_SOURCES ${BA_SRC_ROOT}/ballistica/base/python/support/python_context_call.cc ${BA_SRC_ROOT}/ballistica/base/python/support/python_context_call.h ${BA_SRC_ROOT}/ballistica/base/python/support/python_context_call_runnable.h + ${BA_SRC_ROOT}/ballistica/base/support/app_config.cc + ${BA_SRC_ROOT}/ballistica/base/support/app_config.h ${BA_SRC_ROOT}/ballistica/base/support/app_timer.h ${BA_SRC_ROOT}/ballistica/base/support/classic_soft.h ${BA_SRC_ROOT}/ballistica/base/support/context.cc @@ -421,6 +419,8 @@ set(BALLISTICA_SOURCES ${BA_SRC_ROOT}/ballistica/base/support/plus_soft.h ${BA_SRC_ROOT}/ballistica/base/support/stdio_console.cc ${BA_SRC_ROOT}/ballistica/base/support/stdio_console.h + ${BA_SRC_ROOT}/ballistica/base/support/stress_test.cc + ${BA_SRC_ROOT}/ballistica/base/support/stress_test.h ${BA_SRC_ROOT}/ballistica/base/support/ui_v1_soft.h ${BA_SRC_ROOT}/ballistica/base/ui/console.cc ${BA_SRC_ROOT}/ballistica/base/ui/console.h diff --git a/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj b/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj index 6eeed769..4ae1e188 100644 --- a/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj +++ b/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj @@ -191,20 +191,16 @@ - - - - - - + + - - - - + + + + @@ -398,6 +394,8 @@ + + @@ -407,6 +405,8 @@ + + diff --git a/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj.filters b/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj.filters index 44f7c590..88b7dd89 100644 --- a/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj.filters +++ b/ballisticakit-windows/Generic/BallisticaKitGeneric.vcxproj.filters @@ -7,28 +7,16 @@ ballistica\base\app - - ballistica\base\app - - - ballistica\base\app - ballistica\base\app ballistica\base\app - + ballistica\base\app - - ballistica\base\app - - - ballistica\base\app - - + ballistica\base\app @@ -37,17 +25,17 @@ ballistica\base\app - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode ballistica\base\assets @@ -628,6 +616,12 @@ ballistica\base\python\support + + ballistica\base\support + + + ballistica\base\support + ballistica\base\support @@ -655,6 +649,12 @@ ballistica\base\support + + ballistica\base\support + + + ballistica\base\support + ballistica\base\support @@ -1866,6 +1866,7 @@ + diff --git a/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj b/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj index 1c77c124..e122c99d 100644 --- a/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj +++ b/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj @@ -186,20 +186,16 @@ - - - - - - + + - - - - + + + + @@ -393,6 +389,8 @@ + + @@ -402,6 +400,8 @@ + + diff --git a/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj.filters b/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj.filters index 44f7c590..88b7dd89 100644 --- a/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj.filters +++ b/ballisticakit-windows/Headless/BallisticaKitHeadless.vcxproj.filters @@ -7,28 +7,16 @@ ballistica\base\app - - ballistica\base\app - - - ballistica\base\app - ballistica\base\app ballistica\base\app - + ballistica\base\app - - ballistica\base\app - - - ballistica\base\app - - + ballistica\base\app @@ -37,17 +25,17 @@ ballistica\base\app - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode - - ballistica\base\app + + ballistica\base\app_mode ballistica\base\assets @@ -628,6 +616,12 @@ ballistica\base\python\support + + ballistica\base\support + + + ballistica\base\support + ballistica\base\support @@ -655,6 +649,12 @@ ballistica\base\support + + ballistica\base\support + + + ballistica\base\support + ballistica\base\support @@ -1866,6 +1866,7 @@ + diff --git a/src/assets/ba_data/python/babase/_app.py b/src/assets/ba_data/python/babase/_app.py index 06e89e6f..641e7a92 100644 --- a/src/assets/ba_data/python/babase/_app.py +++ b/src/assets/ba_data/python/babase/_app.py @@ -64,13 +64,14 @@ class App: # The app launch process has not yet begun. INITIAL = 0 - # Our app subsystems are being inited but should not yet interact. + # Our app subsystems are being inited but should not yet + # interact. LAUNCHING = 1 # App subsystems are inited and interacting, but the app has not - # yet embarked on a high level course of action. It is doing initial - # account logins, workspace & asset downloads, etc. in order to - # prepare for this. + # yet embarked on a high level course of action. It is doing + # initial account logins, workspace & asset downloads, etc. in + # order to prepare for this. LOADING = 2 # All pieces are in place and the app is now doing its thing. @@ -158,7 +159,7 @@ class App: @property def python_directory_user(self) -> str | None: - """Path where ballistica expects its custom user scripts (mods) to live. + """Path where ballistica expects its user scripts (mods) to live. Be aware that this value may be None if ballistica is running in a non-standard environment, and that python-path modifications may @@ -248,13 +249,14 @@ class App: self._app_paused = False self._subsystem_registration_ended = False self._pending_apply_app_config = False + self._shutdown_called = False # Config. self.config_file_healthy = False - # This is incremented any time the app is backgrounded/foregrounded; - # can be a simple way to determine if network data should be - # refreshed/etc. + # This is incremented any time the app is + # backgrounded/foregrounded; can be a simple way to determine if + # network data should be refreshed/etc. self.fg_state = 0 self._aioloop: asyncio.AbstractEventLoop | None = None @@ -273,9 +275,10 @@ class App: self.iircade_mode: bool = self._env['iircade_mode'] assert isinstance(self.iircade_mode, bool) - # Default executor which can be used for misc background processing. - # It should also be passed to any additional asyncio loops we create - # so that everything shares the same single set of worker threads. + # Default executor which can be used for misc background + # processing. It should also be passed to any additional asyncio + # loops we create so that everything shares the same single set + # of worker threads. self.threadpool = ThreadPoolExecutor(thread_name_prefix='baworker') self._config: babase.AppConfig | None = None @@ -288,10 +291,10 @@ class App: self._intent: AppIntent | None = None self._mode: AppMode | None = None - # Controls which app-modes we use for handling given app-intents. - # Plugins can override this to change high level app behavior and - # spinoff projects can change the default implementation for the - # same effect. + # Controls which app-modes we use for handling given + # app-intents. Plugins can override this to change high level + # app behavior and spinoff projects can change the default + # implementation for the same effect. self.mode_selector: AppModeSelector | None = None self._asyncio_timer: babase.AppTimer | None = None @@ -492,7 +495,7 @@ class App: self._app_bootstrapping_complete = True self._update_state() - def on_app_launching(self) -> None: + def _on_app_launching(self) -> None: """Called when the app enters the launching state. Here we can put together subsystems and other pieces for the @@ -520,8 +523,8 @@ class App: return # For now on other systems we just overwrite the bum config. - # At this point settings are already set; lets just commit them - # to disk. + # At this point settings are already set; lets just commit + # them to disk. _appconfig.commit_app_config(force=True) # __FEATURESET_APP_SUBSYSTEM_CREATE_BEGIN__ @@ -537,7 +540,7 @@ class App: self._launch_completed = True self._update_state() - def on_app_loading(self) -> None: + def _on_app_loading(self) -> None: """Called when the app enters the loading state. At this point, all built-in pieces of the app should be in place @@ -551,7 +554,7 @@ class App: assert _babase.in_logic_thread() # Get meta-system scanning built-in stuff in the bg. - self.meta.start_scan(scan_complete_cb=self.on_meta_scan_complete) + self.meta.start_scan(scan_complete_cb=self._on_meta_scan_complete) # If any traceback dumps happened last run, log and clear them. log_dumped_app_state() @@ -567,13 +570,13 @@ class App: 'Error in on_app_loading for subsystem %s.', subsystem ) - # Normally plus tells us when initial sign-in is done. If it's - # not present, however, we just do that ourself so we can + # Normally plus tells us when initial sign-in is done. If plus + # is not present, however, we just do it ourself so we can # proceed on to the running state. if self.plus is None: _babase.pushcall(self.on_initial_sign_in_completed) - def on_meta_scan_complete(self) -> None: + def _on_meta_scan_complete(self) -> None: """Called when meta-scan is done doing its thing.""" assert _babase.in_logic_thread() @@ -584,7 +587,7 @@ class App: self._meta_scan_completed = True self._update_state() - def on_app_running(self) -> None: + def _on_app_running(self) -> None: """Called when the app enters the running state. At this point, all workspaces, initial accounts, etc. are in place @@ -636,7 +639,8 @@ class App: _babase.lifecyclelog('apply-app-config') - # If multiple apply calls have been made, only actually apply once. + # If multiple apply calls have been made, only actually apply + # once. if not self._pending_apply_app_config: return @@ -701,15 +705,22 @@ class App: # pylint: disable=too-many-branches assert _babase.in_logic_thread() - if self._app_paused: + if self._shutdown_called: + # Entering shutdown state: + if self.state is not self.State.SHUTTING_DOWN: + self.state = self.State.SHUTTING_DOWN + _babase.lifecyclelog('app state shutting down') + self._on_app_shutdown() + + elif self._app_paused: # Entering paused state: if self.state is not self.State.PAUSED: self.state = self.State.PAUSED - self.on_app_pause() + self._on_app_pause() else: # Leaving paused state: if self.state is self.State.PAUSED: - self.on_app_resume() + self._on_app_resume() # Handle initially entering or returning to other states. if self._initial_sign_in_completed and self._meta_scan_completed: @@ -718,14 +729,14 @@ class App: _babase.lifecyclelog('app state running') if not self._called_on_app_running: self._called_on_app_running = True - self.on_app_running() + self._on_app_running() elif self._launch_completed: if self.state is not self.State.LOADING: self.state = self.State.LOADING _babase.lifecyclelog('app state loading') if not self._called_on_app_loading: self._called_on_app_loading = True - self.on_app_loading() + self._on_app_loading() else: # Only thing left is launching. We shouldn't be getting # called before at least that is complete. @@ -735,7 +746,7 @@ class App: _babase.lifecyclelog('app state launching') if not self._called_on_app_launching: self._called_on_app_launching = True - self.on_app_launching() + self._on_app_launching() def pause(self) -> None: """Should be called by the native layer when the app pauses.""" @@ -749,7 +760,12 @@ class App: self._app_paused = False self._update_state() - def on_app_pause(self) -> None: + def shutdown(self) -> None: + """Should be called by the native layer when the app wants to quit.""" + self._shutdown_called = True + self._update_state() + + def _on_app_pause(self) -> None: """Called when the app goes to a paused state.""" assert _babase.in_logic_thread() @@ -762,7 +778,7 @@ class App: 'Error in on_app_pause for subsystem %s.', subsystem ) - def on_app_resume(self) -> None: + def _on_app_resume(self) -> None: """Called when resuming.""" assert _babase.in_logic_thread() self.fg_state += 1 @@ -776,13 +792,12 @@ class App: 'Error in on_app_resume for subsystem %s.', subsystem ) - def on_app_shutdown(self) -> None: + def _on_app_shutdown(self) -> None: """(internal)""" assert _babase.in_logic_thread() - self.state = self.State.SHUTTING_DOWN - # Shutdown all app subsystems in the opposite order they were - # inited. + # Inform app subsystems that we're shutting down in the opposite + # order they were inited. for subsystem in reversed(self._subsystems): try: subsystem.on_app_shutdown() @@ -821,16 +836,16 @@ class App: """Callback to be run after initial sign-in (or lack thereof). This normally gets called by the plus subsystem. - This period includes things such as syncing account workspaces - or other data so it may take a substantial amount of time. - This should also run after a short amount of time if no login - has occurred. + The initial-sign-in process may include tasks such as syncing + account workspaces or other data so it may take a substantial + amount of time. This should also run after a short amount of + time if no login is occurring. """ assert _babase.in_logic_thread() assert not self._initial_sign_in_completed - # Tell meta it can start scanning extra stuff that just showed up - # (namely account workspaces). + # Tell meta it can start scanning extra stuff that just showed + # up (namely account workspaces). self.meta.start_extra_scan() self._initial_sign_in_completed = True diff --git a/src/assets/ba_data/python/babase/_hooks.py b/src/assets/ba_data/python/babase/_hooks.py index 8b35d67a..413a2310 100644 --- a/src/assets/ba_data/python/babase/_hooks.py +++ b/src/assets/ba_data/python/babase/_hooks.py @@ -301,7 +301,7 @@ def do_quit() -> None: def shutdown() -> None: - _babase.app.on_app_shutdown() + _babase.app.shutdown() def hash_strings(inputs: list[str]) -> str: diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index d020e38e..10c108cf 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 = 21215 +TARGET_BALLISTICA_BUILD = 21221 TARGET_BALLISTICA_VERSION = '1.7.26' @@ -476,7 +476,8 @@ def _modular_main() -> None: # Deal with a few key things here ourself before even running # configure. - # Extract stuff below modifies this so work with a copy. + # The extract_arg stuff below modifies this so we work with a + # copy. args = sys.argv.copy() # NOTE: We need to keep these arg long/short arg versions synced @@ -496,8 +497,8 @@ def _modular_main() -> None: mods_dir = extract_arg(args, ['--mods-dir', '-m'], is_dir=True) # We run configure() BEFORE importing babase. (part of its job - # is to wrangle paths to determine where babase and everything - # else gets loaded from). + # is to wrangle paths which can affect where babase and + # everything else gets loaded from). configure( config_dir=config_dir, data_dir=data_dir, diff --git a/src/ballistica/base/app/app.cc b/src/ballistica/base/app/app.cc index e76631fd..376f4f08 100644 --- a/src/ballistica/base/app/app.cc +++ b/src/ballistica/base/app/app.cc @@ -2,7 +2,6 @@ #include "ballistica/base/app/app.h" -#include "ballistica/base/app/stress_test.h" #include "ballistica/base/graphics/graphics_server.h" #include "ballistica/base/graphics/renderer/renderer.h" #include "ballistica/base/input/device/touch_input.h" @@ -12,6 +11,7 @@ #include "ballistica/base/networking/networking.h" #include "ballistica/base/platform/base_platform.h" #include "ballistica/base/support/stdio_console.h" +#include "ballistica/base/support/stress_test.h" #include "ballistica/base/ui/console.h" #include "ballistica/base/ui/ui.h" #include "ballistica/shared/foundation/event_loop.h" @@ -134,7 +134,7 @@ void App::LogicThreadShutdownComplete() { done_ = true; - // Kill our own event loop (or tell the OS to kill its). + // Flag our own event loop to exit (or tell the OS to do so for its own). if (ManagesEventLoop()) { event_loop()->Quit(); } else { @@ -147,28 +147,29 @@ void App::RunEvents() { stress_test_->Update(); // Give platforms a chance to pump/handle their own events. - // FIXME: now that we have app class overrides, platform should really - // not be doing event handling. (need to fix rift build). + // + // FIXME: now that we have app class overrides, platform should really not + // be doing event handling. (need to fix Rift build in this regard). g_core->platform->RunEvents(); } -void App::UpdatePauseResume() { +void App::UpdatePauseResume_() { if (actually_paused_) { // Unpause if no one wants pause. if (!sys_paused_app_) { - OnAppResume(); + OnAppResume_(); actually_paused_ = false; } } else { // OnAppPause if anyone wants. if (sys_paused_app_) { - OnAppPause(); + OnAppPause_(); actually_paused_ = true; } } } -void App::OnAppPause() { +void App::OnAppPause_() { assert(g_core->InMainThread()); // IMPORTANT: Any pause related stuff that event-loop-threads need to do @@ -186,7 +187,7 @@ void App::OnAppPause() { g_core->platform->OnAppPause(); } -void App::OnAppResume() { +void App::OnAppResume_() { assert(g_core->InMainThread()); last_app_resume_time_ = g_core->GetAppTimeMillisecs(); @@ -244,7 +245,7 @@ void App::PauseApp() { "PauseApp@" + std::to_string(core::CorePlatform::GetCurrentMillisecs())); assert(!sys_paused_app_); sys_paused_app_ = true; - UpdatePauseResume(); + UpdatePauseResume_(); // We assume that the OS will completely suspend our process the moment // we return from this call (though this is not technically true on all @@ -286,7 +287,7 @@ void App::ResumeApp() { "ResumeApp@" + std::to_string(core::CorePlatform::GetCurrentMillisecs())); assert(sys_paused_app_); sys_paused_app_ = false; - UpdatePauseResume(); + UpdatePauseResume_(); if (g_buildconfig.debug_build()) { Log(LogLevel::kDebug, "ResumeApp() completed in " diff --git a/src/ballistica/base/app/app.h b/src/ballistica/base/app/app.h index 73f98c69..d18de011 100644 --- a/src/ballistica/base/app/app.h +++ b/src/ballistica/base/app/app.h @@ -8,48 +8,44 @@ #include #include -#include "ballistica/base/app/stress_test.h" #include "ballistica/base/base.h" +#include "ballistica/base/support/stress_test.h" namespace ballistica::base { -/// Encapsulates high level app behavior based on platform, build type, or -/// other factors determined at launch. A single binary can support multiple -/// app-flavors (standard, vr, headless, etc.), but the app will always have -/// a single constant flavor for a given run. +/// Encapsulates high level app behavior for regular apps, vr apps, +/// headless apps, etc. class App { public: explicit App(EventLoop* event_loop); - /// Should be run after the instance is created and assigned. - /// Any setup that may trigger virtual methods or lookups via global - /// should go here. + /// Should be run after the instance is created and assigned. Any setup + /// that may trigger virtual methods or lookups via global should go here. void PostInit(); - /// Gets called when the app config is being applied. - /// Note that this call happens in the logic thread, so we should - /// do any reading that needs to happen in the logic thread and then - /// forward the values to ourself back in our main thread. + /// Gets called when the app config is being applied. Note that this call + /// happens in the logic thread, so we should do any reading that needs to + /// happen in the logic thread and then forward the values to ourself back + /// in our main thread. void DoLogicThreadApplyAppConfig(); - /// Return whether this class runs its own event loop. - /// If true, MonolithicMain() will continuously ask the app for events - /// until the app is quit, at which point MonolithicMain() returns. - /// If false, MonolithicMain returns immediately and it is assumed - /// that the OS handles the app lifecycle and pushes events to the app - /// via callbacks/etc. + /// Return whether this class runs its own event loop. If true, + /// MonolithicMain() will continuously ask the app for events until the + /// app is quit, at which point MonolithicMain() returns. If false, + /// MonolithicMain returns immediately and it is assumed that the OS + /// handles the app lifecycle and pushes events to the app via + /// callbacks/etc. auto ManagesEventLoop() const -> bool; - /// Called for non-event-loop apps to give them an opportunity to - /// ensure they are self-sustaining. For instance, an app relying on - /// frame-draws for its main thread event processing may need to - /// manually pump events until frame rendering begins. + /// Called for non-event-loop apps to give them an opportunity to ensure + /// they are self-sustaining. For instance, an app relying on frame-draws + /// for its main thread event processing may need to manually pump events + /// until frame rendering begins. virtual void PrimeMainThreadEventPump(); - /// Handle any pending OS events. - /// On normal graphical builds this is triggered by RunRenderUpkeepCycle(); - /// timer intervals for headless builds, etc. - /// Should process any pending OS events, etc. + /// Handle any pending OS events. On normal graphical builds this is + /// triggered by RunRenderUpkeepCycle(); timer intervals for headless + /// builds, etc. Should process any pending OS events, etc. virtual void RunEvents(); /// Put the app into a paused state. Should be called from the main @@ -62,8 +58,8 @@ class App { auto paused() const -> bool { return actually_paused_; } - /// OnAppResume the app; corresponds to returning to foreground on mobile/etc. - /// Spins threads back up, re-opens network sockets, etc. + /// OnAppResume the app; corresponds to returning to foreground on + /// mobile/etc. Spins threads back up, re-opens network sockets, etc. void ResumeApp(); /// The last time the app was resumed (uses GetAppTimeMillisecs() value). @@ -77,21 +73,20 @@ class App { /// Attempt to draw a frame. void DrawFrame(bool during_resize = false); - /// Run updates in the logic thread. Generally called once per frame rendered - /// or at some fixed rate for headless builds. + /// Run updates in the logic thread. Generally called once per frame + /// rendered or at some fixed rate for headless builds. void LogicThreadStepDisplayTime(); /// Used on platforms where our main thread event processing is driven by - /// frame-draw commands given to us. This should be called after drawing - /// a frame in order to bring game state up to date and process OS events. + /// frame-draw commands given to us. This should be called after drawing a + /// frame in order to bring game state up to date and process OS events. void RunRenderUpkeepCycle(); /// Called by the graphics-server when drawing completes for a frame. virtual void DidFinishRenderingFrame(FrameDef* frame); - /// Return the price of an IAP product as a human-readable string, - /// or an empty string if not found. - /// FIXME: move this to platform. + /// Return the price of an IAP product as a human-readable string, or an + /// empty string if not found. FIXME: move this to platform. auto GetProductPrice(const std::string& product) -> std::string; void SetProductPrice(const std::string& product, const std::string& price); @@ -124,15 +119,18 @@ class App { void PushPurchaseAckCall(const std::string& purchase, const std::string& order_id); auto event_loop() const -> EventLoop* { return event_loop_; } + + /// Called by the logic thread when all shutdown-related tasks are done + /// and it is safe to exit the main event loop. void LogicThreadShutdownComplete(); void LogicThreadOnAppRunning(); void LogicThreadOnInitialAppModeSet(); private: - void UpdatePauseResume(); - void OnAppPause(); - void OnAppResume(); + void UpdatePauseResume_(); + void OnAppPause_(); + void OnAppResume_(); EventLoop* event_loop_{}; bool done_{}; bool server_wrapper_managed_{}; diff --git a/src/ballistica/base/app/sdl_app.cc b/src/ballistica/base/app/app_sdl.cc similarity index 94% rename from src/ballistica/base/app/sdl_app.cc rename to src/ballistica/base/app/app_sdl.cc index 066921a1..edcc6b0a 100644 --- a/src/ballistica/base/app/sdl_app.cc +++ b/src/ballistica/base/app/app_sdl.cc @@ -2,9 +2,8 @@ #if BA_SDL_BUILD -#include "ballistica/base/app/sdl_app.h" +#include "ballistica/base/app/app_sdl.h" -#include "ballistica/base/app/stress_test.h" #include "ballistica/base/dynamics/bg/bg_dynamics.h" #include "ballistica/base/graphics/gl/gl_sys.h" #include "ballistica/base/graphics/graphics_server.h" @@ -12,6 +11,7 @@ #include "ballistica/base/input/input.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" +#include "ballistica/base/support/stress_test.h" #include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/python/python.h" @@ -20,7 +20,7 @@ namespace ballistica::base { // NOTE TO SELF: slowly try to phase everything out from here and into // non-sdl event/call pushes. -void SDLApp::HandleSDLEvent(const SDL_Event& event) { +void AppSDL::HandleSDLEvent(const SDL_Event& event) { assert(g_core->InMainThread()); switch (event.type) { @@ -236,7 +236,7 @@ auto FilterSDLEvent(const SDL_Event* event) -> int { try { // If this event is coming from this thread, handle it immediately. if (std::this_thread::get_id() == g_core->main_thread_id) { - auto app = static_cast_check_type(g_base->app); + auto app = static_cast_check_type(g_base->app); assert(app); if (app) { app->HandleSDLEvent(*event); @@ -260,9 +260,9 @@ inline auto FilterSDL2Event(void* user_data, SDL_Event* event) -> int { } #endif -// Note: can move this to SDLApp::SDLApp() once it is no longer needed by +// Note: can move this to AppSDL::AppSDL() once it is no longer needed by // the legacy mac build. -void SDLApp::InitSDL() { +void AppSDL::InitSDL() { assert(g_core); if (g_buildconfig.ostype_macos()) { @@ -287,8 +287,8 @@ void SDLApp::InitSDL() { // KILL THIS ONCE MAC SDL1.2 BUILD IS DEAD. // Register our hotplug callbacks in our funky custom mac build. #if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD - SDL_JoystickSetHotPlugCallbacks(SDLApp::SDLJoystickConnected, - SDLApp::SDLJoystickDisconnected); + SDL_JoystickSetHotPlugCallbacks(AppSDL::SDLJoystickConnected, + AppSDL::SDLJoystickDisconnected); #endif } } @@ -322,7 +322,7 @@ void SDLApp::InitSDL() { #endif } -SDLApp::SDLApp(EventLoop* event_loop) : App(event_loop) { +AppSDL::AppSDL(EventLoop* event_loop) : App(event_loop) { InitSDL(); // If we're not running our own even loop, we set up a filter to intercept @@ -351,7 +351,7 @@ SDLApp::SDLApp(EventLoop* event_loop) : App(event_loop) { } } -void SDLApp::RunEvents() { +void AppSDL::RunEvents() { App::RunEvents(); // Now run all pending SDL events until we run out or we're told to quit. @@ -361,12 +361,12 @@ void SDLApp::RunEvents() { } } -void SDLApp::DidFinishRenderingFrame(FrameDef* frame) { +void AppSDL::DidFinishRenderingFrame(FrameDef* frame) { App::DidFinishRenderingFrame(frame); SwapBuffers(); } -void SDLApp::DoSwap() { +void AppSDL::DoSwap() { assert(g_base->InGraphicsThread()); if (g_buildconfig.debug_build()) { @@ -413,7 +413,7 @@ void SDLApp::DoSwap() { last_swap_time_ = cur_time; } -void SDLApp::SwapBuffers() { +void AppSDL::SwapBuffers() { swap_start_time_ = g_core->GetAppTimeMillisecs(); assert(event_loop()->ThreadIsCurrent()); DoSwap(); @@ -431,7 +431,7 @@ void SDLApp::SwapBuffers() { } } -void SDLApp::UpdateAutoVSync(int diff) { +void AppSDL::UpdateAutoVSync(int diff) { assert(auto_vsync_); // If we're currently vsyncing, watch for slow frames. @@ -499,7 +499,7 @@ void SDLApp::UpdateAutoVSync(int diff) { } } -void SDLApp::SetAutoVSync(bool enable) { +void AppSDL::SetAutoVSync(bool enable) { auto_vsync_ = enable; // If we're doing auto, start with vsync on. if (enable) { @@ -510,7 +510,7 @@ void SDLApp::SetAutoVSync(bool enable) { } } -void SDLApp::OnMainThreadStartApp() { +void AppSDL::OnMainThreadStartApp() { App::OnMainThreadStartApp(); if (!g_core->HeadlessMode() && g_buildconfig.enable_sdl_joysticks()) { @@ -521,7 +521,7 @@ void SDLApp::OnMainThreadStartApp() { if (explicit_bool(true)) { int joystick_count = SDL_NumJoysticks(); for (int i = 0; i < joystick_count; i++) { - SDLApp::SDLJoystickConnected(i); + AppSDL::SDLJoystickConnected(i); } // We want events from joysticks. @@ -530,7 +530,7 @@ void SDLApp::OnMainThreadStartApp() { } } -void SDLApp::SDLJoystickConnected(int device_index) { +void AppSDL::SDLJoystickConnected(int device_index) { assert(g_core && g_core->InMainThread()); // We add all existing inputs when bootstrapping is complete; we should @@ -556,17 +556,17 @@ void SDLApp::SDLJoystickConnected(int device_index) { } } -void SDLApp::SDLJoystickDisconnected(int index) { +void AppSDL::SDLJoystickDisconnected(int index) { assert(g_core->InMainThread()); assert(index >= 0); get()->RemoveSDLInputDevice(index); } -void SDLApp::SetInitialScreenDimensions(const Vector2f& dimensions) { +void AppSDL::SetInitialScreenDimensions(const Vector2f& dimensions) { screen_dimensions_ = dimensions; } -void SDLApp::AddSDLInputDevice(JoystickInput* input, int index) { +void AppSDL::AddSDLInputDevice(JoystickInput* input, int index) { assert(g_base && g_base->input != nullptr); assert(input != nullptr); assert(g_core->InMainThread()); @@ -581,7 +581,7 @@ void SDLApp::AddSDLInputDevice(JoystickInput* input, int index) { g_base->input->PushAddInputDeviceCall(input, true); } -void SDLApp::RemoveSDLInputDevice(int index) { +void AppSDL::RemoveSDLInputDevice(int index) { assert(g_core->InMainThread()); assert(index >= 0); JoystickInput* j = GetSDLJoyStickInput(index); @@ -596,7 +596,7 @@ void SDLApp::RemoveSDLInputDevice(int index) { g_base->input->PushRemoveInputDeviceCall(j, true); } -auto SDLApp::GetSDLJoyStickInput(const SDL_Event* e) const -> JoystickInput* { +auto AppSDL::GetSDLJoyStickInput(const SDL_Event* e) const -> JoystickInput* { assert(g_core->InMainThread()); int joy_id; @@ -621,7 +621,7 @@ auto SDLApp::GetSDLJoyStickInput(const SDL_Event* e) const -> JoystickInput* { return GetSDLJoyStickInput(joy_id); } -auto SDLApp::GetSDLJoyStickInput(int sdl_joystick_id) const -> JoystickInput* { +auto AppSDL::GetSDLJoyStickInput(int sdl_joystick_id) const -> JoystickInput* { assert(g_core->InMainThread()); for (auto sdl_joystick : sdl_joysticks_) { if ((sdl_joystick != nullptr) && (*sdl_joystick).sdl_joystick_id() >= 0 diff --git a/src/ballistica/base/app/sdl_app.h b/src/ballistica/base/app/app_sdl.h similarity index 78% rename from src/ballistica/base/app/sdl_app.h rename to src/ballistica/base/app/app_sdl.h index 7584c4d4..14d6d518 100644 --- a/src/ballistica/base/app/sdl_app.h +++ b/src/ballistica/base/app/app_sdl.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_BASE_APP_SDL_APP_H_ -#define BALLISTICA_BASE_APP_SDL_APP_H_ +#ifndef BALLISTICA_BASE_APP_APP_SDL_H_ +#define BALLISTICA_BASE_APP_APP_SDL_H_ #if BA_SDL_BUILD @@ -12,10 +12,10 @@ namespace ballistica::base { -class SDLApp : public App { +class AppSDL : public App { public: static void InitSDL(); - explicit SDLApp(EventLoop* event_loop); + explicit AppSDL(EventLoop* event_loop); void HandleSDLEvent(const SDL_Event& event); void RunEvents() override; void DidFinishRenderingFrame(FrameDef* frame) override; @@ -24,12 +24,12 @@ class SDLApp : public App { static void SDLJoystickDisconnected(int index); void OnMainThreadStartApp() override; - /// Return g_base->app as a SDLApp. (assumes it actually is one). - static SDLApp* get() { + /// Return g_base->app as a AppSDL. (assumes it actually is one). + static AppSDL* get() { assert(g_base && g_base->app != nullptr); - assert(dynamic_cast(g_base->app) - == static_cast(g_base->app)); - return static_cast(g_base->app); + assert(dynamic_cast(g_base->app) + == static_cast(g_base->app)); + return static_cast(g_base->app); } void SetInitialScreenDimensions(const Vector2f& dimensions); @@ -63,4 +63,4 @@ class SDLApp : public App { #endif // BA_SDL_BUILD -#endif // BALLISTICA_BASE_APP_SDL_APP_H_ +#endif // BALLISTICA_BASE_APP_APP_SDL_H_ diff --git a/src/ballistica/base/app/app_vr.cc b/src/ballistica/base/app/app_vr.cc index 042a1de1..f9fd6a88 100644 --- a/src/ballistica/base/app/app_vr.cc +++ b/src/ballistica/base/app/app_vr.cc @@ -23,8 +23,8 @@ void AppVR::PushVRSimpleRemoteStateCall(const VRSimpleRemoteState& state) { s.l.tz = -0.3f; // Hmm; for now lets always assign this as right hand even when its in - // left-handed mode to keep things simple on the back-end. Can change later - // if there's a downside to that. + // left-handed mode to keep things simple on the back-end. Can change + // later if there's a downside to that. s.r.type = VRHandType::kDaydreamRemote; s.r.tx = 0.2f; s.r.ty = -0.2f; @@ -47,9 +47,9 @@ void AppVR::VRPreDraw() { } assert(g_base->InGraphicsThread()); if (FrameDef* frame_def = g_base->graphics_server->GetRenderFrameDef()) { - // Note: this could be part of PreprocessRenderFrameDef but - // the non-vr path needs it to be separate since preprocess doesn't - // happen sometimes. Should probably clean that up. + // Note: this could be part of PreprocessRenderFrameDef but the non-vr + // path needs it to be separate since preprocess doesn't happen + // sometimes. Should probably clean that up. g_base->graphics_server->RunFrameDefMeshUpdates(frame_def); // store this for the duration of this frame @@ -82,8 +82,8 @@ void AppVR::VRSetHead(float tx, float ty, float tz, float yaw, float pitch, void AppVR::VRSetHands(const VRHandsState& state) { assert(g_base->InGraphicsThread()); - // Pass this along to the renderer (in this same thread) for drawing - // (so hands can be drawn at their absolute most up-to-date positions, etc). + // Pass this along to the renderer (in this same thread) for drawing (so + // hands can be drawn at their absolute most up-to-date positions, etc). Renderer* renderer = g_base->graphics_server->renderer(); if (renderer == nullptr) { return; @@ -91,10 +91,10 @@ void AppVR::VRSetHands(const VRHandsState& state) { renderer->VRSetHands(state); // ALSO ship it off to the logic thread to actually handle input from it. + // // FIXME: This should get shipped to a logic or input variant once we have - // that for vr; not the graphics variant. - // Shipping it to the renderer above covers graphics needs in a lower - // latency way. + // that for vr; not the graphics variant. Shipping it to the renderer + // above covers graphics needs in a lower latency way. g_base->logic->event_loop()->PushCall( [state] { GraphicsVR::get()->set_vr_hands_state(state); }); } diff --git a/src/ballistica/base/app/app_mode.cc b/src/ballistica/base/app_mode/app_mode.cc similarity index 97% rename from src/ballistica/base/app/app_mode.cc rename to src/ballistica/base/app_mode/app_mode.cc index ff1c45c8..1aeaf6b2 100644 --- a/src/ballistica/base/app/app_mode.cc +++ b/src/ballistica/base/app_mode/app_mode.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/input/device/input_device_delegate.h" #include "ballistica/base/support/context.h" diff --git a/src/ballistica/base/app/app_mode.h b/src/ballistica/base/app_mode/app_mode.h similarity index 92% rename from src/ballistica/base/app/app_mode.h rename to src/ballistica/base/app_mode/app_mode.h index 69b26cd8..178f5fcf 100644 --- a/src/ballistica/base/app/app_mode.h +++ b/src/ballistica/base/app_mode/app_mode.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_BASE_APP_APP_MODE_H_ -#define BALLISTICA_BASE_APP_APP_MODE_H_ +#ifndef BALLISTICA_BASE_APP_MODE_APP_MODE_H_ +#define BALLISTICA_BASE_APP_MODE_APP_MODE_H_ #include @@ -19,9 +19,9 @@ const microsecs_t kAppModeMaxHeadlessDisplayStep{500000}; const microsecs_t kAppModeMinHeadlessDisplayStep{1000}; /// Represents 'what the app is doing'. The global app-mode can be switched -/// as the app is running. Be aware that, unlike the App/App classes -/// which operate in the main thread, most functionality here is based in the -/// logic thread. +/// as the app is running. Be aware that, unlike the App classes which +/// primarily operate in the main thread, most functionality here is based +/// in the logic thread. class AppMode { public: AppMode(); @@ -118,4 +118,4 @@ class AppMode { } // namespace ballistica::base -#endif // BALLISTICA_BASE_APP_APP_MODE_H_ +#endif // BALLISTICA_BASE_APP_MODE_APP_MODE_H_ diff --git a/src/ballistica/base/app/app_mode_empty.cc b/src/ballistica/base/app_mode/app_mode_empty.cc similarity index 88% rename from src/ballistica/base/app/app_mode_empty.cc rename to src/ballistica/base/app_mode/app_mode_empty.cc index a19e5c2e..9e65b2c7 100644 --- a/src/ballistica/base/app/app_mode_empty.cc +++ b/src/ballistica/base/app_mode/app_mode_empty.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/base/app/app_mode_empty.h" +#include "ballistica/base/app_mode/app_mode_empty.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/graphics/graphics.h" @@ -23,9 +23,9 @@ auto AppModeEmpty::GetSingleton() -> AppModeEmpty* { } void AppModeEmpty::Reset() { - // When we are first created (for use as a placeholder before any app-modes - // are set) we just draw nothing. However once we actually get reset for use - // as a an explicit app mode, we do our hello thing. + // When we are first created (for use as a placeholder before any + // app-modes are set) we just draw nothing. However once we actually get + // reset for use as a an explicit app mode, we do our hello thing. hello_mode_ = true; // Fade in if we currently aren't. @@ -37,7 +37,7 @@ void AppModeEmpty::DrawWorld(base::FrameDef* frame_def) { return; } - // Just draw our spinning hello text. + // Draw some lovely spinning text. if (!hello_text_group_.Exists()) { hello_text_group_ = Object::New(); hello_text_group_->set_text("Potato!"); diff --git a/src/ballistica/base/app/app_mode_empty.h b/src/ballistica/base/app_mode/app_mode_empty.h similarity index 55% rename from src/ballistica/base/app/app_mode_empty.h rename to src/ballistica/base/app_mode/app_mode_empty.h index 21c476b5..17c97b53 100644 --- a/src/ballistica/base/app/app_mode_empty.h +++ b/src/ballistica/base/app_mode/app_mode_empty.h @@ -1,15 +1,18 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_BASE_APP_APP_MODE_EMPTY_H_ -#define BALLISTICA_BASE_APP_APP_MODE_EMPTY_H_ +#ifndef BALLISTICA_BASE_APP_MODE_APP_MODE_EMPTY_H_ +#define BALLISTICA_BASE_APP_MODE_APP_MODE_EMPTY_H_ #include -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/shared/foundation/object.h" namespace ballistica::base { +/// An app-mode that doesn't do much of anything in particular. It is set as +/// a default when starting the app, but can also be used for 'hello world' +/// type stuff. class AppModeEmpty : public AppMode { public: AppModeEmpty(); @@ -25,4 +28,4 @@ class AppModeEmpty : public AppMode { } // namespace ballistica::base -#endif // BALLISTICA_BASE_APP_APP_MODE_EMPTY_H_ +#endif // BALLISTICA_BASE_APP_MODE_APP_MODE_EMPTY_H_ diff --git a/src/ballistica/base/assets/assets.cc b/src/ballistica/base/assets/assets.cc index 2f603a7b..0d19e03e 100644 --- a/src/ballistica/base/assets/assets.cc +++ b/src/ballistica/base/assets/assets.cc @@ -2,7 +2,7 @@ #include "ballistica/base/assets/assets.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/assets/assets_server.h" #include "ballistica/base/assets/collision_mesh_asset.h" #include "ballistica/base/assets/data_asset.h" diff --git a/src/ballistica/base/audio/audio.cc b/src/ballistica/base/audio/audio.cc index bd7f64d3..383b1477 100644 --- a/src/ballistica/base/audio/audio.cc +++ b/src/ballistica/base/audio/audio.cc @@ -2,10 +2,10 @@ #include "ballistica/base/audio/audio.h" -#include "ballistica/base/app/app_config.h" #include "ballistica/base/assets/sound_asset.h" #include "ballistica/base/audio/audio_server.h" #include "ballistica/base/audio/audio_source.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index 42da0575..a1816840 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -3,8 +3,7 @@ #include "ballistica/base/base.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_config.h" -#include "ballistica/base/app/app_mode_empty.h" +#include "ballistica/base/app_mode/app_mode_empty.h" #include "ballistica/base/assets/assets.h" #include "ballistica/base/assets/assets_server.h" #include "ballistica/base/audio/audio.h" @@ -22,6 +21,7 @@ #include "ballistica/base/python/base_python.h" #include "ballistica/base/python/class/python_class_feature_set_data.h" #include "ballistica/base/python/support/python_context_call.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/support/huffman.h" #include "ballistica/base/support/plus_soft.h" #include "ballistica/base/support/stdio_console.h" @@ -237,8 +237,8 @@ void BaseFeatureSet::LogVersionInfo() { void BaseFeatureSet::set_app_mode(AppMode* mode) { assert(InLogicThread()); - // Make an exception here for empty mode since that's in place before an - // app mode is officially set. + // Redundant sets should not happen (make an exception here for empty mode + // since that's in place before any app mode is officially set). if (mode == app_mode_ && mode != AppModeEmpty::GetSingleton()) { Log(LogLevel::kWarning, "set_app_mode called with already-current app-mode; unexpected."); diff --git a/src/ballistica/base/base.h b/src/ballistica/base/base.h index fd8d1c62..e467156f 100644 --- a/src/ballistica/base/base.h +++ b/src/ballistica/base/base.h @@ -99,7 +99,7 @@ class RenderTarget; class RemoteAppServer; class RemoteControlInput; class ScoreToBeat; -class SDLApp; +class AppSDL; class SDLContext; class SoundAsset; class SpriteMesh; @@ -688,7 +688,8 @@ class BaseFeatureSet : public FeatureSetNativeComponent, const std::string& arg) override; void OnReachedEndOfBaBaseImport(); - /// Called in the logic thread once our screen is up and assets are loading. + /// Called in the logic thread once our screen is up and assets are + /// loading. void OnAssetsAvailable(); // Const subsystems. diff --git a/src/ballistica/base/dynamics/collision_cache.cc b/src/ballistica/base/dynamics/collision_cache.cc index 2f005dc0..a063f743 100644 --- a/src/ballistica/base/dynamics/collision_cache.cc +++ b/src/ballistica/base/dynamics/collision_cache.cc @@ -192,8 +192,8 @@ void CollisionCache::CollideAgainstGeom(dGeomID g1, void* data, collideAABBs(g1, g2, data, callback); } - // While we're here, lets run one pass of tests on these cells to zero in on - // the actual collide/empty cutoff. + // While we're here, lets run one pass of tests on these cells to zero in + // on the actual collide/empty cutoff. for (int z = z_min; z <= z_max; z++) { int base_index = z * grid_width_; for (int x = x_min; x <= x_max; x++) { diff --git a/src/ballistica/base/dynamics/collision_cache.h b/src/ballistica/base/dynamics/collision_cache.h index 62eaa654..e6a77b87 100644 --- a/src/ballistica/base/dynamics/collision_cache.h +++ b/src/ballistica/base/dynamics/collision_cache.h @@ -10,8 +10,8 @@ namespace ballistica::base { -// Given geoms, creates/samples a height map on the fly -// which can be used for very fast AABB tests against the geometry. +// Given geoms, creates/samples a height map on the fly which can be used +// for very fast AABB tests against the geometry. class CollisionCache { public: CollisionCache(); @@ -23,8 +23,8 @@ class CollisionCache { void CollideAgainstSpace(dSpaceID space, void* data, dNearCallback* callback); void CollideAgainstGeom(dGeomID geom, void* data, dNearCallback* callback); - // Call this periodically (once per cycle or so) to slowly fill in - // the cache so there's less to do during spurts of activity; + // Call this periodically (once per sim step or so) to slowly fill in + // the cache so there's less to do during spurts of activity. void Precalc(); private: diff --git a/src/ballistica/base/graphics/gl/gl_sys.cc b/src/ballistica/base/graphics/gl/gl_sys.cc index ce1aed42..e1bc31a8 100644 --- a/src/ballistica/base/graphics/gl/gl_sys.cc +++ b/src/ballistica/base/graphics/gl/gl_sys.cc @@ -3,7 +3,7 @@ #if BA_ENABLE_OPENGL #include "ballistica/base/graphics/gl/gl_sys.h" -#include "ballistica/base/app/sdl_app.h" +#include "ballistica/base/app/app_sdl.h" #include "ballistica/base/base.h" #include "ballistica/core/core.h" @@ -149,7 +149,7 @@ GLContext::GLContext(int target_res_x, int target_res_y, bool fullscreen) // devices. int win_size_x, win_size_y; SDL_GetWindowSize(sdl_window_, &win_size_x, &win_size_y); - SDLApp::get()->SetInitialScreenDimensions(Vector2f( + AppSDL::get()->SetInitialScreenDimensions(Vector2f( static_cast(win_size_x), static_cast(win_size_y))); #if BA_OSTYPE_IOS_TVOS || BA_OSTYPE_ANDROID res_x_ = win_size_x; @@ -188,7 +188,7 @@ GLContext::GLContext(int target_res_x, int target_res_y, bool fullscreen) } res_x_ = surface_->w; res_y_ = surface_->h; - SDLApp::get()->SetInitialScreenDimensions(Vector2f(res_x_, res_y_)); + AppSDL::get()->SetInitialScreenDimensions(Vector2f(res_x_, res_y_)); SDL_WM_SetCaption("BallisticaKit", "BallisticaKit"); #elif BA_OSTYPE_ANDROID // On Android the Java layer creates a GL setup before even calling us. diff --git a/src/ballistica/base/graphics/graphics.cc b/src/ballistica/base/graphics/graphics.cc index 57e10ec4..6594897d 100644 --- a/src/ballistica/base/graphics/graphics.cc +++ b/src/ballistica/base/graphics/graphics.cc @@ -3,8 +3,7 @@ #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_config.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/dynamics/bg/bg_dynamics.h" #include "ballistica/base/graphics/component/empty_component.h" #include "ballistica/base/graphics/component/object_component.h" @@ -20,6 +19,7 @@ #include "ballistica/base/input/input.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/support/python_context_call.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/console.h" #include "ballistica/base/ui/ui.h" #include "ballistica/core/core.h" @@ -1116,8 +1116,8 @@ void Graphics::BuildAndPushFrameDef() { assert(!building_frame_def_); building_frame_def_ = true; - // We should not be building/pushing any frames until after - // app-launch-commands have been run. + // We should not be building/pushing any frames until the native + // layer is fully bootstrapped. BA_PRECONDITION_FATAL(g_base->logic->app_bootstrapping_complete()); // This should no longer be necessary.. diff --git a/src/ballistica/base/graphics/graphics_server.cc b/src/ballistica/base/graphics/graphics_server.cc index 8c21647c..8ca89292 100644 --- a/src/ballistica/base/graphics/graphics_server.cc +++ b/src/ballistica/base/graphics/graphics_server.cc @@ -8,7 +8,7 @@ // FIXME: clear out this conditional stuff. #if BA_SDL_BUILD -#include "ballistica/base/app/sdl_app.h" +#include "ballistica/base/app/app_sdl.h" #else #include "ballistica/base/app/app.h" #include "ballistica/base/assets/assets.h" @@ -799,12 +799,12 @@ void GraphicsServer::PushSetVSyncCall(bool sync, bool auto_sync) { #if BA_SDL_BUILD - // Currently only supported for SDLApp. + // Currently only supported for AppSDL. // May want to revisit this later. if (g_buildconfig.sdl_build()) { // Even if we were built with SDL, we may not be running in sdl-app-mode // (for instance, Rift in VR mode). Only do this if we're an sdl app. - if (auto app = dynamic_cast(g_base->app)) { + if (auto app = dynamic_cast(g_base->app)) { v_sync_ = sync; auto_vsync_ = auto_sync; if (gl_context_) { diff --git a/src/ballistica/base/input/device/input_device.cc b/src/ballistica/base/input/device/input_device.cc index a86a227a..df8fdbdb 100644 --- a/src/ballistica/base/input/device/input_device.cc +++ b/src/ballistica/base/input/device/input_device.cc @@ -86,7 +86,7 @@ void InputDevice::UpdateLastInputTime() { // the overall input system know something happened. last_input_time_millisecs_ = static_cast(g_base->logic->display_time() * 1000.0); - g_base->input->mark_input_active(); + g_base->input->MarkInputActive(); } void InputDevice::InputCommand(InputType type, float value) { diff --git a/src/ballistica/base/input/device/joystick_input.cc b/src/ballistica/base/input/device/joystick_input.cc index 4b769ed1..345b076a 100644 --- a/src/ballistica/base/input/device/joystick_input.cc +++ b/src/ballistica/base/input/device/joystick_input.cc @@ -3,7 +3,7 @@ #include "ballistica/base/input/device/joystick_input.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_mode.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/input/input.h" diff --git a/src/ballistica/base/input/device/touch_input.cc b/src/ballistica/base/input/device/touch_input.cc index 2aef6651..f677df22 100644 --- a/src/ballistica/base/input/device/touch_input.cc +++ b/src/ballistica/base/input/device/touch_input.cc @@ -2,11 +2,11 @@ #include "ballistica/base/input/device/touch_input.h" -#include "ballistica/base/app/app_config.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/graphics/support/camera.h" #include "ballistica/base/input/input.h" #include "ballistica/base/python/base_python.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/ui.h" namespace ballistica::base { diff --git a/src/ballistica/base/input/input.cc b/src/ballistica/base/input/input.cc index df7f669c..8d536254 100644 --- a/src/ballistica/base/input/input.cc +++ b/src/ballistica/base/input/input.cc @@ -2,8 +2,7 @@ #include "ballistica/base/input/input.h" -#include "ballistica/base/app/app_config.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/audio/audio.h" #include "ballistica/base/graphics/support/camera.h" #include "ballistica/base/input/device/joystick_input.h" @@ -12,6 +11,7 @@ #include "ballistica/base/input/device/touch_input.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/console.h" #include "ballistica/base/ui/ui.h" #include "ballistica/shared/foundation/event_loop.h" @@ -819,7 +819,7 @@ void Input::ProcessStressTesting(int player_count) { void Input::PushTextInputEvent(const std::string& text) { SafePushCall(__func__, [this, text] { - mark_input_active(); + MarkInputActive(); // Ignore if input is locked. if (IsInputLocked()) { @@ -854,7 +854,7 @@ void Input::HandleJoystickEvent(const SDL_Event& event, } // Make note that we're not idle. - mark_input_active(); + MarkInputActive(); // And that this particular device isn't idle either. input_device->UpdateLastInputTime(); @@ -909,7 +909,7 @@ void Input::ReleaseJoystickInput() { void Input::HandleKeyPress(const SDL_Keysym* keysym) { assert(g_base->InLogicThread()); - mark_input_active(); + MarkInputActive(); // Ignore all key presses if input is locked. if (IsInputLocked()) { @@ -1081,7 +1081,7 @@ void Input::HandleKeyRelease(const SDL_Keysym* keysym) { // Note: we want to let these through even if input is locked. - mark_input_active(); + MarkInputActive(); // If someone is capturing these events, give them a crack at it. if (keyboard_input_capture_release_) { @@ -1160,7 +1160,7 @@ void Input::HandleMouseScroll(const Vector2f& amount) { if (IsInputLocked()) { return; } - mark_input_active(); + MarkInputActive(); if (std::abs(amount.y) > 0.0001f) { g_base->ui->SendWidgetMessage( @@ -1194,7 +1194,7 @@ void Input::HandleSmoothMouseScroll(const Vector2f& velocity, bool momentum) { if (IsInputLocked()) { return; } - mark_input_active(); + MarkInputActive(); bool handled = false; handled = g_base->ui->SendWidgetMessage( @@ -1222,7 +1222,7 @@ void Input::PushMouseMotionEvent(const Vector2f& position) { void Input::HandleMouseMotion(const Vector2f& position) { assert(g_base->graphics); assert(g_base->InLogicThread()); - mark_input_active(); + MarkInputActive(); float old_cursor_pos_x = cursor_pos_x_; float old_cursor_pos_y = cursor_pos_y_; @@ -1285,7 +1285,7 @@ void Input::HandleMouseDown(int button, const Vector2f& position) { // return; // } - mark_input_active(); + MarkInputActive(); last_mouse_move_time_ = g_core->GetAppTimeMillisecs(); mouse_move_count_++; @@ -1350,7 +1350,7 @@ void Input::PushMouseUpEvent(int button, const Vector2f& position) { void Input::HandleMouseUp(int button, const Vector2f& position) { assert(g_base->InLogicThread()); - mark_input_active(); + MarkInputActive(); // Convert normalized view coords to our virtual ones. cursor_pos_x_ = g_base->graphics->PixelToVirtualX( @@ -1407,7 +1407,7 @@ void Input::HandleTouchEvent(const TouchEvent& e) { return; } - mark_input_active(); + MarkInputActive(); // float x = e.x; // float y = e.y; diff --git a/src/ballistica/base/input/input.h b/src/ballistica/base/input/input.h index 70fad87f..3d0a0877 100644 --- a/src/ballistica/base/input/input.h +++ b/src/ballistica/base/input/input.h @@ -96,7 +96,7 @@ class Input { // Should be called whenever user-input of some form comes through. // void ResetIdleTime() { last_input_time_ = GetAppTimeMillisecs(); } - auto mark_input_active() { input_active_ = true; } + auto MarkInputActive() { input_active_ = true; } // returns true if more than one non-keyboard device has been active recently // ..this is used to determine whether we need to have strict menu ownership diff --git a/src/ballistica/base/logic/logic.cc b/src/ballistica/base/logic/logic.cc index 9cb2f4a6..10c358f2 100644 --- a/src/ballistica/base/logic/logic.cc +++ b/src/ballistica/base/logic/logic.cc @@ -3,7 +3,7 @@ #include "ballistica/base/logic/logic.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/audio/audio.h" #include "ballistica/base/input/input.h" #include "ballistica/base/python/base_python.h" @@ -168,23 +168,33 @@ void Logic::DoApplyAppConfig() { void Logic::OnInitialScreenCreated() { assert(g_base->InLogicThread()); - // Ok; graphics-server is telling us we've got a screen - // (or no screen in the case of headless-mode). - // We use this as a cue to kick off our business logic. + // Ok; graphics-server is telling us we've got a screen (or no screen in + // the case of headless-mode). We use this as a cue to kick off our + // business logic. - // Let the Python layer know what's up. It will probably flip to - // 'Launching' state. + // Let the Python layer know the native layer is now fully functional. + // This will probably result in the Python layer flipping to the LAUNCHING + // state. CompleteAppBootstrapping(); - // Push an initial frame to the graphics thread. From this point it will be - // self-sustaining; sending us a request for a new one each time it receives - // one we send it. if (!g_core->HeadlessMode()) { + // In gui mode, push an initial frame to the graphics server. From this + // point it will be self-sustaining, sending us a frame request each + // time it receives a new frame from us. g_base->graphics->BuildAndPushFrameDef(); + } else { + // Normally we step display-time as part of our frame-drawing process. + // If we're headless, we're not drawing any frames, but we still want to + // do minimal processing on any display-time timers. Let's run at a + // low-ish rate (10hz) to keep things efficient. Anyone dealing in + // display-time should be able to handle a wide variety of rates anyway. + // NOTE: This length is currently milliseconds. + headless_display_time_step_timer_ = event_loop()->NewTimer( + kAppModeMinHeadlessDisplayStep / 1000, true, + NewLambdaRunnable([this] { StepDisplayTime(); })); } } -// Launch into main menu or whatever else. void Logic::CompleteAppBootstrapping() { assert(g_base->InLogicThread()); assert(g_base->CurrentContext().IsEmpty()); @@ -201,7 +211,7 @@ void Logic::CompleteAppBootstrapping() { // the renderer is ready and then seamlessly create renderer-specific // ones once the renderer is up. We could likely at least get a lot // of preloads done in the meantime. Though this would require preloads - // to be renderer-agnostic; not sure if that's the case. + // to be renderer-agnostic; not sure if that will always be the case. g_base->assets->StartLoading(); // Let base know it can create the console or other asset-dependent things. @@ -213,17 +223,6 @@ void Logic::CompleteAppBootstrapping() { asset_prune_timer_ = event_loop()->NewTimer( 2345, true, NewLambdaRunnable([] { g_base->assets->Prune(); })); - // Normally we step display-time as part of our frame-drawing process. If - // we're headless, we're not drawing any frames, but we still want to do - // minimal processing on any display-time timers. Let's run at a low-ish - // rate (10hz) to keep things efficient. Anyone dealing in display-time - // should be able to handle a wide variety of rates anyway. - if (g_core->HeadlessMode()) { - // NOTE: This length is currently milliseconds. - headless_display_time_step_timer_ = event_loop()->NewTimer( - kAppModeMinHeadlessDisplayStep / 1000, true, - NewLambdaRunnable([this] { StepDisplayTime(); })); - } // Let our initial app-mode know it has become active. g_base->app_mode()->OnActivate(); @@ -247,10 +246,10 @@ void Logic::OnScreenSizeChange(float virtual_width, float virtual_height, float pixel_width, float pixel_height) { assert(g_base->InLogicThread()); - // First, pass the new values to the graphics subsystem. - // Then inform everyone else simply that they changed; they can ask - // g_graphics for whatever specific values they need. - // Note: keep these in the same order as OnAppStart. + // First, pass the new values to the graphics subsystem. Then inform + // everyone else simply that they changed; they can ask g_graphics for + // whatever specific values they need. Note: keep these in the same order + // as OnAppStart. g_base->graphics->OnScreenSizeChange(virtual_width, virtual_height, pixel_width, pixel_height); g_base->audio->OnScreenSizeChange(); @@ -306,8 +305,8 @@ void Logic::StepDisplayTime() { void Logic::OnAppModeChanged() { assert(g_base->InLogicThread()); - // Kick our headless stepping into high gear; this will snap us out of - // any long sleep we're currently in the middle of. + // Kick our headless stepping into high gear; this will snap us out of any + // long sleep we're currently in the middle of. if (g_core->HeadlessMode()) { if (debug_log_display_time_) { Log(LogLevel::kDebug, @@ -322,13 +321,13 @@ void Logic::OnAppModeChanged() { void Logic::UpdateDisplayTimeForHeadlessMode() { assert(g_base->InLogicThread()); - // In this case we just keep display time synced up with app time; we don't - // care about keeping the increments smooth or consistent. + // In this case we just keep display time synced up with app time; we + // don't care about keeping the increments smooth or consistent. // The one thing we *do* try to do, however, is keep our timer length // updated so that we fire exactly when the app mode has events scheduled - // (or at least close enough so we can fudge it and tell them its that exact - // time). + // (or at least close enough so we can fudge it and tell them its that + // exact time). auto app_time_microsecs = g_core->GetAppTimeMicrosecs(); @@ -352,9 +351,9 @@ void Logic::UpdateDisplayTimeForHeadlessMode() { void Logic::PostUpdateDisplayTimeForHeadlessMode() { assert(g_base->InLogicThread()); - // At this point we've stepped our app-mode, so let's ask it how - // long we've got until the next event. We'll plug this into our - // display-update timer so we can try to sleep until that point. + // At this point we've stepped our app-mode, so let's ask it how long + // we've got until the next event. We'll plug this into our display-update + // timer so we can try to sleep until that point. auto headless_display_step_microsecs = std::max(std::min(g_base->app_mode()->GetHeadlessDisplayStep(), kAppModeMaxHeadlessDisplayStep), @@ -376,14 +375,14 @@ void Logic::PostUpdateDisplayTimeForHeadlessMode() { } void Logic::UpdateDisplayTimeForFrameDraw() { - // Here we update our smoothed display-time-increment based on how fast - // we are currently rendering frames. We want display-time to basically - // be progressing at the same rate as app-time but in as constant - // of a manner as possible so that animations, simulation-stepping/etc. - // appears smooth (app-time measurements at render times exhibit quite a bit - // of jitter). Though we also don't want it to be *too* smooth; drops in - // framerate should still be reflected quickly in display-time-increment - // otherwise it can look like the game is slowing down or speeding up. + // Here we update our smoothed display-time-increment based on how fast we + // are currently rendering frames. We want display-time to basically be + // progressing at the same rate as app-time but in as constant of a manner + // as possible so that animations, simulation-stepping/etc. appears smooth + // (app-time measurements at render times exhibit quite a bit of jitter). + // Though we also don't want it to be *too* smooth; drops in framerate + // should still be reflected quickly in display-time-increment otherwise + // it can look like the game is slowing down or speeding up. // Flip this on to debug this stuff. // Things to look for: @@ -417,9 +416,9 @@ void Logic::UpdateDisplayTimeForFrameDraw() { } // It seems that when things get thrown off it is often due to a single - // rogue sample being unusually long and often the next one being unusually - // short. Let's try to filter out some of these cases by ignoring both - // the longest and shortest sample in our set. + // rogue sample being unusually long and often the next one being + // unusually short. Let's try to filter out some of these cases by + // ignoring both the longest and shortest sample in our set. int max_index{}; int min_index{}; double max_val{recent_display_time_increments_[0]}; @@ -523,8 +522,8 @@ void Logic::UpdateDisplayTimeForFrameDraw() { void Logic::UpdatePendingWorkTimer() { assert(g_base->InLogicThread()); - // This might get called before we set up our timer in some cases. (such as - // very early) should be safe to ignore since we update the interval + // This might get called before we set up our timer in some cases. (such + // as very early) should be safe to ignore since we update the interval // explicitly after creating the timers. if (!process_pending_work_timer_) { return; @@ -535,7 +534,8 @@ void Logic::UpdatePendingWorkTimer() { assert(process_pending_work_timer_); process_pending_work_timer_->SetLength(1); } else { - // Otherwise we've got nothing to do; go to sleep until something changes. + // Otherwise we've got nothing to do; go to sleep until something + // changes. assert(process_pending_work_timer_); process_pending_work_timer_->SetLength(-1); } @@ -550,9 +550,9 @@ void Logic::HandleInterruptSignal() { return; } - // Go with a low level process shutdown here. In situations - // where we're getting interrupt signals I don't think we'd ever want - // high level 'soft' quits. + // Go with a low level process shutdown here. In situations where we're + // getting interrupt signals I don't think we'd ever want high level + // 'soft' quits. Shutdown(); } @@ -560,17 +560,18 @@ void Logic::Draw() { assert(g_base->InLogicThread()); assert(!g_core->HeadlessMode()); - // Push a snapshot of our current state to be rendered in the graphics thread. + // Push a snapshot of our current state to be rendered in the graphics + // thread. g_base->graphics->BuildAndPushFrameDef(); - // Now bring logic up to date. - // By doing this *after* fulfilling the draw request, we're minimizing the - // chance of long logic updates leading to delays in frame-def delivery - // leading to frame drops. The downside is that when logic updates are fast - // then logic is basically sitting around twiddling its thumbs and getting - // a full frame out of date before being drawn. But as high frame rates are - // becoming more normal this becomes less and less meaningful and its probably - // best to prioritize smooth visuals. + // Now bring logic up to date. By doing this *after* fulfilling the draw + // request, we're minimizing the chance of long logic updates leading to + // delays in frame-def delivery leading to frame drops. The downside is + // that when logic updates are fast then logic is basically sitting around + // twiddling its thumbs and getting a full frame out of date before being + // drawn. But as high frame rates are becoming more normal this becomes + // less and less meaningful and its probably best to prioritize smooth + // visuals. StepDisplayTime(); } diff --git a/src/ballistica/base/logic/logic.h b/src/ballistica/base/logic/logic.h index 6f2d539e..631085aa 100644 --- a/src/ballistica/base/logic/logic.h +++ b/src/ballistica/base/logic/logic.h @@ -49,6 +49,7 @@ class Logic { /// FIXME: I feel like this should be in one of the App classes. void Shutdown(); + /// Has CompleteAppBootstrapping been called? auto app_bootstrapping_complete() const { return app_bootstrapping_complete_; } diff --git a/src/ballistica/base/networking/network_reader.cc b/src/ballistica/base/networking/network_reader.cc index 6c0ab4ef..661499f9 100644 --- a/src/ballistica/base/networking/network_reader.cc +++ b/src/ballistica/base/networking/network_reader.cc @@ -2,7 +2,7 @@ #include "ballistica/base/networking/network_reader.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/input/support/remote_app_server.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" diff --git a/src/ballistica/base/networking/networking.cc b/src/ballistica/base/networking/networking.cc index a7a4927a..7bdd1e76 100644 --- a/src/ballistica/base/networking/networking.cc +++ b/src/ballistica/base/networking/networking.cc @@ -3,8 +3,8 @@ #include "ballistica/base/networking/networking.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_config.h" #include "ballistica/base/networking/network_reader.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/networking/sockaddr.h" diff --git a/src/ballistica/base/platform/base_platform.cc b/src/ballistica/base/platform/base_platform.cc index 38fb3f81..3750a9cc 100644 --- a/src/ballistica/base/platform/base_platform.cc +++ b/src/ballistica/base/platform/base_platform.cc @@ -25,7 +25,7 @@ #endif #include "ballistica/base/app/app.h" -#include "ballistica/base/app/sdl_app.h" +#include "ballistica/base/app/app_sdl.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/graphics/graphics_vr.h" @@ -113,7 +113,7 @@ auto BasePlatform::CreateApp() -> App* { // TEMP - need to init sdl on our legacy mac build even though its not // technically an SDL app. Kill this once the old mac build is gone. #if BA_LEGACY_MACOS_BUILD - SDLApp::InitSDL(); + AppSDL::InitSDL(); #endif App* app{}; @@ -125,12 +125,12 @@ auto BasePlatform::CreateApp() -> App* { if (g_core->vr_mode) { app = new AppVR(g_core->main_event_loop()); } else { - app = new SDLApp(g_core->main_event_loop()); + app = new AppSDL(g_core->main_event_loop()); } #elif BA_CARDBOARD_BUILD app = new AppVR(g_core->main_event_loop()); #elif BA_SDL_BUILD - app = new SDLApp(g_core->main_event_loop()); + app = new AppSDL(g_core->main_event_loop()); #else app = new App(g_core->main_event_loop()); #endif diff --git a/src/ballistica/base/python/methods/python_methods_app.cc b/src/ballistica/base/python/methods/python_methods_app.cc index 6e8be733..34e4a23f 100644 --- a/src/ballistica/base/python/methods/python_methods_app.cc +++ b/src/ballistica/base/python/methods/python_methods_app.cc @@ -3,8 +3,8 @@ #include "ballistica/base/python/methods/python_methods_app.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_mode.h" -#include "ballistica/base/app/app_mode_empty.h" +#include "ballistica/base/app_mode/app_mode.h" +#include "ballistica/base/app_mode/app_mode_empty.h" #include "ballistica/base/graphics/graphics_server.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" diff --git a/src/ballistica/base/python/methods/python_methods_misc.cc b/src/ballistica/base/python/methods/python_methods_misc.cc index 07a6a0f8..0361aef0 100644 --- a/src/ballistica/base/python/methods/python_methods_misc.cc +++ b/src/ballistica/base/python/methods/python_methods_misc.cc @@ -5,13 +5,13 @@ #include #include -#include "ballistica/base/app/app_config.h" #include "ballistica/base/assets/assets.h" #include "ballistica/base/assets/sound_asset.h" #include "ballistica/base/input/input.h" #include "ballistica/base/platform/base_platform.h" #include "ballistica/base/python/base_python.h" #include "ballistica/base/python/class/python_class_simple_sound.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/ui.h" #include "ballistica/shared/generic/utils.h" diff --git a/src/ballistica/base/app/app_config.cc b/src/ballistica/base/support/app_config.cc similarity index 99% rename from src/ballistica/base/app/app_config.cc rename to src/ballistica/base/support/app_config.cc index fcac66f0..e52dc466 100644 --- a/src/ballistica/base/app/app_config.cc +++ b/src/ballistica/base/support/app_config.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/base/app/app_config.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/python/base_python.h" #include "ballistica/core/core.h" diff --git a/src/ballistica/base/app/app_config.h b/src/ballistica/base/support/app_config.h similarity index 96% rename from src/ballistica/base/app/app_config.h rename to src/ballistica/base/support/app_config.h index d27e7786..b819b3e5 100644 --- a/src/ballistica/base/app/app_config.h +++ b/src/ballistica/base/support/app_config.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_BASE_APP_APP_CONFIG_H_ -#define BALLISTICA_BASE_APP_APP_CONFIG_H_ +#ifndef BALLISTICA_BASE_SUPPORT_APP_CONFIG_H_ +#define BALLISTICA_BASE_SUPPORT_APP_CONFIG_H_ #include #include @@ -139,4 +139,4 @@ class AppConfig { } // namespace ballistica::base -#endif // BALLISTICA_BASE_APP_APP_CONFIG_H_ +#endif // BALLISTICA_BASE_SUPPORT_APP_CONFIG_H_ diff --git a/src/ballistica/base/support/stdio_console.cc b/src/ballistica/base/support/stdio_console.cc index cb517419..6e1c830f 100644 --- a/src/ballistica/base/support/stdio_console.cc +++ b/src/ballistica/base/support/stdio_console.cc @@ -5,7 +5,7 @@ #include #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/support/context.h" #include "ballistica/core/platform/core_platform.h" diff --git a/src/ballistica/base/app/stress_test.cc b/src/ballistica/base/support/stress_test.cc similarity index 98% rename from src/ballistica/base/app/stress_test.cc rename to src/ballistica/base/support/stress_test.cc index e35da034..0438e972 100644 --- a/src/ballistica/base/app/stress_test.cc +++ b/src/ballistica/base/support/stress_test.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/base/app/stress_test.h" +#include "ballistica/base/support/stress_test.h" #include "ballistica/base/graphics/graphics_server.h" #include "ballistica/base/graphics/renderer/renderer.h" diff --git a/src/ballistica/base/app/stress_test.h b/src/ballistica/base/support/stress_test.h similarity index 75% rename from src/ballistica/base/app/stress_test.h rename to src/ballistica/base/support/stress_test.h index 7ad13129..6da0ec7b 100644 --- a/src/ballistica/base/app/stress_test.h +++ b/src/ballistica/base/support/stress_test.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_BASE_APP_STRESS_TEST_H_ -#define BALLISTICA_BASE_APP_STRESS_TEST_H_ +#ifndef BALLISTICA_BASE_SUPPORT_STRESS_TEST_H_ +#define BALLISTICA_BASE_SUPPORT_STRESS_TEST_H_ #include "ballistica/shared/ballistica.h" @@ -22,4 +22,4 @@ class StressTest { } // namespace ballistica::base -#endif // BALLISTICA_BASE_APP_STRESS_TEST_H_ +#endif // BALLISTICA_BASE_SUPPORT_STRESS_TEST_H_ diff --git a/src/ballistica/base/ui/console.cc b/src/ballistica/base/ui/console.cc index c519c896..9809c92c 100644 --- a/src/ballistica/base/ui/console.cc +++ b/src/ballistica/base/ui/console.cc @@ -2,7 +2,7 @@ #include "ballistica/base/ui/console.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/audio/audio.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/graphics/text/text_graphics.h" diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index 3f166c1e..daf674fe 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -2,12 +2,12 @@ #include "ballistica/base/ui/ui.h" -#include "ballistica/base/app/app_config.h" #include "ballistica/base/audio/audio.h" #include "ballistica/base/input/device/keyboard_input.h" #include "ballistica/base/input/input.h" #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/support/ui_v1_soft.h" #include "ballistica/base/ui/console.h" #include "ballistica/shared/foundation/event_loop.h" @@ -147,17 +147,17 @@ void UI::PushBackButtonCall(InputDevice* input_device) { } else { // If there's no main screen or overlay windows, ask for a menu owned by // this device. - MainMenuPress(input_device); + MainMenuPress_(input_device); } }); } void UI::PushMainMenuPressCall(InputDevice* device) { g_base->logic->event_loop()->PushCall( - [this, device] { MainMenuPress(device); }); + [this, device] { MainMenuPress_(device); }); } -void UI::MainMenuPress(InputDevice* device) { +void UI::MainMenuPress_(InputDevice* device) { assert(g_base->InLogicThread()); if (g_base->HaveUIV1()) { g_base->ui_v1()->DoHandleDeviceMenuPress(device); diff --git a/src/ballistica/base/ui/ui.h b/src/ballistica/base/ui/ui.h index 800d2f28..f1d0dae3 100644 --- a/src/ballistica/base/ui/ui.h +++ b/src/ballistica/base/ui/ui.h @@ -10,9 +10,9 @@ #include "ballistica/base/ui/widget_message.h" #include "ballistica/shared/generic/timer_list.h" -// UI-Locks: make sure widget-lists don't change under you. -// Use a read-lock if you just need to ensure lists remain intact but won't be -// changing anything. Use a write-lock whenever modifying a list. +// UI-Locks: make sure widget-lists don't change under you. Use a read-lock +// if you just need to ensure lists remain intact but won't be changing +// anything. Use a write-lock whenever modifying a list. #if BA_DEBUG_BUILD #define BA_DEBUG_UI_READ_LOCK ::ballistica::base::UI::UILock ui_lock(false) #define BA_DEBUG_UI_WRITE_LOCK ::ballistica::base::UI::UILock ui_lock(true) @@ -30,7 +30,8 @@ class Widget; namespace ballistica::base { -// Our global UI subsystem. This wrangles all app +// Our global UI subsystem. This acts as a manager/wrapper for individual UI +// feature-sets that provide specific UI functionality. class UI { public: UI(); @@ -47,12 +48,12 @@ class UI { void Reset(); - /// Pop up an in-game window to show a url (NOT in a browser). - /// Can be called from any thread. + /// Pop up an in-app window to show a url (NOT in a browser). Can be + /// called from any thread. void ShowURL(const std::string& url); - /// High level call to request a quit ui (or in some cases quit immediately). - /// This can be called from any thread. + /// High level call to request a quit ui (or in some cases quit + /// immediately). This can be called from any thread. void ConfirmQuit(); /// Return whether there is UI present in either the main or overlay @@ -67,9 +68,9 @@ class UI { void Draw(FrameDef* frame_def); - // Returns the widget an input should send commands to, if any. - // Also potentially locks other inputs out of controlling the UI, - // so only call this if you intend on sending a message to that widget. + // Returns the widget an input should send commands to, if any. Also + // potentially locks other inputs out of controlling the UI, so only call + // this if you intend on sending a message to that widget. auto GetWidgetForInput(InputDevice* input_device) -> ui_v1::Widget*; // Send message to the active widget. @@ -77,18 +78,19 @@ class UI { void SetUIInputDevice(InputDevice* input_device); - // Returns the input-device that currently owns the menu; otherwise nullptr. + // Returns the input-device that currently owns the menu; otherwise + // nullptr. auto GetUIInputDevice() const -> InputDevice*; void PushBackButtonCall(InputDevice* input_device); - // Returns whether currently selected widgets should flash. - // This will be false in some situations such as when only touch screen - // control is active. + // Returns whether currently selected widgets should flash. This will be + // false in some situations such as when only touch screen control is + // active. auto ShouldHighlightWidgets() const -> bool; - // Same except for button shortcuts; these generally only get shown - // if a joystick of some form is present. + // Same except for button shortcuts; these generally only get shown if a + // joystick of some form is present. auto ShouldShowButtonShortcuts() const -> bool; // Used to ensure widgets are not created or destroyed at certain times @@ -111,7 +113,7 @@ class UI { void PushMainMenuPressCall(InputDevice* device); private: - void MainMenuPress(InputDevice* device); + void MainMenuPress_(InputDevice* device); Object::WeakRef ui_input_device_; millisecs_t last_input_device_use_time_{}; millisecs_t last_widget_input_reject_err_sound_time_{}; diff --git a/src/ballistica/classic/README.md b/src/ballistica/classic/README.md index ad2e6be1..0aa8feb9 100644 --- a/src/ballistica/classic/README.md +++ b/src/ballistica/classic/README.md @@ -1,4 +1,4 @@ # Classic Feature Set -This feature set contains bits which are required to keep old functionality going -but which should not generally be used for new features. \ No newline at end of file +This feature set contains bits which are required to keep old functionality +going but which should not generally be used for new features. diff --git a/src/ballistica/core/README.md b/src/ballistica/core/README.md index f54be9f2..c0bdda27 100644 --- a/src/ballistica/core/README.md +++ b/src/ballistica/core/README.md @@ -3,13 +3,14 @@ This feature set contains basic state and functionality for the overall Ballistica system. -**Core** is a unique feature set in that it is *not* associated with a Python module. -It instead directly allocates and/or returns itself when its `Import()` method is -called in C++. +**Core** is a unique feature set in that it is *not* associated with a Python +module. It instead directly allocates and/or returns itself when its `Import()` +method is called in C++. -This is because, in 'monolithic' builds (where a complete Ballistica app is compiled into -a single binary), **core** itself is responsible for bootstrapping the Python environment. -One can't import something through Python when there's no Python. +This is because, in 'monolithic' builds (where a complete Ballistica app is +compiled into a single binary), **core** itself is responsible for bootstrapping +the Python environment. One can't import something through Python when there's +no Python. -So the purpose of **core** is to be the bare minimum functionality that needs to exist -to bootstrap Python. \ No newline at end of file +So the purpose of **core** is to be the bare minimum functionality that needs to +exist to bootstrap Python. diff --git a/src/ballistica/core/core.h b/src/ballistica/core/core.h index cc9e90a0..e1715e14 100644 --- a/src/ballistica/core/core.h +++ b/src/ballistica/core/core.h @@ -62,6 +62,7 @@ class CoreFeatureSet { /// ensure we don't hang indefinitely. void StartSuicideTimer(const std::string& action, millisecs_t delay); + /// Apply the config set up by baenv to the engine. void ApplyBaEnvConfig(); // Call this if the main thread changes. diff --git a/src/ballistica/plus/README.md b/src/ballistica/plus/README.md index fcb16a64..fabdf2cc 100644 --- a/src/ballistica/plus/README.md +++ b/src/ballistica/plus/README.md @@ -1,6 +1,8 @@ # Plus Feature Set -Bits of the engine related to accounts and cloud functionality. In prefab builds -the compiled code for this feature set is contained in the pre-compiled static -ballisticaplus library. The plus feature set can also be removed from -spinoff projects if desired to remove the need for that library. +Bits of the engine related to things like Ballistica accounts and cloud +functionality. Due to its sensitive nature, source code to this part of the +engine is not available publicly. It is instead distributed as precompiled +static libraries which can be linked in with the rest of the open sourced +engine. The Plus feature can be removed from spinoff projects in order to create +a 100% open-source project. diff --git a/src/ballistica/scene_v1/README.md b/src/ballistica/scene_v1/README.md index 9f2718be..75c3cdb0 100644 --- a/src/ballistica/scene_v1/README.md +++ b/src/ballistica/scene_v1/README.md @@ -1,3 +1,4 @@ # Scene V1 Feature Set -Gameplay code for classic BombSquad +Gameplay code for classic BombSquad, as well as app-modes and other support +classes required to use it. diff --git a/src/ballistica/scene_v1/support/scene_v1_app_mode.cc b/src/ballistica/scene_v1/support/scene_v1_app_mode.cc index 8871c393..750c1e24 100644 --- a/src/ballistica/scene_v1/support/scene_v1_app_mode.cc +++ b/src/ballistica/scene_v1/support/scene_v1_app_mode.cc @@ -2,7 +2,6 @@ #include "ballistica/scene_v1/support/scene_v1_app_mode.h" -#include "ballistica/base/app/app_config.h" #include "ballistica/base/assets/assets.h" #include "ballistica/base/audio/audio.h" #include "ballistica/base/audio/audio_source.h" @@ -10,6 +9,7 @@ #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/support/app_config.h" #include "ballistica/base/support/plus_soft.h" #include "ballistica/base/ui/ui.h" #include "ballistica/core/platform/core_platform.h" diff --git a/src/ballistica/scene_v1/support/scene_v1_app_mode.h b/src/ballistica/scene_v1/support/scene_v1_app_mode.h index eb94e343..9d0b2b54 100644 --- a/src/ballistica/scene_v1/support/scene_v1_app_mode.h +++ b/src/ballistica/scene_v1/support/scene_v1_app_mode.h @@ -10,7 +10,7 @@ #include #include -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/base.h" #include "ballistica/scene_v1/scene_v1.h" #include "ballistica/shared/foundation/object.h" diff --git a/src/ballistica/scene_v1/support/scene_v1_context.cc b/src/ballistica/scene_v1/support/scene_v1_context.cc index 28f4f930..d4f8f9c5 100644 --- a/src/ballistica/scene_v1/support/scene_v1_context.cc +++ b/src/ballistica/scene_v1/support/scene_v1_context.cc @@ -2,7 +2,7 @@ #include "ballistica/scene_v1/support/scene_v1_context.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/scene_v1/support/host_activity.h" #include "ballistica/shared/generic/runnable.h" #include "ballistica/shared/python/python_sys.h" diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index b9d00891..a6983b4e 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 = 21215; +const int kEngineBuildNumber = 21221; const char* kEngineVersion = "1.7.26"; #if BA_MONOLITHIC_BUILD 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 979df1e3..29b65a6d 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 @@ -3,7 +3,7 @@ #include "ballistica/ui_v1/python/methods/python_methods_ui_v1.h" #include "ballistica/base/app/app.h" -#include "ballistica/base/app/app_mode.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/python/base_python.h" diff --git a/src/ballistica/ui_v1/support/root_ui.cc b/src/ballistica/ui_v1/support/root_ui.cc index 483a6da8..e6952aba 100644 --- a/src/ballistica/ui_v1/support/root_ui.cc +++ b/src/ballistica/ui_v1/support/root_ui.cc @@ -2,7 +2,7 @@ #include "ballistica/ui_v1/support/root_ui.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/input/device/keyboard_input.h" #include "ballistica/base/input/device/touch_input.h" diff --git a/src/ballistica/ui_v1/ui_v1.cc b/src/ballistica/ui_v1/ui_v1.cc index d0c8f3c0..c5d40412 100644 --- a/src/ballistica/ui_v1/ui_v1.cc +++ b/src/ballistica/ui_v1/ui_v1.cc @@ -2,11 +2,11 @@ #include "ballistica/ui_v1/ui_v1.h" -#include "ballistica/base/app/app_config.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/graphics/component/empty_component.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/input/input.h" +#include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/ui.h" #include "ballistica/ui_v1/python/ui_v1_python.h" #include "ballistica/ui_v1/support/root_ui.h" diff --git a/src/ballistica/ui_v1/widget/root_widget.cc b/src/ballistica/ui_v1/widget/root_widget.cc index 280e29ed..1fcbdd15 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -2,7 +2,7 @@ #include "ballistica/ui_v1/widget/root_widget.h" -#include "ballistica/base/app/app_mode.h" +#include "ballistica/base/app_mode/app_mode.h" #include "ballistica/base/graphics/renderer/renderer.h" #include "ballistica/base/ui/ui.h" #include "ballistica/ui_v1/python/ui_v1_python.h"