From 84dde1bcf075793e5c75de8bea770c5514fb608a Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 30 May 2023 14:28:47 -0700 Subject: [PATCH] more untangling --- .efrocachemap | 88 ++++++++--------- CHANGELOG.md | 2 +- src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/base/base.cc | 95 +++++++++++++++---- src/ballistica/base/base.h | 44 +++++---- .../base/input/device/joystick_input.cc | 75 ++++++++------- .../base/input/device/keyboard_input.cc | 22 ++--- src/ballistica/base/logic/logic.cc | 14 +-- src/ballistica/base/python/base_python.cc | 20 ++++ src/ballistica/base/python/base_python.h | 2 + src/ballistica/base/support/classic_soft.h | 5 + src/ballistica/base/support/ui_v1_soft.h | 6 ++ src/ballistica/base/ui/ui.cc | 16 ++-- src/ballistica/classic/classic.cc | 15 ++- src/ballistica/classic/classic.h | 4 + src/ballistica/classic/support/v1_account.cc | 2 +- src/ballistica/core/core.cc | 5 +- src/ballistica/core/core.h | 1 + .../connection/connection_to_client.cc | 2 +- .../scene_v1/connection/connection_to_host.cc | 4 +- .../python/methods/python_methods_scene.cc | 2 +- .../scene_v1/support/scene_v1_app_mode.cc | 14 +-- .../support/scene_v1_input_device_delegate.cc | 2 +- src/ballistica/shared/ballistica.cc | 2 +- .../python/methods/python_methods_ui_v1.cc | 8 +- src/ballistica/ui_v1/ui_v1.cc | 7 +- src/ballistica/ui_v1/ui_v1.h | 1 + 27 files changed, 294 insertions(+), 166 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 5efb04f7..5464acd4 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4072,50 +4072,50 @@ "build/assets/workspace/ninjafightplug.py": "https://files.ballistica.net/cache/ba1/c5/09/4f10b8a21ba87aa5509cff7a164b", "build/assets/workspace/onslaughtplug.py": "https://files.ballistica.net/cache/ba1/ff/0a/a354984f9c074dab0676ac7e4877", "build/assets/workspace/runaroundplug.py": "https://files.ballistica.net/cache/ba1/2a/1c/9ee5db6d1bceca7fa6638fb8abde", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/26/28/76adeaf883a0ce33dffdf2940d5b", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/62/f6/bf633c2dc38d61b73b8109cc002b", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d1/5b/7ce29036b8eae3226fa440761b11", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8e/f4/5fd5e80bec1d9bda19f43932400a", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/b7/62/e50ab9f38db10874d32715c11e29", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/90/86/fc717a6aab51a451313da677a630", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/85/e3/72d4977a7238491402788eecc44d", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/46/be/0ca1d581bee963f3f2adc30bbdbc", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/5b/a4/68472d57ebe52dd72db1a78a302d", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/49/78f788f23a025707360b23d7daf3", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/7b/f3/3e0101776643cff6bdbd3bbb089f", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/81/6a/6784af212260aef7375936705d08", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/3b/5a/fd4873250526f81d98acf374face", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/e5/3554a91085d6c99cf4225991a49b", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/6c/7a/0a43c1a584fae923c7f9b006aa00", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d8/6e/b6c78fd05b4082a56101251d80a7", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/a0/10/73c560964fcc4834ab4d383166d7", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/de/46/fb9e06c434c2a4a2f9ef5b559d1b", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/f9/c2/634df05be8abea32da3e8ca3095e", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/76/16/8c323c36f0e5d37c667b78f6e164", - "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/5f/35/b7d5e6c2446f339bdd61527ea735", - "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/f8/52577356f2ff5229ed4e5a6764cf", - "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f1/f5/ee7230a33652160f1a69d37d0b1d", - "build/prefab/lib/linux_arm64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/3f/91/9d57b5688d3fdedc41ad0a91cfcc", - "build/prefab/lib/linux_x86_64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/3b/a8/25df998ef2e458e4b3df4f9e4bc3", - "build/prefab/lib/linux_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/40/35/f0ce16f78cb98281471dc4fb1048", - "build/prefab/lib/linux_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/d3/f6/9b895fa7a559163f3ba301a5b082", - "build/prefab/lib/linux_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b6/e7/1d76994d633f5e189754b477da1d", - "build/prefab/lib/mac_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/fb/7b/7a6549bb17264a5040d4db99a4cc", - "build/prefab/lib/mac_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/eb/ab/4311e83907061aad56967531f41b", - "build/prefab/lib/mac_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/85/0f/8d444fa4c7774c1c93d7b863ff59", - "build/prefab/lib/mac_arm64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/e6/c2/f5c2b4284534e68f6e41a4b4b2ca", - "build/prefab/lib/mac_x86_64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/0d/d2/f99384c5c22ae99e0a70b7d2534a", - "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/30/4a/aa281e0eb46722098ec29d7da4f8", - "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/0b/e4/a9d278c1bc9a5d731f865ac91a0b", - "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/92/f7/8898478ab4ef0a342c727dd64195", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/54/37/fe9ce1e5ac553d1efbfe87f0b3db", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/14/9b/9339463649a9c9c4f5a17c8612c9", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/33/6a/1b57410d2fb4b0537ecec3648850", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/6d/f9/b35d9ebe3503c3f24cf6774d5458", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/de/ff/32c6e83e91a48cd9500d710ab1af", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/1f/7e/b8cf9ad9f8cd86a292e1609fdd93", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/19/7f/fa2c37a849648ada4bbaa4c826d4", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/65/32/b571911edfbbffa5263a29dbece2", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/22/34/9c6e311971f0e3fa8e54c8daa246", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fb/d6/98273d4900876df499ce3eeaf361", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/6f/0b/d133fa30c71b55fe9a74fc1566c8", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ff/d8/35c664ca3240e987b1583ba4dd45", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/01/97/93c7102a60ba833bb72b2c8a2d54", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/3f/4f/25171f50ccbd6ac79176b5b5fef3", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ea/d9/728e18ae1bab507f0c945eb1c655", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/75/f3/ddb8deb5bde3812552eb3d36f71f", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/be/e8/ad05d8293f0bdaa2c08fd0f63991", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/67/e3/baf1f62cd02099caecd60cf730e8", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b3/be/eb85ab4a6fdbfe8ee0e98ecdc103", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8a/d8/9853c09db52bd79c50a479b3af2a", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/f2/8d/352428c787aecf14dfcee6effbf7", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/19/2c/d9cf78db6a2ead74e80309d94db5", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c0/a0/21b721e3c573d3a31cf1031ba26c", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/15/3e/f4760e8ef6b649dba231d7a0ceca", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/57/2f/651436ae6b72f37d7b22d8fb9d6c", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/e2/0e/a6ebee9cd0d483a78ca747065d44", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/0d/bc/27bdcdc662cbc4c30eb8df6b0cfc", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/63/03/5b3dc50d5ff12bc00091faa66d6d", + "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/21/2f/7d4a687d49772e1e5ef78afe6953", + "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/97/a8/64f3e8e31f4ea820da487e80776b", + "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/7b/8e/e95a4dbbe3dd345463fc8fa0bd96", + "build/prefab/lib/linux_arm64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/ae/bb/c1e106cd2952f58e1e40c38f8ac8", + "build/prefab/lib/linux_x86_64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/51/24/8ecde92d034247c9d193b094c9a7", + "build/prefab/lib/linux_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/55/16/9257bf17c2e1e2b69f9ca9565bfd", + "build/prefab/lib/linux_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/8f/ce/613f1f5bd5154a0b0bc0498a1cd9", + "build/prefab/lib/linux_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c9/09/5f2e451716a9a637fa4f57081d1a", + "build/prefab/lib/mac_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/e3/22/3c2f4b5041b7529b43c6f02d2bb0", + "build/prefab/lib/mac_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/2f/53/c7463229114457f9961fe982cf6e", + "build/prefab/lib/mac_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/47/47/725d64124db479e4e3bfc869ad7e", + "build/prefab/lib/mac_arm64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/61/d25c351d34cbcc9f5a13a07e37b0", + "build/prefab/lib/mac_x86_64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/a0/ec/eaee7f3df8e63262054d5c9fb478", + "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/27/38/c234ba181b79f2f02960dbed6f74", + "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/5b/b8/c26d5a60d055ec764f63670b5c1f", + "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/98/2f/7ed250c1d9c346cecb6e08a3b4a9", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/9e/b0/65db8b08f85ef9f83115c13168db", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/20/5b/8b6cebb37bcf05554ca39d3797e3", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/0d/57/f6ec440223b09c7aa5b3daa0104a", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/57/48/c35182859a71db36c15a88b68399", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/ca/6f/952eed4ce1dd6d4e721743d6f274", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/5c/bf/79a1a07dd329a9f84b9b31cc25b5", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/d7/d3/6fb6c212fd7dbf4c105bdf0d1e26", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/78/ad/d247c9c9050ff3efbcfd2f828115", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/b4/3d/e352190a0e5673d101c0f3ee3ad2", diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a76927..c00bba6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21025, api 8, 2023-05-30) +### 1.7.20 (build 21026, api 8, 2023-05-30) - This seems like a good time for a `refactoring` release in anticipation of changes coming in 1.8. Basically this means that a lot of things will be diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 80c9ed22..b0b19b80 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -31,7 +31,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21025 +TARGET_BALLISTICA_BUILD = 21026 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index d6fd3f14..2d888c37 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -40,11 +40,6 @@ namespace ballistica::base { core::CoreFeatureSet* g_core{}; BaseFeatureSet* g_base{}; -PlusSoftInterface* g_plus_soft{}; -classic::ClassicFeatureSet* g_classic{}; -ClassicSoftInterface* g_classic_soft{}; -// ui_v1::UIV1FeatureSet* g_ui_v1{}; -UIV1SoftInterface* g_ui_v1_soft{}; BaseFeatureSet::BaseFeatureSet() : python{new BasePython()}, @@ -115,13 +110,6 @@ void BaseFeatureSet::OnModuleExec(PyObject* module) { g_base->python->ImportPythonObjs(); - // Import any other C++ feature-set-front-ends we use. - // FIXME: neither of these should be here. - assert(g_classic == nullptr); - g_classic = classic::ClassicFeatureSet::Import(); - // assert(g_ui_v1 == nullptr); - // g_ui_v1 = ui_v1::UIV1FeatureSet::Import(); - // let baenv know it can now feed us logs and run some checks. g_core->python->RunBaEnvOnBaBaseImport(); @@ -238,11 +226,16 @@ auto BaseFeatureSet::HavePlus() -> bool { // hurt anything. tried_importing_plus_ = true; } - return g_plus_soft != nullptr; + return plus_soft_ != nullptr; +} + +void BaseFeatureSet::set_plus(PlusSoftInterface* plus) { + assert(plus_soft_ == nullptr); + plus_soft_ = plus; } /// Access the plus feature-set. Will throw an exception if not present. -auto BaseFeatureSet::Plus() -> PlusSoftInterface* { +auto BaseFeatureSet::plus() -> PlusSoftInterface* { if (!tried_importing_plus_) { python->SoftImportPlus(); // Important to set this *after* import attempt, or a second import attempt @@ -250,7 +243,71 @@ auto BaseFeatureSet::Plus() -> PlusSoftInterface* { // hurt anything. tried_importing_plus_ = true; } - return g_plus_soft; + if (!plus_soft_) { + throw Exception("plus feature-set not present."); + } + return plus_soft_; +} + +auto BaseFeatureSet::HaveClassic() -> bool { + if (!tried_importing_classic_) { + python->SoftImportClassic(); + // Important to set this *after* import attempt, or a second import attempt + // while first is ongoing can insta-fail. Multiple import attempts shouldn't + // hurt anything. + tried_importing_classic_ = true; + } + return classic_soft_ != nullptr; +} + +/// Access the plus feature-set. Will throw an exception if not present. +auto BaseFeatureSet::classic() -> ClassicSoftInterface* { + if (!tried_importing_classic_) { + python->SoftImportClassic(); + // Important to set this *after* import attempt, or a second import attempt + // while first is ongoing can insta-fail. Multiple import attempts shouldn't + // hurt anything. + tried_importing_classic_ = true; + } + if (!classic_soft_) { + throw Exception("classic feature-set not present."); + } + return classic_soft_; +} +void BaseFeatureSet::set_classic(ClassicSoftInterface* classic) { + assert(classic_soft_ == nullptr); + classic_soft_ = classic; +} + +auto BaseFeatureSet::HaveUIV1() -> bool { + if (!tried_importing_ui_v1_) { + python->SoftImportUIV1(); + // Important to set this *after* import attempt, or a second import attempt + // while first is ongoing can insta-fail. Multiple import attempts shouldn't + // hurt anything. + tried_importing_ui_v1_ = true; + } + return ui_v1_soft_ != nullptr; +} + +/// Access the plus feature-set. Will throw an exception if not present. +auto BaseFeatureSet::ui_v1() -> UIV1SoftInterface* { + if (!tried_importing_ui_v1_) { + python->SoftImportUIV1(); + // Important to set this *after* import attempt, or a second import attempt + // while first is ongoing can insta-fail. Multiple import attempts shouldn't + // hurt anything. + tried_importing_ui_v1_ = true; + } + if (!ui_v1_soft_) { + throw Exception("ui_v1 feature-set not present."); + } + return ui_v1_soft_; +} + +void BaseFeatureSet::set_ui_v1(UIV1SoftInterface* ui_v1) { + assert(ui_v1_soft_ == nullptr); + ui_v1_soft_ = ui_v1; } auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { @@ -287,8 +344,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { void BaseFeatureSet::PlusDirectSendV1CloudLogs(const std::string& prefix, const std::string& suffix, bool instant, int* result) { - if (g_plus_soft != nullptr) { - g_plus_soft->DirectSendV1CloudLogs(prefix, suffix, instant, result); + if (plus_soft_ != nullptr) { + plus_soft_->DirectSendV1CloudLogs(prefix, suffix, instant, result); } } @@ -308,7 +365,7 @@ auto BaseFeatureSet::FeatureSetFromData(PyObject* obj) auto BaseFeatureSet::IsUnmodifiedBlessedBuild() -> bool { // If we've got plus present, ask them. Otherwise assume no. if (HavePlus()) { - return Plus()->IsUnmodifiedBlessedBuild(); + return plus()->IsUnmodifiedBlessedBuild(); } return false; } @@ -381,7 +438,7 @@ void BaseFeatureSet::V1CloudLog(const std::string& msg) { if (g_core == nullptr) { logsuffix = msg; } - Plus()->DirectSendV1CloudLogs(logprefix, logsuffix, false, nullptr); + plus()->DirectSendV1CloudLogs(logprefix, logsuffix, false, nullptr); } } } diff --git a/src/ballistica/base/base.h b/src/ballistica/base/base.h index a81a6fa3..43e9e08b 100644 --- a/src/ballistica/base/base.h +++ b/src/ballistica/base/base.h @@ -18,15 +18,6 @@ namespace ballistica::core { class CoreConfig; class CoreFeatureSet; } // namespace ballistica::core -namespace ballistica::plus { -class PlusFeatureSet; -} -namespace ballistica::classic { -class ClassicFeatureSet; -} -namespace ballistica::ui_v1 { -class UIV1FeatureSet; -} namespace ballistica::base { @@ -593,11 +584,6 @@ enum class SysMeshID { // are initially imported (just as regular Python modules do). extern core::CoreFeatureSet* g_core; extern base::BaseFeatureSet* g_base; -extern PlusSoftInterface* g_plus_soft; -extern classic::ClassicFeatureSet* g_classic; -extern base::ClassicSoftInterface* g_classic_soft; -extern base::UIV1SoftInterface* g_ui_v1_soft; -// extern ui_v1::UIV1FeatureSet* g_ui_v1; /// Our C++ front-end to our feature set. This is what other C++ /// feature-sets can 'Import' from us. @@ -629,11 +615,29 @@ class BaseFeatureSet : public FeatureSetNativeComponent, void SetCurrentContext(const ContextRef& context); - /// Whether the plus feature-set is available. + /// Try to load the plus feature-set and return whether it is available. auto HavePlus() -> bool; /// Access the plus feature-set. Will throw an exception if not present. - auto Plus() -> PlusSoftInterface*; + auto plus() -> PlusSoftInterface*; + + void set_plus(PlusSoftInterface* plus); + + /// Try to load the classic feature-set and return whether it is available. + auto HaveClassic() -> bool; + + /// Access the classic feature-set. Will throw an exception if not present. + auto classic() -> ClassicSoftInterface*; + + void set_classic(ClassicSoftInterface* classic); + + /// Try to load the ui_v1 feature-set and return whether it is available. + auto HaveUIV1() -> bool; + + /// Access the ui_v1 feature-set. Will throw an exception if not present. + auto ui_v1() -> UIV1SoftInterface*; + + void set_ui_v1(UIV1SoftInterface* ui_v1); /// Return a string that should be universally unique to this particular /// running instance of the app. @@ -721,11 +725,17 @@ class BaseFeatureSet : public FeatureSetNativeComponent, AppMode* app_mode_; Console* console_{}; + PlusSoftInterface* plus_soft_{}; + ClassicSoftInterface* classic_soft_{}; + UIV1SoftInterface* ui_v1_soft_{}; + std::string console_startup_messages_; + bool tried_importing_plus_{}; + bool tried_importing_classic_{}; + bool tried_importing_ui_v1_{}; bool called_start_app_{}; bool app_running_{}; bool called_run_app_to_completion_{}; - bool tried_importing_plus_{}; }; } // namespace ballistica::base diff --git a/src/ballistica/base/input/device/joystick_input.cc b/src/ballistica/base/input/device/joystick_input.cc index ed7e6e5e..944334dc 100644 --- a/src/ballistica/base/input/device/joystick_input.cc +++ b/src/ballistica/base/input/device/joystick_input.cc @@ -1308,7 +1308,12 @@ void JoystickInput::UpdateMapping() { return; } - auto* cpy{g_classic->python}; + auto* cl{g_base->HaveClassic() ? g_base->classic() : nullptr}; + + if (!cl) { + Log(LogLevel::kWarning, + "Classic not present; can't config joystick mapping."); + } // If we're a child, use our parent's id to search for config values and just // tack on a '2'. @@ -1318,36 +1323,36 @@ void JoystickInput::UpdateMapping() { // Grab all button values from Python. Traditionally we stored these // with the first index 1 so we need to subtract 1 to get the zero-indexed // value. (grumble). - jump_button_ = cpy->GetControllerValue(js, "buttonJump" + ext) - 1; - punch_button_ = cpy->GetControllerValue(js, "buttonPunch" + ext) - 1; - bomb_button_ = cpy->GetControllerValue(js, "buttonBomb" + ext) - 1; - pickup_button_ = cpy->GetControllerValue(js, "buttonPickUp" + ext) - 1; - start_button_ = cpy->GetControllerValue(js, "buttonStart" + ext) - 1; - start_button_2_ = cpy->GetControllerValue(js, "buttonStart2" + ext) - 1; + jump_button_ = cl->GetControllerValue(js, "buttonJump" + ext) - 1; + punch_button_ = cl->GetControllerValue(js, "buttonPunch" + ext) - 1; + bomb_button_ = cl->GetControllerValue(js, "buttonBomb" + ext) - 1; + pickup_button_ = cl->GetControllerValue(js, "buttonPickUp" + ext) - 1; + start_button_ = cl->GetControllerValue(js, "buttonStart" + ext) - 1; + start_button_2_ = cl->GetControllerValue(js, "buttonStart2" + ext) - 1; hold_position_button_ = - cpy->GetControllerValue(js, "buttonHoldPosition" + ext) - 1; - run_button1_ = cpy->GetControllerValue(js, "buttonRun1" + ext) - 1; - run_button2_ = cpy->GetControllerValue(js, "buttonRun2" + ext) - 1; + cl->GetControllerValue(js, "buttonHoldPosition" + ext) - 1; + run_button1_ = cl->GetControllerValue(js, "buttonRun1" + ext) - 1; + run_button2_ = cl->GetControllerValue(js, "buttonRun2" + ext) - 1; vr_reorient_button_ = - cpy->GetControllerValue(js, "buttonVRReorient" + ext) - 1; - ignored_button_ = cpy->GetControllerValue(js, "buttonIgnored" + ext) - 1; - ignored_button2_ = cpy->GetControllerValue(js, "buttonIgnored2" + ext) - 1; - ignored_button3_ = cpy->GetControllerValue(js, "buttonIgnored3" + ext) - 1; - ignored_button4_ = cpy->GetControllerValue(js, "buttonIgnored4" + ext) - 1; + cl->GetControllerValue(js, "buttonVRReorient" + ext) - 1; + ignored_button_ = cl->GetControllerValue(js, "buttonIgnored" + ext) - 1; + ignored_button2_ = cl->GetControllerValue(js, "buttonIgnored2" + ext) - 1; + ignored_button3_ = cl->GetControllerValue(js, "buttonIgnored3" + ext) - 1; + ignored_button4_ = cl->GetControllerValue(js, "buttonIgnored4" + ext) - 1; int old_run_trigger_1 = run_trigger1_; - run_trigger1_ = cpy->GetControllerValue(js, "triggerRun1" + ext) - 1; + run_trigger1_ = cl->GetControllerValue(js, "triggerRun1" + ext) - 1; int old_run_trigger_2 = run_trigger2_; - run_trigger2_ = cpy->GetControllerValue(js, "triggerRun2" + ext) - 1; - up_button_ = cpy->GetControllerValue(js, "buttonUp" + ext) - 1; - left_button_ = cpy->GetControllerValue(js, "buttonLeft" + ext) - 1; - right_button_ = cpy->GetControllerValue(js, "buttonRight" + ext) - 1; - down_button_ = cpy->GetControllerValue(js, "buttonDown" + ext) - 1; - up_button2_ = cpy->GetControllerValue(js, "buttonUp2" + ext) - 1; - left_button2_ = cpy->GetControllerValue(js, "buttonLeft2" + ext) - 1; - right_button2_ = cpy->GetControllerValue(js, "buttonRight2" + ext) - 1; - down_button2_ = cpy->GetControllerValue(js, "buttonDown2" + ext) - 1; + run_trigger2_ = cl->GetControllerValue(js, "triggerRun2" + ext) - 1; + up_button_ = cl->GetControllerValue(js, "buttonUp" + ext) - 1; + left_button_ = cl->GetControllerValue(js, "buttonLeft" + ext) - 1; + right_button_ = cl->GetControllerValue(js, "buttonRight" + ext) - 1; + down_button_ = cl->GetControllerValue(js, "buttonDown" + ext) - 1; + up_button2_ = cl->GetControllerValue(js, "buttonUp2" + ext) - 1; + left_button2_ = cl->GetControllerValue(js, "buttonLeft2" + ext) - 1; + right_button2_ = cl->GetControllerValue(js, "buttonRight2" + ext) - 1; + down_button2_ = cl->GetControllerValue(js, "buttonDown2" + ext) - 1; unassigned_buttons_run_ = static_cast( - cpy->GetControllerValue(js, "unassignedButtonsRun" + ext)); + cl->GetControllerValue(js, "unassignedButtonsRun" + ext)); // If our run trigger has changed, reset its calibration. // NOTE: It looks like on Mac we're getting analog trigger values from -1 to 1 @@ -1362,21 +1367,21 @@ void JoystickInput::UpdateMapping() { run_trigger2_max_ = 0.8f; } - int ival = cpy->GetControllerValue(js, "uiOnly" + ext); + int ival = cl->GetControllerValue(js, "uiOnly" + ext); if (ival == -1) { ui_only_ = false; } else { ui_only_ = static_cast(ival); } - ival = cpy->GetControllerValue(js, "ignoreCompletely" + ext); + ival = cl->GetControllerValue(js, "ignoreCompletely" + ext); if (ival == -1) { ignore_completely_ = false; } else { ignore_completely_ = static_cast(ival); } - ival = cpy->GetControllerValue(js, "autoRecalibrateAnalogSticks" + ext); + ival = cl->GetControllerValue(js, "autoRecalibrateAnalogSticks" + ext); { bool was_on = auto_recalibrate_analog_stick_; @@ -1402,7 +1407,7 @@ void JoystickInput::UpdateMapping() { } } - ival = cpy->GetControllerValue(js, "startButtonActivatesDefaultWidget" + ext); + ival = cl->GetControllerValue(js, "startButtonActivatesDefaultWidget" + ext); if (ival == -1) { start_button_activates_default_widget_ = true; @@ -1411,7 +1416,7 @@ void JoystickInput::UpdateMapping() { } // Update calibration stuff. - float as = cpy->GetControllerFloatValue(js, "analogStickDeadZone" + ext); + float as = cl->GetControllerFloatValue(js, "analogStickDeadZone" + ext); if (as < 0) { as = 1.0f; @@ -1425,7 +1430,7 @@ void JoystickInput::UpdateMapping() { calibration_threshold_ = kJoystickCalibrationThreshold * as; calibration_break_threshold_ = kJoystickCalibrationBreakThreshold * as; - hat_ = cpy->GetControllerValue(js, "dpad" + ext) - 1; + hat_ = cl->GetControllerValue(js, "dpad" + ext) - 1; // If unset, use our default. if (hat_ == -2) { @@ -1437,7 +1442,7 @@ void JoystickInput::UpdateMapping() { } // Grab our analog stick. - analog_lr_ = cpy->GetControllerValue(js, "analogStickLR" + ext) - 1; + analog_lr_ = cl->GetControllerValue(js, "analogStickLR" + ext) - 1; // If we got unset, set to our default. if (analog_lr_ == -2) { @@ -1448,7 +1453,7 @@ void JoystickInput::UpdateMapping() { } } - analog_ud_ = cpy->GetControllerValue(js, "analogStickUD" + ext) - 1; + analog_ud_ = cl->GetControllerValue(js, "analogStickUD" + ext) - 1; // If we got unset, set to our default. if (analog_ud_ == -2) { @@ -1461,7 +1466,7 @@ void JoystickInput::UpdateMapping() { // See whether we have a child-joystick and create it if need be. if (!parent_joy_stick_) { - int enable = cpy->GetControllerValue(js, "enableSecondary"); + int enable = cl->GetControllerValue(js, "enableSecondary"); if (enable == -1) { enable = 0; } diff --git a/src/ballistica/base/input/device/keyboard_input.cc b/src/ballistica/base/input/device/keyboard_input.cc index b668d808..d74f3d49 100644 --- a/src/ballistica/base/input/device/keyboard_input.cc +++ b/src/ballistica/base/input/device/keyboard_input.cc @@ -375,7 +375,7 @@ void KeyboardInput::UpdateRun(SDL_Keycode key, bool down) { void KeyboardInput::UpdateMapping() { assert(g_base->InLogicThread()); - auto* cpy = g_classic->python; + auto* cl{g_base->HaveClassic() ? g_base->classic() : nullptr}; SDL_Keycode up_key_default, down_key_default, left_key_default, right_key_default, jump_key_default, punch_key_default, bomb_key_default, @@ -413,44 +413,44 @@ void KeyboardInput::UpdateMapping() { left_key_assigned_ = right_key_assigned_ = up_key_assigned_ = down_key_assigned_ = false; - int val = cpy->GetControllerValue(this, "buttonJump"); + int val = cl ? cl->GetControllerValue(this, "buttonJump") : -1; jump_key_ = (val == -1) ? jump_key_default : (SDL_Keycode)val; UpdateArrowKeys(jump_key_); - val = cpy->GetControllerValue(this, "buttonPunch"); + val = cl ? cl->GetControllerValue(this, "buttonPunch") : -1; punch_key_ = (val == -1) ? punch_key_default : (SDL_Keycode)val; UpdateArrowKeys(punch_key_); - val = cpy->GetControllerValue(this, "buttonBomb"); + val = cl ? cl->GetControllerValue(this, "buttonBomb") : -1; bomb_key_ = (val == -1) ? bomb_key_default : (SDL_Keycode)val; UpdateArrowKeys(bomb_key_); - val = cpy->GetControllerValue(this, "buttonPickUp"); + val = cl ? cl->GetControllerValue(this, "buttonPickUp") : -1; pick_up_key_ = (val == -1) ? pick_up_key_default : (SDL_Keycode)val; UpdateArrowKeys(pick_up_key_); - val = cpy->GetControllerValue(this, "buttonHoldPosition"); + val = cl ? cl->GetControllerValue(this, "buttonHoldPosition") : -1; hold_position_key_ = (val == -1) ? hold_position_key_default : (SDL_Keycode)val; UpdateArrowKeys(hold_position_key_); - val = cpy->GetControllerValue(this, "buttonStart"); + val = cl ? cl->GetControllerValue(this, "buttonStart") : -1; start_key_ = (val == -1) ? start_key_default : (SDL_Keycode)val; UpdateArrowKeys(start_key_); - val = cpy->GetControllerValue(this, "buttonUp"); + val = cl ? cl->GetControllerValue(this, "buttonUp") : -1; up_key_ = (val == -1) ? up_key_default : (SDL_Keycode)val; UpdateArrowKeys(up_key_); - val = cpy->GetControllerValue(this, "buttonDown"); + val = cl ? cl->GetControllerValue(this, "buttonDown") : -1; down_key_ = (val == -1) ? down_key_default : (SDL_Keycode)val; UpdateArrowKeys(down_key_); - val = cpy->GetControllerValue(this, "buttonLeft"); + val = cl ? cl->GetControllerValue(this, "buttonLeft") : -1; left_key_ = (val == -1) ? left_key_default : (SDL_Keycode)val; UpdateArrowKeys(left_key_); - val = cpy->GetControllerValue(this, "buttonRight"); + val = cl ? cl->GetControllerValue(this, "buttonRight") : -1; right_key_ = (val == -1) ? right_key_default : (SDL_Keycode)val; UpdateArrowKeys(right_key_); diff --git a/src/ballistica/base/logic/logic.cc b/src/ballistica/base/logic/logic.cc index a0effe00..8c514a19 100644 --- a/src/ballistica/base/logic/logic.cc +++ b/src/ballistica/base/logic/logic.cc @@ -65,7 +65,7 @@ void Logic::OnAppStart() { g_core->platform->OnAppStart(); g_base->app_mode()->OnAppStart(); if (g_base->HavePlus()) { - g_base->Plus()->OnAppStart(); + g_base->plus()->OnAppStart(); } g_base->python->OnAppStart(); } catch (const std::exception& e) { @@ -89,7 +89,7 @@ void Logic::OnAppPause() { // Note: keep these in opposite order of OnAppStart. g_base->python->OnAppPause(); if (g_base->HavePlus()) { - g_base->Plus()->OnAppPause(); + g_base->plus()->OnAppPause(); } g_base->app_mode()->OnAppPause(); g_core->platform->OnAppPause(); @@ -110,7 +110,7 @@ void Logic::OnAppResume() { g_core->platform->OnAppResume(); g_base->app_mode()->OnAppResume(); if (g_base->HavePlus()) { - g_base->Plus()->OnAppResume(); + g_base->plus()->OnAppResume(); } g_base->python->OnAppResume(); } @@ -125,7 +125,7 @@ void Logic::OnAppShutdown() { // Note: keep these in opposite order of OnAppStart. g_base->python->OnAppShutdown(); if (g_base->HavePlus()) { - g_base->Plus()->OnAppShutdown(); + g_base->plus()->OnAppShutdown(); } g_base->app_mode()->OnAppShutdown(); g_core->platform->OnAppResume(); @@ -154,7 +154,7 @@ void Logic::ApplyAppConfig() { g_core->platform->ApplyAppConfig(); g_base->app_mode()->ApplyAppConfig(); if (g_base->HavePlus()) { - g_base->Plus()->ApplyAppConfig(); + g_base->plus()->ApplyAppConfig(); } g_base->python->ApplyAppConfig(); @@ -259,7 +259,7 @@ void Logic::OnScreenSizeChange(float virtual_width, float virtual_height, g_core->platform->OnScreenSizeChange(); g_base->app_mode()->OnScreenSizeChange(); if (g_base->HavePlus()) { - g_base->Plus()->OnScreenSizeChange(); + g_base->plus()->OnScreenSizeChange(); } g_base->python->OnScreenSizeChange(); } @@ -279,7 +279,7 @@ void Logic::StepDisplayTime() { g_core->platform->StepDisplayTime(); g_base->app_mode()->StepDisplayTime(); if (g_base->HavePlus()) { - g_base->Plus()->StepDisplayTime(); + g_base->plus()->StepDisplayTime(); } g_base->python->StepDisplayTime(); g_base->app->LogicThreadStepDisplayTime(); diff --git a/src/ballistica/base/python/base_python.cc b/src/ballistica/base/python/base_python.cc index b0d2c717..59983154 100644 --- a/src/ballistica/base/python/base_python.cc +++ b/src/ballistica/base/python/base_python.cc @@ -76,6 +76,26 @@ void BasePython::SoftImportPlus() { } } +void BasePython::SoftImportClassic() { + auto gil{Python::ScopedInterpreterLock()}; + auto result = PythonRef::Stolen(PyImport_ImportModule("_baclassic")); + if (!result.Exists()) { + // Ignore any errors here for now. All that will matter is whether plus + // gave us its interface. + PyErr_Clear(); + } +} + +void BasePython::SoftImportUIV1() { + auto gil{Python::ScopedInterpreterLock()}; + auto result = PythonRef::Stolen(PyImport_ImportModule("_bauiv1")); + if (!result.Exists()) { + // Ignore any errors here for now. All that will matter is whether plus + // gave us its interface. + PyErr_Clear(); + } +} + void BasePython::ReadConfig() { // Read the config file and store the config dict for easy access. objs().Get(ObjID::kReadConfigCall).Call(); diff --git a/src/ballistica/base/python/base_python.h b/src/ballistica/base/python/base_python.h index 0482f7eb..a97b9f3d 100644 --- a/src/ballistica/base/python/base_python.h +++ b/src/ballistica/base/python/base_python.h @@ -157,6 +157,8 @@ class BasePython { auto DoOnce() -> bool; void SoftImportPlus(); + void SoftImportClassic(); + void SoftImportUIV1(); private: std::set do_once_locations_; diff --git a/src/ballistica/base/support/classic_soft.h b/src/ballistica/base/support/classic_soft.h index dd35cb4d..caec2343 100644 --- a/src/ballistica/base/support/classic_soft.h +++ b/src/ballistica/base/support/classic_soft.h @@ -11,6 +11,11 @@ namespace ballistica::base { /// case. class ClassicSoftInterface { public: + virtual auto GetControllerValue(base::InputDevice* device, + const std::string& value_name) -> int = 0; + virtual auto GetControllerFloatValue(base::InputDevice* device, + const std::string& value_name) + -> float = 0; }; } // namespace ballistica::base diff --git a/src/ballistica/base/support/ui_v1_soft.h b/src/ballistica/base/support/ui_v1_soft.h index 089ec33a..1b3240c0 100644 --- a/src/ballistica/base/support/ui_v1_soft.h +++ b/src/ballistica/base/support/ui_v1_soft.h @@ -3,6 +3,11 @@ #ifndef BALLISTICA_BASE_SUPPORT_UI_V1_SOFT_H_ #define BALLISTICA_BASE_SUPPORT_UI_V1_SOFT_H_ +// Predeclare some types we use. +namespace ballistica::ui_v1 { +class RootUI; +} + namespace ballistica::base { /// 'Soft' interface to the ui_v1 feature-set. @@ -14,6 +19,7 @@ class UIV1SoftInterface { virtual void DoHandleDeviceMenuPress(base::InputDevice* device) = 0; virtual void DoShowURL(const std::string& url) = 0; virtual void DoQuitWindow() = 0; + virtual auto NewRootUI() -> ui_v1::RootUI* = 0; }; } // namespace ballistica::base diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index f7dbcff5..7ab7bd1d 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -58,7 +58,7 @@ void UI::StepDisplayTime() { assert(g_base->InLogicThread()); } void UI::OnAppStart() { assert(g_base->InLogicThread()); - root_ui_ = new ui_v1::RootUI(); + root_ui_ = g_base->ui_v1()->NewRootUI(); // Make sure we know when forced-ui-scale is enabled. if (force_scale_) { @@ -121,11 +121,11 @@ void UI::PushMainMenuPressCall(InputDevice* device) { void UI::MainMenuPress(InputDevice* device) { assert(g_base->InLogicThread()); - if (g_ui_v1_soft) { - g_ui_v1_soft->DoHandleDeviceMenuPress(device); + if (g_base->HaveUIV1()) { + g_base->ui_v1()->DoHandleDeviceMenuPress(device); } else { Log(LogLevel::kWarning, - "UI::MainMenuPress called without g_ui_v1_soft; unexpected."); + "UI::MainMenuPress called without ui_v1 present; unexpected."); } } @@ -411,8 +411,8 @@ void UI::Draw(FrameDef* frame_def) { } void UI::ShowURL(const std::string& url) { - if (g_ui_v1_soft) { - g_ui_v1_soft->DoShowURL(url); + if (g_base->HaveUIV1()) { + g_base->ui_v1()->DoShowURL(url); } else { Log(LogLevel::kWarning, "UI::ShowURL called without g_ui_v1_soft present; unexpected."); @@ -427,7 +427,7 @@ void UI::ConfirmQuit() { } else { // If input is locked or the in-app-console is up or we don't have ui-v1, // just quit immediately; a confirm screen wouldn't work anyway. - if (g_base->input->IsInputLocked() || g_ui_v1_soft == nullptr + if (g_base->input->IsInputLocked() || !g_base->HaveUIV1() || (g_base->console() != nullptr && g_base->console()->active())) { // Just go through _babase.quit(). // FIXME: Shouldn't need to go out to the Python layer here; @@ -438,7 +438,7 @@ void UI::ConfirmQuit() { } else { ScopedSetContext ssc(nullptr); g_base->audio->PlaySound(g_base->assets->SysSound(SysSoundID::kSwish)); - g_ui_v1_soft->DoQuitWindow(); + g_base->ui_v1()->DoQuitWindow(); // If we have a keyboard, give it UI ownership. InputDevice* keyboard = g_base->input->keyboard_input(); diff --git a/src/ballistica/classic/classic.cc b/src/ballistica/classic/classic.cc index 5bea6beb..10781a89 100644 --- a/src/ballistica/classic/classic.cc +++ b/src/ballistica/classic/classic.cc @@ -38,8 +38,9 @@ void ClassicFeatureSet::OnModuleExec(PyObject* module) { assert(g_base == nullptr); // Should be getting set once here. g_base = base::BaseFeatureSet::Import(); - // Let base know that we exist. - base::g_classic_soft = g_classic; + // Let base know we exist. + // (save it the trouble of trying to load us if it uses us passively). + g_base->set_classic(g_classic); g_core->BootLog("_baclassic exec end"); } @@ -57,4 +58,14 @@ auto ClassicFeatureSet::Import() -> ClassicFeatureSet* { return ImportThroughPythonModule("_baclassic"); } +int ClassicFeatureSet::GetControllerValue(base::InputDevice* device, + const std::string& value_name) { + return python->GetControllerValue(device, value_name); +} + +float ClassicFeatureSet::GetControllerFloatValue( + base::InputDevice* device, const std::string& value_name) { + return python->GetControllerFloatValue(device, value_name); +} + } // namespace ballistica::classic diff --git a/src/ballistica/classic/classic.h b/src/ballistica/classic/classic.h index 10c1113a..16972ee1 100644 --- a/src/ballistica/classic/classic.h +++ b/src/ballistica/classic/classic.h @@ -67,6 +67,10 @@ class ClassicFeatureSet : public FeatureSetNativeComponent, /// Called when our associated Python module is instantiated. static void OnModuleExec(PyObject* module); + auto GetControllerValue(base::InputDevice* device, + const std::string& value_name) -> int override; + auto GetControllerFloatValue(base::InputDevice* device, + const std::string& value_name) -> float override; ClassicPython* const python; V1Account* const v1_account; diff --git a/src/ballistica/classic/support/v1_account.cc b/src/ballistica/classic/support/v1_account.cc index eefd4d78..7d12d88f 100644 --- a/src/ballistica/classic/support/v1_account.cc +++ b/src/ballistica/classic/support/v1_account.cc @@ -190,7 +190,7 @@ void V1Account::SetLogin(V1AccountType account_type, V1LoginState login_state, } if (call_login_did_change) { // Inform a few subsystems of the change. - g_base->Plus()->V1LoginDidChange(); + g_base->plus()->V1LoginDidChange(); g_core->platform->V1LoginDidChange(); } } diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index ab765534..1e774b38 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -150,8 +150,11 @@ void CoreFeatureSet::PostInit() { } auto CoreFeatureSet::SoftImportBase() -> BaseSoftInterface* { - if (!g_base_soft) { + if (!tried_importing_base_) { python->SoftImportBase(); + // Important to set this *AFTER*. Otherwise imports can fail if there is + // already one in progress. + tried_importing_base_ = true; } return g_base_soft; } diff --git a/src/ballistica/core/core.h b/src/ballistica/core/core.h index a977cf4d..aeda83d8 100644 --- a/src/ballistica/core/core.h +++ b/src/ballistica/core/core.h @@ -141,6 +141,7 @@ class CoreFeatureSet { void UpdateAppTime(); explicit CoreFeatureSet(CoreConfig config); void PostInit(); + bool tried_importing_base_{}; EventLoop* main_event_loop_{}; CoreConfig core_config_; bool started_suicide_{}; diff --git a/src/ballistica/scene_v1/connection/connection_to_client.cc b/src/ballistica/scene_v1/connection/connection_to_client.cc index c5cf2fb9..5bb9ba75 100644 --- a/src/ballistica/scene_v1/connection/connection_to_client.cc +++ b/src/ballistica/scene_v1/connection/connection_to_client.cc @@ -416,7 +416,7 @@ void ConnectionToClient::HandleMessagePacket( if (!token_.empty()) { // Kick off a query to the master-server for this client's info. // FIXME: we need to add retries for this in case of failure. - g_base->Plus()->ClientInfoQuery( + g_base->plus()->ClientInfoQuery( token_, our_handshake_player_spec_str_ + our_handshake_salt_, peer_hash_, build_number_); } diff --git a/src/ballistica/scene_v1/connection/connection_to_host.cc b/src/ballistica/scene_v1/connection/connection_to_host.cc index 0f51d8b0..0e9e3f7e 100644 --- a/src/ballistica/scene_v1/connection/connection_to_host.cc +++ b/src/ballistica/scene_v1/connection/connection_to_host.cc @@ -197,7 +197,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { set_peer_spec(PlayerSpec(string_buffer.data())); } - peer_hash_ = g_base->Plus()->CalcV1PeerHash(peer_hash_input_); + peer_hash_ = g_base->plus()->CalcV1PeerHash(peer_hash_input_); set_can_communicate(true); appmode->LaunchClientSession(); @@ -222,7 +222,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { JsonDict dict; dict.AddNumber("b", kEngineBuildNumber); - g_base->Plus()->V1SetClientInfo(&dict); + g_base->plus()->V1SetClientInfo(&dict); // Pass the hash we generated from their handshake; they can use // this to make sure we're who we say we are. diff --git a/src/ballistica/scene_v1/python/methods/python_methods_scene.cc b/src/ballistica/scene_v1/python/methods/python_methods_scene.cc index 62b7974f..4e6a2457 100644 --- a/src/ballistica/scene_v1/python/methods/python_methods_scene.cc +++ b/src/ballistica/scene_v1/python/methods/python_methods_scene.cc @@ -1341,7 +1341,7 @@ static auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) // Let's also include a public account-id if we have one. std::string account_id; if (clientid == -1) { - account_id = g_base->Plus()->GetPublicV1AccountID(); + account_id = g_base->plus()->GetPublicV1AccountID(); } else { if (auto* appmode = SceneV1AppMode::GetActiveOrWarn()) { auto client2 = 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 d3f1c799..5e64ceb1 100644 --- a/src/ballistica/scene_v1/support/scene_v1_app_mode.cc +++ b/src/ballistica/scene_v1/support/scene_v1_app_mode.cc @@ -1203,7 +1203,7 @@ void SceneV1AppMode::SetPublicPartyEnabled(bool val) { return; } public_party_enabled_ = val; - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } void SceneV1AppMode::SetPublicPartySize(int count) { @@ -1216,7 +1216,7 @@ void SceneV1AppMode::SetPublicPartySize(int count) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } @@ -1230,7 +1230,7 @@ void SceneV1AppMode::SetPublicPartyQueueEnabled(bool enabled) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } @@ -1244,7 +1244,7 @@ void SceneV1AppMode::SetPublicPartyMaxSize(int count) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } @@ -1258,7 +1258,7 @@ void SceneV1AppMode::SetPublicPartyName(const std::string& name) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } @@ -1272,7 +1272,7 @@ void SceneV1AppMode::SetPublicPartyStatsURL(const std::string& url) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } @@ -1295,7 +1295,7 @@ void SceneV1AppMode::SetPublicPartyPlayerCount(int count) { // Push our new state to the server *ONLY* if public-party is turned on // (wasteful otherwise). if (public_party_enabled_) { - g_base->Plus()->PushPublicPartyState(); + g_base->plus()->PushPublicPartyState(); } } diff --git a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc index 20cdc20c..c464c296 100644 --- a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc +++ b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc @@ -243,7 +243,7 @@ auto SceneV1InputDeviceDelegate::GetPublicV1AccountID() const -> std::string { // This default implementation assumes the device is local // so just returns the locally signed in account's public id. - return g_base->Plus()->GetPublicV1AccountID(); + return g_base->plus()->GetPublicV1AccountID(); } auto SceneV1InputDeviceDelegate::GetPlayerProfiles() const -> PyObject* { diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 6d3d25e6..d1cf2d45 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 = 21025; +const int kEngineBuildNumber = 21026; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { 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 59c170d5..c24554ac 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 @@ -2397,7 +2397,7 @@ static auto PyShowAd(PyObject* self, PyObject* args, PyObject* keywds) &on_completion_call_obj, &pass_actually_showed)) { return nullptr; } - g_base->Plus()->SetAdCompletionCall(on_completion_call_obj, + g_base->plus()->SetAdCompletionCall(on_completion_call_obj, static_cast(pass_actually_showed)); // In cases where we support ads, store our callback and kick one off. @@ -2407,7 +2407,7 @@ static auto PyShowAd(PyObject* self, PyObject* args, PyObject* keywds) if (g_core->platform->GetHasAds()) { g_core->platform->ShowAd(purpose); } else { - g_base->Plus()->PushAdViewComplete(purpose, false); + g_base->plus()->PushAdViewComplete(purpose, false); } Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -2442,7 +2442,7 @@ static auto PyShowAd2(PyObject* self, PyObject* args, PyObject* keywds) &on_completion_call_obj, &pass_actually_showed)) { return nullptr; } - g_base->Plus()->SetAdCompletionCall(on_completion_call_obj, + g_base->plus()->SetAdCompletionCall(on_completion_call_obj, static_cast(pass_actually_showed)); // In cases where we support ads, store our callback and kick one off. @@ -2452,7 +2452,7 @@ static auto PyShowAd2(PyObject* self, PyObject* args, PyObject* keywds) if (g_core->platform->GetHasAds()) { g_core->platform->ShowAd(purpose); } else { - g_base->Plus()->PushAdViewComplete(purpose, false); + g_base->plus()->PushAdViewComplete(purpose, false); } Py_RETURN_NONE; BA_PYTHON_CATCH; diff --git a/src/ballistica/ui_v1/ui_v1.cc b/src/ballistica/ui_v1/ui_v1.cc index 67fffa9e..e74ab478 100644 --- a/src/ballistica/ui_v1/ui_v1.cc +++ b/src/ballistica/ui_v1/ui_v1.cc @@ -3,6 +3,7 @@ #include "ballistica/ui_v1/ui_v1.h" #include "ballistica/ui_v1/python/ui_v1_python.h" +#include "ballistica/ui_v1/support/root_ui.h" namespace ballistica::ui_v1 { @@ -44,8 +45,9 @@ void UIV1FeatureSet::OnModuleExec(PyObject* module) { assert(g_base == nullptr); // Should be getting set once here. g_base = base::BaseFeatureSet::Import(); - // Let base know that we exist. - base::g_ui_v1_soft = g_ui_v1; + // Let base know we exist. + // (save it the trouble of trying to load us if it uses us passively). + g_base->set_ui_v1(g_ui_v1); g_core->BootLog("_bauiv1 exec end"); } @@ -67,4 +69,5 @@ void UIV1FeatureSet::DoQuitWindow() { g_ui_v1->python->objs().Get(ui_v1::UIV1Python::ObjID::kQuitWindowCall).Call(); } +RootUI* UIV1FeatureSet::NewRootUI() { return new RootUI(); } } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/ui_v1.h b/src/ballistica/ui_v1/ui_v1.h index 243fcfef..7a819cf8 100644 --- a/src/ballistica/ui_v1/ui_v1.h +++ b/src/ballistica/ui_v1/ui_v1.h @@ -57,6 +57,7 @@ class UIV1FeatureSet : public FeatureSetNativeComponent, void DoHandleDeviceMenuPress(base::InputDevice* device) override; void DoShowURL(const std::string& url) override; void DoQuitWindow() override; + auto NewRootUI() -> ui_v1::RootUI* override; UIV1Python* const python;