diff --git a/.efrocachemap b/.efrocachemap index a152912b..474b5987 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4099,51 +4099,51 @@ "build/assets/windows/Win32/ucrtbased.dll": "bfd1180c269d3950b76f35a63655e9e1", "build/assets/windows/Win32/vc_redist.x86.exe": "15a5f1f876503885adbdf5b3989b3718", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "50d0964d88773c42240a5bab91bdb55b", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "f251ef80240622765973c3ef7c69c52a", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "ed5a3bab3db459f2f689d7d20d27b1d3", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "2c25dc80903426d04798d60ab034cccf", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "fcc9e1d77db31973a5b7fc94253cd395", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "974c55de42de299b4e0ae2ce80cc602b", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "25362f407d7aa6443009143a71dac4cc", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "6d2607f58e1d58506f371ededa39a93f", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "fbf112a5577022943d2517482af664c2", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "cda4565610d94db3536a72db44b8f061", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "92df5db19c30eba8c1abda56f25a8657", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "ebe2508e3ffdd6670bfceeb659e1e113", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "4eab8af208c0525d3b0041482d6fadef", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "5fa353067144d00b79259b6d353d6676", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "85dc7db8ccdc016d7984fc361d20cc5b", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "e8054b92e88f6e0230cf320fb0015be5", - "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "7160ce46f35063764e1a5d3e0f0bd35b", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "c9c741a8c1908f709d9e69f95078e54d", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "48f6568ba24b78e376fcb0109d8811fa", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "74f4a7a42a51aab41baa0b06933ba90a", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "7c3305d87a435b8a2308faf9798af681", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "f10715043bcd264941d66e63b00bb171", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "701b28fdf672a88bdc85aac449a52933", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "a9b00364c83414d86b81e99e5d9e1b10", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "76e1077a37e919260846cfd96985bb3e", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "fd6c8276e03e6af24c897d974838dc34", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "d5c311bb092286d8ef7f48f51e7da95f", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "be9ae9fa1f04a87c4dfd319c02158b92", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "bd15c256a1dd4e086564b23055904a68", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "380d586848a9351eaff8da027b1d3aeb", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "352089e2917fef437e176e148f5fcd91", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "7667304055cd226341597c45534c812e", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "b323fe4cdd3b7d2f31f6e05db7bb04f3", + "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "e57cd21ff8c3566b1eb5fc9e79474d69", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "206f0407a6d912b292c6530cd969030b", - "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "7160ce46f35063764e1a5d3e0f0bd35b", + "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "e57cd21ff8c3566b1eb5fc9e79474d69", "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "206f0407a6d912b292c6530cd969030b", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "cdb4b500ef2c285388824da423171431", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "6a891ea7e3609d5c30a3b321db59dc78", "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "7f37a6249393fc422a536b3e1622b96f", - "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "cdb4b500ef2c285388824da423171431", + "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "6a891ea7e3609d5c30a3b321db59dc78", "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "7f37a6249393fc422a536b3e1622b96f", - "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "e4e4c5ce769f8c3a1535b7a4e64e7d90", + "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "209def6990e220110e5433581dad95e7", "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "910f66cc0ddf5d17e751dc295f84e63e", - "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "e4e4c5ce769f8c3a1535b7a4e64e7d90", + "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "209def6990e220110e5433581dad95e7", "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "910f66cc0ddf5d17e751dc295f84e63e", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "67e333892eb9c549a0977931c38bfb74", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "7e5443e649cb63bd32ac99c860a3bbe8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "61a11a9e832e646c52ddda720de8e639", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "929c50574c279d24e048a7cd9e3362db", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "71836aff8062a6925f4770a3d6ead4e2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "b0b309105ad26e0123835a50c8c1793e", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "8c735fee3348fe41efc61d6fcbe6e3cd", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "75c49e5ec7410f372c90c728125e6fc2", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "8cba3a66655dc40054d11acf13131226", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "a23295d8e71df2f8c308cfcd4b628827", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "72eaa6f4466fad2260c121711ec9ed09", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "c9748838494847186721a17dde8fd069", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "e41041e152263ae5552eb0e25c6ae8b8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "a566b94b52cc4c281ada8a32a7fe078b", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "604c937543f27648e66217818cfc9714", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "d57aa1b54409ef038b2e86b1d59f9d26", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad", - "src/ballistica/base/mgen/pyembed/binding_base.inc": "3a583e7e03bd4907b21adc3bf5729d15", - "src/ballistica/base/mgen/pyembed/binding_base_app.inc": "f0f9dc33ecd4ef7a384f131d62c96c97", - "src/ballistica/classic/mgen/pyembed/binding_classic.inc": "3ceb412513963f0818ab39c58bf292e3", - "src/ballistica/core/mgen/pyembed/binding_core.inc": "aa91582493f32d54825d0c8bc007a902", + "src/ballistica/base/mgen/pyembed/binding_base.inc": "06042d31df0ff9af96b99477162e2a91", + "src/ballistica/base/mgen/pyembed/binding_base_app.inc": "2d228e7c5578261d394f9c407f4becb1", + "src/ballistica/classic/mgen/pyembed/binding_classic.inc": "fc09126750304b2761049aa9d93a951e", + "src/ballistica/core/mgen/pyembed/binding_core.inc": "217c84a30f866aaca3a4373e82af7db2", "src/ballistica/core/mgen/pyembed/env.inc": "f015d726b44d2922112fc14d9f146d8b", "src/ballistica/core/mgen/python_modules_monolithic.h": "fb967ed1c7db0c77d8deb4f00a7103c5", - "src/ballistica/scene_v1/mgen/pyembed/binding_scene_v1.inc": "c25b263f2a31fb5ebe057db07d144879", - "src/ballistica/template_fs/mgen/pyembed/binding_template_fs.inc": "44a45492db057bf7f7158c3b0fa11f0f", - "src/ballistica/ui_v1/mgen/pyembed/binding_ui_v1.inc": "1081c8d6a7ed45cbe211b26b6a3b8af0" + "src/ballistica/scene_v1/mgen/pyembed/binding_scene_v1.inc": "24319dcd493e3d0271dd9e1b67839844", + "src/ballistica/template_fs/mgen/pyembed/binding_template_fs.inc": "4957085dad60cc136fc513215ffeaf78", + "src/ballistica/ui_v1/mgen/pyembed/binding_ui_v1.inc": "04770b89b892d9891b29064685a89287" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e01d135e..c660f178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22118, api 9, 2024-11-30) +### 1.7.37 (build 22123, api 9, 2024-12-03) - Bumping api version to 9. As you'll see below, there's some UI changes that will require a bit of work for any UI mods to adapt to. If your mods don't touch UI stuff at all you can simply bump your api version and call it a day. @@ -166,6 +166,11 @@ a custom selector that selects your custom app-mode(s). - The `ba*.app.threadpool_submit_no_wait()` method has been merged into the `threadpool` object, so it now is `ba*.app.threadpool.submit_no_wait()`. +- Clarified project rules for `snake_case` methods in C++ and updated various + methods accordingly such as `Object::Ref::get()` and `Object::Ref::exists()`. + See 'Getter/Setter Function Names' in + https://github.com/efroemling/ballistica/wiki/Coding-Style-Guide for more + info. ### 1.7.36 (build 21944, api 8, 2024-07-26) - Wired up Tokens, BombSquad's new purchasable currency. The first thing these diff --git a/config/requirements.txt b/config/requirements.txt index 1822d122..82811250 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -6,9 +6,9 @@ mypy==1.13.0 pbxproj==4.2.1 pdoc==15.0.0 pur==7.3.2 -pylint==3.3.1 +pylint==3.3.2 pylsp-mypy==0.6.9 -pytest==8.3.3 +pytest==8.3.4 python-daemon==3.1.0 python-lsp-black==2.0.0 python-lsp-server==1.12.0 diff --git a/src/assets/ba_data/python/baclassic/_appmode.py b/src/assets/ba_data/python/baclassic/_appmode.py index 949526f4..2db6bfc1 100644 --- a/src/assets/ba_data/python/baclassic/_appmode.py +++ b/src/assets/ba_data/python/baclassic/_appmode.py @@ -187,6 +187,7 @@ class ClassicAppMode(babase.AppMode): achievements_percent_text='-', level_text='-', xp_text='-', + inbox_count_text='', ) else: @@ -216,6 +217,7 @@ class ClassicAppMode(babase.AppMode): achievements_percent_text=f'{achp}%', level_text=str(val.level), xp_text=f'{val.xp}/{val.xpmax}', + inbox_count_text=str(val.inbox_count), ) def _root_ui_menu_press(self) -> None: diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 4bf354ef..08b3c57c 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -53,7 +53,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 22118 +TARGET_BALLISTICA_BUILD = 22123 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/assets/ba_data/python/bauiv1/_appsubsystem.py b/src/assets/ba_data/python/bauiv1/_appsubsystem.py index 9711c51b..36bc7749 100644 --- a/src/assets/ba_data/python/bauiv1/_appsubsystem.py +++ b/src/assets/ba_data/python/bauiv1/_appsubsystem.py @@ -243,10 +243,7 @@ class UIV1AppSubsystem(babase.AppSubsystem): window_weakref = weakref.ref(window) window_widget = window.get_root_widget() - if isinstance(from_window, MainWindow): - # from_window_widget = from_window.get_root_widget() - pass - else: + if not isinstance(from_window, MainWindow): if from_window is not None and not isinstance(from_window, bool): raise RuntimeError( f'set_main_window() now takes a MainWindow or bool or None' @@ -267,6 +264,7 @@ class UIV1AppSubsystem(babase.AppSubsystem): 'Provided back_state is incomplete.' ' Make sure to only pass fully-filled-out MainWindowStates.' ) + # If a top-level main-window is being set, complain if there already # is a main-window. if is_top_level: @@ -278,8 +276,8 @@ class UIV1AppSubsystem(babase.AppSubsystem): existing, ) else: - # In other cases, sanity-check that the window ordering this - # switch is the one we're switching away from. + # In other cases, sanity-check that the window asking for + # this switch is the one we're switching away from. try: if isinstance(from_window, bool): # For default val True we warn that the arg wasn't @@ -391,7 +389,7 @@ class UIV1AppSubsystem(babase.AppSubsystem): def save_main_window_state(self, window: MainWindow) -> MainWindowState: """Fully initialize a window-state from a window. - Use this to get a state for later restoration purposes. + Use this to get a complete state for later restoration purposes. Calling the window's get_main_window_state() directly is insufficient. """ diff --git a/src/assets/ba_data/python/bauiv1/_uitypes.py b/src/assets/ba_data/python/bauiv1/_uitypes.py index 00d906f1..8f974395 100644 --- a/src/assets/ba_data/python/bauiv1/_uitypes.py +++ b/src/assets/ba_data/python/bauiv1/_uitypes.py @@ -215,6 +215,7 @@ class MainWindowState: self.is_top_level: bool | None = None self.is_auxiliary: bool | None = None self.window_type: type[MainWindow] | None = None + self.selection: str | None = None def create_window( self, diff --git a/src/assets/ba_data/python/bauiv1lib/account/settings.py b/src/assets/ba_data/python/bauiv1lib/account/settings.py index afb642b7..928ebf5f 100644 --- a/src/assets/ba_data/python/bauiv1lib/account/settings.py +++ b/src/assets/ba_data/python/bauiv1lib/account/settings.py @@ -90,8 +90,8 @@ class AccountSettingsWindow(bui.MainWindow): # Always want to show our web-based v2 login option. self._show_sign_in_buttons.append('V2Proxy') - # Legacy v1 device accounts available only if the user - # has explicitly enabled deprecated login types. + # Legacy v1 device accounts available only if the user has + # explicitly enabled deprecated login types. if bui.app.config.resolve('Show Deprecated Login Types'): self._show_sign_in_buttons.append('Device') @@ -212,8 +212,8 @@ class AccountSettingsWindow(bui.MainWindow): return # Hmm should update this to use get_account_state_num. - # Theoretically if we switch from one signed-in account to another - # in the background this would break. + # Theoretically if we switch from one signed-in account to + # another in the background this would break. v1_account_state_num = plus.get_v1_account_state_num() v1_account_state = plus.get_v1_account_state() show_legacy_unlink_button = self._should_show_legacy_unlink_button() @@ -228,8 +228,8 @@ class AccountSettingsWindow(bui.MainWindow): self._show_legacy_unlink_button = show_legacy_unlink_button self._refresh() - # Go ahead and refresh some individual things - # that may change under us. + # Go ahead and refresh some individual things that may change + # under us. self._update_linked_accounts_text() self._update_unlink_accounts_button() self._refresh_campaign_progress_text() diff --git a/src/assets/ba_data/python/bauiv1lib/ingamemenu.py b/src/assets/ba_data/python/bauiv1lib/ingamemenu.py index b048b18b..2dd73541 100644 --- a/src/assets/ba_data/python/bauiv1lib/ingamemenu.py +++ b/src/assets/ba_data/python/bauiv1lib/ingamemenu.py @@ -48,12 +48,7 @@ class InGameMenuWindow(bui.MainWindow): @override def get_main_window_state(self) -> bui.MainWindowState: - # Support recreating our window for back/refresh purposes. - return self.do_get_main_window_state() - - @classmethod - def do_get_main_window_state(cls) -> bui.MainWindowState: - """Classmethod to gen a windowstate for the main menu.""" + cls = type(self) return bui.BasicMainWindowState( create_call=lambda transition, origin_widget: cls( transition=transition, origin_widget=origin_widget diff --git a/src/assets/ba_data/python/bauiv1lib/mainmenu.py b/src/assets/ba_data/python/bauiv1lib/mainmenu.py index 26db7be2..3da6fc62 100644 --- a/src/assets/ba_data/python/bauiv1lib/mainmenu.py +++ b/src/assets/ba_data/python/bauiv1lib/mainmenu.py @@ -70,11 +70,7 @@ class MainMenuWindow(bui.MainWindow): @override def get_main_window_state(self) -> bui.MainWindowState: # Support recreating our window for back/refresh purposes. - return self.do_get_main_window_state() - - @classmethod - def do_get_main_window_state(cls) -> bui.MainWindowState: - """Classmethod to gen a windowstate for the main menu.""" + cls = type(self) return bui.BasicMainWindowState( create_call=lambda transition, origin_widget: cls( transition=transition, origin_widget=origin_widget @@ -100,6 +96,7 @@ class MainMenuWindow(bui.MainWindow): def _show_remote_app_info_on_first_launch(self) -> None: app = bui.app assert app.classic is not None + # The first time the non-in-game menu pops up, we might wanna # show a 'get-remote-app' dialog in front of it. if app.classic.first_main_menu: @@ -270,6 +267,7 @@ class MainMenuWindow(bui.MainWindow): demo_menu_delay = 0.0 self._demo_menu_button = bui.buttonwidget( parent=self._root_widget, + id='demo', position=(self._width * 0.5 - this_b_width * 0.5, v + 90), size=(this_b_width, 45), autoselect=True, @@ -338,7 +336,6 @@ class MainMenuWindow(bui.MainWindow): texture=bui.gettexture('usersButton'), ) thistdelay = self._tdelay + td1 * self._t_delay_inc - # self._tdelay += self._t_delay_inc h -= ( side_button_width * side_button_scale * 0.5 @@ -349,6 +346,7 @@ class MainMenuWindow(bui.MainWindow): btn = bui.buttonwidget( parent=self._root_widget, + id='howtoplay', position=(h, v), autoselect=self._use_autoselect, size=(side_button_2_width, side_button_2_height * 2.0), diff --git a/src/ballistica/base/app_mode/empty_app_mode.cc b/src/ballistica/base/app_mode/empty_app_mode.cc index 34138439..3049e7ac 100644 --- a/src/ballistica/base/app_mode/empty_app_mode.cc +++ b/src/ballistica/base/app_mode/empty_app_mode.cc @@ -51,7 +51,7 @@ void EmptyAppMode::DrawWorld(base::FrameDef* frame_def) { } // Draw some lovely spinning text. - if (!hello_text_group_.Exists()) { + if (!hello_text_group_.exists()) { hello_text_group_ = Object::New(); hello_text_group_->SetText("Potato!"); } diff --git a/src/ballistica/base/assets/assets.cc b/src/ballistica/base/assets/assets.cc index 1b22fa95..a05f24d4 100644 --- a/src/ballistica/base/assets/assets.cc +++ b/src/ballistica/base/assets/assets.cc @@ -386,30 +386,30 @@ void Assets::MarkAllAssetsForLoad() { AssetListLock m_lock; for (auto&& i : textures_) { if (!i.second->preloaded()) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); have_pending_loads_[static_cast(AssetType::kTexture)] = true; - MarkAssetForLoad(i.second.Get()); + MarkAssetForLoad(i.second.get()); } } for (auto&& i : text_textures_) { if (!i.second->preloaded()) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); have_pending_loads_[static_cast(AssetType::kTexture)] = true; - MarkAssetForLoad(i.second.Get()); + MarkAssetForLoad(i.second.get()); } } for (auto&& i : qr_textures_) { if (!i.second->preloaded()) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); have_pending_loads_[static_cast(AssetType::kTexture)] = true; - MarkAssetForLoad(i.second.Get()); + MarkAssetForLoad(i.second.get()); } } for (auto&& i : meshes_) { if (!i.second->preloaded()) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); have_pending_loads_[static_cast(AssetType::kMesh)] = true; - MarkAssetForLoad(i.second.Get()); + MarkAssetForLoad(i.second.get()); } } } @@ -423,21 +423,21 @@ void Assets::UnloadRendererBits(bool do_textures, bool do_meshes) { if (do_textures) { assert(asset_lists_locked_); for (auto&& i : textures_) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); i.second->Unload(true); } for (auto&& i : text_textures_) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); i.second->Unload(true); } for (auto&& i : qr_textures_) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); i.second->Unload(true); } } if (do_meshes) { for (auto&& i : meshes_) { - Asset::LockGuard lock(i.second.Get()); + Asset::LockGuard lock(i.second.get()); i.second->Unload(true); } } @@ -470,14 +470,14 @@ auto Assets::GetAsset(const std::string& file_name, assert(asset_loads_allowed_); auto i = c_list->find(file_name); if (i != c_list->end()) { - return Object::Ref(i->second.Get()); + return Object::Ref(i->second.get()); } else { auto d(Object::New(file_name)); (*c_list)[file_name] = d; { - Asset::LockGuard lock(d.Get()); + Asset::LockGuard lock(d.get()); have_pending_loads_[static_cast(d->GetAssetType())] = true; - MarkAssetForLoad(d.Get()); + MarkAssetForLoad(d.get()); } d->set_last_used_time(g_core->GetAppTimeMillisecs()); return Object::Ref(d); @@ -490,14 +490,14 @@ auto Assets::GetTexture(TextPacker* packer) -> Object::Ref { const std::string& hash(packer->hash()); auto i = text_textures_.find(hash); if (i != text_textures_.end()) { - return Object::Ref(i->second.Get()); + return Object::Ref(i->second.get()); } else { auto d{Object::New(packer)}; text_textures_[hash] = d; { - Asset::LockGuard lock(d.Get()); + Asset::LockGuard lock(d.get()); have_pending_loads_[static_cast(d->GetAssetType())] = true; - MarkAssetForLoad(d.Get()); + MarkAssetForLoad(d.get()); } d->set_last_used_time(g_core->GetAppTimeMillisecs()); return Object::Ref(d); @@ -510,14 +510,14 @@ auto Assets::GetQRCodeTexture(const std::string& url) assert(asset_lists_locked_); auto i = qr_textures_.find(url); if (i != qr_textures_.end()) { - return Object::Ref(i->second.Get()); + return Object::Ref(i->second.get()); } else { auto d(Object::New(url)); qr_textures_[url] = d; { - Asset::LockGuard lock(d.Get()); + Asset::LockGuard lock(d.get()); have_pending_loads_[static_cast(d->GetAssetType())] = true; - MarkAssetForLoad(d.Get()); + MarkAssetForLoad(d.get()); } d->set_last_used_time(g_core->GetAppTimeMillisecs()); return Object::Ref(d); @@ -532,15 +532,15 @@ auto Assets::GetCubeMapTexture(const std::string& file_name) assert(asset_lists_locked_); auto i = textures_.find(file_name); if (i != textures_.end()) { - return Object::Ref(i->second.Get()); + return Object::Ref(i->second.get()); } else { auto d(Object::New(file_name, TextureType::kCubeMap, TextureMinQuality::kLow)); textures_[file_name] = d; { - Asset::LockGuard lock(d.Get()); + Asset::LockGuard lock(d.get()); have_pending_loads_[static_cast(d->GetAssetType())] = true; - MarkAssetForLoad(d.Get()); + MarkAssetForLoad(d.get()); } d->set_last_used_time(g_core->GetAppTimeMillisecs()); return Object::Ref(d); @@ -555,7 +555,7 @@ auto Assets::GetTexture(const std::string& file_name) assert(asset_lists_locked_); auto i = textures_.find(file_name); if (i != textures_.end()) { - return Object::Ref(i->second.Get()); + return Object::Ref(i->second.get()); } else { static std::set* quality_map_medium = nullptr; static std::set* quality_map_high = nullptr; @@ -594,9 +594,9 @@ auto Assets::GetTexture(const std::string& file_name) auto d(Object::New(file_name, TextureType::k2D, min_quality)); textures_[file_name] = d; { - Asset::LockGuard lock(d.Get()); + Asset::LockGuard lock(d.get()); have_pending_loads_[static_cast(d->GetAssetType())] = true; - MarkAssetForLoad(d.Get()); + MarkAssetForLoad(d.get()); } d->set_last_used_time(g_core->GetAppTimeMillisecs()); return Object::Ref(d); @@ -713,9 +713,9 @@ auto Assets::GetAssetPendingLoadCount( int c = 0; for (auto&& i : (*t_list)) { - if (i.second.Exists()) { + if (i.second.exists()) { if (i.second->TryLock()) { - Asset::LockGuard lock(i.second.Get(), + Asset::LockGuard lock(i.second.get(), Asset::LockGuard::Type::kInheritLock); if (!i.second->loaded()) { c++; @@ -876,7 +876,7 @@ void Assets::Prune(int level) { // Prune textures. assert(asset_lists_locked_); for (auto i = textures_.begin(); i != textures_.end();) { - TextureAsset* texture = i->second.Get(); + TextureAsset* texture = i->second.get(); // Attempt to prune if there are no references remaining except our own and // its been a while since it was used. if (current_time - texture->last_used_time() > standard_asset_prune_time @@ -902,7 +902,7 @@ void Assets::Prune(int level) { // time. assert(asset_lists_locked_); for (auto i = text_textures_.begin(); i != text_textures_.end();) { - TextureAsset* texture = i->second.Get(); + TextureAsset* texture = i->second.get(); // Attempt to prune if there are no references remaining except our own and // its been a while since it was used. if (current_time - texture->last_used_time() > text_texture_prune_time @@ -926,7 +926,7 @@ void Assets::Prune(int level) { // Prune qr-textures. assert(asset_lists_locked_); for (auto i = qr_textures_.begin(); i != qr_textures_.end();) { - TextureAsset* texture = i->second.Get(); + TextureAsset* texture = i->second.get(); // Attempt to prune if there are no references remaining except our own and // its been a while since it was used. if (current_time - texture->last_used_time() > qr_texture_prune_time @@ -950,7 +950,7 @@ void Assets::Prune(int level) { // Prune meshes. assert(asset_lists_locked_); for (auto i = meshes_.begin(); i != meshes_.end();) { - MeshAsset* mesh = i->second.Get(); + MeshAsset* mesh = i->second.get(); // Attempt to prune if there are no references remaining except our own and // its been a while since it was used. if (current_time - mesh->last_used_time() > standard_asset_prune_time @@ -974,7 +974,7 @@ void Assets::Prune(int level) { // Prune collision-meshes. assert(asset_lists_locked_); for (auto i = collision_meshes_.begin(); i != collision_meshes_.end();) { - CollisionMeshAsset* mesh = i->second.Get(); + CollisionMeshAsset* mesh = i->second.get(); // Attempt to prune if there are no references remaining except our own and // its been a while since it was used. if (current_time - mesh->last_used_time() > standard_asset_prune_time @@ -998,7 +998,7 @@ void Assets::Prune(int level) { if (explicit_bool(false)) { assert(asset_lists_locked_); for (auto i = sounds_.begin(); i != sounds_.end();) { - SoundAsset* sound = i->second.Get(); + SoundAsset* sound = i->second.get(); // Attempt to prune if there are no references remaining except our own // and its been a while since it was used. if (current_time - sound->last_used_time() > standard_asset_prune_time @@ -1641,14 +1641,14 @@ auto Assets::SysTexture(SysTextureID id) -> TextureAsset* { assert(asset_loads_allowed_ && sys_assets_loaded_); assert(g_base->InLogicThread()); assert(static_cast(id) < system_textures_.size()); - return system_textures_[static_cast(id)].Get(); + return system_textures_[static_cast(id)].get(); } auto Assets::SysCubeMapTexture(SysCubeMapTextureID id) -> TextureAsset* { assert(asset_loads_allowed_ && sys_assets_loaded_); assert(g_base->InLogicThread()); assert(static_cast(id) < system_cube_map_textures_.size()); - return system_cube_map_textures_[static_cast(id)].Get(); + return system_cube_map_textures_[static_cast(id)].get(); } auto Assets::IsValidSysSound(SysSoundID id) -> bool { @@ -1659,14 +1659,14 @@ auto Assets::SysSound(SysSoundID id) -> SoundAsset* { assert(asset_loads_allowed_ && sys_assets_loaded_); assert(g_base->InLogicThread()); assert(IsValidSysSound(id)); - return system_sounds_[static_cast(id)].Get(); + return system_sounds_[static_cast(id)].get(); } auto Assets::SysMesh(SysMeshID id) -> MeshAsset* { assert(asset_loads_allowed_ && sys_assets_loaded_); assert(g_base->InLogicThread()); assert(static_cast(id) < system_meshes_.size()); - return system_meshes_[static_cast(id)].Get(); + return system_meshes_[static_cast(id)].get(); } } // namespace ballistica::base diff --git a/src/ballistica/base/assets/assets_server.cc b/src/ballistica/base/assets/assets_server.cc index ee029bd6..eed4f43f 100644 --- a/src/ballistica/base/assets/assets_server.cc +++ b/src/ballistica/base/assets/assets_server.cc @@ -30,7 +30,7 @@ void AssetsServer::OnAppStartInThread_() { // Ask our thread to give us periodic processing time (close to but not // *exactly* one second; try to avoid aliasing with similar updates). process_timer_ = event_loop()->NewTimer( - 987 * 1000, true, NewLambdaRunnable([this] { Process_(); }).Get()); + 987 * 1000, true, NewLambdaRunnable([this] { Process_(); }).get()); } void AssetsServer::PushPendingPreload(Object::Ref* asset_ref_ptr) { diff --git a/src/ballistica/base/assets/data_asset.cc b/src/ballistica/base/assets/data_asset.cc index 051158c2..ea918982 100644 --- a/src/ballistica/base/assets/data_asset.cc +++ b/src/ballistica/base/assets/data_asset.cc @@ -49,7 +49,7 @@ void DataAsset::DoLoad() { object_ = g_core->python->objs() .Get(core::CorePython::ObjID::kJsonLoadsCall) .Call(args); - if (!object_.Exists()) { + if (!object_.exists()) { throw Exception("Unable to load data: '" + file_name_ + "'."); } } diff --git a/src/ballistica/base/assets/mesh_asset.cc b/src/ballistica/base/assets/mesh_asset.cc index 7be25131..c93d01fe 100644 --- a/src/ballistica/base/assets/mesh_asset.cc +++ b/src/ballistica/base/assets/mesh_asset.cc @@ -113,7 +113,7 @@ void MeshAsset::DoPreload() { } void MeshAsset::DoLoad() { - assert(!renderer_data_.Exists()); + assert(!renderer_data_.exists()); renderer_data_ = g_base->graphics_server->renderer()->NewMeshAssetData(*this); // once we're loaded lets free up our vert data memory @@ -125,7 +125,7 @@ void MeshAsset::DoLoad() { void MeshAsset::DoUnload() { assert(valid_); - assert(renderer_data_.Exists()); + assert(renderer_data_.exists()); std::vector().swap(vertices_); std::vector().swap(indices8_); std::vector().swap(indices16_); diff --git a/src/ballistica/base/assets/mesh_asset.h b/src/ballistica/base/assets/mesh_asset.h index d5e91836..865b0eb8 100644 --- a/src/ballistica/base/assets/mesh_asset.h +++ b/src/ballistica/base/assets/mesh_asset.h @@ -22,8 +22,8 @@ class MeshAsset : public Asset { auto GetName() const -> std::string override; auto renderer_data() const -> MeshAssetRendererData* { - assert(renderer_data_.Exists()); - return renderer_data_.Get(); + assert(renderer_data_.exists()); + return renderer_data_.get(); } auto vertices() const -> const std::vector& { return vertices_; @@ -53,7 +53,6 @@ class MeshAsset : public Asset { std::vector indices8_; std::vector indices16_; std::vector indices32_; - friend class MeshAssetRendererData; BA_DISALLOW_CLASS_COPIES(MeshAsset); }; diff --git a/src/ballistica/base/assets/texture_asset.cc b/src/ballistica/base/assets/texture_asset.cc index da6eb9eb..55dbafe5 100644 --- a/src/ballistica/base/assets/texture_asset.cc +++ b/src/ballistica/base/assets/texture_asset.cc @@ -112,7 +112,7 @@ void TextureAsset::DoPreload() { auto texture_quality = g_base->graphics->placeholder_texture_quality(); // If we're a text-texture. - if (packer_.Exists()) { + if (packer_.exists()) { assert(type_ == TextureType::k2D); int width = packer_->texture_width(); @@ -448,9 +448,9 @@ void TextureAsset::DoPreload() { void TextureAsset::DoLoad() { assert(g_base->app_adapter->InGraphicsContext()); - assert(!renderer_data_.Exists()); + assert(!renderer_data_.exists()); renderer_data_ = g_base->graphics_server->renderer()->NewTextureData(*this); - assert(renderer_data_.Exists()); + assert(renderer_data_.exists()); renderer_data_->Load(); // Store our base-level from the preload-data so we know if we're lower than @@ -465,7 +465,7 @@ void TextureAsset::DoLoad() { void TextureAsset::DoUnload() { assert(g_base->app_adapter->InGraphicsContext()); assert(valid_); - assert(renderer_data_.Exists()); + assert(renderer_data_.exists()); renderer_data_.Clear(); base_level_ = 0; } diff --git a/src/ballistica/base/assets/texture_asset.h b/src/ballistica/base/assets/texture_asset.h index 88e90346..61f6cb44 100644 --- a/src/ballistica/base/assets/texture_asset.h +++ b/src/ballistica/base/assets/texture_asset.h @@ -38,8 +38,8 @@ class TextureAsset : public Asset { return preload_datas_; } auto renderer_data() const -> TextureAssetRendererData* { - assert(renderer_data_.Exists()); - return renderer_data_.Get(); + assert(renderer_data_.exists()); + return renderer_data_.get(); } auto base_level() const -> int { return base_level_; } diff --git a/src/ballistica/base/audio/audio_server.cc b/src/ballistica/base/audio/audio_server.cc index a71b84e1..6ac888cd 100644 --- a/src/ballistica/base/audio/audio_server.cc +++ b/src/ballistica/base/audio/audio_server.cc @@ -113,7 +113,7 @@ class AudioServer::ThreadSource_ : public Object { auto GetDefaultOwnerThread() const -> EventLoopID override; auto client_source() const -> AudioSource* { return client_source_.get(); } auto source_sound() const -> SoundAsset* { - return source_sound_ ? source_sound_->Get() : nullptr; + return source_sound_ ? source_sound_->get() : nullptr; } void UpdatePitch(); @@ -228,7 +228,7 @@ void AudioServer::OnAppStartInThread_() { // Get our thread to give us periodic processing time. process_timer_ = event_loop()->NewTimer(kAudioProcessIntervalNormal, true, - NewLambdaRunnable([this] { Process_(); }).Get()); + NewLambdaRunnable([this] { Process_(); }).get()); #if BA_ENABLE_AUDIO @@ -1248,7 +1248,7 @@ void AudioServer::ThreadSource_::UpdateAvailability() { // off, stuttering, etc.). If it's non-looping, we check its play state and // snatch it if it's not playing. bool busy; - if (looping_ || (is_streamed_ && streamer_.Exists() && streamer_->loops())) { + if (looping_ || (is_streamed_ && streamer_.exists() && streamer_->loops())) { busy = want_to_play_; } else { // If our context is suspended, we know nothing is playing @@ -1380,7 +1380,7 @@ auto AudioServer::ThreadSource_::Play(const Object::Ref* sound) #if BA_ENABLE_AUDIO assert(g_base->InAudioThread()); - assert(sound->Exists()); + assert(sound->exists()); // Stop whatever we were doing. Stop(); @@ -1430,7 +1430,7 @@ void AudioServer::ThreadSource_::ExecPlay() { #if BA_ENABLE_AUDIO assert(g_core); - assert(source_sound_->Exists()); + assert(source_sound_->exists()); assert((**source_sound_).valid()); assert((**source_sound_).loaded()); assert(!is_actually_playing_); @@ -1502,7 +1502,7 @@ void AudioServer::ThreadSource_::Stop() { if (is_actually_playing_) { ExecStop(); } - if (streamer_.Exists()) { + if (streamer_.exists()) { streamer_.Clear(); } // If we've got an attached sound, toss it back to the main thread @@ -1523,7 +1523,7 @@ void AudioServer::ThreadSource_::ExecStop() { assert(g_base->InAudioThread()); assert(!g_base->audio_server->suspended_); assert(is_actually_playing_); - if (streamer_.Exists()) { + if (streamer_.exists()) { assert(is_streamed_); streamer_->Stop(); for (auto i = audio_server_->streaming_sources_.begin(); diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index 95fa14cf..3db78327 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -121,7 +121,7 @@ void BaseFeatureSet::OnModuleExec(PyObject* module) { bool success = g_base->python->objs() .Get(BasePython::ObjID::kEnvOnNativeModuleImportCall) .Call() - .Exists(); + .exists(); if (!success) { FatalError("babase._env.on_native_module_import() call failed."); } @@ -177,7 +177,7 @@ auto BaseFeatureSet::GetV2AccountID() -> std::optional { auto gil = Python::ScopedInterpreterLock(); auto result = python->objs().Get(BasePython::ObjID::kGetV2AccountIdCall).Call(); - if (result.Exists()) { + if (result.exists()) { if (result.ValueIsNone()) { return {}; } @@ -561,7 +561,7 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { Python::ScopedInterpreterLock gil; auto uuid = g_base->python->objs().Get(BasePython::ObjID::kUUIDStrCall).Call(); - if (uuid.Exists()) { + if (uuid.exists()) { app_instance_uuid = uuid.ValueAsString(); have_app_instance_uuid = true; } @@ -736,31 +736,31 @@ void BaseFeatureSet::PushDevConsolePrintCall(const std::string& msg, PyObject* BaseFeatureSet::GetPyExceptionType(PyExcType exctype) { switch (exctype) { case PyExcType::kContext: - return python->objs().Get(BasePython::ObjID::kContextError).Get(); + return python->objs().Get(BasePython::ObjID::kContextError).get(); case PyExcType::kNotFound: - return python->objs().Get(BasePython::ObjID::kNotFoundError).Get(); + return python->objs().Get(BasePython::ObjID::kNotFoundError).get(); case PyExcType::kNodeNotFound: - return python->objs().Get(BasePython::ObjID::kNodeNotFoundError).Get(); + return python->objs().Get(BasePython::ObjID::kNodeNotFoundError).get(); case PyExcType::kSessionPlayerNotFound: return python->objs() .Get(BasePython::ObjID::kSessionPlayerNotFoundError) - .Get(); + .get(); case PyExcType::kInputDeviceNotFound: return python->objs() .Get(BasePython::ObjID::kInputDeviceNotFoundError) - .Get(); + .get(); case PyExcType::kDelegateNotFound: return python->objs() .Get(BasePython::ObjID::kDelegateNotFoundError) - .Get(); + .get(); case PyExcType::kWidgetNotFound: - return python->objs().Get(BasePython::ObjID::kWidgetNotFoundError).Get(); + return python->objs().Get(BasePython::ObjID::kWidgetNotFoundError).get(); case PyExcType::kActivityNotFound: return python->objs() .Get(BasePython::ObjID::kActivityNotFoundError) - .Get(); + .get(); case PyExcType::kSessionNotFound: - return python->objs().Get(BasePython::ObjID::kSessionNotFoundError).Get(); + return python->objs().Get(BasePython::ObjID::kSessionNotFoundError).get(); default: return nullptr; } diff --git a/src/ballistica/base/dynamics/bg/bg_dynamics.cc b/src/ballistica/base/dynamics/bg/bg_dynamics.cc index 0c9d3a0a..2a7ae486 100644 --- a/src/ballistica/base/dynamics/bg/bg_dynamics.cc +++ b/src/ballistica/base/dynamics/bg/bg_dynamics.cc @@ -183,8 +183,8 @@ void BGDynamics::Draw(FrameDef* frame_def) { } // Draw sparks. - if (ds->spark_vertices.Exists()) { - if (!sparks_mesh_.Exists()) sparks_mesh_ = Object::New(); + if (ds->spark_vertices.exists()) { + if (!sparks_mesh_.exists()) sparks_mesh_ = Object::New(); sparks_mesh_->SetIndexData(ds->spark_indices); sparks_mesh_->SetData( Object::Ref>(ds->spark_vertices)); @@ -198,29 +198,29 @@ void BGDynamics::Draw(FrameDef* frame_def) { c.SetColor(2.0f, 2.0f, 2.0f, 1.0f); c.SetOverlay(draw_in_overlay); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kSparks)); - c.DrawMesh(sparks_mesh_.Get(), kMeshDrawFlagNoReflection); + c.DrawMesh(sparks_mesh_.get(), kMeshDrawFlagNoReflection); c.Submit(); } // Draw lights. - if (ds->light_vertices.Exists()) { - assert(ds->light_indices.Exists()); + if (ds->light_vertices.exists()) { + assert(ds->light_indices.exists()); assert(!ds->light_indices->elements.empty()); assert(!ds->light_vertices->elements.empty()); - if (!lights_mesh_.Exists()) lights_mesh_ = Object::New(); + if (!lights_mesh_.exists()) lights_mesh_ = Object::New(); lights_mesh_->SetIndexData(ds->light_indices); lights_mesh_->SetData( Object::Ref>(ds->light_vertices)); SpriteComponent c(frame_def->light_shadow_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kLightSoft)); - c.DrawMesh(lights_mesh_.Get()); + c.DrawMesh(lights_mesh_.get()); c.Submit(); } // Draw shadows. - if (ds->shadow_vertices.Exists()) { - assert(ds->shadow_indices.Exists()); - if (!shadows_mesh_.Exists()) { + if (ds->shadow_vertices.exists()) { + assert(ds->shadow_indices.exists()); + if (!shadows_mesh_.exists()) { shadows_mesh_ = Object::New(); } shadows_mesh_->SetIndexData(ds->shadow_indices); @@ -228,7 +228,7 @@ void BGDynamics::Draw(FrameDef* frame_def) { Object::Ref>(ds->shadow_vertices)); SpriteComponent c(frame_def->light_shadow_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kLight)); - c.DrawMesh(shadows_mesh_.Get()); + c.DrawMesh(shadows_mesh_.get()); c.Submit(); } @@ -243,8 +243,8 @@ void BGDynamics::Draw(FrameDef* frame_def) { DrawChunks(frame_def, &ds->flag_stands, BGDynamicsChunkType::kFlagStand); // Draw tendrils. - if (ds->tendril_vertices.Exists()) { - if (!tendrils_mesh_.Exists()) + if (ds->tendril_vertices.exists()) { + if (!tendrils_mesh_.exists()) tendrils_mesh_ = Object::New(); tendrils_mesh_->SetIndexData(ds->tendril_indices); tendrils_mesh_->SetData( @@ -254,7 +254,7 @@ void BGDynamics::Draw(FrameDef* frame_def) { : frame_def->beauty_pass()); c.SetOverlay(draw_in_overlay); c.SetColor(1.0f, 1.0f, 1.0f, 1.0f); - c.DrawMesh(tendrils_mesh_.Get(), kMeshDrawFlagNoReflection); + c.DrawMesh(tendrils_mesh_.get(), kMeshDrawFlagNoReflection); c.Submit(); // Shadows. @@ -270,9 +270,9 @@ void BGDynamics::Draw(FrameDef* frame_def) { } // Draw fuses. - if (ds->fuse_vertices.Exists()) { + if (ds->fuse_vertices.exists()) { // Update our mesh with this data. - if (!fuses_mesh_.Exists()) + if (!fuses_mesh_.exists()) fuses_mesh_ = Object::New(); fuses_mesh_->SetIndexData(ds->fuse_indices); fuses_mesh_->SetData( @@ -280,7 +280,7 @@ void BGDynamics::Draw(FrameDef* frame_def) { { // Draw! ObjectComponent c(frame_def->beauty_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kFuse)); - c.DrawMesh(fuses_mesh_.Get(), kMeshDrawFlagNoReflection); + c.DrawMesh(fuses_mesh_.get(), kMeshDrawFlagNoReflection); c.Submit(); } } diff --git a/src/ballistica/base/dynamics/bg/bg_dynamics_draw_snapshot.h b/src/ballistica/base/dynamics/bg/bg_dynamics_draw_snapshot.h index 977e2db3..09916bdb 100644 --- a/src/ballistica/base/dynamics/bg/bg_dynamics_draw_snapshot.h +++ b/src/ballistica/base/dynamics/bg/bg_dynamics_draw_snapshot.h @@ -28,16 +28,16 @@ class BGDynamicsDrawSnapshot { // over or else the debug thread-access-checks will error. void SetLogicThreadOwnership() { if (g_buildconfig.debug_build()) { - for (Object* o : {static_cast(tendril_indices.Get()), - static_cast(tendril_vertices.Get()), - static_cast(fuse_indices.Get()), - static_cast(fuse_vertices.Get()), - static_cast(shadow_indices.Get()), - static_cast(shadow_vertices.Get()), - static_cast(light_indices.Get()), - static_cast(light_vertices.Get()), - static_cast(spark_indices.Get()), - static_cast(spark_vertices.Get())}) { + for (Object* o : {static_cast(tendril_indices.get()), + static_cast(tendril_vertices.get()), + static_cast(fuse_indices.get()), + static_cast(fuse_vertices.get()), + static_cast(shadow_indices.get()), + static_cast(shadow_vertices.get()), + static_cast(light_indices.get()), + static_cast(light_vertices.get()), + static_cast(spark_indices.get()), + static_cast(spark_vertices.get())}) { if (o) { o->SetThreadOwnership(Object::ThreadOwnership::kClassDefault); } diff --git a/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc b/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc index da56a67f..29ef9e4a 100644 --- a/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc +++ b/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc @@ -85,7 +85,7 @@ class BGDynamicsServer::Terrain { } auto GetCollisionMesh() const -> CollisionMeshAsset* { - return collision_mesh_->Get(); + return collision_mesh_->get(); } ~Terrain() { diff --git a/src/ballistica/base/graphics/component/object_component.cc b/src/ballistica/base/graphics/component/object_component.cc index 7030abef..fcc2eeb1 100644 --- a/src/ballistica/base/graphics/component/object_component.cc +++ b/src/ballistica/base/graphics/component/object_component.cc @@ -10,12 +10,12 @@ void ObjectComponent::WriteConfig() { // If they didn't give us a texture, just use a blank white texture. // This is not a common case and easier than forking all our shaders to // create non-textured versions. - if (!texture_.Exists()) { + if (!texture_.exists()) { texture_ = g_base->assets->SysTexture(SysTextureID::kWhite); } if (reflection_ == ReflectionType::kNone) { assert(!double_sided_); // Unsupported combo. - assert(!colorize_texture_.Exists()); // Unsupported combo. + assert(!colorize_texture_.exists()); // Unsupported combo. assert(!have_color_add_); // Unsupported combo. if (light_shadow_ == LightShadowType::kNone) { if (transparent_) { @@ -47,7 +47,7 @@ void ObjectComponent::WriteConfig() { } else { if (light_shadow_ == LightShadowType::kNone) { assert(!double_sided_); // Unsupported combo. - assert(!colorize_texture_.Exists()); // Unsupported combo. + assert(!colorize_texture_.exists()); // Unsupported combo. if (transparent_) { assert(!world_space_); // Unsupported combo. if (have_color_add_) { @@ -87,7 +87,7 @@ void ObjectComponent::WriteConfig() { // With add. assert(!transparent_); // Unsupported combo. if (!have_color_add_) { - if (colorize_texture_.Exists()) { + if (colorize_texture_.exists()) { assert(!double_sided_); // Unsupported combo. assert(!world_space_); // Unsupported combo. if (do_colorize_2_) { @@ -148,7 +148,7 @@ void ObjectComponent::WriteConfig() { } else { assert(!double_sided_); // Unsupported combo. assert(!world_space_); // Unsupported config. - if (colorize_texture_.Exists()) { + if (colorize_texture_.exists()) { if (do_colorize_2_) { ConfigForShading( ShadingType::kObjectReflectLightShadowAddColorized2); diff --git a/src/ballistica/base/graphics/component/render_component.h b/src/ballistica/base/graphics/component/render_component.h index 9184a9fe..1ab6196c 100644 --- a/src/ballistica/base/graphics/component/render_component.h +++ b/src/ballistica/base/graphics/component/render_component.h @@ -7,6 +7,7 @@ #include "ballistica/base/assets/mesh_asset.h" #include "ballistica/base/graphics/graphics.h" +#include "ballistica/base/graphics/mesh/mesh.h" #include "ballistica/base/graphics/renderer/render_pass.h" #include "ballistica/base/graphics/support/frame_def.h" #include "ballistica/base/graphics/support/render_command_buffer.h" diff --git a/src/ballistica/base/graphics/component/simple_component.cc b/src/ballistica/base/graphics/component/simple_component.cc index e99f438c..f5f366b1 100644 --- a/src/ballistica/base/graphics/component/simple_component.cc +++ b/src/ballistica/base/graphics/component/simple_component.cc @@ -11,15 +11,15 @@ void SimpleComponent::WriteConfig() { // swapping (ie: when color is 1). This is because it can affect draw // order, which is important unlike with opaque stuff. if (transparent_) { - if (texture_.Exists()) { - if (colorize_texture_.Exists()) { + if (texture_.exists()) { + if (colorize_texture_.exists()) { assert(flatness_ == 0.0f); // unimplemented combo assert(glow_amount_ == 0.0f); // unimplemented combo assert(shadow_opacity_ == 0.0f); // unimplemented combo assert(!double_sided_); // unimplemented combo - assert(!mask_uv2_texture_.Exists()); // unimplemented combo + assert(!mask_uv2_texture_.exists()); // unimplemented combo if (do_colorize_2_) { - if (mask_texture_.Exists()) { + if (mask_texture_.exists()) { ConfigForShading( ShadingType:: kSimpleTextureModulatedTransparentColorized2Masked); @@ -43,7 +43,7 @@ void SimpleComponent::WriteConfig() { cmd_buffer_->PutTexture(colorize_texture_); } } else { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo ConfigForShading( ShadingType::kSimpleTextureModulatedTransparentColorized); cmd_buffer_->PutInt(premultiplied_); @@ -56,12 +56,12 @@ void SimpleComponent::WriteConfig() { } else { // Non-colorized with texture. if (double_sided_) { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo assert(flatness_ == 0.0f); // unimplemented combo assert(glow_amount_ == 0.0f); // unimplemented combo assert(shadow_opacity_ == 0.0f); // unimplemented combo - assert(!mask_texture_.Exists()); // unimplemented combo - assert(!mask_uv2_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo + assert(!mask_uv2_texture_.exists()); // unimplemented combo ConfigForShading( ShadingType::kSimpleTextureModulatedTransparentDoubleSided); cmd_buffer_->PutInt(premultiplied_); @@ -69,9 +69,9 @@ void SimpleComponent::WriteConfig() { cmd_buffer_->PutTexture(texture_); } else { if (shadow_opacity_ > 0.0f) { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo assert(glow_amount_ == 0.0f); // unimplemented combo - assert(mask_uv2_texture_.Exists()); + assert(mask_uv2_texture_.exists()); if (flatness_ != 0.0f) { ConfigForShading( ShadingType::kSimpleTexModulatedTransShadowFlatness); @@ -93,9 +93,9 @@ void SimpleComponent::WriteConfig() { } } else { if (glow_amount_ > 0.0f) { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo assert(flatness_ == 0.0f); // unimplemented combo - if (mask_uv2_texture_.Exists()) { + if (mask_uv2_texture_.exists()) { ConfigForShading( ShadingType::kSimpleTextureModulatedTransparentGlowMaskUV2); cmd_buffer_->PutInt(premultiplied_); @@ -113,7 +113,7 @@ void SimpleComponent::WriteConfig() { } } else { if (flatness_ != 0.0f) { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo ConfigForShading( ShadingType::kSimpleTextureModulatedTransFlatness); cmd_buffer_->PutInt(premultiplied_); @@ -121,7 +121,7 @@ void SimpleComponent::WriteConfig() { flatness_); cmd_buffer_->PutTexture(texture_); } else { - if (mask_texture_.Exists()) { + if (mask_texture_.exists()) { // Currently mask functionality requires colorize too, so // just send a black texture for that. ConfigForShading( @@ -153,9 +153,9 @@ void SimpleComponent::WriteConfig() { assert(flatness_ == 0.0f); // unimplemented combo assert(glow_amount_ == 0.0f); // unimplemented combo assert(shadow_opacity_ == 0.0f); // unimplemented combo - assert(!colorize_texture_.Exists()); // unimplemented combo - assert(!mask_texture_.Exists()); // unimplemented combo - assert(!mask_uv2_texture_.Exists()); // unimplemented combo + assert(!colorize_texture_.exists()); // unimplemented combo + assert(!mask_texture_.exists()); // unimplemented combo + assert(!mask_uv2_texture_.exists()); // unimplemented combo if (double_sided_) { ConfigForShading(ShadingType::kSimpleColorTransparentDoubleSided); cmd_buffer_->PutInt(premultiplied_); @@ -173,10 +173,10 @@ void SimpleComponent::WriteConfig() { assert(glow_amount_ == 0.0f); // unimplemented combo assert(shadow_opacity_ == 0.0f); // unimplemented combo assert(!double_sided_); // unimplemented combo - assert(!mask_uv2_texture_.Exists()); // unimplemented combo - if (texture_.Exists()) { - if (colorize_texture_.Exists()) { - assert(!mask_texture_.Exists()); // unimplemented combo + assert(!mask_uv2_texture_.exists()); // unimplemented combo + if (texture_.exists()) { + if (colorize_texture_.exists()) { + assert(!mask_texture_.exists()); // unimplemented combo if (do_colorize_2_) { ConfigForShading(ShadingType::kSimpleTextureModulatedColorized2); cmd_buffer_->PutFloats(color_r_, color_g_, color_b_, @@ -195,7 +195,7 @@ void SimpleComponent::WriteConfig() { } } else { assert(!do_colorize_2_); // unsupported combo - if (mask_texture_.Exists()) { + if (mask_texture_.exists()) { // Currently mask functionality requires colorize too, so // we have to send a black texture along for that. ConfigForShading( @@ -221,8 +221,8 @@ void SimpleComponent::WriteConfig() { } } } else { - assert(!mask_texture_.Exists()); // unimplemented combo - assert(!colorize_texture_.Exists()); // unsupported here + assert(!mask_texture_.exists()); // unimplemented combo + assert(!colorize_texture_.exists()); // unsupported here ConfigForShading(ShadingType::kSimpleColor); cmd_buffer_->PutFloats(color_r_, color_g_, color_b_); } diff --git a/src/ballistica/base/graphics/component/sprite_component.cc b/src/ballistica/base/graphics/component/sprite_component.cc index b653bb26..c92310c5 100644 --- a/src/ballistica/base/graphics/component/sprite_component.cc +++ b/src/ballistica/base/graphics/component/sprite_component.cc @@ -10,7 +10,7 @@ void SpriteComponent::WriteConfig() { // if they didn't give us a texture, just use a blank white texture; // this is not a common case and easier than forking all our shaders // to create non-textured versions. - if (!texture_.Exists()) { + if (!texture_.exists()) { texture_ = g_base->assets->SysTexture(SysTextureID::kWhite); } if (exponent_ == 1) { diff --git a/src/ballistica/base/graphics/gl/render_target_gl.h b/src/ballistica/base/graphics/gl/render_target_gl.h index f4c87f9c..3bd79b96 100644 --- a/src/ballistica/base/graphics/gl/render_target_gl.h +++ b/src/ballistica/base/graphics/gl/render_target_gl.h @@ -13,7 +13,7 @@ class RendererGL::RenderTargetGL : public RenderTarget { public: void Bind() { if (type_ == Type::kFramebuffer) { - assert(framebuffer_.Exists()); + assert(framebuffer_.exists()); framebuffer_->Bind(); } else { assert(type_ == Type::kScreen); @@ -79,7 +79,7 @@ class RendererGL::RenderTargetGL : public RenderTarget { auto GetFramebufferID() -> GLuint { if (type_ == Type::kFramebuffer) { - assert(framebuffer_.Exists()); + assert(framebuffer_.exists()); return framebuffer_->id(); } else { return 0; // screen @@ -88,7 +88,7 @@ class RendererGL::RenderTargetGL : public RenderTarget { auto framebuffer() -> FramebufferObjectGL* { assert(type_ == Type::kFramebuffer); - return framebuffer_.Get(); + return framebuffer_.get(); } // Screen constructor. diff --git a/src/ballistica/base/graphics/gl/renderer_gl.cc b/src/ballistica/base/graphics/gl/renderer_gl.cc index b75623ad..ed46a130 100644 --- a/src/ballistica/base/graphics/gl/renderer_gl.cc +++ b/src/ballistica/base/graphics/gl/renderer_gl.cc @@ -827,21 +827,21 @@ void RendererGL::SyncGLState_() { assert(*index_size == 4 || *index_size == 2); \ bool use_indices32 = (*index_size == 4); \ if (use_indices32) { \ - indices32 = static_cast(buffer->Get()); \ + indices32 = static_cast(buffer->get()); \ assert(indices32&& indices32 \ - == dynamic_cast(buffer->Get())); \ + == dynamic_cast(buffer->get())); \ } else { \ - indices16 = static_cast(buffer->Get()); \ + indices16 = static_cast(buffer->get()); \ assert(indices16&& indices16 \ - == dynamic_cast(buffer->Get())); \ + == dynamic_cast(buffer->get())); \ } \ index_size++; \ buffer++ #define GET_BUFFER(TYPE, VAR) \ assert(buffer != buffers.end()); \ - auto* VAR = static_cast(buffer->Get()); \ - assert(VAR&& VAR == dynamic_cast(buffer->Get())); \ + auto* VAR = static_cast(buffer->get()); \ + assert(VAR&& VAR == dynamic_cast(buffer->get())); \ buffer++ // Takes all latest mesh data from the client side and applies it to our gl @@ -3128,7 +3128,7 @@ void RendererGL::GenerateCameraBufferBlurPasses() { FramebufferObjectGL* src_fb = static_cast(camera_render_target())->framebuffer(); for (auto&& i : blur_buffers_) { - FramebufferObjectGL* fb = i.Get(); + FramebufferObjectGL* fb = i.get(); assert(fb); fb->Bind(); SetViewport_(0, 0, fb->width(), fb->height()); diff --git a/src/ballistica/base/graphics/graphics.cc b/src/ballistica/base/graphics/graphics.cc index c60d4c8c..69d49a11 100644 --- a/src/ballistica/base/graphics/graphics.cc +++ b/src/ballistica/base/graphics/graphics.cc @@ -162,7 +162,7 @@ void Graphics::UpdateInitialGraphicsSettingsSend_() { g_base->app_adapter->PushGraphicsContextCall([settings] { assert(g_base->app_adapter->InGraphicsContext()); - g_base->graphics_server->ApplySettings(settings->Get()); + g_base->graphics_server->ApplySettings(settings->get()); g_base->logic->event_loop()->PushCall([settings] { // Release our strong ref back here in the logic thread. assert(g_base->InLogicThread()); @@ -319,11 +319,11 @@ void Graphics::DrawProgressBar(RenderPass* pass, float opacity) { (t - b)); c.SetColor(0.0f, 0.07f, 0.0f, 1 * o); - c.DrawMesh(progress_bar_bottom_mesh_.Get()); + c.DrawMesh(progress_bar_bottom_mesh_.get()); c.Submit(); c.SetColor(0.23f, 0.17f, 0.35f, 1 * o); - c.DrawMesh(progress_bar_top_mesh_.Get()); + c.DrawMesh(progress_bar_top_mesh_.get()); c.Submit(); } @@ -378,7 +378,7 @@ void Graphics::DrawMiscOverlays(FrameDef* frame_def) { snprintf(fps_str, sizeof(fps_str), "%d", last_fps_); if (fps_str != fps_string_) { fps_string_ = fps_str; - if (!fps_text_group_.Exists()) { + if (!fps_text_group_.exists()) { fps_text_group_ = Object::New(); } fps_text_group_->SetText(fps_string_); @@ -415,7 +415,7 @@ void Graphics::DrawMiscOverlays(FrameDef* frame_def) { snprintf(ping_str, sizeof(ping_str), "%.0f ms", *ping); if (ping_str != ping_string_) { ping_string_ = ping_str; - if (!ping_text_group_.Exists()) { + if (!ping_text_group_.exists()) { ping_text_group_ = Object::New(); } ping_text_group_->SetText(ping_string_); @@ -451,7 +451,7 @@ void Graphics::DrawMiscOverlays(FrameDef* frame_def) { if (!net_info_str.empty()) { if (net_info_str != net_info_string_) { net_info_string_ = net_info_str; - if (!net_info_text_group_.Exists()) { + if (!net_info_text_group_.exists()) { net_info_text_group_ = Object::New(); } net_info_text_group_->SetText(net_info_string_); @@ -479,7 +479,7 @@ void Graphics::DrawMiscOverlays(FrameDef* frame_def) { float debug_graph_y = 50.0; auto now = g_core->GetAppTimeMillisecs(); for (auto it = debug_graphs_.begin(); it != debug_graphs_.end();) { - assert(it->second.Exists()); + assert(it->second.exists()); if (now - it->second->LastUsedTime() > 1000) { it = debug_graphs_.erase(it); } else { @@ -504,7 +504,7 @@ auto Graphics::GetDebugGraph(const std::string& name, bool smoothed) debug_graphs_[name]->SetSmoothed(smoothed); } debug_graphs_[name]->SetLastUsedTime(g_core->GetAppTimeMillisecs()); - return debug_graphs_[name].Get(); + return debug_graphs_[name].get(); } void Graphics::GetSafeColor(float* red, float* green, float* blue, @@ -543,7 +543,7 @@ void Graphics::Reset() { fade_ = 0; fade_start_ = 0; - if (!camera_.Exists()) { + if (!camera_.exists()) { camera_ = Object::New(); } @@ -599,13 +599,13 @@ auto Graphics::GetGraphicsSettingsSnapshot() -> Snapshot* { graphics_settings_dirty_ = false; // We keep a cached copy of this value since we use it a lot. - tv_border_ = settings_snapshot_->Get()->tv_border; + tv_border_ = settings_snapshot_->get()->tv_border; // This can affect placeholder settings; keep those up to date. UpdatePlaceholderSettings(); } - assert(settings_snapshot_.Exists()); - return settings_snapshot_.Get(); + assert(settings_snapshot_.exists()); + return settings_snapshot_.get(); } void Graphics::ClearFrameDefDeleteList() { @@ -628,7 +628,7 @@ void Graphics::FadeScreen(bool to, millisecs_t time, PyObject* endcall) { assert(g_base->InLogicThread()); // If there's an ourstanding fade-end command, go ahead and run it. // (otherwise, overlapping fades can cause things to get lost) - if (fade_end_call_.Exists()) { + if (fade_end_call_.exists()) { if (g_buildconfig.debug_build()) { g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, "2 fades overlapping; running first fade-end-call early."); @@ -657,7 +657,7 @@ void Graphics::DrawLoadDot(RenderPass* pass) { } else { c.SetColor(0, 0.2f, 0, 1); } - c.DrawMesh(load_dot_mesh_.Get()); + c.DrawMesh(load_dot_mesh_.get()); c.Submit(); } @@ -757,7 +757,7 @@ void Graphics::BuildAndPushFrameDef() { assert(g_base->InLogicThread()); assert(g_base->logic->app_bootstrapping_complete()); - assert(camera_.Exists()); + assert(camera_.exists()); assert(!g_core->HeadlessMode()); // Keep track of when we're in here; can be useful for making sure stuff @@ -1045,7 +1045,7 @@ void Graphics::DrawFades(FrameDef* frame_def) { } } else { fade_ = 0; - if (!was_done && fade_end_call_.Exists()) { + if (!was_done && fade_end_call_.exists()) { fade_end_call_->Schedule(); fade_end_call_.Clear(); } @@ -1087,7 +1087,7 @@ void Graphics::DoDrawFade(FrameDef* frame_def, float amt) { // need stuff covering this methinks. auto xf = c.ScopedTransform(); c.Translate(0.0f, 0.0f, 1.0f); - c.DrawMesh(screen_mesh_.Get()); + c.DrawMesh(screen_mesh_.get()); } c.Submit(); } @@ -1145,7 +1145,7 @@ void Graphics::DrawCursor(FrameDef* frame_def) { void Graphics::DrawBlotches(FrameDef* frame_def) { if (!blotch_verts_.empty()) { - if (!shadow_blotch_mesh_.Exists()) { + if (!shadow_blotch_mesh_.exists()) { shadow_blotch_mesh_ = Object::New(); } shadow_blotch_mesh_->SetIndexData(Object::New( @@ -1154,11 +1154,11 @@ void Graphics::DrawBlotches(FrameDef* frame_def) { blotch_verts_.size(), &blotch_verts_[0])); SpriteComponent c(frame_def->light_shadow_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kLight)); - c.DrawMesh(shadow_blotch_mesh_.Get()); + c.DrawMesh(shadow_blotch_mesh_.get()); c.Submit(); } if (!blotch_soft_verts_.empty()) { - if (!shadow_blotch_soft_mesh_.Exists()) { + if (!shadow_blotch_soft_mesh_.exists()) { shadow_blotch_soft_mesh_ = Object::New(); } shadow_blotch_soft_mesh_->SetIndexData(Object::New( @@ -1167,11 +1167,11 @@ void Graphics::DrawBlotches(FrameDef* frame_def) { blotch_soft_verts_.size(), &blotch_soft_verts_[0])); SpriteComponent c(frame_def->light_shadow_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kLightSoft)); - c.DrawMesh(shadow_blotch_soft_mesh_.Get()); + c.DrawMesh(shadow_blotch_soft_mesh_.get()); c.Submit(); } if (!blotch_soft_obj_verts_.empty()) { - if (!shadow_blotch_soft_obj_mesh_.Exists()) { + if (!shadow_blotch_soft_obj_mesh_.exists()) { shadow_blotch_soft_obj_mesh_ = Object::New(); } shadow_blotch_soft_obj_mesh_->SetIndexData(Object::New( @@ -1180,7 +1180,7 @@ void Graphics::DrawBlotches(FrameDef* frame_def) { blotch_soft_obj_verts_.size(), &blotch_soft_obj_verts_[0])); SpriteComponent c(frame_def->light_pass()); c.SetTexture(g_base->assets->SysTexture(SysTextureID::kLightSoft)); - c.DrawMesh(shadow_blotch_soft_obj_mesh_.Get()); + c.DrawMesh(shadow_blotch_soft_obj_mesh_.get()); c.Submit(); } } @@ -1235,7 +1235,7 @@ void Graphics::ToggleManualCamera() { void Graphics::LocalCameraShake(float mag) { assert(g_base->InLogicThread()); - if (camera_.Exists()) { + if (camera_.exists()) { camera_->Shake(mag); } } @@ -1731,7 +1731,7 @@ void Graphics::set_client_context(Snapshot* context) { // Currently we only expect this to be set once. That will change once we // support renderer swapping/etc. assert(!g_base->logic->graphics_ready()); - assert(!client_context_snapshot_.Exists()); + assert(!client_context_snapshot_.exists()); client_context_snapshot_ = context; // Placeholder settings are affected by client context, so update them @@ -1747,7 +1747,7 @@ void Graphics::UpdatePlaceholderSettings() { assert(g_base->InLogicThread()); // Need both of these in place. - if (!settings_snapshot_.Exists() || !has_client_context()) { + if (!settings_snapshot_.exists() || !has_client_context()) { return; } diff --git a/src/ballistica/base/graphics/graphics.h b/src/ballistica/base/graphics/graphics.h index 2b898e1d..18002cec 100644 --- a/src/ballistica/base/graphics/graphics.h +++ b/src/ballistica/base/graphics/graphics.h @@ -158,7 +158,7 @@ class Graphics { // Enable progress bar drawing locally. void EnableProgressBar(bool fade_in); - auto* camera() { return camera_.Get(); } + auto* camera() { return camera_.get(); } void ToggleManualCamera(); void LocalCameraShake(float intensity); void ToggleDebugDraw(); @@ -316,8 +316,8 @@ class Graphics { auto* settings() const { assert(g_base->InLogicThread()); - assert(settings_snapshot_.Exists()); - return settings_snapshot_.Get()->Get(); + assert(settings_snapshot_.exists()); + return settings_snapshot_.get()->get(); } auto GetGraphicsSettingsSnapshot() -> Snapshot*; @@ -328,13 +328,13 @@ class Graphics { void UpdatePlaceholderSettings(); auto has_client_context() -> bool { - return client_context_snapshot_.Exists(); + return client_context_snapshot_.exists(); } auto client_context() const -> const GraphicsClientContext* { assert(g_base->InLogicThread()); - assert(client_context_snapshot_.Exists()); - return client_context_snapshot_.Get()->Get(); + assert(client_context_snapshot_.exists()); + return client_context_snapshot_.get()->get(); } static auto GraphicsQualityFromRequest(GraphicsQualityRequest request, @@ -348,7 +348,7 @@ class Graphics { /// possible and replaced with proper safe thread-specific access patterns /// (so we can support switching renderers/etc.). auto placeholder_texture_quality() const { - assert(client_context_snapshot_.Exists()); + assert(client_context_snapshot_.exists()); return texture_quality_placeholder_; } @@ -359,8 +359,8 @@ class Graphics { // Using this from arbitrary threads is currently ok currently since // context never changes once set. Will need to kill this call once that // can happen though. - assert(client_context_snapshot_.Exists()); - return client_context_snapshot_.Get()->Get(); + assert(client_context_snapshot_.exists()); + return client_context_snapshot_.get()->get(); } auto draw_ui_bounds() const { return draw_ui_bounds_; } void set_draw_ui_bounds(bool val) { draw_ui_bounds_ = val; } diff --git a/src/ballistica/base/graphics/mesh/mesh_indexed.h b/src/ballistica/base/graphics/mesh/mesh_indexed.h index 84c0f8a6..24759464 100644 --- a/src/ballistica/base/graphics/mesh/mesh_indexed.h +++ b/src/ballistica/base/graphics/mesh/mesh_indexed.h @@ -22,7 +22,7 @@ class MeshIndexed : public MeshIndexedBase { auto data() const -> const Object::Ref>& { return data_; } auto IsValid() const -> bool override { - if (!data_.Exists() || data_->elements.empty() + if (!data_.exists() || data_->elements.empty() || !MeshIndexedBase::IsValid()) { return false; } diff --git a/src/ballistica/base/graphics/mesh/mesh_indexed_base.h b/src/ballistica/base/graphics/mesh/mesh_indexed_base.h index 675dbe6e..2e0de3e2 100644 --- a/src/ballistica/base/graphics/mesh/mesh_indexed_base.h +++ b/src/ballistica/base/graphics/mesh/mesh_indexed_base.h @@ -22,11 +22,11 @@ class MeshIndexedBase : public Mesh { } void SetIndexData(const Object::Ref& data) { - assert(data.Exists() && !data->elements.empty()); + assert(data.exists() && !data->elements.empty()); // unlike vertex data, index data might often remain the same, so lets test // for that and avoid some gl updates.. - if (index_data_32_.Exists()) { - assert(data.Exists() && index_data_32_.Get()); + if (index_data_32_.exists()) { + assert(data.exists() && index_data_32_.get()); if (data->elements == index_data_32_->elements) { return; // just keep our existing one } @@ -39,11 +39,11 @@ class MeshIndexedBase : public Mesh { } void SetIndexData(const Object::Ref& data) { - assert(data.Exists() && !data->elements.empty()); + assert(data.exists() && !data->elements.empty()); // unlike vertex data, index data might often remain the same, so lets test // for that and avoid some gl updates.. - if (index_data_16_.Exists()) { - assert(index_data_16_.Get()); + if (index_data_16_.exists()) { + assert(index_data_16_.get()); if (data->elements == index_data_16_->elements) { return; // just keep our existing one } @@ -64,9 +64,9 @@ class MeshIndexedBase : public Mesh { auto IsValid() const -> bool override { switch (index_data_size()) { case 4: - return (index_data_32_.Exists() && !index_data_32_->elements.empty()); + return (index_data_32_.exists() && !index_data_32_->elements.empty()); case 2: - return (index_data_16_.Exists() && !index_data_16_->elements.empty()); + return (index_data_16_.exists() && !index_data_16_->elements.empty()); default: return false; } @@ -87,9 +87,9 @@ class MeshIndexedBase : public Mesh { auto GetIndexData() const -> MeshBufferBase* { switch (index_data_size()) { case 4: - return index_data_32_.Get(); + return index_data_32_.get(); case 2: - return index_data_16_.Get(); + return index_data_16_.get(); default: throw Exception(); } diff --git a/src/ballistica/base/graphics/mesh/mesh_indexed_static_dynamic.h b/src/ballistica/base/graphics/mesh/mesh_indexed_static_dynamic.h index 4f12ae6a..4c4585f7 100644 --- a/src/ballistica/base/graphics/mesh/mesh_indexed_static_dynamic.h +++ b/src/ballistica/base/graphics/mesh/mesh_indexed_static_dynamic.h @@ -24,8 +24,8 @@ class MeshIndexedStaticDynamic : public MeshIndexedBase { dynamic_data_->state = ++dynamic_state_; } auto IsValid() const -> bool override { - if (!static_data_.Exists() || static_data_->elements.empty() - || !dynamic_data_.Exists() || dynamic_data_->elements.empty() + if (!static_data_.exists() || static_data_->elements.empty() + || !dynamic_data_.exists() || dynamic_data_->elements.empty() || !MeshIndexedBase::IsValid()) { return false; } diff --git a/src/ballistica/base/graphics/mesh/text_mesh.cc b/src/ballistica/base/graphics/mesh/text_mesh.cc index 86722ac4..1fcd708f 100644 --- a/src/ballistica/base/graphics/mesh/text_mesh.cc +++ b/src/ballistica/base/graphics/mesh/text_mesh.cc @@ -61,8 +61,8 @@ void TextMesh::SetText(const std::string& text_in, HAlign alignment_h, } auto vertices(Object::New>(4 * text_size)); - uint16_t* index16 = indices16.Exists() ? indices16->elements.data() : nullptr; - uint32_t* index32 = indices32.Exists() ? indices32->elements.data() : nullptr; + uint16_t* index16 = indices16.exists() ? indices16->elements.data() : nullptr; + uint32_t* index32 = indices32.exists() ? indices32->elements.data() : nullptr; VertexDualTextureFull* v = &vertices->elements[0]; uint32_t index_offset = 0; diff --git a/src/ballistica/base/graphics/renderer/renderer.cc b/src/ballistica/base/graphics/renderer/renderer.cc index 4695d416..2a61bc60 100644 --- a/src/ballistica/base/graphics/renderer/renderer.cc +++ b/src/ballistica/base/graphics/renderer/renderer.cc @@ -114,7 +114,7 @@ void Renderer::RenderFrameDef(FrameDef* frame_def) { // In higher-quality modes we draw the world into the camera buffer // which we'll later render into the backing buffer with depth-of-field // and other stuff added. - if (camera_render_target_.Exists()) { + if (camera_render_target_.exists()) { DrawWorldToCameraBuffer(frame_def); } @@ -124,7 +124,7 @@ void Renderer::RenderFrameDef(FrameDef* frame_def) { SetDepthWriting(true); SetDepthTesting(true); RenderTarget* backing; - if (backing_render_target_.Exists()) { + if (backing_render_target_.exists()) { backing = backing_render_target(); } else { backing = screen_render_target(); @@ -163,7 +163,7 @@ void Renderer::RenderFrameDef(FrameDef* frame_def) { frame_def->overlay_pass()->Render(backing, false); frame_def->overlay_fixed_pass()->Render(backing, false); } - if (camera_render_target_.Exists()) { + if (camera_render_target_.exists()) { UpdateDOFParams(frame_def); // We've already drawn the world. // Now just draw our blit shapes (opaque shapes which blit portions of the @@ -187,7 +187,7 @@ void Renderer::RenderFrameDef(FrameDef* frame_def) { SetDrawAtEqualDepth(true); // Now draw transparent stuff back to front. - if (camera_render_target_.Exists()) { + if (camera_render_target_.exists()) { // When copying camera buffer to the backing there's nothing transparent // to draw. } else { @@ -219,7 +219,7 @@ void Renderer::RenderFrameDef(FrameDef* frame_def) { PopGroupMarker(); // If we've been drawing to a backing buffer, blit it to the screen. - if (backing_render_target_.Exists()) { + if (backing_render_target_.exists()) { // FIXME - should we just be discarding both depth and color // after the blit?.. (of course, this code path shouldn't be used on // mobile/slow-stuff so maybe it doesn't matter) @@ -255,7 +255,7 @@ void Renderer::VRPreprocess(FrameDef* frame_def) { } // if we're in VR mode, make sure we've got our VR overlay target - if (!vr_overlay_flat_render_target_.Exists()) { + if (!vr_overlay_flat_render_target_.exists()) { // find this res to be ideal on current gen equipment // (2017-ish, 1st gen rift/gear-vr/etc) // ..can revisit once higher-res stuff is commonplace @@ -466,8 +466,8 @@ void Renderer::UpdateSizesQualitiesAndColors(FrameDef* frame_def) { } void Renderer::UpdateLightAndShadowBuffers(FrameDef* frame_def) { - if (!light_render_target_.Exists() || !light_shadow_render_target_.Exists()) { - assert(screen_render_target_.Exists()); + if (!light_render_target_.exists() || !light_shadow_render_target_.exists()) { + assert(screen_render_target_.exists()); // Base shadow res on quality. if (frame_def->quality() >= GraphicsQuality::kHigher) { @@ -535,7 +535,7 @@ void Renderer::UpdateCameraRenderTargets(FrameDef* frame_def) { // In higher-quality modes we render the world into a buffer // so we can do depth-of-field filtering and whatnot. if (frame_def->quality() >= GraphicsQuality::kHigh) { - if (!camera_render_target_.Exists()) { + if (!camera_render_target_.exists()) { float pixel_scale_fin = std::min(1.0f, std::max(0.1f, pixel_scale_)); int w = static_cast(screen_render_target_->physical_width() * pixel_scale_fin); @@ -622,7 +622,7 @@ void Renderer::UpdatePixelScaleAndBackingBuffer(FrameDef* frame_def) { // We need our backing buffer for non-1.0 pixel-scales. if (pixel_scale_requested_ != 1.0f) { if (pixel_scale_requested_ != pixel_scale_ - || !backing_render_target_.Exists()) { + || !backing_render_target_.exists()) { float pixel_scale_fin = std::min(1.0f, std::max(0.1f, pixel_scale_requested_)); int w = static_cast(screen_render_target_->physical_width() @@ -642,7 +642,7 @@ void Renderer::UpdatePixelScaleAndBackingBuffer(FrameDef* frame_def) { } } else { // Otherwise we don't need backing buffer. Kill it if it exists. - if (backing_render_target_.Exists()) { + if (backing_render_target_.exists()) { backing_render_target_.Clear(); } } @@ -652,7 +652,7 @@ void Renderer::UpdatePixelScaleAndBackingBuffer(FrameDef* frame_def) { void Renderer::LoadMedia(FrameDef* frame_def) { millisecs_t t = g_core->GetAppTimeMillisecs(); for (auto&& i : frame_def->media_components()) { - Asset* mc = i.Get(); + Asset* mc = i.get(); assert(mc); mc->Load(); diff --git a/src/ballistica/base/graphics/renderer/renderer.h b/src/ballistica/base/graphics/renderer/renderer.h index f3c32fe2..5482279a 100644 --- a/src/ballistica/base/graphics/renderer/renderer.h +++ b/src/ballistica/base/graphics/renderer/renderer.h @@ -71,38 +71,38 @@ class Renderer { void OnScreenSizeChange(); auto has_camera_render_target() const -> bool { - return camera_render_target_.Exists(); + return camera_render_target_.exists(); } auto has_camera_msaa_render_target() const -> bool { - return camera_msaa_render_target_.Exists(); + return camera_msaa_render_target_.exists(); } auto camera_render_target() -> RenderTarget* { - assert(camera_render_target_.Exists()); - return camera_render_target_.Get(); + assert(camera_render_target_.exists()); + return camera_render_target_.get(); } auto camera_msaa_render_target() -> RenderTarget* { - assert(camera_msaa_render_target_.Exists()); - return camera_msaa_render_target_.Get(); + assert(camera_msaa_render_target_.exists()); + return camera_msaa_render_target_.get(); } auto backing_render_target() -> RenderTarget* { - assert(backing_render_target_.Exists()); - return backing_render_target_.Get(); + assert(backing_render_target_.exists()); + return backing_render_target_.get(); } auto screen_render_target() -> RenderTarget* { - assert(screen_render_target_.Exists()); - return screen_render_target_.Get(); + assert(screen_render_target_.exists()); + return screen_render_target_.get(); } auto light_render_target() -> RenderTarget* { - assert(light_render_target_.Exists()); - return light_render_target_.Get(); + assert(light_render_target_.exists()); + return light_render_target_.get(); } auto light_shadow_render_target() -> RenderTarget* { - assert(light_shadow_render_target_.Exists()); - return light_shadow_render_target_.Get(); + assert(light_shadow_render_target_.exists()); + return light_shadow_render_target_.get(); } auto vr_overlay_flat_render_target() -> RenderTarget* { - assert(vr_overlay_flat_render_target_.Exists()); - return vr_overlay_flat_render_target_.Get(); + assert(vr_overlay_flat_render_target_.exists()); + return vr_overlay_flat_render_target_.get(); } auto shadow_res() const -> int { return shadow_res_; } auto blur_res_count() const -> int { return blur_res_count_; } diff --git a/src/ballistica/base/graphics/support/frame_def.cc b/src/ballistica/base/graphics/support/frame_def.cc index 9c7c1e2c..f17f12e7 100644 --- a/src/ballistica/base/graphics/support/frame_def.cc +++ b/src/ballistica/base/graphics/support/frame_def.cc @@ -59,7 +59,7 @@ void FrameDef::Reset() { // Update & grab the current settings. settings_snapshot_ = g_base->graphics->GetGraphicsSettingsSnapshot(); - auto* settings = settings_snapshot_->Get(); + auto* settings = settings_snapshot_->get(); auto* client_context = g_base->graphics->client_context(); app_time_microsecs_ = 0; diff --git a/src/ballistica/base/graphics/support/frame_def.h b/src/ballistica/base/graphics/support/frame_def.h index e962f48b..56a000a2 100644 --- a/src/ballistica/base/graphics/support/frame_def.h +++ b/src/ballistica/base/graphics/support/frame_def.h @@ -217,8 +217,8 @@ class FrameDef { // auto pixel_scale() const { return pixel_scale_; } auto* settings() const { - assert(settings_snapshot_.Exists()); - return settings_snapshot_->Get(); + assert(settings_snapshot_.exists()); + return settings_snapshot_->get(); } private: diff --git a/src/ballistica/base/graphics/support/render_command_buffer.h b/src/ballistica/base/graphics/support/render_command_buffer.h index 304725b0..b52452a2 100644 --- a/src/ballistica/base/graphics/support/render_command_buffer.h +++ b/src/ballistica/base/graphics/support/render_command_buffer.h @@ -6,9 +6,8 @@ #include #include "ballistica/base/assets/texture_asset.h" -#include "ballistica/base/graphics/mesh/mesh.h" +#include "ballistica/base/graphics/mesh/mesh_data.h" #include "ballistica/base/graphics/support/frame_def.h" -#include "ballistica/shared/ballistica.h" #include "ballistica/shared/math/matrix44f.h" namespace ballistica::base { @@ -269,8 +268,8 @@ class RenderCommandBuffer { } void PutTexture(const Object::Ref& texture) { - assert(texture.Exists()); - PutTexture(texture.Get()); + assert(texture.exists()); + PutTexture(texture.get()); } void PutCubeMapTexture(TextureAsset* texture) { diff --git a/src/ballistica/base/graphics/support/screen_messages.cc b/src/ballistica/base/graphics/support/screen_messages.cc index 4c04c36f..c857d99d 100644 --- a/src/ballistica/base/graphics/support/screen_messages.cc +++ b/src/ballistica/base/graphics/support/screen_messages.cc @@ -221,8 +221,8 @@ void ScreenMessages::DrawMiscOverlays(FrameDef* frame_def) { c.Translate(0, 0.5f, 0); } // c.DrawMeshAsset(g_base->assets->SysMesh(SysMeshID::kImage1x1)); - assert(i->shadow_mesh_.Exists()); - c.DrawMesh(i->shadow_mesh_.Get()); + assert(i->shadow_mesh_.exists()); + c.DrawMesh(i->shadow_mesh_.get()); } v += scale * (36 + str_height); @@ -384,14 +384,14 @@ void ScreenMessages::DrawMiscOverlays(FrameDef* frame_def) { last_v = i->v_smoothed; // Draw the image if they provided one. - if (i->texture.Exists()) { + if (i->texture.exists()) { c.Submit(); SimpleComponent c2(pass); c2.SetTransparent(true); c2.SetTexture(i->texture); - if (i->tint_texture.Exists()) { - c2.SetColorizeTexture(i->tint_texture.Get()); + if (i->tint_texture.exists()) { + c2.SetColorizeTexture(i->tint_texture.get()); c2.SetColorizeColor(i->tint.x, i->tint.y, i->tint.z); c2.SetColorizeColor2(i->tint2.x, i->tint2.y, i->tint2.z); c2.SetMaskTexture( @@ -498,7 +498,7 @@ auto ScreenMessages::ScreenMessageEntry::GetText() -> TextGroup& { LogName::kBaGraphics, LogLevel::kWarning, "Found dirty translation on screenmessage GetText; raw=" + s_raw); } - if (!s_mesh_.Exists()) { + if (!s_mesh_.exists()) { s_mesh_ = Object::New(); mesh_dirty = true; } diff --git a/src/ballistica/base/graphics/text/text_group.cc b/src/ballistica/base/graphics/text/text_group.cc index f92f372e..614e9f21 100644 --- a/src/ballistica/base/graphics/text/text_group.cc +++ b/src/ballistica/base/graphics/text/text_group.cc @@ -108,16 +108,16 @@ void TextGroup::SetText(const std::string& text, TextMesh::HAlign alignment_h, } entry->mesh.SetText(text, alignment_h, alignment_v, false, min, max, - entry->type, packer.Get()); + entry->type, packer.get()); - if (packer.Exists()) { + if (packer.exists()) { // If we made a text-packer, we need to fetch/generate a texture // that matches it. // There should only ever be one of these. - assert(!os_texture_.Exists()); + assert(!os_texture_.exists()); { Assets::AssetListLock lock; - os_texture_ = g_base->assets->GetTexture(packer.Get()); + os_texture_ = g_base->assets->GetTexture(packer.get()); } // We also need to know what uv-scales to use for shadows/etc. diff --git a/src/ballistica/base/graphics/text/text_group.h b/src/ballistica/base/graphics/text/text_group.h index 7a65a8ee..3870e0fc 100644 --- a/src/ballistica/base/graphics/text/text_group.h +++ b/src/ballistica/base/graphics/text/text_group.h @@ -29,7 +29,7 @@ class TextGroup : public Object { auto GetElementTexture(int index) const -> TextureAsset* { assert(index < static_cast(entries_.size())); - return entries_[index]->tex.Get(); + return entries_[index]->tex.get(); } // if you are doing any shader effects in UV-space (such as drop-shadows), diff --git a/src/ballistica/base/input/device/input_device.h b/src/ballistica/base/input/device/input_device.h index cca2b06c..cde0e240 100644 --- a/src/ballistica/base/input/device/input_device.h +++ b/src/ballistica/base/input/device/input_device.h @@ -121,7 +121,7 @@ class InputDevice : public Object { auto delegate() -> InputDeviceDelegate& { // TEMP - Tracking down a crash in the wild. // Delegate should always exist any time we're accessing it. - if (!delegate_.Exists()) { + if (!delegate_.exists()) { FatalError("Input-device delegate unexpectedly invalid."); } return *delegate_; diff --git a/src/ballistica/base/input/device/input_device_delegate.h b/src/ballistica/base/input/device/input_device_delegate.h index ac4da9c2..437edab1 100644 --- a/src/ballistica/base/input/device/input_device_delegate.h +++ b/src/ballistica/base/input/device/input_device_delegate.h @@ -46,11 +46,11 @@ class InputDeviceDelegate : public Object { /// our accessor returns a reference to show this does not need /// to be checked. auto input_device() const -> InputDevice& { - BA_PRECONDITION_FATAL(input_device_.Exists()); + BA_PRECONDITION_FATAL(input_device_.exists()); return *input_device_; } void set_input_device(InputDevice* device); - auto InputDeviceExists() const -> bool { return input_device_.Exists(); } + auto InputDeviceExists() const -> bool { return input_device_.exists(); } private: Object::WeakRef input_device_; diff --git a/src/ballistica/base/input/input.cc b/src/ballistica/base/input/input.cc index e3bd3210..2363588e 100644 --- a/src/ballistica/base/input/input.cc +++ b/src/ballistica/base/input/input.cc @@ -68,16 +68,16 @@ auto Input::GetInputDevice(int id) -> InputDevice* { if (id < 0 || id >= static_cast(input_devices_.size())) { return nullptr; } - return input_devices_[id].Get(); + return input_devices_[id].get(); } auto Input::GetInputDevice(const std::string& name, const std::string& unique_id) -> InputDevice* { assert(g_base->InLogicThread()); for (auto&& i : input_devices_) { - if (i.Exists() && (i->GetDeviceName() == name) + if (i.exists() && (i->GetDeviceName() == name) && i->GetPersistentIdentifier() == unique_id) { - return i.Get(); + return i.get(); } } return nullptr; @@ -109,7 +109,7 @@ auto Input::GetNewNumberedIdentifier_(const std::string& name, // Scan other devices with the same device-name and find the first number // suffix that's not taken. for (auto&& i : input_devices_) { - if (i.Exists()) { + if (i.exists()) { if ((i->GetRawDeviceName() == name) && i->number() == num) { in_use = true; break; @@ -245,7 +245,7 @@ void Input::ShowStandardInputDeviceConnectedMessage_(InputDevice* j) { } connect_print_timer_id_ = g_base->logic->NewAppTimer( 500 * 1000, false, - NewLambdaRunnable([this] { AnnounceConnects_(); }).Get()); + NewLambdaRunnable([this] { AnnounceConnects_(); }).get()); } void Input::ShowStandardInputDeviceDisconnectedMessage_(InputDevice* j) { @@ -261,7 +261,7 @@ void Input::ShowStandardInputDeviceDisconnectedMessage_(InputDevice* j) { } disconnect_print_timer_id_ = g_base->logic->NewAppTimer( 250 * 1000, false, - NewLambdaRunnable([this] { AnnounceDisconnects_(); }).Get()); + NewLambdaRunnable([this] { AnnounceDisconnects_(); }).get()); } void Input::PushAddInputDeviceCall(InputDevice* input_device, @@ -275,7 +275,7 @@ void Input::PushAddInputDeviceCall(InputDevice* input_device, void Input::RebuildInputDeviceDelegates() { assert(g_base->InLogicThread()); for (auto&& device_ref : input_devices_) { - if (auto* device = device_ref.Get()) { + if (auto* device = device_ref.get()) { auto delegate = Object::CompleteDeferred( g_base->app_mode()->CreateInputDeviceDelegate(device)); device->set_delegate(delegate); @@ -298,7 +298,7 @@ void Input::AddInputDevice(InputDevice* device, bool standard_message) { int index = 0; bool found_slot = false; for (auto& input_device : input_devices_) { - if (!input_device.Exists()) { + if (!input_device.exists()) { input_device = Object::CompleteDeferred(device); found_slot = true; device->set_index(index); @@ -357,7 +357,7 @@ void Input::RemoveInputDevice(InputDevice* input, bool standard_message) { // Just look for it in our list.. if we find it, simply clear the ref (we // need to keep the ref around so our list indices don't change). for (auto& input_device : input_devices_) { - if (input_device.Exists() && (input_device.Get() == input)) { + if (input_device.exists() && (input_device.get() == input)) { // Pull it off the list before killing it (in case it tries to trigger // another kill itself). auto device = Object::Ref(input_device); @@ -393,7 +393,7 @@ void Input::UpdateInputDeviceCounts_() { // have been active recently.. (we're starting to get lots of virtual // devices and other cruft on android; don't wanna show controller UIs // just due to those) - if (input_device.Exists() + if (input_device.exists() && ((*input_device).IsTouchScreen() || (*input_device).IsKeyboard() || ((*input_device).last_active_time_millisecs() != 0 && current_time_millisecs @@ -441,7 +441,7 @@ auto Input::GetLocalActiveInputDeviceCount() -> int { for (auto& input_device : input_devices_) { // Tally up local non-keyboard, non-touchscreen devices that have been // used in the last minute. - if (input_device.Exists() && !input_device->IsKeyboard() + if (input_device.exists() && !input_device->IsKeyboard() && !input_device->IsTouchScreen() && !input_device->IsUIOnly() && input_device->IsLocal() && (input_device->last_active_time_millisecs() != 0 @@ -459,7 +459,7 @@ auto Input::GetLocalActiveInputDeviceCount() -> int { auto Input::HaveControllerWithPlayer() -> bool { assert(g_base->InLogicThread()); for (auto& input_device : input_devices_) { - if (input_device.Exists() && (*input_device).IsController() + if (input_device.exists() && (*input_device).IsController() && (*input_device).AttachedToPlayer()) { return true; } @@ -470,7 +470,7 @@ auto Input::HaveControllerWithPlayer() -> bool { auto Input::HaveRemoteAppController() -> bool { assert(g_base->InLogicThread()); for (auto& input_device : input_devices_) { - if (input_device.Exists() && (*input_device).IsRemoteApp()) { + if (input_device.exists() && (*input_device).IsRemoteApp()) { return true; } } @@ -482,8 +482,8 @@ auto Input::GetInputDevicesWithName(const std::string& name) std::vector vals; if (!g_core->HeadlessMode()) { for (auto& input_device : input_devices_) { - if (input_device.Exists()) { - auto* js = dynamic_cast(input_device.Get()); + if (input_device.exists()) { + auto* js = dynamic_cast(input_device.get()); if (js && js->GetDeviceName() == name) { vals.push_back(js); } @@ -498,8 +498,8 @@ auto Input::GetConfigurableGamePads() -> std::vector { std::vector vals; if (!g_core->HeadlessMode()) { for (auto& input_device : input_devices_) { - if (input_device.Exists()) { - auto* js = dynamic_cast(input_device.Get()); + if (input_device.exists()) { + auto* js = dynamic_cast(input_device.get()); if (js && js->GetAllowsConfiguring() && !js->ShouldBeHiddenFromUser()) { vals.push_back(js); } @@ -540,7 +540,7 @@ void Input::DoApplyAppConfig() { // with a copy of it. std::vector > input_devices = input_devices_; for (auto& input_device : input_devices) { - if (input_device.Exists()) { + if (input_device.exists()) { input_device->UpdateMapping(); } } @@ -591,7 +591,7 @@ void Input::StepDisplayTime() { } for (auto& input_device : input_devices_) { - if (input_device.Exists()) { + if (input_device.exists()) { (*input_device).Update(); } } @@ -602,7 +602,7 @@ void Input::Reset() { // Detach all inputs from players. for (auto& input_device : input_devices_) { - if (input_device.Exists()) { + if (input_device.exists()) { input_device->DetachFromPlayer(); } } @@ -1488,7 +1488,7 @@ void Input::HandleTouchEvent_(const TouchEvent& e) { void Input::ResetJoyStickHeldButtons() { for (auto&& i : input_devices_) { - if (i.Exists()) { + if (i.exists()) { i->ResetHeldStates(); } } diff --git a/src/ballistica/base/logic/logic.cc b/src/ballistica/base/logic/logic.cc index 4c4a89de..76e4f106 100644 --- a/src/ballistica/base/logic/logic.cc +++ b/src/ballistica/base/logic/logic.cc @@ -104,7 +104,7 @@ void Logic::OnGraphicsReady() { // variety of rates anyway. NOTE: This length is currently milliseconds. headless_display_time_step_timer_ = event_loop()->NewTimer( kHeadlessMinDisplayTimeStep, true, - NewLambdaRunnable([this] { StepDisplayTime_(); }).Get()); + NewLambdaRunnable([this] { StepDisplayTime_(); }).get()); } else { // 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 @@ -138,7 +138,7 @@ void Logic::CompleteAppBootstrapping_() { // Set up our timers. process_pending_work_timer_ = event_loop()->NewTimer( - 0, true, NewLambdaRunnable([this] { ProcessPendingWork_(); }).Get()); + 0, true, NewLambdaRunnable([this] { ProcessPendingWork_(); }).get()); // asset_prune_timer_ = event_loop()->NewTimer( // 2345 * 1000, true, NewLambdaRunnable([] { g_base->assets->Prune(); // }).Get()); diff --git a/src/ballistica/base/platform/base_platform.cc b/src/ballistica/base/platform/base_platform.cc index 7711fc3b..f5326973 100644 --- a/src/ballistica/base/platform/base_platform.cc +++ b/src/ballistica/base/platform/base_platform.cc @@ -264,7 +264,7 @@ void BasePlatform::InvokeStringEditor(PyObject* string_edit_adapter) { void BasePlatform::StringEditorApply(const std::string& val) { BA_PRECONDITION(HaveStringEditor()); BA_PRECONDITION(g_base->InLogicThread()); - BA_PRECONDITION(string_edit_adapter_.Exists()); + BA_PRECONDITION(string_edit_adapter_.exists()); auto args = PythonRef::Stolen(Py_BuildValue("(s)", val.c_str())); string_edit_adapter_.GetAttr("apply").Call(args); string_edit_adapter_.Release(); @@ -274,7 +274,7 @@ void BasePlatform::StringEditorApply(const std::string& val) { void BasePlatform::StringEditorCancel() { BA_PRECONDITION(HaveStringEditor()); BA_PRECONDITION(g_base->InLogicThread()); - BA_PRECONDITION(string_edit_adapter_.Exists()); + BA_PRECONDITION(string_edit_adapter_.exists()); string_edit_adapter_.GetAttr("cancel").Call(); string_edit_adapter_.Release(); } diff --git a/src/ballistica/base/python/base_python.cc b/src/ballistica/base/python/base_python.cc index 8ad7c3cc..fd1252b6 100644 --- a/src/ballistica/base/python/base_python.cc +++ b/src/ballistica/base/python/base_python.cc @@ -61,7 +61,7 @@ void BasePython::AddPythonClasses(PyObject* module) { .GetAttr("Sequence") .GetAttr("register"); PythonRef args(Py_BuildValue("(O)", vec3), PythonRef::kSteal); - BA_PRECONDITION(register_call.Call(args).Exists()); + BA_PRECONDITION(register_call.Call(args).exists()); } void BasePython::ImportPythonObjs() { @@ -84,7 +84,7 @@ void BasePython::SoftImportPlus() { auto gil{Python::ScopedInterpreterLock()}; auto result = PythonRef::StolenSoft(PyImport_ImportModule("_baplus")); - if (!result.Exists()) { + if (!result.exists()) { // Ignore any errors here for now. All that will matter is whether plus // gave us its interface. PyErr_Clear(); @@ -99,7 +99,7 @@ void BasePython::SoftImportClassic() { auto gil{Python::ScopedInterpreterLock()}; auto result = PythonRef::StolenSoft(PyImport_ImportModule("_baclassic")); - if (!result.Exists()) { + if (!result.exists()) { // Ignore any errors here for now. All that will matter is whether plus // gave us its interface. PyErr_Clear(); @@ -123,7 +123,7 @@ void BasePython::OnMainThreadStartApp() { auto result = g_base->python->objs() .Get(BasePython::ObjID::kOnMainThreadStartAppCall) .Call(); - if (!result.Exists()) { + if (!result.exists()) { FatalError("babase._env.on_main_thread_start_app() failed."); } } @@ -191,7 +191,7 @@ auto BasePython::IsPyLString(PyObject* o) -> bool { assert(base::g_base); return (PyUnicode_Check(o) - || PyObject_IsInstance(o, objs().Get(ObjID::kLStrClass).Get())); + || PyObject_IsInstance(o, objs().Get(ObjID::kLStrClass).get())); } auto BasePython::GetPyLString(PyObject* o) -> std::string { @@ -203,7 +203,7 @@ auto BasePython::GetPyLString(PyObject* o) -> std::string { return PyUnicode_AsUTF8(o); } else { // Check if its a Lstr. If so; we pull its json string representation. - int result = PyObject_IsInstance(o, objs().Get(ObjID::kLStrClass).Get()); + int result = PyObject_IsInstance(o, objs().Get(ObjID::kLStrClass).get()); if (result == -1) { PyErr_Clear(); result = 0; @@ -217,8 +217,8 @@ auto BasePython::GetPyLString(PyObject* o) -> std::string { PythonRef::kSteal); if (get_json_call.CallableCheck()) { PythonRef json = get_json_call.Call(); - if (PyUnicode_Check(json.Get())) { - return PyUnicode_AsUTF8(json.Get()); + if (PyUnicode_Check(json.get())) { + return PyUnicode_AsUTF8(json.get()); } } } @@ -239,9 +239,9 @@ auto BasePython::GetPyLStrings(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.Get()); - PyObject** py_objects = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.get()); + PyObject** py_objects = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(static_cast(size)); assert(vals.size() == size); for (Py_ssize_t i = 0; i < size; i++) { @@ -261,14 +261,14 @@ auto BasePython::CanGetPyVector3f(PyObject* o) -> bool { return false; } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); // Should always work; we checked seq. - if (PySequence_Fast_GET_SIZE(sequence.Get()) != 3) { + assert(sequence.exists()); // Should always work; we checked seq. + if (PySequence_Fast_GET_SIZE(sequence.get()) != 3) { return false; } return ( - Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.Get(), 0)) - && Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.Get(), 1)) - && Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.Get(), 2))); + Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.get(), 0)) + && Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.get(), 1)) + && Python::CanGetPyDouble(PySequence_Fast_GET_ITEM(sequence.get(), 2))); } auto BasePython::GetPyVector3f(PyObject* o) -> Vector3f { @@ -283,13 +283,13 @@ auto BasePython::GetPyVector3f(PyObject* o) -> Vector3f { PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); // Should always work; we checked seq. - if (PySequence_Fast_GET_SIZE(sequence.Get()) != 3) { + assert(sequence.exists()); // Should always work; we checked seq. + if (PySequence_Fast_GET_SIZE(sequence.get()) != 3) { throw Exception("Sequence is not of size 3.", PyExcType::kValue); } - return {Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.Get(), 0)), - Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.Get(), 1)), - Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.Get(), 2))}; + return {Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.get(), 0)), + Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.get(), 1)), + Python::GetPyFloat(PySequence_Fast_GET_ITEM(sequence.get(), 2))}; } void BasePython::StoreEnv(PyObject* obj) { objs_.Store(ObjID::kEnv, obj); } @@ -301,8 +301,8 @@ void BasePython::SetRawConfigValue(const char* name, float value) { assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PythonRef value_obj(PyFloat_FromDouble(value), PythonRef::kSteal); - int result = PyDict_SetItemString(objs().Get(ObjID::kConfig).Get(), name, - value_obj.Get()); + int result = PyDict_SetItemString(objs().Get(ObjID::kConfig).get(), name, + value_obj.get()); if (result == -1) { // Failed, we have. Clear any Python error that got us here; we're in // C++ Exception land now. @@ -314,7 +314,7 @@ void BasePython::SetRawConfigValue(const char* name, float value) { auto BasePython::GetRawConfigValue(const char* name) -> PyObject* { assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); - return PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + return PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); } auto BasePython::GetRawConfigValue(const char* name, const char* default_value) @@ -322,7 +322,7 @@ auto BasePython::GetRawConfigValue(const char* name, const char* default_value) assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PyObject* value = - PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); if (value == nullptr || !PyUnicode_Check(value)) { return default_value; } @@ -334,7 +334,7 @@ auto BasePython::GetRawConfigValue(const char* name, float default_value) assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PyObject* value = - PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); if (value == nullptr) { return default_value; } @@ -354,7 +354,7 @@ auto BasePython::GetRawConfigValue(const char* name, assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PyObject* value = - PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); if (value == nullptr) { return default_value; } @@ -375,7 +375,7 @@ auto BasePython::GetRawConfigValue(const char* name, int default_value) -> int { assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PyObject* value = - PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); if (value == nullptr) { return default_value; } @@ -394,7 +394,7 @@ auto BasePython::GetRawConfigValue(const char* name, bool default_value) assert(Python::HaveGIL()); assert(objs().Exists(ObjID::kConfig)); PyObject* value = - PyDict_GetItemString(objs().Get(ObjID::kConfig).Get(), name); + PyDict_GetItemString(objs().Get(ObjID::kConfig).get(), name); if (value == nullptr) { return default_value; } @@ -409,7 +409,7 @@ auto BasePython::GetRawConfigValue(const char* name, bool default_value) } template auto IsPyEnum(BasePython::ObjID enum_class_id, PyObject* obj) -> bool { - PyObject* enum_class_obj = g_base->python->objs().Get(enum_class_id).Get(); + PyObject* enum_class_obj = g_base->python->objs().Get(enum_class_id).get(); assert(enum_class_obj != nullptr && enum_class_obj != Py_None); return static_cast(PyObject_IsInstance(obj, enum_class_obj)); } @@ -418,7 +418,7 @@ template auto GetPyEnum(BasePython::ObjID enum_class_id, PyObject* obj) -> T { // First, make sure what they passed is an instance of the enum class // we want. - PyObject* enum_class_obj = g_base->python->objs().Get(enum_class_id).Get(); + PyObject* enum_class_obj = g_base->python->objs().Get(enum_class_id).get(); assert(enum_class_obj != nullptr && enum_class_obj != Py_None); if (!PyObject_IsInstance(obj, enum_class_obj)) { throw Exception(Python::ObjToString(obj) + " is not an instance of " @@ -429,12 +429,12 @@ auto GetPyEnum(BasePython::ObjID enum_class_id, PyObject* obj) -> T { // Now get its value as an int and make sure its in range // (based on its kLast member in C++ land). PythonRef value_obj(PyObject_GetAttrString(obj, "value"), PythonRef::kSteal); - if (!value_obj.Exists() || !PyLong_Check(value_obj.Get())) { + if (!value_obj.exists() || !PyLong_Check(value_obj.get())) { throw Exception( Python::ObjToString(obj) + " is not a valid int-valued enum.", PyExcType::kType); } - auto value = PyLong_AS_LONG(value_obj.Get()); + auto value = PyLong_AS_LONG(value_obj.get()); if (value < 0 || value >= static_cast(T::kLast)) { throw Exception( Python::ObjToString(obj) + " is an invalid out-of-range enum value.", @@ -467,7 +467,7 @@ auto BasePython::GetPyEnum_InputType(PyObject* obj) -> InputType { auto BasePython::PyQuitType(QuitType val) -> PythonRef { auto args = PythonRef::Stolen(Py_BuildValue("(i)", static_cast(val))); auto out = objs().Get(BasePython::ObjID::kQuitTypeClass).Call(args); - BA_PRECONDITION(out.Exists()); + BA_PRECONDITION(out.exists()); return out; } @@ -506,9 +506,9 @@ auto BasePython::GetResource(const char* key, const char* fallback_resource, // Don't print errors. results = get_resource_call.Call(args, PythonRef(), false); } - if (results.Exists()) { + if (results.exists()) { try { - return g_base->python->GetPyLString(results.Get()); + return g_base->python->GetPyLString(results.get()); } catch (const std::exception&) { g_core->Log(LogName::kBa, LogLevel::kError, "GetResource failed for '" + std::string(key) + "'"); @@ -535,9 +535,9 @@ auto BasePython::GetTranslation(const char* category, const char* s) results = g_base->python->objs() .Get(base::BasePython::ObjID::kTranslateCall) .Call(args, PythonRef(), false); - if (results.Exists()) { + if (results.exists()) { try { - return g_base->python->GetPyLString(results.Get()); + return g_base->python->GetPyLString(results.get()); } catch (const std::exception&) { g_core->Log(LogName::kBa, LogLevel::kError, "GetTranslation failed for '" + std::string(category) + "'"); @@ -581,15 +581,15 @@ auto BasePython::CanPyStringEditAdapterBeReplaced(PyObject* o) -> bool { auto result = g_base->python->objs() .Get(BasePython::ObjID::kStringEditAdapterCanBeReplacedCall) .Call(args); - if (!result.Exists()) { + if (!result.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Error getting StringEdit valid state."); return false; } - if (result.Get() == Py_True) { + if (result.get() == Py_True) { return true; } - if (result.Get() == Py_False) { + if (result.get() == Py_False) { return false; } g_core->Log(LogName::kBa, LogLevel::kError, diff --git a/src/ballistica/base/python/class/python_class_app_timer.cc b/src/ballistica/base/python/class/python_class_app_timer.cc index 1c9452c4..2140a2ca 100644 --- a/src/ballistica/base/python/class/python_class_app_timer.cc +++ b/src/ballistica/base/python/class/python_class_app_timer.cc @@ -97,7 +97,7 @@ auto PythonClassAppTimer::tp_new(PyTypeObject* type, PyObject* args, self->timer_id_ = g_base->logic->NewAppTimer( static_cast(length * 1000000.0), repeat, - Object::New(call_obj).Get()); + Object::New(call_obj).get()); self->have_timer_ = true; diff --git a/src/ballistica/base/python/class/python_class_context_call.cc b/src/ballistica/base/python/class/python_class_context_call.cc index d43b1629..897b8389 100644 --- a/src/ballistica/base/python/class/python_class_context_call.cc +++ b/src/ballistica/base/python/class/python_class_context_call.cc @@ -110,7 +110,7 @@ auto PythonClassContextCall::tp_call(PythonClassContextCall* self, auto PythonClassContextCall::tp_repr(PythonClassContextCall* self) -> PyObject* { BA_PYTHON_TRY; - assert(self->context_call_->Exists()); + assert(self->context_call_->exists()); return PyUnicode_FromString( ("") diff --git a/src/ballistica/base/python/class/python_class_display_timer.cc b/src/ballistica/base/python/class/python_class_display_timer.cc index ea84dffc..420d1dbb 100644 --- a/src/ballistica/base/python/class/python_class_display_timer.cc +++ b/src/ballistica/base/python/class/python_class_display_timer.cc @@ -105,7 +105,7 @@ auto PythonClassDisplayTimer::tp_new(PyTypeObject* type, PyObject* args, } self->timer_id_ = g_base->logic->NewDisplayTimer( static_cast(length * 1000000.0), repeat, - Object::New(call_obj).Get()); + Object::New(call_obj).get()); self->have_timer_ = true; diff --git a/src/ballistica/base/python/class/python_class_env.cc b/src/ballistica/base/python/class/python_class_env.cc index 273a9102..5151372a 100644 --- a/src/ballistica/base/python/class/python_class_env.cc +++ b/src/ballistica/base/python/class/python_class_env.cc @@ -252,7 +252,7 @@ auto PythonClassEnv::Dir(PythonClassEnv* self) -> PyObject* { for (auto&& env : *g_entries_) { PyList_Append(dir_list, PythonRef(PyUnicode_FromString(env.first.c_str()), PythonRef::kSteal) - .Get()); + .get()); } PyList_Sort(dir_list); return dir_list; diff --git a/src/ballistica/base/python/class/python_class_simple_sound.cc b/src/ballistica/base/python/class/python_class_simple_sound.cc index 881b24ff..132afcc5 100644 --- a/src/ballistica/base/python/class/python_class_simple_sound.cc +++ b/src/ballistica/base/python/class/python_class_simple_sound.cc @@ -46,7 +46,7 @@ auto PythonClassSimpleSound::Create(const Object::Ref& sound) auto PythonClassSimpleSound::tp_repr(PythonClassSimpleSound* self) -> PyObject* { BA_PYTHON_TRY; - SoundAsset* s = self->sound_->Get(); + SoundAsset* s = self->sound_->get(); return Py_BuildValue( "s", (std::string("GetName()) + "'>") .c_str()); @@ -94,7 +94,7 @@ auto PythonClassSimpleSound::Play(PythonClassSimpleSound* self, PyObject* args, const_cast(kwlist), &volume)) { return nullptr; } - SoundAsset* s = self->sound_->Get(); + SoundAsset* s = self->sound_->get(); g_base->audio->PlaySound(s, volume); Py_RETURN_NONE; BA_PYTHON_CATCH; diff --git a/src/ballistica/base/python/methods/python_methods_base_1.cc b/src/ballistica/base/python/methods/python_methods_base_1.cc index e4ac7c02..a0c925ba 100644 --- a/src/ballistica/base/python/methods/python_methods_base_1.cc +++ b/src/ballistica/base/python/methods/python_methods_base_1.cc @@ -396,7 +396,7 @@ static auto PyAppTimer(PyObject* self, PyObject* args, PyObject* keywds) } g_base->logic->NewAppTimer( static_cast(length * 1000000.0), false, - Object::New(call_obj).Get()); + Object::New(call_obj).get()); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -489,7 +489,7 @@ static auto PyDisplayTimer(PyObject* self, PyObject* args, PyObject* keywds) } g_base->logic->NewDisplayTimer( static_cast(length * 1000000.0), false, - Object::New(call_obj).Get()); + Object::New(call_obj).get()); Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/base/python/methods/python_methods_base_2.cc b/src/ballistica/base/python/methods/python_methods_base_2.cc index bbd017cd..e2009fa6 100644 --- a/src/ballistica/base/python/methods/python_methods_base_2.cc +++ b/src/ballistica/base/python/methods/python_methods_base_2.cc @@ -434,15 +434,15 @@ static auto PySafeColor(PyObject* self, PyObject* args, PyObject* keywds) PythonRef red_obj(PySequence_GetItem(color_obj, 0), PythonRef::kSteal); PythonRef green_obj(PySequence_GetItem(color_obj, 1), PythonRef::kSteal); PythonRef blue_obj(PySequence_GetItem(color_obj, 2), PythonRef::kSteal); - red = Python::GetPyFloat(red_obj.Get()); - green = Python::GetPyFloat(green_obj.Get()); - blue = Python::GetPyFloat(blue_obj.Get()); + red = Python::GetPyFloat(red_obj.get()); + green = Python::GetPyFloat(green_obj.get()); + blue = Python::GetPyFloat(blue_obj.get()); Graphics::GetSafeColor(&red, &green, &blue, target_intensity); if (len == 3) { return Py_BuildValue("(fff)", red, green, blue); } else { PythonRef alpha_obj(PySequence_GetItem(color_obj, 3), PythonRef::kSteal); - float alpha = Python::GetPyFloat(alpha_obj.Get()); + float alpha = Python::GetPyFloat(alpha_obj.get()); return Py_BuildValue("(ffff)", red, green, blue, alpha); } BA_PYTHON_CATCH; diff --git a/src/ballistica/base/python/methods/python_methods_base_3.cc b/src/ballistica/base/python/methods/python_methods_base_3.cc index c9d05921..a74e0789 100644 --- a/src/ballistica/base/python/methods/python_methods_base_3.cc +++ b/src/ballistica/base/python/methods/python_methods_base_3.cc @@ -795,7 +795,7 @@ static auto PyAppConfigGetBuiltinKeys(PyObject* self, PyObject* args, } PythonRef list(PyList_New(0), PythonRef::kSteal); for (auto&& i : g_base->app_config->entries_by_name()) { - PyList_Append(list.Get(), PyUnicode_FromString(i.first.c_str())); + PyList_Append(list.get(), PyUnicode_FromString(i.first.c_str())); } return list.HandOver(); BA_PYTHON_CATCH; diff --git a/src/ballistica/base/python/support/python_context_call.cc b/src/ballistica/base/python/support/python_context_call.cc index 0d50f2e1..e5355a04 100644 --- a/src/ballistica/base/python/support/python_context_call.cc +++ b/src/ballistica/base/python/support/python_context_call.cc @@ -88,11 +88,11 @@ void PythonContextCall::Run(PyObject* args) { current_call_ = this; assert(Python::HaveGIL()); PyObject* o = - PyObject_Call(object_.Get(), + PyObject_Call(object_.get(), args ? args : g_core->python->objs() .Get(core::CorePython::ObjID::kEmptyTuple) - .Get(), + .get(), nullptr); current_call_ = prev_call; @@ -129,7 +129,7 @@ void PythonContextCall::Schedule() { assert(base::g_base); base::g_base->logic->event_loop()->PushCall([ref] { - assert(ref.Exists()); + assert(ref.exists()); ref->Run(); }); } @@ -140,7 +140,7 @@ void PythonContextCall::Schedule(const PythonRef& args) { Object::Ref ref(this); assert(base::g_base); base::g_base->logic->event_loop()->PushCall([ref, args] { - assert(ref.Exists()); + assert(ref.exists()); ref->Run(args); }); } @@ -151,7 +151,7 @@ void PythonContextCall::ScheduleWeak() { Object::WeakRef ref(this); assert(base::g_base); base::g_base->logic->event_loop()->PushCall([ref] { - if (auto* call = ref.Get()) { + if (auto* call = ref.get()) { call->Run(); } }); @@ -163,7 +163,7 @@ void PythonContextCall::ScheduleWeak(const PythonRef& args) { Object::WeakRef ref(this); assert(base::g_base); base::g_base->logic->event_loop()->PushCall([ref, args] { - if (auto* call = ref.Get()) { + if (auto* call = ref.get()) { call->Run(args); } }); @@ -176,7 +176,7 @@ void PythonContextCall::ScheduleInUIOperation() { assert(base::g_base); g_base->ui->PushUIOperationRunnable(NewLambdaRunnableUnmanaged([ref] { - assert(ref.Exists()); + assert(ref.exists()); ref->Run(); })); } @@ -188,7 +188,7 @@ void PythonContextCall::ScheduleInUIOperation(const PythonRef& args) { assert(base::g_base); g_base->ui->PushUIOperationRunnable(NewLambdaRunnableUnmanaged([ref, args] { - assert(ref.Exists()); + assert(ref.exists()); ref->Run(args); })); } diff --git a/src/ballistica/base/python/support/python_context_call.h b/src/ballistica/base/python/support/python_context_call.h index 7b6e961c..9737a115 100644 --- a/src/ballistica/base/python/support/python_context_call.h +++ b/src/ballistica/base/python/support/python_context_call.h @@ -26,11 +26,11 @@ class PythonContextCall : public Object { /// Initialize with a callable PythonRef. explicit PythonContextCall(const PythonRef& ref) - : PythonContextCall(ref.Get()) {} + : PythonContextCall(ref.get()) {} void Run(PyObject* args = nullptr); - void Run(const PythonRef& args) { Run(args.Get()); } - auto Exists() const -> bool { return object_.Exists(); } + void Run(const PythonRef& args) { Run(args.get()); } + auto exists() const -> bool { return object_.exists(); } auto GetObjectDescription() const -> std::string override; void MarkDead(); auto object() const -> const PythonRef& { return object_; } diff --git a/src/ballistica/base/python/support/python_context_call_runnable.h b/src/ballistica/base/python/support/python_context_call_runnable.h index 66235e83..9117b651 100644 --- a/src/ballistica/base/python/support/python_context_call_runnable.h +++ b/src/ballistica/base/python/support/python_context_call_runnable.h @@ -15,7 +15,7 @@ class PythonContextCallRunnable : public Runnable { : call(Object::New(o)) {} Object::Ref call; void Run() override { - assert(call.Exists()); + assert(call.exists()); call->Run(); } ~PythonContextCallRunnable() override = default; diff --git a/src/ballistica/base/support/app_timer.h b/src/ballistica/base/support/app_timer.h index 6289ab75..9d9776c6 100644 --- a/src/ballistica/base/support/app_timer.h +++ b/src/ballistica/base/support/app_timer.h @@ -5,7 +5,6 @@ #include "ballistica/base/base.h" #include "ballistica/base/logic/logic.h" -#include "ballistica/shared/ballistica.h" #include "ballistica/shared/foundation/object.h" #include "ballistica/shared/generic/lambda_runnable.h" @@ -22,7 +21,7 @@ class AppTimer : public Object { template static auto New(seconds_t length, bool repeat, const F& lambda) { return Object::New(length, repeat, - NewLambdaRunnable(lambda).Get()); + NewLambdaRunnable(lambda).get()); } void SetLength(seconds_t length) { diff --git a/src/ballistica/base/support/context.cc b/src/ballistica/base/support/context.cc index f2a0c673..76d63040 100644 --- a/src/ballistica/base/support/context.cc +++ b/src/ballistica/base/support/context.cc @@ -17,8 +17,8 @@ auto ContextRef::operator==(const ContextRef& other) const -> bool { // we're equal. The one exception to this is if we're both pointing to // targets that have died; in that case we have no way of knowing so // we say we're unequal. - if (target_.Get() == other.target_.Get() && empty_ == other.empty_) { - if (!empty_ && target_.Get() == nullptr) { + if (target_.get() == other.target_.get() && empty_ == other.empty_) { + if (!empty_ && target_.get() == nullptr) { return false; } return true; @@ -30,7 +30,7 @@ ContextRef::ContextRef(Context* target_in) : target_(target_in), empty_(target_in == nullptr) {} auto ContextRef::GetDescription() const -> std::string { - if (auto* c = target_.Get()) { + if (auto* c = target_.get()) { return c->GetContextDescription(); } return "empty"; @@ -45,7 +45,7 @@ auto Context::ContextAllowsDefaultTimerTypes() -> bool { return true; } ScopedSetContext::ScopedSetContext(const Object::Ref& target) : context_prev_(g_base->CurrentContext()) { - g_base->context_ref->SetTarget(target.Get()); + g_base->context_ref->SetTarget(target.get()); } ScopedSetContext::ScopedSetContext(Context* target) diff --git a/src/ballistica/base/support/context.h b/src/ballistica/base/support/context.h index e1d603f8..ac1133bb 100644 --- a/src/ballistica/base/support/context.h +++ b/src/ballistica/base/support/context.h @@ -46,7 +46,7 @@ class ContextRef { // Note: if it ever seems like speed is an issue here, we can // cache the results with std::type_index entries. There should // generally be a very small number of types involved. - return dynamic_cast(target_.Get()); + return dynamic_cast(target_.get()); } /// An empty context-ref was explicitly set to an empty state. @@ -60,13 +60,13 @@ class ContextRef { if (empty_) { return false; // Can't kill what was never alive. } - return !target_.Exists(); + return !target_.exists(); } /// Return the context this ref points to. This will be nullptr for empty /// contexts. Throws an exception if a target context was set but has expired. auto Get() const -> Context* { - auto* target = target_.Get(); + auto* target = target_.get(); if (target == nullptr && !empty_) { // We once existed but now don't. throw Exception("Context is expired.", PyExcType::kNotFound); diff --git a/src/ballistica/base/support/display_timer.h b/src/ballistica/base/support/display_timer.h index f8f72db8..3416cf7f 100644 --- a/src/ballistica/base/support/display_timer.h +++ b/src/ballistica/base/support/display_timer.h @@ -5,7 +5,6 @@ #include "ballistica/base/base.h" #include "ballistica/base/logic/logic.h" -#include "ballistica/shared/ballistica.h" #include "ballistica/shared/foundation/object.h" #include "ballistica/shared/generic/lambda_runnable.h" @@ -22,7 +21,7 @@ class DisplayTimer : public Object { template static auto New(seconds_t length, bool repeat, const F& lambda) { return Object::New(length, repeat, - NewLambdaRunnable(lambda).Get()); + NewLambdaRunnable(lambda).get()); } void SetLength(seconds_t length) { diff --git a/src/ballistica/base/support/repeater.cc b/src/ballistica/base/support/repeater.cc index 8e306593..f2199dae 100644 --- a/src/ballistica/base/support/repeater.cc +++ b/src/ballistica/base/support/repeater.cc @@ -34,9 +34,9 @@ void Repeater::PostInit_() { auto weak_this = Object::WeakRef(this); timer_ = DisplayTimer::New(weak_this->initial_delay_, false, [weak_this] { // Timer should not have fired if we died. - assert(weak_this.Exists()); + assert(weak_this.exists()); weak_this->runnable_->RunAndLogErrors(); - if (!weak_this.Exists()) { + if (!weak_this.exists()) { // Runnable we just ran might have killed us. return; } @@ -44,7 +44,7 @@ void Repeater::PostInit_() { weak_this->timer_ = DisplayTimer::New(weak_this->repeat_delay_, true, [weak_this] { // Timer should not have fired if we died. - assert(weak_this.Exists()); + assert(weak_this.exists()); weak_this->runnable_->RunAndLogErrors(); // Doesn't matter if Runnable killed us since we don't // touch anything for the remainder of this function. diff --git a/src/ballistica/base/support/repeater.h b/src/ballistica/base/support/repeater.h index df48e66b..0d522ec2 100644 --- a/src/ballistica/base/support/repeater.h +++ b/src/ballistica/base/support/repeater.h @@ -18,7 +18,7 @@ class Repeater : public Object { static auto New(seconds_t initial_delay, seconds_t repeat_delay, const F& lambda) { auto&& rep = Object::New(initial_delay, repeat_delay, - NewLambdaRunnable(lambda).Get()); + NewLambdaRunnable(lambda).get()); // We need to run this bit *after* constructing our obj since it creates // a strong ref. rep->PostInit_(); diff --git a/src/ballistica/base/support/stdio_console.cc b/src/ballistica/base/support/stdio_console.cc index 000ada76..ca8c918c 100644 --- a/src/ballistica/base/support/stdio_console.cc +++ b/src/ballistica/base/support/stdio_console.cc @@ -135,12 +135,12 @@ void StdioConsole::PushCommand_(const std::string& command) { // Eval this if possible (so we can possibly print return value). if (cmd.CanEval()) { auto obj = cmd.Eval(true, nullptr, nullptr); - if (obj.Exists()) { + if (obj.exists()) { // Print the value if we're running directly from a terminal // (or being run under the server-manager) if ((g_core->platform->is_stdin_a_terminal() || g_base->server_wrapper_managed()) - && obj.Get() != Py_None) { + && obj.get() != Py_None) { printf("%s\n", obj.Repr().c_str()); fflush(stdout); } diff --git a/src/ballistica/base/ui/dev_console.cc b/src/ballistica/base/ui/dev_console.cc index 504de0d3..e3603ea4 100644 --- a/src/ballistica/base/ui/dev_console.cc +++ b/src/ballistica/base/ui/dev_console.cc @@ -305,8 +305,8 @@ class DevConsole::Button_ : public DevConsole::Widget_ { if (pressed) { pressed = false; if (InUs(mx, my)) { - if (call.Exists()) { - call.Get()->Run(); + if (call.exists()) { + call.get()->Run(); } } } @@ -465,8 +465,8 @@ class DevConsole::ToggleButton_ : public DevConsole::Widget_ { if (InUs(mx, my)) { on = !on; auto&& call = on ? on_call : off_call; - if (call.Exists()) { - call.Get()->Run(); + if (call.exists()) { + call.get()->Run(); } } } @@ -546,8 +546,8 @@ class DevConsole::TabButton_ : public DevConsole::Widget_ { // unselected for a frame before the deferred call runs. selected = true; - if (call.Exists()) { - call.Get()->Run(); + if (call.exists()) { + call.get()->Run(); } } } @@ -579,7 +579,7 @@ class DevConsole::OutputLine_ { float scale; Vector4f color; auto GetText() -> TextGroup& { - if (!s_mesh_.Exists()) { + if (!s_mesh_.exists()) { s_mesh_ = Object::New(); s_mesh_->SetText(s); } @@ -721,7 +721,7 @@ void DevConsole::AddButton(const char* label, float x, float y, float width, widgets_.emplace_back(std::make_unique( label, label_scale, h_anchor, x, y, width, height, corner_radius, style, disabled, [this, callref = PythonRef::Acquired(call)] { - if (callref.Get() != Py_None) { + if (callref.get() != Py_None) { callref.Call(); } })); @@ -838,9 +838,9 @@ void DevConsole::HandleMouseUp(int button, float x, float y) { void DevConsole::InvokeStringEditor_() { // If there's already a valid edit-adapter attached to us, do nothing. - if (string_edit_adapter_.Exists() + if (string_edit_adapter_.exists() && !g_base->python->CanPyStringEditAdapterBeReplaced( - string_edit_adapter_.Get())) { + string_edit_adapter_.get())) { return; } @@ -849,7 +849,7 @@ void DevConsole::InvokeStringEditor_() { auto result = g_base->python->objs() .Get(BasePython::ObjID::kDevConsoleStringEditAdapterClass) .Call(); - if (!result.Exists()) { + if (!result.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Error invoking string edit dialog."); return; @@ -857,14 +857,14 @@ void DevConsole::InvokeStringEditor_() { // If this new one is already marked replacable, it means it wasn't able // to register as the active one, so we can ignore it. - if (g_base->python->CanPyStringEditAdapterBeReplaced(result.Get())) { + if (g_base->python->CanPyStringEditAdapterBeReplaced(result.get())) { return; } // Ok looks like we're good; store the adapter as our active one. string_edit_adapter_ = result; - g_base->platform->InvokeStringEditor(string_edit_adapter_.Get()); + g_base->platform->InvokeStringEditor(string_edit_adapter_.get()); } void DevConsole::set_input_string(const std::string& val) { @@ -1256,7 +1256,7 @@ void DevConsole::SubmitPythonCommand_(const std::string& command) { } if (cmd.CanEval()) { auto obj = cmd.Eval(true, nullptr, nullptr); - if (obj.Exists() && obj.Get() != Py_None) { + if (obj.exists() && obj.get() != Py_None) { Print(obj.Repr(), 1.0f, kVector4f1); } } else { @@ -1522,7 +1522,7 @@ void DevConsole::Draw(FrameDef* frame_def) { } // Carat. - if (!carat_mesh_.Exists() || carat_dirty_) { + if (!carat_mesh_.exists() || carat_dirty_) { // Note: we explicitly update here if carat is dirty because // that updates last_carat_change_time_ which affects whether // we draw or not. GetCaratX_() only updates it *if* we draw. @@ -1541,7 +1541,7 @@ void DevConsole::Draw(FrameDef* frame_def) { c.Translate(15.0f * bs, bottom + 14.5f * bs, kDevConsoleZDepth); c.Scale(0.5f * bs, 0.5f * bs, 1.0f); c.Translate(carat_x, 0.0f, 0.0f); - c.DrawMesh(carat_glow_mesh_.Get()); + c.DrawMesh(carat_glow_mesh_.get()); } c.SetTexture(g_base->assets->SysTexture(SysTextureID::kShadowSharp)); c.SetColor(1.0, 1.0, 1.0, 1.0f); @@ -1551,7 +1551,7 @@ void DevConsole::Draw(FrameDef* frame_def) { c.Translate(15.0f * bs, bottom + 14.5f * bs, kDevConsoleZDepth); c.Scale(0.5f * bs, 0.5f * bs, 1.0f); c.Translate(carat_x, 0.0f, 0.0f); - c.DrawMesh(carat_mesh_.Get()); + c.DrawMesh(carat_mesh_.get()); } } diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index 1056d70e..749351cc 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -418,7 +418,7 @@ void UI::LanguageChanged() { auto UI::GetUIInputDevice() const -> InputDevice* { assert(g_base->InLogicThread()); - return ui_input_device_.Get(); + return ui_input_device_.get(); } auto UI::GetWidgetForInput(InputDevice* input_device) -> ui_v1::Widget* { @@ -557,7 +557,7 @@ auto UI::InDevConsoleButton_(float x, float y) const -> bool { } void UI::DrawDevConsoleButton_(FrameDef* frame_def) { - if (!dev_console_button_txt_.Exists()) { + if (!dev_console_button_txt_.exists()) { dev_console_button_txt_ = Object::New(); dev_console_button_txt_->SetText("dev"); } diff --git a/src/ballistica/classic/classic.cc b/src/ballistica/classic/classic.cc index 6d9ec1e4..e011a655 100644 --- a/src/ballistica/classic/classic.cc +++ b/src/ballistica/classic/classic.cc @@ -206,7 +206,7 @@ void ClassicFeatureSet::SetV1DeviceAccount(const std::string& name) { auto ClassicFeatureSet::GetClientInfoQueryResponseCall() -> PyObject* { return g_scene_v1->python->objs() .Get(scene_v1::SceneV1Python::ObjID::kClientInfoQueryResponseCall) - .Get(); + .get(); } auto ClassicFeatureSet::BuildPublicPartyStateVal() -> PyObject* { diff --git a/src/ballistica/classic/python/classic_python.cc b/src/ballistica/classic/python/classic_python.cc index cfd3b966..4cc7a3b6 100644 --- a/src/ballistica/classic/python/classic_python.cc +++ b/src/ballistica/classic/python/classic_python.cc @@ -61,12 +61,12 @@ auto ClassicPython::GetControllerValue(base::InputDevice* device, Python::ScopedCallLabel label("get_device_value"); ret_val = objs().Get(ObjID::kGetInputDeviceMappedValueCall).Call(args); } - BA_PRECONDITION(ret_val.Exists()); - if (!PyLong_Check(ret_val.Get())) { + BA_PRECONDITION(ret_val.exists()); + if (!PyLong_Check(ret_val.get())) { throw Exception("Non-int returned from get_device_value call.", PyExcType::kType); } - return static_cast(PyLong_AsLong(ret_val.Get())); + return static_cast(PyLong_AsLong(ret_val.get())); } auto ClassicPython::GetControllerFloatValue(base::InputDevice* device, @@ -81,17 +81,17 @@ auto ClassicPython::GetControllerFloatValue(base::InputDevice* device, PythonRef::kSteal); PythonRef ret_val = objs().Get(ObjID::kGetInputDeviceMappedValueCall).Call(args); - BA_PRECONDITION(ret_val.Exists()); - if (!PyFloat_Check(ret_val.Get())) { - if (PyLong_Check(ret_val.Get())) { - return static_cast(PyLong_AsLong(ret_val.Get())); + BA_PRECONDITION(ret_val.exists()); + if (!PyFloat_Check(ret_val.get())) { + if (PyLong_Check(ret_val.get())) { + return static_cast(PyLong_AsLong(ret_val.get())); } else { throw Exception( "Non float/int returned from GetControllerFloatValue call.", PyExcType::kType); } } - return static_cast(PyFloat_AsDouble(ret_val.Get())); + return static_cast(PyFloat_AsDouble(ret_val.get())); } auto ClassicPython::BuildPublicPartyStateVal() -> PyObject* { diff --git a/src/ballistica/classic/python/methods/python_methods_classic.cc b/src/ballistica/classic/python/methods/python_methods_classic.cc index 35243815..4539f86a 100644 --- a/src/ballistica/classic/python/methods/python_methods_classic.cc +++ b/src/ballistica/classic/python/methods/python_methods_classic.cc @@ -302,6 +302,7 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) const char* achievements_percent_text; const char* level_text; const char* xp_text; + const char* inbox_count_text; static const char* kwlist[] = {"tickets_text", "tokens_text", @@ -310,17 +311,21 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) "achievements_percent_text", "level_text", "xp_text", + "inbox_count_text", nullptr}; - if (!PyArg_ParseTupleAndKeywords( - args, keywds, "sssssss", const_cast(kwlist), &tickets_text, - &tokens_text, &league_rank_text, &league_type, - &achievements_percent_text, &level_text, &xp_text)) { + if (!PyArg_ParseTupleAndKeywords(args, keywds, "ssssssss", + const_cast(kwlist), &tickets_text, + &tokens_text, &league_rank_text, + &league_type, &achievements_percent_text, + &level_text, &xp_text, &inbox_count_text)) { return nullptr; } BA_PRECONDITION(g_base->InLogicThread()); auto* appmode = ClassicAppMode::GetActiveOrThrow(); + // Pass these all along to the app-mode which will store them and forward + // them to any existing UI. appmode->SetRootUITicketsMeterText(tickets_text); appmode->SetRootUITokensMeterText(tokens_text); appmode->SetRootUILeagueRankText(league_rank_text); @@ -328,6 +333,7 @@ static auto PySetRootUIValues(PyObject* self, PyObject* args, PyObject* keywds) appmode->SetRootUIAchievementsPercentText(achievements_percent_text); appmode->SetRootUILevelText(level_text); appmode->SetRootUIXPText(xp_text); + appmode->SetRootUIInboxCountText(inbox_count_text); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -345,6 +351,7 @@ static PyMethodDef PySetRootUIValuesDef = { " achievements_percent_text: str,\n" " level_text: str,\n" " xp_text: str,\n" + " inbox_count_text: str,\n" ") -> None\n" "\n" "(internal)", diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index 641c2286..3a66ee96 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -11,6 +11,7 @@ #include "ballistica/base/audio/audio_source.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/graphics/support/frame_def.h" +#include "ballistica/base/logic/logic.h" #include "ballistica/base/networking/network_writer.h" #include "ballistica/base/networking/networking.h" #include "ballistica/base/support/app_config.h" @@ -155,6 +156,7 @@ void ClassicAppMode::Reset_() { root_widget->SetAchievementPercentText(root_ui_achievement_percent_text_); root_widget->SetLevelText(root_ui_level_text_); root_widget->SetXPText(root_ui_xp_text_); + root_widget->SetInboxCountText(root_ui_inbox_count_text_); } } @@ -490,7 +492,7 @@ auto ClassicAppMode::GetPartySize() const -> int { auto ClassicAppMode::GetHeadlessNextDisplayTimeStep() -> microsecs_t { std::optional min_time_to_next; for (auto&& i : sessions_) { - if (!i.Exists()) { + if (!i.exists()) { continue; } auto this_time_to_next = i->TimeToNextEvent(); @@ -566,7 +568,7 @@ void ClassicAppMode::StepDisplayTime() { // Update all of our sessions. for (auto&& i : sessions_) { - if (!i.Exists()) { + if (!i.exists()) { continue; } // Pass our old int milliseconds time vals for legacy purposes @@ -710,7 +712,7 @@ void ClassicAppMode::UpdateGameRoster() { client_delegate->connection_to_client(); // Add some basic info for each remote player. - if (ctc != nullptr && ctc == i.second.Get()) { + if (ctc != nullptr && ctc == i.second.get()) { cJSON* player_dict = cJSON_CreateObject(); cJSON_AddItemToObject(player_dict, "n", cJSON_CreateString(p->GetName().c_str())); @@ -747,8 +749,8 @@ void ClassicAppMode::UpdateKickVote_() { if (!kick_vote_in_progress_) { return; } - scene_v1::ConnectionToClient* kick_vote_starter = kick_vote_starter_.Get(); - scene_v1::ConnectionToClient* kick_vote_target = kick_vote_target_.Get(); + scene_v1::ConnectionToClient* kick_vote_starter = kick_vote_starter_.get(); + scene_v1::ConnectionToClient* kick_vote_target = kick_vote_target_.get(); // If the target is no longer with us, silently end. if (kick_vote_target == nullptr) { @@ -950,7 +952,7 @@ void ClassicAppMode::StartKickVote(scene_v1::ConnectionToClient* starter, void ClassicAppMode::SetForegroundScene(scene_v1::Scene* sg) { assert(g_base->InLogicThread()); - if (foreground_scene_.Get() != sg) { + if (foreground_scene_.get() != sg) { foreground_scene_ = sg; // If this scene has a globals-node, put it in charge of stuff. @@ -987,7 +989,7 @@ auto ClassicAppMode::GetNetworkDebugString() -> std::string { } else { int connected_count = 0; for (auto&& i : connections()->connections_to_clients()) { - scene_v1::ConnectionToClient* client = i.second.Get(); + scene_v1::ConnectionToClient* client = i.second.get(); if (client->can_communicate()) { show = true; connected_count += 1; @@ -1071,7 +1073,7 @@ void ClassicAppMode::LaunchHostSession(PyObject* session_type_obj, } catch (const std::exception& e) { // If it failed, restore the previous session context and re-throw the // exception. - SetForegroundSession(old_foreground_session.Get()); + SetForegroundSession(old_foreground_session.get()); throw Exception(std::string("HostSession failed: ") + e.what()); } } @@ -1103,7 +1105,7 @@ void ClassicAppMode::LaunchReplaySession(const std::string& file_name) { } catch (const std::exception& e) { // If it failed, restore the previous current session and re-throw the // exception. - SetForegroundSession(old_foreground_session.Get()); + SetForegroundSession(old_foreground_session.get()); throw Exception(std::string("HostSession failed: ") + e.what()); } } @@ -1133,7 +1135,7 @@ void ClassicAppMode::LaunchClientSession() { assert(foreground_session_ == s); } catch (const std::exception& e) { // If it failed, restore the previous current session and re-throw. - SetForegroundSession(old_foreground_session.Get()); + SetForegroundSession(old_foreground_session.get()); throw Exception(std::string("HostSession failed: ") + e.what()); } } @@ -1223,7 +1225,7 @@ void ClassicAppMode::LocalDisplayChatMessage( void ClassicAppMode::DoApplyAppConfig() { // Kick-idle-players setting (hmm is this still relevant?). auto* host_session = - dynamic_cast(foreground_session_.Get()); + dynamic_cast(foreground_session_.get()); kick_idle_players_ = g_base->app_config->Resolve(base::AppConfig::BoolID::kKickIdlePlayers); if (host_session) { @@ -1240,9 +1242,9 @@ void ClassicAppMode::DoApplyAppConfig() { void ClassicAppMode::PruneSessions_() { bool have_dead_session = false; for (auto&& i : sessions_) { - if (i.Exists()) { + if (i.exists()) { // If this session is no longer foreground and is ready to die, kill it. - if (i.Exists() && i.Get() != foreground_session_.Get()) { + if (i.exists() && i.get() != foreground_session_.get()) { try { i.Clear(); } catch (const std::exception& e) { @@ -1258,7 +1260,7 @@ void ClassicAppMode::PruneSessions_() { if (have_dead_session) { std::vector > live_list; for (auto&& i : sessions_) { - if (i.Exists()) { + if (i.exists()) { live_list.push_back(i); } } @@ -1538,7 +1540,7 @@ void ClassicAppMode::RunMainMenu() { g_scene_v1->python->objs() .Get(scene_v1::SceneV1Python::ObjID::kLaunchMainMenuSessionCall) .Call(); - if (!result.Exists()) { + if (!result.exists()) { throw Exception("Error running scene_v1 main menu."); } } @@ -1657,4 +1659,21 @@ void ClassicAppMode::SetRootUIXPText(const std::string text) { } } +void ClassicAppMode::SetRootUIInboxCountText(const std::string text) { + BA_PRECONDITION(g_base->InLogicThread()); + if (text == root_ui_inbox_count_text_) { + return; + } + + // Store the value. + root_ui_inbox_count_text_ = text; + + // Apply it to any existing UI. + if (uiv1_) { + if (auto* root_widget = uiv1_->root_widget()) { + root_widget->SetInboxCountText(root_ui_inbox_count_text_); + } + } +} + } // namespace ballistica::classic diff --git a/src/ballistica/classic/support/classic_app_mode.h b/src/ballistica/classic/support/classic_app_mode.h index b1b04273..1eac527e 100644 --- a/src/ballistica/classic/support/classic_app_mode.h +++ b/src/ballistica/classic/support/classic_app_mode.h @@ -89,13 +89,13 @@ class ClassicAppMode : public base::AppMode { // Return whichever session is front and center. auto GetForegroundSession() const -> scene_v1::Session* { - return foreground_session_.Get(); + return foreground_session_.get(); } // Used to know which globals is in control currently/etc. auto GetForegroundScene() const -> scene_v1::Scene* { assert(g_base->InLogicThread()); - return foreground_scene_.Get(); + return foreground_scene_.get(); } auto GetForegroundContext() -> base::ContextRef override; auto debug_speed_mult() const -> float { return debug_speed_mult_; } @@ -220,6 +220,7 @@ class ClassicAppMode : public base::AppMode { void SetRootUIAchievementsPercentText(const std::string text); void SetRootUILevelText(const std::string text); void SetRootUIXPText(const std::string text); + void SetRootUIInboxCountText(const std::string text); private: ClassicAppMode(); @@ -300,6 +301,7 @@ class ClassicAppMode : public base::AppMode { std::string root_ui_achievement_percent_text_; std::string root_ui_level_text_; std::string root_ui_xp_text_; + std::string root_ui_inbox_count_text_; std::list > banned_players_; std::optional idle_exit_minutes_{}; std::optional internal_music_play_id_{}; diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index 63cf391e..d8b41e5d 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -144,7 +144,7 @@ void CoreFeatureSet::ApplyBaEnvConfig() { // Ask baenv for the config we should use. auto envcfg = python->objs().Get(core::CorePython::ObjID::kBaEnvGetConfigCall).Call(); - BA_PRECONDITION_FATAL(envcfg.Exists()); + BA_PRECONDITION_FATAL(envcfg.exists()); assert(!have_ba_env_vals_); have_ba_env_vals_ = true; diff --git a/src/ballistica/core/python/core_python.cc b/src/ballistica/core/python/core_python.cc index ba1bbd71..9e2fffed 100644 --- a/src/ballistica/core/python/core_python.cc +++ b/src/ballistica/core/python/core_python.cc @@ -278,7 +278,7 @@ void CorePython::UpdateInternalLoggerLevels(LogLevel* log_levels) { auto logname{pair.first}; auto objid{pair.second}; auto out{objs().Get(objid).GetAttr("getEffectiveLevel").Call()}; - assert(out.Exists()); + assert(out.exists()); auto outval{static_cast(out.ValueAsInt())}; switch (outval) { @@ -316,7 +316,7 @@ void CorePython::UpdateInternalLoggerLevels(LogLevel* log_levels) { void CorePython::SoftImportBase() { auto gil{Python::ScopedInterpreterLock()}; auto result = PythonRef::StolenSoft(PyImport_ImportModule("_babase")); - if (!result.Exists()) { + if (!result.exists()) { // Ignore any errors here for now. All that will matter is whether base // gave us its interface. PyErr_Clear(); @@ -387,7 +387,7 @@ void CorePython::MonolithicModeBaEnvConfigure() { auto result = objs() .Get(ObjID::kBaEnvConfigureCall) .Call(objs().Get(ObjID::kEmptyTuple), kwargs); - if (!result.Exists()) { + if (!result.exists()) { FatalError("Environment setup failed (no error info available)."); } if (result.ValueIsString()) { @@ -504,7 +504,7 @@ void CorePython::LoggingCall(LogName logname, LogLevel loglevel, break; } PythonRef args( - Py_BuildValue("(Os)", objs().Get(loglevelobjid).Get(), msg.c_str()), + Py_BuildValue("(Os)", objs().Get(loglevelobjid).get(), msg.c_str()), PythonRef::kSteal); objs().Get(logcallobj).Call(args); } diff --git a/src/ballistica/scene_v1/assets/scene_asset.h b/src/ballistica/scene_v1/assets/scene_asset.h index f7eb416d..6fe44041 100644 --- a/src/ballistica/scene_v1/assets/scene_asset.h +++ b/src/ballistica/scene_v1/assets/scene_asset.h @@ -3,7 +3,6 @@ #ifndef BALLISTICA_SCENE_V1_ASSETS_SCENE_ASSET_H_ #define BALLISTICA_SCENE_V1_ASSETS_SCENE_ASSET_H_ -#include #include #include @@ -23,8 +22,8 @@ static auto GetAsset(std::unordered_map >* list, // If we have an entry pointing to a live component, just return a new ref // to it. - if (i != list->end() && i->second.Exists()) { - return Object::Ref(i->second.Get()); + if (i != list->end() && i->second.exists()) { + return Object::Ref(i->second.get()); } else { // Otherwise make a new one, pop a weak-ref on our list, and return a // strong-ref to it. @@ -44,7 +43,7 @@ class SceneAsset : public Object { auto NewPyRef() -> PyObject* { return GetPyRef(true); } auto BorrowPyRef() -> PyObject* { return GetPyRef(false); } auto GetObjectDescription() const -> std::string override; - auto scene() const -> Scene* { return scene_.Get(); } + auto scene() const -> Scene* { return scene_.get(); } auto stream_id() const -> int64_t { return stream_id_; } void set_stream_id(int64_t val) { diff --git a/src/ballistica/scene_v1/assets/scene_collision_mesh.cc b/src/ballistica/scene_v1/assets/scene_collision_mesh.cc index 36874204..32b94908 100644 --- a/src/ballistica/scene_v1/assets/scene_collision_mesh.cc +++ b/src/ballistica/scene_v1/assets/scene_collision_mesh.cc @@ -4,6 +4,7 @@ #include +#include "ballistica/base/assets/assets.h" #include "ballistica/scene_v1/python/class/python_class_scene_collision_mesh.h" #include "ballistica/scene_v1/support/scene.h" #include "ballistica/scene_v1/support/session_stream.h" @@ -22,7 +23,7 @@ SceneCollisionMesh::SceneCollisionMesh(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; collision_mesh_data_ = g_base->assets->GetCollisionMesh(name); } - assert(collision_mesh_data_.Exists()); + assert(collision_mesh_data_.exists()); } SceneCollisionMesh::~SceneCollisionMesh() { MarkDead(); } diff --git a/src/ballistica/scene_v1/assets/scene_collision_mesh.h b/src/ballistica/scene_v1/assets/scene_collision_mesh.h index c7953aab..e7ee83f3 100644 --- a/src/ballistica/scene_v1/assets/scene_collision_mesh.h +++ b/src/ballistica/scene_v1/assets/scene_collision_mesh.h @@ -5,7 +5,6 @@ #include -#include "ballistica/base/assets/assets.h" #include "ballistica/base/assets/collision_mesh_asset.h" #include "ballistica/scene_v1/assets/scene_asset.h" @@ -18,7 +17,7 @@ class SceneCollisionMesh : public SceneAsset { ~SceneCollisionMesh() override; auto collision_mesh_data() const -> base::CollisionMeshAsset* { - return collision_mesh_data_.Get(); + return collision_mesh_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "CollisionMesh"; diff --git a/src/ballistica/scene_v1/assets/scene_cube_map_texture.cc b/src/ballistica/scene_v1/assets/scene_cube_map_texture.cc index 30164e7d..a86be885 100644 --- a/src/ballistica/scene_v1/assets/scene_cube_map_texture.cc +++ b/src/ballistica/scene_v1/assets/scene_cube_map_texture.cc @@ -17,7 +17,7 @@ SceneCubeMapTexture::SceneCubeMapTexture(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; texture_data_ = g_base->assets->GetCubeMapTexture(name); } - assert(texture_data_.Exists()); + assert(texture_data_.exists()); } } // namespace ballistica::scene_v1 diff --git a/src/ballistica/scene_v1/assets/scene_cube_map_texture.h b/src/ballistica/scene_v1/assets/scene_cube_map_texture.h index 13b7c450..22bfdf03 100644 --- a/src/ballistica/scene_v1/assets/scene_cube_map_texture.h +++ b/src/ballistica/scene_v1/assets/scene_cube_map_texture.h @@ -18,7 +18,7 @@ class SceneCubeMapTexture : public SceneAsset { // note that a texture's data can change over time as different // versions are spooled in/out/etc auto GetTextureData() const -> base::TextureAsset* { - return texture_data_.Get(); + return texture_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "CubeMapTexture"; diff --git a/src/ballistica/scene_v1/assets/scene_data_asset.cc b/src/ballistica/scene_v1/assets/scene_data_asset.cc index 98f6f7e4..41b9589c 100644 --- a/src/ballistica/scene_v1/assets/scene_data_asset.cc +++ b/src/ballistica/scene_v1/assets/scene_data_asset.cc @@ -23,7 +23,7 @@ SceneDataAsset::SceneDataAsset(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; data_data_ = g_base->assets->GetDataAsset(name); } - assert(data_data_.Exists()); + assert(data_data_.exists()); } SceneDataAsset::~SceneDataAsset() { MarkDead(); } diff --git a/src/ballistica/scene_v1/assets/scene_data_asset.h b/src/ballistica/scene_v1/assets/scene_data_asset.h index 863bf885..ed86bd44 100644 --- a/src/ballistica/scene_v1/assets/scene_data_asset.h +++ b/src/ballistica/scene_v1/assets/scene_data_asset.h @@ -24,7 +24,7 @@ class SceneDataAsset : public SceneAsset { // return the DataData currently associated with this data // note that a data's data can change over time as different // versions are spooled in/out/etc. - auto data_data() const -> base::DataAsset* { return data_data_.Get(); } + auto data_data() const -> base::DataAsset* { return data_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "Data"; } void MarkDead(); diff --git a/src/ballistica/scene_v1/assets/scene_mesh.cc b/src/ballistica/scene_v1/assets/scene_mesh.cc index 2a30cde0..03b27621 100644 --- a/src/ballistica/scene_v1/assets/scene_mesh.cc +++ b/src/ballistica/scene_v1/assets/scene_mesh.cc @@ -24,7 +24,7 @@ SceneMesh::SceneMesh(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; mesh_data_ = g_base->assets->GetMesh(name); } - assert(mesh_data_.Exists()); + assert(mesh_data_.exists()); } SceneMesh::~SceneMesh() { MarkDead(); } diff --git a/src/ballistica/scene_v1/assets/scene_mesh.h b/src/ballistica/scene_v1/assets/scene_mesh.h index 1cc8d9f0..1b4db5dc 100644 --- a/src/ballistica/scene_v1/assets/scene_mesh.h +++ b/src/ballistica/scene_v1/assets/scene_mesh.h @@ -17,7 +17,7 @@ class SceneMesh : public SceneAsset { SceneMesh(const std::string& name, Scene* scene); ~SceneMesh() override; - auto mesh_data() const -> base::MeshAsset* { return mesh_data_.Get(); } + auto mesh_data() const -> base::MeshAsset* { return mesh_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "Mesh"; } void MarkDead(); diff --git a/src/ballistica/scene_v1/assets/scene_sound.cc b/src/ballistica/scene_v1/assets/scene_sound.cc index f26086bf..8fc26260 100644 --- a/src/ballistica/scene_v1/assets/scene_sound.cc +++ b/src/ballistica/scene_v1/assets/scene_sound.cc @@ -24,7 +24,7 @@ SceneSound::SceneSound(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; sound_data_ = g_base->assets->GetSound(name); } - assert(sound_data_.Exists()); + assert(sound_data_.exists()); } SceneSound::~SceneSound() { MarkDead(); } diff --git a/src/ballistica/scene_v1/assets/scene_sound.h b/src/ballistica/scene_v1/assets/scene_sound.h index 01d0bfb0..b0fa569f 100644 --- a/src/ballistica/scene_v1/assets/scene_sound.h +++ b/src/ballistica/scene_v1/assets/scene_sound.h @@ -19,7 +19,7 @@ class SceneSound : public SceneAsset { // Return the SoundData currently associated with this sound. // Note that a sound's data can change over time as different // versions are spooled in/out/etc. - auto GetSoundData() const -> base::SoundAsset* { return sound_data_.Get(); } + auto GetSoundData() const -> base::SoundAsset* { return sound_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "Sound"; } void MarkDead(); diff --git a/src/ballistica/scene_v1/assets/scene_texture.cc b/src/ballistica/scene_v1/assets/scene_texture.cc index d57760fb..bd0a53bc 100644 --- a/src/ballistica/scene_v1/assets/scene_texture.cc +++ b/src/ballistica/scene_v1/assets/scene_texture.cc @@ -25,7 +25,7 @@ SceneTexture::SceneTexture(const std::string& name, Scene* scene) base::Assets::AssetListLock lock; texture_data_ = g_base->assets->GetTexture(name); } - assert(texture_data_.Exists()); + assert(texture_data_.exists()); } // qrcode version @@ -36,7 +36,7 @@ SceneTexture::SceneTexture(const std::string& qr_url) base::Assets::AssetListLock lock; texture_data_ = g_base->assets->GetQRCodeTexture(qr_url); } - assert(texture_data_.Exists()); + assert(texture_data_.exists()); } SceneTexture::~SceneTexture() { MarkDead(); } diff --git a/src/ballistica/scene_v1/assets/scene_texture.h b/src/ballistica/scene_v1/assets/scene_texture.h index 764e1a34..ec3b4acc 100644 --- a/src/ballistica/scene_v1/assets/scene_texture.h +++ b/src/ballistica/scene_v1/assets/scene_texture.h @@ -21,7 +21,7 @@ class SceneTexture : public SceneAsset { // Note that a texture's data can change over time as different // versions are spooled in/out/etc. auto texture_data() const -> base::TextureAsset* { - return texture_data_.Get(); + return texture_data_.get(); } auto GetAssetTypeName() const -> std::string override { return "Texture"; } void MarkDead(); diff --git a/src/ballistica/scene_v1/connection/connection_set.cc b/src/ballistica/scene_v1/connection/connection_set.cc index c76c2f94..c2926c30 100644 --- a/src/ballistica/scene_v1/connection/connection_set.cc +++ b/src/ballistica/scene_v1/connection/connection_set.cc @@ -8,6 +8,7 @@ #include #include "ballistica/base/assets/assets.h" +#include "ballistica/base/logic/logic.h" #include "ballistica/base/networking/network_writer.h" #include "ballistica/classic/support/classic_app_mode.h" #include "ballistica/scene_v1/connection/connection_to_client_udp.h" @@ -23,7 +24,7 @@ namespace ballistica::scene_v1 { ConnectionSet::ConnectionSet() = default; auto ConnectionSet::GetConnectionToHostUDP() -> ConnectionToHostUDP* { - ConnectionToHost* h = connection_to_host_.Get(); + ConnectionToHost* h = connection_to_host_.get(); return h ? h->GetAsUDP() : nullptr; } @@ -35,7 +36,7 @@ void ConnectionSet::RegisterClientController(ClientControllerInterface* c) { "RegisterClientController() called " "but already have a controller; bad."); for (auto&& i : connections_to_clients_) { - assert(i.second.Exists()); + assert(i.second.exists()); i.second->SetController(nullptr); } } @@ -44,7 +45,7 @@ void ConnectionSet::RegisterClientController(ClientControllerInterface* c) { client_controller_ = c; if (client_controller_) { for (auto&& i : connections_to_clients_) { - assert(i.second.Exists()); + assert(i.second.exists()); if (i.second->can_communicate()) { i.second->SetController(client_controller_); } @@ -59,10 +60,10 @@ void ConnectionSet::Update() { i.second->Update(); // Make sure the connection didn't kill itself in the update. - assert(test_ref.Exists()); + assert(test_ref.exists()); } - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { connection_to_host_->Update(); } } @@ -71,7 +72,7 @@ auto ConnectionSet::GetConnectedClientCount() const -> int { assert(g_base->InLogicThread()); int count = 0; for (auto&& i : connections_to_clients_) { - if (i.second.Exists() && i.second->can_communicate()) { + if (i.second.exists() && i.second->can_communicate()) { count++; } } @@ -211,8 +212,8 @@ auto ConnectionSet::GetConnectionsToClients() std::vector connections; connections.reserve(connections_to_clients_.size()); for (auto& connections_to_client : connections_to_clients_) { - if (connections_to_client.second.Exists()) { - connections.push_back(connections_to_client.second.Get()); + if (connections_to_client.second.exists()) { + connections.push_back(connections_to_client.second.get()); } else { g_core->Log(LogName::kBaNetworking, LogLevel::kError, "HAVE NONEXISTENT CONNECTION_TO_CLIENT IN LIST; UNEXPECTED"); @@ -227,7 +228,7 @@ void ConnectionSet::Shutdown() { for (auto& connection : connections_to_clients_) { connection.second->RequestDisconnect(); } - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { connection_to_host_->RequestDisconnect(); } } @@ -235,7 +236,7 @@ void ConnectionSet::Shutdown() { void ConnectionSet::SendScreenMessageToClients(const std::string& s, float r, float g, float b) { for (auto&& i : connections_to_clients_) { - if (i.second.Exists() && i.second->can_communicate()) { + if (i.second.exists() && i.second->can_communicate()) { i.second->SendScreenMessage(s, r, g, b); } } @@ -245,7 +246,7 @@ void ConnectionSet::SendScreenMessageToSpecificClients( const std::string& s, float r, float g, float b, const std::vector& clients) { for (auto&& i : connections_to_clients_) { - if (i.second.Exists() && i.second->can_communicate()) { + if (i.second.exists() && i.second->can_communicate()) { // Only send if this client is in our list. for (auto c : clients) { if (c == i.second->id()) { @@ -273,7 +274,7 @@ void ConnectionSet::SendScreenMessageToAll(const std::string& s, float r, void ConnectionSet::PrepareForLaunchHostSession() { // If for some reason we're still attached to a host, kill the connection. - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { g_core->Log( LogName::kBaNetworking, LogLevel::kError, "Had host-connection during LaunchHostSession(); shouldn't happen."); @@ -315,7 +316,7 @@ void ConnectionSet::HandleClientDisconnected(int id) { auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool { assert(g_base->InLogicThread()); - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { // Kick-votes first appeared in 14248 if (connection_to_host_->build_number() < 14248) { return false; @@ -362,7 +363,7 @@ void ConnectionSet::PushClientDisconnectedCall(int id) { void ConnectionSet::PushDisconnectedFromHostCall() { g_base->logic->event_loop()->PushCall([this] { - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { bool was_connected = connection_to_host_->can_communicate(); connection_to_host_.Clear(); has_connection_to_host_ = false; @@ -400,7 +401,7 @@ void ConnectionSet::PushHostConnectedUDPCall(const SockAddr& addr, void ConnectionSet::PushDisconnectFromHostCall() { g_base->logic->event_loop()->PushCall([this] { - if (connection_to_host_.Exists()) { + if (connection_to_host_.exists()) { connection_to_host_->RequestDisconnect(); } }); @@ -428,7 +429,7 @@ void ConnectionSet::UnregisterClientController(ClientControllerInterface* c) { void ConnectionSet::ForceDisconnectClients() { for (auto&& i : connections_to_clients_) { - if (ConnectionToClient* client = i.second.Get()) { + if (ConnectionToClient* client = i.second.get()) { client->RequestDisconnect(); } } @@ -637,7 +638,7 @@ void ConnectionSet::HandleIncomingUDPPacket(const std::vector& data_in, g_base->network_writer->PushSendToCall( {BA_PACKET_CLIENT_DENY, request_id}, addr); - } else if (connection_to_host_.Exists()) { + } else if (connection_to_host_.exists()) { // If we're connected to someone else, we can't have clients. g_base->network_writer->PushSendToCall( {BA_PACKET_CLIENT_DENY_ALREADY_IN_PARTY, request_id}, addr); @@ -655,7 +656,7 @@ void ConnectionSet::HandleIncomingUDPPacket(const std::vector& data_in, } } } - if (!connection_to_client.Exists()) { + if (!connection_to_client.exists()) { // Create them a client object. // Try to find an unused client-id in the range 0-255. int client_id = 0; diff --git a/src/ballistica/scene_v1/connection/connection_set.h b/src/ballistica/scene_v1/connection/connection_set.h index 4decd65b..7d6c29c1 100644 --- a/src/ballistica/scene_v1/connection/connection_set.h +++ b/src/ballistica/scene_v1/connection/connection_set.h @@ -32,7 +32,7 @@ class ConnectionSet { // Returns our host-connection or nullptr if there is none. auto connection_to_host() -> ConnectionToHost* { - return connection_to_host_.Get(); + return connection_to_host_.get(); } auto GetConnectionToHostUDP() -> ConnectionToHostUDP*; diff --git a/src/ballistica/scene_v1/connection/connection_to_client.cc b/src/ballistica/scene_v1/connection/connection_to_client.cc index 7a54e998..b4b05acf 100644 --- a/src/ballistica/scene_v1/connection/connection_to_client.cc +++ b/src/ballistica/scene_v1/connection/connection_to_client.cc @@ -285,7 +285,7 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { for (auto&& i : appmode->connections()->connections_to_clients()) { // Also send a 'party-member-joined' notification to all clients // *except* the new one. - if (i.second.Exists() && i.second.Get() != this + if (i.second.exists() && i.second.get() != this && appmode->ShouldAnnouncePartyJoinsAndLeaves()) { i.second->SendReliableMessage(join_msg); } @@ -384,7 +384,7 @@ void ConnectionToClient::HandleMessagePacket( case BA_MESSAGE_KICK_VOTE: { if (buffer.size() == 2) { for (auto&& i : appmode->connections()->connections_to_clients()) { - ConnectionToClient* client = i.second.Get(); + ConnectionToClient* client = i.second.get(); if (client->id() == static_cast(buffer[1])) { appmode->StartKickVote(this, client); break; @@ -461,7 +461,7 @@ void ConnectionToClient::HandleMessagePacket( PythonRef results = g_core->python->objs() .Get(core::CorePython::ObjID::kJsonLoadsCall) .Call(args); - if (results.Exists()) { + if (results.exists()) { player_profiles_ = results; } } diff --git a/src/ballistica/scene_v1/connection/connection_to_client.h b/src/ballistica/scene_v1/connection/connection_to_client.h index 63050f20..7bc338e4 100644 --- a/src/ballistica/scene_v1/connection/connection_to_client.h +++ b/src/ballistica/scene_v1/connection/connection_to_client.h @@ -25,7 +25,7 @@ class ConnectionToClient : public Connection { // More efficient than dynamic_cast (hmm do we still want this?). virtual auto GetAsUDP() -> ConnectionToClientUDP*; void SetController(ClientControllerInterface* c); - auto GetPlayerProfiles() const -> PyObject* { return player_profiles_.Get(); } + auto GetPlayerProfiles() const -> PyObject* { return player_profiles_.get(); } auto build_number() const -> int { return build_number_; } void SendScreenMessage(const std::string& s, float r = 1.0f, float g = 1.0f, float b = 1.0f); diff --git a/src/ballistica/scene_v1/connection/connection_to_host.cc b/src/ballistica/scene_v1/connection/connection_to_host.cc index 50412045..877e4b7d 100644 --- a/src/ballistica/scene_v1/connection/connection_to_host.cc +++ b/src/ballistica/scene_v1/connection/connection_to_host.cc @@ -253,7 +253,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { g_core->Log(LogName::kBaNetworking, LogLevel::kError, "No profiles found; sending empty list to host"); empty_dict.Steal(PyDict_New()); - profiles = empty_dict.Get(); + profiles = empty_dict.get(); } if (profiles != nullptr) { // Dump them to a json string. @@ -264,7 +264,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { g_core->python->objs() .Get(core::CorePython::ObjID::kJsonDumpsCall) .Call(args, keywds); - if (!results.Exists()) { + if (!results.exists()) { g_core->Log(LogName::kBaNetworking, LogLevel::kError, "Error getting json dump of local profiles"); } else { @@ -556,7 +556,7 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { case BA_MESSAGE_SESSION_RESET: case BA_MESSAGE_SESSION_DYNAMICS_CORRECTION: { // These commands are consumed directly by the session. - if (client_session_.Exists()) { + if (client_session_.exists()) { client_session_->HandleSessionMessage(buffer); } break; diff --git a/src/ballistica/scene_v1/dynamics/dynamics.cc b/src/ballistica/scene_v1/dynamics/dynamics.cc index d8d1bbc8..b545aea6 100644 --- a/src/ballistica/scene_v1/dynamics/dynamics.cc +++ b/src/ballistica/scene_v1/dynamics/dynamics.cc @@ -259,7 +259,7 @@ auto Dynamics::GetCollision(Part* p1_in, Part* p2_in, MaterialContext** cc1, // If it didnt exist, go ahead and set up the collision. if (i.second) { i.first->second = Object::New(scene_); - new_collision = i.first->second.Get(); + new_collision = i.first->second.get(); } else { new_collision = nullptr; } @@ -333,8 +333,8 @@ void Dynamics::Impl_::HandleDisconnect( // Add the contexts' disconnect commands to be executed. for (auto m = l->second->src_context.disconnect_actions.begin(); m != l->second->src_context.disconnect_actions.end(); m++) { - Part* src_part = l->second->src_part.Get(); - Part* dst_part = l->second->dst_part.Get(); + Part* src_part = l->second->src_part.get(); + Part* dst_part = l->second->dst_part.get(); dynamics_->collision_events_.emplace_back( src_part ? src_part->node() : nullptr, dst_part ? dst_part->node() : nullptr, *m, l->second); @@ -342,8 +342,8 @@ void Dynamics::Impl_::HandleDisconnect( for (auto m = l->second->dst_context.disconnect_actions.begin(); m != l->second->dst_context.disconnect_actions.end(); m++) { - Part* src_part = l->second->src_part.Get(); - Part* dst_part = l->second->dst_part.Get(); + Part* src_part = l->second->src_part.get(); + Part* dst_part = l->second->dst_part.get(); dynamics_->collision_events_.emplace_back( dst_part ? dst_part->node() : nullptr, src_part ? src_part->node() : nullptr, *m, l->second); @@ -353,14 +353,14 @@ void Dynamics::Impl_::HandleDisconnect( // tell them they're no longer colliding with the other. bool physical = l->second->src_context.physical && l->second->dst_context.physical; - Part* p1 = l->second->dst_part.Get(); - Part* p2 = l->second->src_part.Get(); + Part* p1 = l->second->dst_part.get(); + Part* p2 = l->second->src_part.get(); if (p1) { - assert(p1 == l->second->dst_part.Get()); + assert(p1 == l->second->dst_part.get()); p1->SetCollidingWith(i->first, k->first, false, physical); // NOLINT } if (p2) { - assert(p2 == l->second->src_part.Get()); + assert(p2 == l->second->src_part.get()); } if (p2 && (p2 != p1)) { p2->SetCollidingWith(j->first, l->first, false, physical); // NOLINT @@ -502,10 +502,10 @@ void Dynamics::ProcessCollision_() { // Execute all events that we built up due to collisions. for (auto&& i : collision_events_) { - active_collision_ = i.collision.Get(); + active_collision_ = i.collision.get(); active_collide_src_node_ = i.node1; active_collide_dst_node_ = i.node2; - i.action->Execute(i.node1.Get(), i.node2.Get(), scene_); + i.action->Execute(i.node1.get(), i.node2.get(), scene_); } active_collision_ = nullptr; collision_events_.clear(); @@ -874,7 +874,7 @@ void Dynamics::CollideCallback_(dGeomID o1, dGeomID o2) { : 1.0f; if (volume > 1) volume = 1; - assert(i.sound.Exists()); + assert(i.sound.exists()); if (base::AudioSource* source = g_base->audio->SourceBeginNew()) { source->SetGain(volume * i.volume); @@ -918,7 +918,7 @@ void Dynamics::CollideCallback_(dGeomID o1, dGeomID o2) { } } else if (real_time - p1->last_skid_sound_time() >= 250 || real_time - p2->last_skid_sound_time() > 250) { - assert(i.sound.Exists()); + assert(i.sound.exists()); if (base::AudioSource* source = g_base->audio->SourceBeginNew()) { source->SetLooping(true); @@ -970,7 +970,7 @@ void Dynamics::CollideCallback_(dGeomID o1, dGeomID o2) { } } else if (real_time - p1->last_roll_sound_time() >= 250 || real_time - p2->last_roll_sound_time() > 250) { - assert(i.sound.Exists()); + assert(i.sound.exists()); if (base::AudioSource* source = g_base->audio->SourceBeginNew()) { source->SetLooping(true); @@ -1017,7 +1017,7 @@ void Dynamics::CollideCallback_(dGeomID o1, dGeomID o2) { if (play_collide_sounds) { for (auto&& i : cc1->connect_sounds) { - assert(i.sound.Exists()); + assert(i.sound.exists()); if (base::AudioSource* source = g_base->audio->SourceBeginNew()) { source->SetPosition(apx, apy, apz); source->SetGain(i.volume); @@ -1026,7 +1026,7 @@ void Dynamics::CollideCallback_(dGeomID o1, dGeomID o2) { } } for (auto&& i : cc2->connect_sounds) { - assert(i.sound.Exists()); + assert(i.sound.exists()); if (base::AudioSource* source = g_base->audio->SourceBeginNew()) { source->SetPosition(apx, apy, apz); source->SetGain(i.volume); diff --git a/src/ballistica/scene_v1/dynamics/dynamics.h b/src/ballistica/scene_v1/dynamics/dynamics.h index 86b6c2d5..3d65628f 100644 --- a/src/ballistica/scene_v1/dynamics/dynamics.h +++ b/src/ballistica/scene_v1/dynamics/dynamics.h @@ -34,7 +34,7 @@ class Dynamics : public Object { assert(active_collision_); return (collide_message_reverse_order_ ? active_collide_dst_node_ : active_collide_src_node_) - .Get(); + .get(); } // Used by collision callbacks - internal. @@ -42,7 +42,7 @@ class Dynamics : public Object { assert(active_collision_); return (collide_message_reverse_order_ ? active_collide_src_node_ : active_collide_dst_node_) - .Get(); + .get(); } auto GetCollideMessageReverseOrder() const -> bool { return collide_message_reverse_order_; diff --git a/src/ballistica/scene_v1/dynamics/material/impact_sound_material_action.cc b/src/ballistica/scene_v1/dynamics/material/impact_sound_material_action.cc index 667a88af..0c85bb43 100644 --- a/src/ballistica/scene_v1/dynamics/material/impact_sound_material_action.cc +++ b/src/ballistica/scene_v1/dynamics/material/impact_sound_material_action.cc @@ -24,7 +24,7 @@ void ImpactSoundMaterialAction::Flatten(char** buffer, for (int i = 0; i < sound_count; i++) { Utils::EmbedInt32NBO(buffer, static_cast_check_fit( - output_stream->GetSoundID(sounds[i].Get()))); + output_stream->GetSoundID(sounds[i].get()))); } Utils::EmbedFloat16NBO(buffer, target_impulse_); Utils::EmbedFloat16NBO(buffer, volume_); @@ -47,7 +47,7 @@ void ImpactSoundMaterialAction::Apply(MaterialContext* context, const Part* dst_part, const Object::Ref& p) { assert(context && src_part && dst_part); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); // Avoid this if we're cutting corners. @@ -62,7 +62,7 @@ void ImpactSoundMaterialAction::Apply(MaterialContext* context, > 100) { assert(!sounds.empty()); context->impact_sounds.emplace_back( - context, sounds[rand() % sounds.size()].Get(), // NOLINT + context, sounds[rand() % sounds.size()].get(), // NOLINT target_impulse_, volume_); context->complex_sound = true; } diff --git a/src/ballistica/scene_v1/dynamics/material/material.cc b/src/ballistica/scene_v1/dynamics/material/material.cc index 2f6cecad..e6a61c3d 100644 --- a/src/ballistica/scene_v1/dynamics/material/material.cc +++ b/src/ballistica/scene_v1/dynamics/material/material.cc @@ -30,7 +30,7 @@ void Material::MarkDead() { components_.clear(); // If we're in a scene with an output-stream, inform them of our demise. - Scene* scene = scene_.Get(); + Scene* scene = scene_.get(); if (scene) { if (SessionStream* os = scene->GetSceneStream()) { os->RemoveMaterial(this); @@ -65,15 +65,15 @@ void Material::Apply(MaterialContext* s, const Part* src_part, void Material::AddComponent(const Object::Ref& c) { // If there's an output stream, push this to that first if (SessionStream* output_stream = scene()->GetSceneStream()) { - output_stream->AddMaterialComponent(this, c.Get()); + output_stream->AddMaterialComponent(this, c.get()); } components_.push_back(c); } void Material::DumpComponents(SessionStream* out) { for (auto& i : components_) { - assert(i.Exists()); - out->AddMaterialComponent(this, i.Get()); + assert(i.exists()); + out->AddMaterialComponent(this, i.get()); } } diff --git a/src/ballistica/scene_v1/dynamics/material/material.h b/src/ballistica/scene_v1/dynamics/material/material.h index b0e4e09d..6ce2ec83 100644 --- a/src/ballistica/scene_v1/dynamics/material/material.h +++ b/src/ballistica/scene_v1/dynamics/material/material.h @@ -30,7 +30,7 @@ class Material : public Object { auto NewPyRef() -> PyObject* { return GetPyRef(true); } auto BorrowPyRef() -> PyObject* { return GetPyRef(false); } void MarkDead(); - auto scene() const -> Scene* { return scene_.Get(); } + auto scene() const -> Scene* { return scene_.get(); } void DumpComponents(SessionStream* out); auto stream_id() const -> int64_t { return stream_id_; } void set_stream_id(int64_t val) { diff --git a/src/ballistica/scene_v1/dynamics/material/material_component.cc b/src/ballistica/scene_v1/dynamics/material/material_component.cc index e651fce1..cb7b359d 100644 --- a/src/ballistica/scene_v1/dynamics/material/material_component.cc +++ b/src/ballistica/scene_v1/dynamics/material/material_component.cc @@ -33,7 +33,7 @@ auto MaterialComponent::eval_conditions( const Part* part, const Part* opposing_part, const MaterialContext& s) -> bool { // If there's no condition, succeed. - if (!condition.Exists()) { + if (!condition.exists()) { return true; } @@ -46,10 +46,10 @@ auto MaterialComponent::eval_conditions( return false; case MaterialCondition::kDstIsMaterial: return ( - (opposing_part->ContainsMaterial(condition->val1_material.Get()))); + (opposing_part->ContainsMaterial(condition->val1_material.get()))); case MaterialCondition::kDstNotMaterial: return ( - !(opposing_part->ContainsMaterial(condition->val1_material.Get()))); + !(opposing_part->ContainsMaterial(condition->val1_material.get()))); case MaterialCondition::kDstIsPart: return ((opposing_part->id() == condition->val1)); case MaterialCondition::kDstNotPart: @@ -84,8 +84,8 @@ auto MaterialComponent::eval_conditions( } else { // A trunk node; eval our left and right children and return // the boolean operation between them. - assert(condition->left_child.Exists()); - assert(condition->right_child.Exists()); + assert(condition->left_child.exists()); + assert(condition->right_child.exists()); bool left_result = eval_conditions(condition->left_child, c, part, opposing_part, s); @@ -128,7 +128,7 @@ auto MaterialComponent::GetFlattenedSize() -> size_t { size += 1; // Embed the size of the condition tree. - if (conditions.Exists()) { + if (conditions.exists()) { size += conditions->GetFlattenedSize(); } @@ -147,10 +147,10 @@ auto MaterialComponent::GetFlattenedSize() -> size_t { void MaterialComponent::Flatten(char** buffer, SessionStream* output_stream) { // Embed a byte telling whether we have conditions. - Utils::EmbedInt8(buffer, conditions.Exists()); + Utils::EmbedInt8(buffer, conditions.exists()); // If we have conditions, have the tree embed itself. - if (conditions.Exists()) { + if (conditions.exists()) { conditions->Flatten(buffer, output_stream); } diff --git a/src/ballistica/scene_v1/dynamics/material/material_condition_node.cc b/src/ballistica/scene_v1/dynamics/material/material_condition_node.cc index 5cb14b31..5e911afb 100644 --- a/src/ballistica/scene_v1/dynamics/material/material_condition_node.cc +++ b/src/ballistica/scene_v1/dynamics/material/material_condition_node.cc @@ -2,7 +2,6 @@ #include "ballistica/scene_v1/dynamics/material/material_condition_node.h" -#include "ballistica/scene_v1/dynamics/material/material.h" #include "ballistica/scene_v1/support/client_session.h" #include "ballistica/scene_v1/support/session_stream.h" #include "ballistica/shared/generic/utils.h" @@ -37,7 +36,7 @@ void MaterialConditionNode::Flatten(char** buffer, || cond == MaterialCondition::kDstNotMaterial) { Utils::EmbedInt32NBO( buffer, static_cast_check_fit( - output_stream->GetMaterialID(val1_material.Get()))); + output_stream->GetMaterialID(val1_material.get()))); } else { Utils::EmbedInt32NBO(buffer, val1); } diff --git a/src/ballistica/scene_v1/dynamics/material/material_condition_node.h b/src/ballistica/scene_v1/dynamics/material/material_condition_node.h index 056aa7dc..d383e570 100644 --- a/src/ballistica/scene_v1/dynamics/material/material_condition_node.h +++ b/src/ballistica/scene_v1/dynamics/material/material_condition_node.h @@ -3,8 +3,8 @@ #ifndef BALLISTICA_SCENE_V1_DYNAMICS_MATERIAL_MATERIAL_CONDITION_NODE_H_ #define BALLISTICA_SCENE_V1_DYNAMICS_MATERIAL_MATERIAL_CONDITION_NODE_H_ +#include "ballistica/scene_v1/dynamics/material/material.h" #include "ballistica/scene_v1/scene_v1.h" -#include "ballistica/shared/ballistica.h" #include "ballistica/shared/foundation/object.h" namespace ballistica::scene_v1 { diff --git a/src/ballistica/scene_v1/dynamics/material/material_context.cc b/src/ballistica/scene_v1/dynamics/material/material_context.cc index 34f85401..cc9ea493 100644 --- a/src/ballistica/scene_v1/dynamics/material/material_context.cc +++ b/src/ballistica/scene_v1/dynamics/material/material_context.cc @@ -38,7 +38,7 @@ MaterialContext::SkidSoundEntry::SkidSoundEntry( *this = other; assert(context); #if BA_DEBUG_BUILD - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); #endif assert(context->dynamics->in_process()); context->dynamics->IncrementSkidSoundCount(); @@ -54,14 +54,14 @@ MaterialContext::SkidSoundEntry::SkidSoundEntry(MaterialContext* context_in, volume(volume_in), playing(false) { assert(context); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); context->dynamics->IncrementSkidSoundCount(); } MaterialContext::SkidSoundEntry::~SkidSoundEntry() { assert(context); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); context->dynamics->DecrementSkidSoundCount(); if (playing) { g_base->audio->PushSourceFadeOutCall(play_id, 200); @@ -78,7 +78,7 @@ MaterialContext::RollSoundEntry::RollSoundEntry(MaterialContext* context_in, volume(volume_in), playing(false) { assert(context); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); context->dynamics->IncrementRollSoundCount(); } @@ -87,14 +87,14 @@ MaterialContext::RollSoundEntry::RollSoundEntry( const MaterialContext::RollSoundEntry& other) { *this = other; assert(context); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); context->dynamics->IncrementRollSoundCount(); } MaterialContext::RollSoundEntry::~RollSoundEntry() { assert(context); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); context->dynamics->DecrementRollSoundCount(); if (playing) { g_base->audio->PushSourceFadeOutCall(play_id, 200); diff --git a/src/ballistica/scene_v1/dynamics/material/node_user_msg_mat_action.cc b/src/ballistica/scene_v1/dynamics/material/node_user_msg_mat_action.cc index 1dbc4eb4..1e19d06e 100644 --- a/src/ballistica/scene_v1/dynamics/material/node_user_msg_mat_action.cc +++ b/src/ballistica/scene_v1/dynamics/material/node_user_msg_mat_action.cc @@ -50,7 +50,7 @@ void NodeUserMessageMaterialAction::Execute(Node* node1, Node* node2, base::ScopedSetContext ssc(target_node->context_ref()); scene->dynamics()->set_collide_message_state(true, target_other); - target_node->DispatchUserMessage(user_message_obj.Get(), + target_node->DispatchUserMessage(user_message_obj.get(), "Material User-Message dispatch"); scene->dynamics()->set_collide_message_state(false); } diff --git a/src/ballistica/scene_v1/dynamics/material/roll_sound_material_action.cc b/src/ballistica/scene_v1/dynamics/material/roll_sound_material_action.cc index e6ea2b64..315d7cfd 100644 --- a/src/ballistica/scene_v1/dynamics/material/roll_sound_material_action.cc +++ b/src/ballistica/scene_v1/dynamics/material/roll_sound_material_action.cc @@ -16,7 +16,7 @@ auto RollSoundMaterialAction::GetFlattenedSize() -> size_t { return 4 + 2 + 2; } void RollSoundMaterialAction::Flatten(char** buffer, SessionStream* output_stream) { Utils::EmbedInt32NBO(buffer, static_cast_check_fit( - output_stream->GetSoundID(sound.Get()))); + output_stream->GetSoundID(sound.get()))); Utils::EmbedFloat16NBO(buffer, target_impulse); Utils::EmbedFloat16NBO(buffer, volume); } @@ -31,7 +31,7 @@ void RollSoundMaterialAction::Apply(MaterialContext* context, const Part* src_part, const Part* dst_part, const Object::Ref& p) { assert(context && src_part && dst_part); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); // Avoid this if we're cutting corners. @@ -42,7 +42,7 @@ void RollSoundMaterialAction::Apply(MaterialContext* context, // Let's limit the amount of skid-sounds we spawn, otherwise we'll // start using up all our sound resources on skids when things get messy if (context->dynamics->roll_sound_count() < 2) { - context->roll_sounds.emplace_back(context, sound.Get(), target_impulse, + context->roll_sounds.emplace_back(context, sound.get(), target_impulse, volume); context->complex_sound = true; } diff --git a/src/ballistica/scene_v1/dynamics/material/skid_sound_material_action.cc b/src/ballistica/scene_v1/dynamics/material/skid_sound_material_action.cc index 3aa71a6c..33f20847 100644 --- a/src/ballistica/scene_v1/dynamics/material/skid_sound_material_action.cc +++ b/src/ballistica/scene_v1/dynamics/material/skid_sound_material_action.cc @@ -16,7 +16,7 @@ auto SkidSoundMaterialAction::GetFlattenedSize() -> size_t { return 4 + 2 + 2; } void SkidSoundMaterialAction::Flatten(char** buffer, SessionStream* output_stream) { Utils::EmbedInt32NBO(buffer, static_cast_check_fit( - output_stream->GetSoundID(sound.Get()))); + output_stream->GetSoundID(sound.get()))); Utils::EmbedFloat16NBO(buffer, target_impulse); Utils::EmbedFloat16NBO(buffer, volume); } @@ -31,7 +31,7 @@ void SkidSoundMaterialAction::Apply(MaterialContext* context, const Part* src_part, const Part* dst_part, const Object::Ref& p) { assert(context && src_part && dst_part); - assert(context->dynamics.Exists()); + assert(context->dynamics.exists()); assert(context->dynamics->in_process()); // Avoid this if we're cutting corners. @@ -42,7 +42,7 @@ void SkidSoundMaterialAction::Apply(MaterialContext* context, // Let's limit the amount of skid-sounds we spawn, otherwise we'll start // using up all our sound resources on skids when things get messy. if (context->dynamics->skid_sound_count() < 2) { - context->skid_sounds.emplace_back(context, sound.Get(), target_impulse, + context->skid_sounds.emplace_back(context, sound.get(), target_impulse, volume); context->complex_sound = true; } diff --git a/src/ballistica/scene_v1/dynamics/material/sound_material_action.cc b/src/ballistica/scene_v1/dynamics/material/sound_material_action.cc index ac0e5cce..873e6287 100644 --- a/src/ballistica/scene_v1/dynamics/material/sound_material_action.cc +++ b/src/ballistica/scene_v1/dynamics/material/sound_material_action.cc @@ -13,14 +13,14 @@ void SoundMaterialAction::Apply(MaterialContext* context, const Part* src_part, const Part* dst_part, const Object::Ref& p) { assert(context && src_part && dst_part); - context->connect_sounds.emplace_back(sound_.Get(), volume_); + context->connect_sounds.emplace_back(sound_.get(), volume_); } auto SoundMaterialAction::GetFlattenedSize() -> size_t { return 4 + 2; } void SoundMaterialAction::Flatten(char** buffer, SessionStream* output_stream) { Utils::EmbedInt32NBO(buffer, static_cast_check_fit( - output_stream->GetSoundID(sound_.Get()))); + output_stream->GetSoundID(sound_.get()))); Utils::EmbedFloat16NBO(buffer, volume_); } diff --git a/src/ballistica/scene_v1/dynamics/part.cc b/src/ballistica/scene_v1/dynamics/part.cc index 2314a04d..d71efe32 100644 --- a/src/ballistica/scene_v1/dynamics/part.cc +++ b/src/ballistica/scene_v1/dynamics/part.cc @@ -15,7 +15,7 @@ Part::Part(Node* node, bool default_collide) : our_id_(node->AddPart(this)), default_collides_(default_collide), node_(node) { - assert(node_.Exists()); + assert(node_.exists()); birth_time_ = node_->scene()->time(); dynamics_ = node_->scene()->dynamics(); } @@ -60,7 +60,7 @@ void Part::SetMaterials(const std::vector& vals) { void Part::ApplyMaterials(MaterialContext* s, const Part* src_part, const Part* dst_part) { for (auto&& i : materials_) { - assert(i.Exists()); + assert(i.exists()); i->Apply(s, src_part, dst_part); } } @@ -68,8 +68,8 @@ void Part::ApplyMaterials(MaterialContext* s, const Part* src_part, auto Part::ContainsMaterial(const Material* m) const -> bool { assert(m); for (auto&& i : materials_) { - assert(i.Exists()); - if (m == i.Get()) { + assert(i.exists()); + if (m == i.get()) { return true; } } @@ -127,7 +127,7 @@ void Part::SetCollidingWith(int64_t node_id, int part, bool colliding, } auto Part::GetAge() const -> millisecs_t { - assert(node_.Exists()); + assert(node_.exists()); assert(node_->scene()->time() >= birth_time_); return node_->scene()->time() - birth_time_; } diff --git a/src/ballistica/scene_v1/dynamics/part.h b/src/ballistica/scene_v1/dynamics/part.h index 67a82980..881b704b 100644 --- a/src/ballistica/scene_v1/dynamics/part.h +++ b/src/ballistica/scene_v1/dynamics/part.h @@ -42,8 +42,8 @@ class Part : public Object { } } auto node() const -> Node* { - assert(node_.Exists()); - return node_.Get(); + assert(node_.exists()); + return node_.get(); } // Apply a set of materials to the part. diff --git a/src/ballistica/scene_v1/dynamics/rigid_body.cc b/src/ballistica/scene_v1/dynamics/rigid_body.cc index 17ac13c1..24fb0038 100644 --- a/src/ballistica/scene_v1/dynamics/rigid_body.cc +++ b/src/ballistica/scene_v1/dynamics/rigid_body.cc @@ -52,7 +52,7 @@ RigidBody::RigidBody(int id_in, Part* part_in, Type type_in, Shape shape_in, } #endif // BA_DEBUG_BUILD - assert(part_.Exists()); + assert(part_.exists()); birth_time_ = part_->node()->scene()->stepnum(); dynamics_ = part_->node()->scene()->dynamics(); @@ -114,7 +114,7 @@ RigidBody::RigidBody(int id_in, Part* part_in, Type type_in, Shape shape_in, // NOTE - we don't add trimeshes do the collision space - we handle them // specially.. dimensions_[0] = dimensions_[1] = dimensions_[2] = 0.6f; - assert(collision_mesh_.Exists()); + assert(collision_mesh_.exists()); collision_mesh_->collision_mesh_data()->Load(); dGeomID g = dCreateTriMesh( nullptr, collision_mesh_->collision_mesh_data()->GetMeshData(), @@ -234,7 +234,7 @@ RigidBody::~RigidBody() { KillConstraints(); // remove ourself from our parent part if we have one - if (part_.Exists()) { + if (part_.exists()) { part_->RemoveBody(this); } if (type_ == Type::kBody) { diff --git a/src/ballistica/scene_v1/dynamics/rigid_body.h b/src/ballistica/scene_v1/dynamics/rigid_body.h index a7c90622..f7b35680 100644 --- a/src/ballistica/scene_v1/dynamics/rigid_body.h +++ b/src/ballistica/scene_v1/dynamics/rigid_body.h @@ -10,8 +10,8 @@ #include "ballistica/scene_v1/scene_v1.h" #include "ballistica/shared/foundation/object.h" #include "ballistica/shared/math/matrix44f.h" -#include "ode/ode.h" #include "ode/ode_joint.h" +#include "ode/ode_objects.h" namespace ballistica::scene_v1 { @@ -93,8 +93,8 @@ class RigidBody : public Object { // Draw a representation of the rigid body for debugging. void Draw(base::RenderPass* pass, bool shaded = true); auto part() const -> Part* { - assert(part_.Exists()); - return part_.Get(); + assert(part_.exists()); + return part_.get(); } void Wake() { if (body_) { diff --git a/src/ballistica/scene_v1/node/bomb_node.cc b/src/ballistica/scene_v1/node/bomb_node.cc index 2aef4e06..adf12525 100644 --- a/src/ballistica/scene_v1/node/bomb_node.cc +++ b/src/ballistica/scene_v1/node/bomb_node.cc @@ -3,8 +3,9 @@ #include "ballistica/scene_v1/node/bomb_node.h" #include "ballistica/base/graphics/graphics.h" -#include "ballistica/scene_v1/assets/scene_collision_mesh.h" #include "ballistica/scene_v1/support/scene.h" +#include "ode/ode_collision.h" +#include "ode/ode_common.h" namespace ballistica::scene_v1 { @@ -48,7 +49,7 @@ void BombNode::OnCreate() { void BombNode::Step() { PropNode::Step(); - if (body_.Exists()) { + if (body_.exists()) { // Update our fuse and light position. dVector3 fuse_tip_pos; dGeomGetRelPointPos(body_->geom(), 0, (fuse_length_ + kFuseOffset), 0, diff --git a/src/ballistica/scene_v1/node/flag_node.cc b/src/ballistica/scene_v1/node/flag_node.cc index 81ce8300..542813bb 100644 --- a/src/ballistica/scene_v1/node/flag_node.cc +++ b/src/ballistica/scene_v1/node/flag_node.cc @@ -17,6 +17,8 @@ #include "ballistica/scene_v1/support/scene.h" #include "ballistica/shared/generic/utils.h" #include "ballistica/shared/math/random.h" +#include "ode/ode_collision.h" +#include "ode/ode_rotation.h" namespace ballistica::scene_v1 { @@ -319,7 +321,7 @@ void FlagNode::Draw(base::FrameDef* frame_def) { dBodyID b = body_->body(); assert(b); dVector3 p; - if (FullShadowSet* full_shadows = full_shadow_set_.Get()) { + if (FullShadowSet* full_shadows = full_shadow_set_.get()) { full_shadows->shadow_flag_.SetPosition( flag_points_[kFlagSizeX * (kFlagSizeY / 2) + (kFlagSizeX / 2)]); dBodyGetRelPointPos(b, 0, 0, kFlagHeight * -0.4f, p); @@ -360,7 +362,7 @@ void FlagNode::Draw(base::FrameDef* frame_def) { s_density * 0.3f); } - } else if (SimpleShadowSet* simple_shadows = simple_shadow_set_.Get()) { + } else if (SimpleShadowSet* simple_shadows = simple_shadow_set_.get()) { dBodyGetRelPointPos(b, 0, 0, kFlagHeight * -0.3f, p); simple_shadows->shadow_.SetPosition(Vector3f(p)); simple_shadows->shadow_.GetValues(&s_scale, &s_density); @@ -390,14 +392,14 @@ void FlagNode::Draw(base::FrameDef* frame_def) { void FlagNode::UpdateAreaOfInterest() { base::AreaOfInterest* aoi = area_of_interest_; if (!aoi) return; - assert(body_.Exists()); + assert(body_.exists()); aoi->set_position(Vector3f(dGeomGetPosition(body_->geom()))); aoi->SetRadius(5.0f); } void FlagNode::Step() { // On happy thoughts, keep us on the 2d plane. - if (g_base->graphics->camera()->happy_thoughts_mode() && body_.Exists()) { + if (g_base->graphics->camera()->happy_thoughts_mode() && body_.exists()) { dBodyID b; const dReal *p, *v; b = body_->body(); @@ -494,7 +496,7 @@ void FlagNode::Step() { UpdateFlagMesh(); } -auto FlagNode::GetRigidBody(int id) -> RigidBody* { return body_.Get(); } +auto FlagNode::GetRigidBody(int id) -> RigidBody* { return body_.get(); } static auto FlagPointIndex(int x, int y) -> int { return kFlagSizeX * (y) + (x); diff --git a/src/ballistica/scene_v1/node/flag_node.h b/src/ballistica/scene_v1/node/flag_node.h index b99c2fd9..14027a0e 100644 --- a/src/ballistica/scene_v1/node/flag_node.h +++ b/src/ballistica/scene_v1/node/flag_node.h @@ -26,7 +26,7 @@ class FlagNode : public Node { void SetIsAreaOfInterest(bool val); auto getPosition() const -> std::vector; void SetPosition(const std::vector& vals); - auto color_texture() const -> SceneTexture* { return color_texture_.Get(); } + auto color_texture() const -> SceneTexture* { return color_texture_.get(); } void set_color_texture(SceneTexture* val) { color_texture_ = val; } auto light_weight() const -> bool { return light_weight_; } void SetLightWeight(bool val); diff --git a/src/ballistica/scene_v1/node/image_node.cc b/src/ballistica/scene_v1/node/image_node.cc index b64a53de..8441d6d8 100644 --- a/src/ballistica/scene_v1/node/image_node.cc +++ b/src/ballistica/scene_v1/node/image_node.cc @@ -333,14 +333,14 @@ void ImageNode::Draw(base::FrameDef* frame_def) { alpha = 0; } base::MeshAsset* mesh_opaque_used = nullptr; - if (mesh_opaque_.Exists()) mesh_opaque_used = mesh_opaque_->mesh_data(); + if (mesh_opaque_.exists()) mesh_opaque_used = mesh_opaque_->mesh_data(); base::MeshAsset* mesh_transparent_used = nullptr; - if (mesh_transparent_.Exists()) { + if (mesh_transparent_.exists()) { mesh_transparent_used = mesh_transparent_->mesh_data(); } // If no meshes were provided, use default image meshes. - if (!mesh_opaque_.Exists() && !mesh_transparent_.Exists()) { + if (!mesh_opaque_.exists() && !mesh_transparent_.exists()) { if (vr && fill_screen_) { #if BA_VR_BUILD mesh_opaque_used = @@ -371,14 +371,14 @@ void ImageNode::Draw(base::FrameDef* frame_def) { // transparent to avoid that. c.SetTransparent(draw_transparent); c.SetPremultiplied(premultiplied_); - c.SetTexture(texture_.Exists() ? texture_->texture_data() : nullptr); + c.SetTexture(texture_.exists() ? texture_->texture_data() : nullptr); c.SetColor(red_, green_, blue_, alpha); - if (tint_texture_.Exists()) { + if (tint_texture_.exists()) { c.SetColorizeTexture(tint_texture_->texture_data()); c.SetColorizeColor(tint_red_, tint_green_, tint_blue_); c.SetColorizeColor2(tint2_red_, tint2_green_, tint2_blue_); } - c.SetMaskTexture(mask_texture_.Exists() ? mask_texture_->texture_data() + c.SetMaskTexture(mask_texture_.exists() ? mask_texture_->texture_data() : nullptr); { auto xf = c.ScopedTransform(); @@ -397,14 +397,14 @@ void ImageNode::Draw(base::FrameDef* frame_def) { base::SimpleComponent c(&pass); c.SetTransparent(true); c.SetPremultiplied(premultiplied_); - c.SetTexture(texture_.Exists() ? texture_->texture_data() : nullptr); + c.SetTexture(texture_.exists() ? texture_->texture_data() : nullptr); c.SetColor(red_, green_, blue_, alpha); - if (tint_texture_.Exists()) { + if (tint_texture_.exists()) { c.SetColorizeTexture(tint_texture_->texture_data()); c.SetColorizeColor(tint_red_, tint_green_, tint_blue_); c.SetColorizeColor2(tint2_red_, tint2_green_, tint2_blue_); } - c.SetMaskTexture(mask_texture_.Exists() ? mask_texture_->texture_data() + c.SetMaskTexture(mask_texture_.exists() ? mask_texture_->texture_data() : nullptr); { auto xf = c.ScopedTransform(); diff --git a/src/ballistica/scene_v1/node/image_node.h b/src/ballistica/scene_v1/node/image_node.h index ee22ba90..fe138492 100644 --- a/src/ballistica/scene_v1/node/image_node.h +++ b/src/ballistica/scene_v1/node/image_node.h @@ -48,16 +48,16 @@ class ImageNode : public Node { void set_premultiplied(bool val) { premultiplied_ = val; } auto GetAttach() const -> std::string; void SetAttach(const std::string& val); - auto texture() const -> SceneTexture* { return texture_.Get(); } + auto texture() const -> SceneTexture* { return texture_.get(); } void set_texture(SceneTexture* t) { texture_ = t; } - auto tint_texture() const -> SceneTexture* { return tint_texture_.Get(); } + auto tint_texture() const -> SceneTexture* { return tint_texture_.get(); } void set_tint_texture(SceneTexture* t) { tint_texture_ = t; } - auto mask_texture() const -> SceneTexture* { return mask_texture_.Get(); } + auto mask_texture() const -> SceneTexture* { return mask_texture_.get(); } void set_mask_texture(SceneTexture* t) { mask_texture_ = t; } - auto mesh_opaque() const -> SceneMesh* { return mesh_opaque_.Get(); } + auto mesh_opaque() const -> SceneMesh* { return mesh_opaque_.get(); } void set_mesh_opaque(SceneMesh* m) { mesh_opaque_ = m; } auto mesh_transparent() const -> SceneMesh* { - return mesh_transparent_.Get(); + return mesh_transparent_.get(); } void set_mesh_transparent(SceneMesh* m) { mesh_transparent_ = m; diff --git a/src/ballistica/scene_v1/node/light_node.cc b/src/ballistica/scene_v1/node/light_node.cc index e600f687..0a2177cb 100644 --- a/src/ballistica/scene_v1/node/light_node.cc +++ b/src/ballistica/scene_v1/node/light_node.cc @@ -52,13 +52,13 @@ void LightNode::Step() { #if !BA_HEADLESS_BUILD // create or destroy our light-volume as needed // (minimize redundant create/destroy/sets this way) - if (lights_volumes_ && !volume_light_.Exists()) { + if (lights_volumes_ && !volume_light_.exists()) { volume_light_ = Object::New(); float i = GetVolumeLightIntensity(); volume_light_->SetColor(color_[0] * i, color_[1] * i, color_[2] * i); volume_light_->SetPosition( Vector3f(position_[0], position_[1], position_[2])); - } else if (!lights_volumes_ && volume_light_.Exists()) { + } else if (!lights_volumes_ && volume_light_.exists()) { volume_light_.Clear(); } #endif // BA_HEADLESS_BUILD @@ -67,7 +67,7 @@ void LightNode::Step() { void LightNode::SetRadius(float val) { radius_ = std::max(0.0f, val); #if !BA_HEADLESS_BUILD - if (volume_light_.Exists()) { + if (volume_light_.exists()) { volume_light_->SetRadius(radius_); } #endif // BA_HEADLESS_BUILD @@ -79,7 +79,7 @@ void LightNode::SetColor(const std::vector& vals) { } color_ = vals; #if !BA_HEADLESS_BUILD - if (volume_light_.Exists()) { + if (volume_light_.exists()) { float i = GetVolumeLightIntensity(); volume_light_->SetColor(color_[0] * i, color_[1] * i, color_[2] * i); } @@ -94,7 +94,7 @@ void LightNode::SetPosition(const std::vector& vals) { #if !BA_HEADLESS_BUILD shadow_.SetPosition(Vector3f(position_[0], position_[1], position_[2])); - if (volume_light_.Exists()) { + if (volume_light_.exists()) { volume_light_->SetPosition( Vector3f(position_[0], position_[1], position_[2])); } @@ -104,7 +104,7 @@ void LightNode::SetPosition(const std::vector& vals) { void LightNode::SetIntensity(float val) { intensity_ = std::max(0.0f, val); #if !BA_HEADLESS_BUILD - if (volume_light_.Exists()) { + if (volume_light_.exists()) { float i = GetVolumeLightIntensity(); volume_light_->SetColor(color_[0] * i, color_[1] * i, color_[2] * i); } @@ -115,7 +115,7 @@ void LightNode::SetVolumeIntensityScale(float val) { volume_intensity_scale_ = std::max(0.0f, val); #if !BA_HEADLESS_BUILD - if (volume_light_.Exists()) { + if (volume_light_.exists()) { float i = GetVolumeLightIntensity(); volume_light_->SetColor(color_[0] * i, color_[1] * i, color_[2] * i); } diff --git a/src/ballistica/scene_v1/node/node.cc b/src/ballistica/scene_v1/node/node.cc index 14172753..00517c6d 100644 --- a/src/ballistica/scene_v1/node/node.cc +++ b/src/ballistica/scene_v1/node/node.cc @@ -43,8 +43,8 @@ void Node::AddToScene(Scene* scene) { Node::~Node() { // Kill any incoming/outgoing attr connections. for (auto& i : attribute_connections_incoming_) { - NodeAttributeConnection* a = i.second.Get(); - assert(a && a->src_node.Exists()); + NodeAttributeConnection* a = i.second.get(); + assert(a && a->src_node.exists()); // Remove from src node's outgoing list. a->src_node->attribute_connections_.erase(a->src_iterator); @@ -53,8 +53,8 @@ Node::~Node() { // Kill all refs on our side; this should kill the connections. attribute_connections_incoming_.clear(); for (auto& attribute_connection : attribute_connections_) { - NodeAttributeConnection* a = attribute_connection.Get(); - assert(a && a->dst_node.Exists()); + NodeAttributeConnection* a = attribute_connection.get(); + assert(a && a->dst_node.exists()); // Remove from dst node's incoming list. auto j = @@ -187,8 +187,8 @@ void Node::UpdateConnections() { for (auto& attribute_connection : attribute_connections_) { // Connections should go away when either node dies; make sure that's // working. - assert(attribute_connection->src_node.Exists() - && attribute_connection->dst_node.Exists()); + assert(attribute_connection->src_node.exists() + && attribute_connection->dst_node.exists()); attribute_connection->Update(); } } @@ -209,7 +209,7 @@ void Node::AddDependentNode(Node* node) { if (!dependent_nodes_.empty()) { std::vector > live_nodes; for (auto& dependent_node : dependent_nodes_) { - if (dependent_node.Exists()) live_nodes.push_back(dependent_node); + if (dependent_node.exists()) live_nodes.push_back(dependent_node); } dependent_nodes_.swap(live_nodes); } @@ -236,7 +236,7 @@ auto Node::GetPyRef(bool new_ref) -> PyObject* { } auto Node::GetDelegate() -> PyObject* { - PyObject* ref = delegate_.Get(); + PyObject* ref = delegate_.get(); if (!ref) { return nullptr; } @@ -262,8 +262,8 @@ void Node::DispatchOutOfBoundsMessage() { .Get(SceneV1Python::ObjID::kOutOfBoundsMessageClass) .Call(); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node OutOfBoundsMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node OutOfBoundsMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating OutOfBoundsMessage"); @@ -280,8 +280,8 @@ void Node::DispatchPickUpMessage(Node* node) { .Get(SceneV1Python::ObjID::kPickUpMessageClass) .Call(args); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node PickUpMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node PickUpMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating PickUpMessage"); } @@ -295,8 +295,8 @@ void Node::DispatchDropMessage() { .Get(SceneV1Python::ObjID::kDropMessageClass) .Call(); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node DropMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node DropMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating DropMessage"); } @@ -313,8 +313,8 @@ void Node::DispatchPickedUpMessage(Node* by_node) { .Get(SceneV1Python::ObjID::kPickedUpMessageClass) .Call(args); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node PickedUpMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node PickedUpMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating PickedUpMessage"); @@ -332,8 +332,8 @@ void Node::DispatchDroppedMessage(Node* by_node) { .Get(SceneV1Python::ObjID::kDroppedMessageClass) .Call(args); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node DroppedMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node DroppedMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating DroppedMessage"); @@ -348,8 +348,8 @@ void Node::DispatchShouldShatterMessage() { .Get(SceneV1Python::ObjID::kShouldShatterMessageClass) .Call(); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node ShouldShatterMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node ShouldShatterMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating ShouldShatterMessage"); @@ -365,8 +365,8 @@ void Node::DispatchImpactDamageMessage(float intensity) { .Get(SceneV1Python::ObjID::kImpactDamageMessageClass) .Call(args); } - if (instance.Exists()) { - DispatchUserMessage(instance.Get(), "Node ImpactDamageMessage dispatch"); + if (instance.exists()) { + DispatchUserMessage(instance.get(), "Node ImpactDamageMessage dispatch"); } else { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating ImpactDamageMessage"); diff --git a/src/ballistica/scene_v1/node/node.h b/src/ballistica/scene_v1/node/node.h index bd68613c..7911f531 100644 --- a/src/ballistica/scene_v1/node/node.h +++ b/src/ballistica/scene_v1/node/node.h @@ -144,7 +144,7 @@ class Node : public Object { return node_type_; } auto HasAttribute(const std::string& name) const -> bool; - auto has_py_ref() -> bool { return (py_ref_ != nullptr); } + auto HasPyRef() -> bool { return (py_ref_ != nullptr); } void UpdateConnections(); auto iterator() -> NodeList::iterator { return iterator_; } diff --git a/src/ballistica/scene_v1/node/node_attribute.cc b/src/ballistica/scene_v1/node/node_attribute.cc index ab078822..c72d0698 100644 --- a/src/ballistica/scene_v1/node/node_attribute.cc +++ b/src/ballistica/scene_v1/node/node_attribute.cc @@ -86,14 +86,14 @@ void NodeAttributeUnbound::DisconnectIncoming(Node* node) { assert(node); auto i = node->attribute_connections_incoming().find(index()); if (i != node->attribute_connections_incoming().end()) { - NodeAttributeConnection* a = i->second.Get(); + NodeAttributeConnection* a = i->second.get(); #if BA_DEBUG_BUILD Object::WeakRef test_ref(a); #endif assert(a != nullptr); - assert(a->src_node.Exists()); + assert(a->src_node.exists()); // Remove from src node's outgoing list. a->src_node->attribute_connections_.erase(a->src_iterator); @@ -102,7 +102,7 @@ void NodeAttributeUnbound::DisconnectIncoming(Node* node) { node->attribute_connections_incoming_.erase(i); #if BA_DEBUG_BUILD - if (test_ref.Exists()) { + if (test_ref.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Attr connection still exists after ref releases!"); } diff --git a/src/ballistica/scene_v1/node/node_attribute_connection.cc b/src/ballistica/scene_v1/node/node_attribute_connection.cc index a4495ce4..840aa0e5 100644 --- a/src/ballistica/scene_v1/node/node_attribute_connection.cc +++ b/src/ballistica/scene_v1/node/node_attribute_connection.cc @@ -11,8 +11,8 @@ namespace ballistica::scene_v1 { void NodeAttributeConnection::Update() { - assert(src_node.Exists() && dst_node.Exists()); - auto* src_node_p{src_node.Get()}; + assert(src_node.exists() && dst_node.exists()); + auto* src_node_p{src_node.get()}; // We no longer update after errors now. // (the constant stream of exceptions slows things down too much) @@ -30,58 +30,58 @@ void NodeAttributeConnection::Update() { assert(dst_attr); switch (dst_attr->type()) { case NodeAttributeType::kFloat: - dst_attr->Set(dst_node.Get(), src_attr->GetAsFloat(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsFloat(src_node_p)); break; case NodeAttributeType::kInt: - dst_attr->Set(dst_node.Get(), src_attr->GetAsInt(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsInt(src_node_p)); break; case NodeAttributeType::kBool: - dst_attr->Set(dst_node.Get(), src_attr->GetAsBool(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsBool(src_node_p)); break; case NodeAttributeType::kString: - dst_attr->Set(dst_node.Get(), src_attr->GetAsString(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsString(src_node_p)); break; case NodeAttributeType::kIntArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsInts(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsInts(src_node_p)); break; case NodeAttributeType::kFloatArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsFloats(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsFloats(src_node_p)); break; case NodeAttributeType::kNode: - dst_attr->Set(dst_node.Get(), src_attr->GetAsNode(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsNode(src_node_p)); break; case NodeAttributeType::kNodeArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsNodes(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsNodes(src_node_p)); break; case NodeAttributeType::kPlayer: - dst_attr->Set(dst_node.Get(), src_attr->GetAsPlayer(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsPlayer(src_node_p)); break; case NodeAttributeType::kMaterialArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsMaterials(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsMaterials(src_node_p)); break; case NodeAttributeType::kTexture: - dst_attr->Set(dst_node.Get(), src_attr->GetAsTexture(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsTexture(src_node_p)); break; case NodeAttributeType::kTextureArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsTextures(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsTextures(src_node_p)); break; case NodeAttributeType::kSound: - dst_attr->Set(dst_node.Get(), src_attr->GetAsSound(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsSound(src_node_p)); break; case NodeAttributeType::kSoundArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsSounds(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsSounds(src_node_p)); break; case NodeAttributeType::kMesh: - dst_attr->Set(dst_node.Get(), src_attr->GetAsMesh(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsMesh(src_node_p)); break; case NodeAttributeType::kMeshArray: - dst_attr->Set(dst_node.Get(), src_attr->GetAsMeshes(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsMeshes(src_node_p)); break; case NodeAttributeType::kCollisionMesh: - dst_attr->Set(dst_node.Get(), src_attr->GetAsCollisionMesh(src_node_p)); + dst_attr->Set(dst_node.get(), src_attr->GetAsCollisionMesh(src_node_p)); break; case NodeAttributeType::kCollisionMeshArray: - dst_attr->Set(dst_node.Get(), + dst_attr->Set(dst_node.get(), src_attr->GetAsCollisionMeshes(src_node_p)); break; default: diff --git a/src/ballistica/scene_v1/node/node_type.h b/src/ballistica/scene_v1/node/node_type.h index aa390e38..aba94ebd 100644 --- a/src/ballistica/scene_v1/node/node_type.h +++ b/src/ballistica/scene_v1/node/node_type.h @@ -74,7 +74,6 @@ class NodeType { std::unordered_map attributes_by_name_; std::vector attributes_by_index_; friend class NodeAttributeUnbound; - friend class Node; }; } // namespace ballistica::scene_v1 diff --git a/src/ballistica/scene_v1/node/prop_node.cc b/src/ballistica/scene_v1/node/prop_node.cc index 5fc40e6b..d59047b7 100644 --- a/src/ballistica/scene_v1/node/prop_node.cc +++ b/src/ballistica/scene_v1/node/prop_node.cc @@ -105,12 +105,12 @@ void PropNode::Draw(base::FrameDef* frame_def) { #if !BA_HEADLESS_BUILD // We need a texture, mesh, and body to be present to draw. - if ((!mesh_.Exists()) || (!color_texture_.Exists()) || (!body_.Exists())) { + if ((!mesh_.exists()) || (!color_texture_.exists()) || (!body_.exists())) { return; } base::ObjectComponent c(frame_def->beauty_pass()); - c.SetTexture(color_texture_.Exists() ? color_texture_->texture_data() + c.SetTexture(color_texture_.exists() ? color_texture_->texture_data() : nullptr); c.SetLightShadow(base::LightShadowType::kObject); if (reflection_ != base::ReflectionType::kNone) { @@ -131,7 +131,7 @@ void PropNode::Draw(base::FrameDef* frame_def) { c.Submit(); { // Shadow. - assert(body_.Exists()); + assert(body_.exists()); const dReal* pos_raw = dGeomGetPosition(body_->geom()); float pos[3]; pos[0] = pos_raw[0] + body_->blend_offset().x; @@ -160,7 +160,7 @@ void PropNode::Draw(base::FrameDef* frame_def) { if (quality > base::GraphicsQuality::kLow) { // More sharp accurate shadow. - if (light_mesh_.Exists()) { + if (light_mesh_.exists()) { base::SimpleComponent c2(frame_def->light_shadow_pass()); c2.SetTransparent(true); float dd = body_type_ == BodyType::LANDMINE ? 0.5f : 1.0f; @@ -182,12 +182,12 @@ void PropNode::Draw(base::FrameDef* frame_def) { // In fancy-pants mode we can do a softened version of ourself // for fake caustic effects. - if (light_mesh_.Exists()) { - assert(color_texture_.Exists()); + if (light_mesh_.exists()) { + assert(color_texture_.exists()); base::SimpleComponent c2(frame_def->light_shadow_pass()); c2.SetTransparent(true); c2.SetPremultiplied(true); - c2.SetTexture(color_texture_.Exists() ? color_texture_->texture_data() + c2.SetTexture(color_texture_.exists() ? color_texture_->texture_data() : nullptr); if (flashing_ && frame_def->frame_number_filtered() % 10 < 5) { c2.SetColor(0.026f * s_density, 0.026f * s_density, @@ -240,7 +240,7 @@ auto PropNode::GetBody() const -> std::string { void PropNode::SetBodyScale(float val) { // this can be set exactly once - if (body_.Exists()) { + if (body_.exists()) { throw Exception("body_scale can't be set once body exists"); } body_scale_ = std::max(0.01f, val); @@ -272,7 +272,7 @@ void PropNode::SetBody(const std::string& val) { } // we're ok with redundant sets, but complain/ignore if they try to switch.. - if (body_.Exists()) { + if (body_.exists()) { if (body_type_ != body_type || shape_ != shape) { g_core->Log(LogName::kBa, LogLevel::kError, "body attr can not be changed from its initial value"); @@ -330,7 +330,7 @@ void PropNode::UpdateAreaOfInterest() { if (!aoi) { return; } - assert(body_.Exists()); + assert(body_.exists()); aoi->set_position(Vector3f(dGeomGetPosition(body_->geom()))); aoi->SetRadius(5.0f); } @@ -371,7 +371,7 @@ void PropNode::SetMaterials(const std::vector& vals) { auto PropNode::GetVelocity() const -> std::vector { // if we've got a body, return its velocity - if (body_.Exists()) { + if (body_.exists()) { const dReal* v = dBodyGetLinearVel(body_->body()); std::vector vv(3); vv[0] = v[0]; @@ -391,7 +391,7 @@ void PropNode::SetVelocity(const std::vector& vals) { PyExcType::kValue); } // if we've got a body, apply the velocity to that - if (body_.Exists()) { + if (body_.exists()) { dBodySetLinearVel(body_->body(), vals[0], vals[1], vals[2]); } else { // otherwise just store it in our internal vector in @@ -402,7 +402,7 @@ void PropNode::SetVelocity(const std::vector& vals) { auto PropNode::GetPosition() const -> std::vector { // if we've got a body, return its position - if (body_.Exists()) { + if (body_.exists()) { const dReal* p = dGeomGetPosition(body_->geom()); std::vector f(3); f[0] = p[0]; @@ -423,7 +423,7 @@ void PropNode::SetPosition(const std::vector& vals) { PyExcType::kValue); } // if we've got a body, apply the position to that - if (body_.Exists()) { + if (body_.exists()) { dBodySetPosition(body_->body(), vals[0], vals[1], vals[2]); } else { // otherwise just store it in our internal vector @@ -444,13 +444,13 @@ void PropNode::Step() { } BA_DEBUG_CHECK_BODIES(); - assert(body_.Exists()); + assert(body_.exists()); // FIXME - this should probably happen for RBDs automatically?... body_->UpdateBlending(); // on happy thoughts, keep us on the 2d plane.. - if (g_base->graphics->camera()->happy_thoughts_mode() && body_.Exists()) { + if (g_base->graphics->camera()->happy_thoughts_mode() && body_.exists()) { dBodyID b; const dReal *p, *v; b = body_->body(); @@ -492,7 +492,7 @@ void PropNode::Step() { } // if we're out of bounds, arrange to have ourself informed - if (body_.Exists()) { + if (body_.exists()) { const dReal* p = dBodyGetPosition(body_->body()); if (scene()->IsOutOfBounds(p[0], p[1], p[2])) { scene()->AddOutOfBoundsNode(this); @@ -543,7 +543,7 @@ void PropNode::Step() { auto PropNode::GetRigidBody(int id) -> RigidBody* { if (id == 0) { - return body_.Get(); + return body_.get(); } return nullptr; } @@ -561,9 +561,9 @@ auto PropNode::CollideCallback(dContact* c, int count, // this should never happen, right?.. assert(opposingbody->part()->node() != nullptr); - if ((stick_to_owner_ || opposingbody->part()->node() != owner_.Get()) + if ((stick_to_owner_ || opposingbody->part()->node() != owner_.get()) && !(f & RigidBody::kIsBumper)) { - if (body_.Exists()) { + if (body_.exists()) { // stick to static stuff: if (opposingbody->type() == RigidBody::Type::kGeomOnly) { const dReal* v; @@ -718,7 +718,7 @@ void PropNode::GetRigidBodyPickupLocations(int id, float* obj, float* character, } void PropNode::SetDensity(float val) { - if (body_.Exists()) { + if (body_.exists()) { throw Exception("can't set density after body has been set"); } density_ = std::max(0.01f, std::min(100.0f, val)); diff --git a/src/ballistica/scene_v1/node/prop_node.h b/src/ballistica/scene_v1/node/prop_node.h index 697ca96c..e72730b8 100644 --- a/src/ballistica/scene_v1/node/prop_node.h +++ b/src/ballistica/scene_v1/node/prop_node.h @@ -35,11 +35,11 @@ class PropNode : public Node { void SetReflectionScale(const std::vector& vals); auto GetReflection() const -> std::string; void SetReflection(const std::string& val); - auto color_texture() const -> SceneTexture* { return color_texture_.Get(); } + auto color_texture() const -> SceneTexture* { return color_texture_.get(); } void set_color_texture(SceneTexture* val) { color_texture_ = val; } - auto GetMesh() const -> SceneMesh* { return mesh_.Get(); } + auto GetMesh() const -> SceneMesh* { return mesh_.get(); } void set_mesh(SceneMesh* val) { mesh_ = val; } - auto light_mesh() const -> SceneMesh* { return light_mesh_.Get(); } + auto light_mesh() const -> SceneMesh* { return light_mesh_.get(); } void set_light_mesh(SceneMesh* val) { light_mesh_ = val; } auto sticky() const -> bool { return sticky_; } void set_sticky(bool val) { sticky_ = val; } @@ -51,7 +51,7 @@ class PropNode : public Node { void set_mesh_scale(float val) { mesh_scale_ = val; } auto flashing() const -> bool { return flashing_; } void set_flashing(bool val) { flashing_ = val; } - auto owner() const -> Node* { return owner_.Get(); } + auto owner() const -> Node* { return owner_.get(); } void set_owner(Node* val) { owner_ = val; } auto GetMaterials() const -> std::vector; void SetMaterials(const std::vector& materials); diff --git a/src/ballistica/scene_v1/node/region_node.cc b/src/ballistica/scene_v1/node/region_node.cc index 9d1cee25..a3dce168 100644 --- a/src/ballistica/scene_v1/node/region_node.cc +++ b/src/ballistica/scene_v1/node/region_node.cc @@ -9,6 +9,7 @@ #include "ballistica/base/graphics/renderer/renderer.h" #include "ballistica/scene_v1/node/node_attribute.h" #include "ballistica/scene_v1/node/node_type.h" +#include "ode/ode_collision.h" namespace ballistica::scene_v1 { @@ -43,7 +44,7 @@ RegionNode::RegionNode(Scene* scene) void RegionNode::Draw(base::FrameDef* frame_def) { if (g_base->graphics_server->renderer()->debug_draw_mode()) { // if (frame_def->renderer()->debug_draw_mode()) { - if (body_.Exists()) { + if (body_.exists()) { body_->Draw(frame_def->beauty_pass(), false); } } @@ -85,7 +86,7 @@ void RegionNode::SetScale(const std::vector& vals) { void RegionNode::Step() { // create our body if we have none - if (!body_.Exists()) { + if (!body_.exists()) { if (region_type_ == "sphere") { body_ = Object::New( 0, &part_, RigidBody::Type::kGeomOnly, RigidBody::Shape::kSphere, diff --git a/src/ballistica/scene_v1/node/sound_node.cc b/src/ballistica/scene_v1/node/sound_node.cc index 3df87d30..2d26f8a8 100644 --- a/src/ballistica/scene_v1/node/sound_node.cc +++ b/src/ballistica/scene_v1/node/sound_node.cc @@ -90,7 +90,7 @@ void SoundNode::SetLoop(bool val) { } void SoundNode::SetSound(SceneSound* s) { - if (s == sound_.Get()) { + if (s == sound_.get()) { return; } sound_ = s; @@ -127,7 +127,7 @@ void SoundNode::SetMusic(bool val) { void SoundNode::Step() { // If we want to start playing, do so. - if (!playing_ && sound_.Exists()) { + if (!playing_ && sound_.exists()) { base::AudioSource* s = g_base->audio->SourceBeginNew(); if (s) { assert(position_.size() == 3); diff --git a/src/ballistica/scene_v1/node/sound_node.h b/src/ballistica/scene_v1/node/sound_node.h index 2ce642e7..01494914 100644 --- a/src/ballistica/scene_v1/node/sound_node.h +++ b/src/ballistica/scene_v1/node/sound_node.h @@ -25,7 +25,7 @@ class SoundNode : public Node { void SetMusic(bool val); auto loop() const -> bool { return loop_; } void SetLoop(bool val); - auto sound() const -> SceneSound* { return sound_.Get(); } + auto sound() const -> SceneSound* { return sound_.get(); } void SetSound(SceneSound* s); private: diff --git a/src/ballistica/scene_v1/node/spaz_node.cc b/src/ballistica/scene_v1/node/spaz_node.cc index 303ad110..b9956ddc 100644 --- a/src/ballistica/scene_v1/node/spaz_node.cc +++ b/src/ballistica/scene_v1/node/spaz_node.cc @@ -37,7 +37,7 @@ namespace ballistica::scene_v1 { template auto GetRandomMedia(const std::vector >& list) -> T* { if (list.empty()) return nullptr; - return list[rand() % list.size()].Get(); // NOLINT yes I know; rand bad. + return list[rand() % list.size()].get(); // NOLINT yes I know; rand bad. } const float kSantaEyeScale = 0.9f; @@ -732,7 +732,7 @@ SpazNode::SpazNode(Scene* scene) Stand(0, 0, 0, 0); // Attach head to torso. - neck_joint_ = CreateFixedJoint(body_head_.Get(), body_torso_.Get(), 1000, 1, + neck_joint_ = CreateFixedJoint(body_head_.get(), body_torso_.get(), 1000, 1, 20.0f, 0.3f); // Drop the y angular stiffness/damping on our neck so our head can whip @@ -741,7 +741,7 @@ SpazNode::SpazNode(Scene* scene) neck_joint_->anchor2[1] += 0.2f; // Attach torso to pelvis. - pelvis_joint_ = CreateFixedJoint(body_pelvis_.Get(), body_torso_.Get(), 0, + pelvis_joint_ = CreateFixedJoint(body_pelvis_.get(), body_torso_.get(), 0, 0, // lin stiff/damp 0, 0); // ang stiff/damp @@ -754,7 +754,7 @@ SpazNode::SpazNode(Scene* scene) // Attach upper right arm to torso. upper_right_arm_joint_ = CreateFixedJoint( - body_torso_.Get(), upper_right_arm_body_.Get(), 0, 0, 0, 0); + body_torso_.get(), upper_right_arm_body_.get(), 0, 0, 0, 0); // Move anchor to top of arm. upper_right_arm_joint_->anchor2[2] = -0.1f; @@ -764,13 +764,13 @@ SpazNode::SpazNode(Scene* scene) // Attach lower right arm to upper right arm. lower_right_arm_joint_ = CreateFixedJoint( - upper_right_arm_body_.Get(), lower_right_arm_body_.Get(), 0, 0, 0, 0); + upper_right_arm_body_.get(), lower_right_arm_body_.get(), 0, 0, 0, 0); lower_right_arm_joint_->anchor2[2] = -0.08f; // Attach upper left arm to torso. upper_left_arm_joint_ = CreateFixedJoint( - body_torso_.Get(), upper_left_arm_body_.Get(), 0, 0, 0, 0); + body_torso_.get(), upper_left_arm_body_.get(), 0, 0, 0, 0); // Move anchor to top of arm. upper_left_arm_joint_->anchor2[2] = -0.1f; @@ -780,25 +780,25 @@ SpazNode::SpazNode(Scene* scene) // Attach lower arm to upper arm. lower_left_arm_joint_ = CreateFixedJoint( - upper_left_arm_body_.Get(), lower_left_arm_body_.Get(), 0, 0, 0, 0); + upper_left_arm_body_.get(), lower_left_arm_body_.get(), 0, 0, 0, 0); lower_left_arm_joint_->anchor2[2] = -0.08f; // Attach upper right leg to leg-mass. upper_right_leg_joint_ = CreateFixedJoint( - body_pelvis_.Get(), upper_right_leg_body_.Get(), 0, 0, 0, 0); + body_pelvis_.get(), upper_right_leg_body_.get(), 0, 0, 0, 0); upper_right_leg_joint_->anchor2[2] = -0.05f; // Attach lower right leg to upper right leg. lower_right_leg_joint_ = CreateFixedJoint( - upper_right_leg_body_.Get(), lower_right_leg_body_.Get(), 0, 0, 0, 0); + upper_right_leg_body_.get(), lower_right_leg_body_.get(), 0, 0, 0, 0); lower_right_leg_joint_->anchor2[2] = -0.05f; // Attach bottom of lower leg to pelvis. right_leg_ik_joint_ = CreateFixedJoint( - body_pelvis_.Get(), lower_right_leg_body_.Get(), 0.3f, 0.001f, 0, 0); + body_pelvis_.get(), lower_right_leg_body_.get(), 0.3f, 0.001f, 0, 0); dQFromAxisAndAngle(right_leg_ik_joint_->qrel, 1, 0, 0, 1.0f); // Move the anchor to the tip of our leg. @@ -809,16 +809,16 @@ SpazNode::SpazNode(Scene* scene) right_leg_ik_joint_->anchor1[2] = 0.0f; // Attach toes to lower right foot. - right_toes_joint_ = CreateFixedJoint(lower_right_leg_body_.Get(), - right_toes_body_.Get(), 0, 0, 0, 0); + right_toes_joint_ = CreateFixedJoint(lower_right_leg_body_.get(), + right_toes_body_.get(), 0, 0, 0, 0); right_toes_joint_->anchor1[1] += -0.0f; right_toes_joint_->anchor2[1] += -0.04f; // And an anchor off to the side to make it hinge-like. right_toes_joint_2_ = nullptr; - right_toes_joint_2_ = CreateFixedJoint(lower_right_leg_body_.Get(), - right_toes_body_.Get(), 0, 0, 0, 0); + right_toes_joint_2_ = CreateFixedJoint(lower_right_leg_body_.get(), + right_toes_body_.get(), 0, 0, 0, 0); right_toes_joint_2_->anchor1[1] += -0.0f; right_toes_joint_2_->anchor2[1] += -0.04f; @@ -828,19 +828,19 @@ SpazNode::SpazNode(Scene* scene) // Attach upper left leg to leg-mass. upper_left_leg_joint_ = CreateFixedJoint( - body_pelvis_.Get(), upper_left_leg_body_.Get(), 0, 0, 0, 0); + body_pelvis_.get(), upper_left_leg_body_.get(), 0, 0, 0, 0); upper_left_leg_joint_->anchor2[2] = -0.05f; // Attach lower left leg to upper left leg. lower_left_leg_joint_ = CreateFixedJoint( - upper_left_leg_body_.Get(), lower_left_leg_body_.Get(), 0, 0, 0, 0); + upper_left_leg_body_.get(), lower_left_leg_body_.get(), 0, 0, 0, 0); lower_left_leg_joint_->anchor2[2] = -0.05f; // Attach bottom of lower leg to pelvis. left_leg_ik_joint_ = CreateFixedJoint( - body_pelvis_.Get(), lower_left_leg_body_.Get(), 0.3f, 0.001f, 0, 0); + body_pelvis_.get(), lower_left_leg_body_.get(), 0.3f, 0.001f, 0, 0); dQFromAxisAndAngle(left_leg_ik_joint_->qrel, 1, 0, 0, 1.0f); @@ -852,16 +852,16 @@ SpazNode::SpazNode(Scene* scene) left_leg_ik_joint_->anchor1[2] = 0.0f; // Attach toes to lower left foot. - left_toes_joint_ = CreateFixedJoint(lower_left_leg_body_.Get(), - left_toes_body_.Get(), 0, 0, 0, 0); + left_toes_joint_ = CreateFixedJoint(lower_left_leg_body_.get(), + left_toes_body_.get(), 0, 0, 0, 0); right_toes_joint_->anchor1[1] += -0.0f; left_toes_joint_->anchor2[1] += -0.04f; // And an anchor off to the side to make it hinge-like. left_toes_joint_2_ = nullptr; - left_toes_joint_2_ = CreateFixedJoint(lower_left_leg_body_.Get(), - left_toes_body_.Get(), 0, 0, 0, 0); + left_toes_joint_2_ = CreateFixedJoint(lower_left_leg_body_.get(), + left_toes_body_.get(), 0, 0, 0, 0); left_toes_joint_2_->anchor1[1] += -0.0f; left_toes_joint_2_->anchor2[1] += -0.04f; @@ -870,22 +870,22 @@ SpazNode::SpazNode(Scene* scene) // Attach end of right arm to torso. right_arm_ik_joint_ = - CreateFixedJoint(body_torso_.Get(), lower_right_arm_body_.Get(), 0.0f, + CreateFixedJoint(body_torso_.get(), lower_right_arm_body_.get(), 0.0f, 0.0f, 0, 0, -0.2f, -0.2f, 0.1f, 0, 0, 0.07f, false); left_arm_ik_joint_ = - CreateFixedJoint(body_torso_.Get(), lower_left_arm_body_.Get(), 0.0f, + CreateFixedJoint(body_torso_.get(), lower_left_arm_body_.get(), 0.0f, 0.0f, 0, 0, 0.2f, -0.2f, 0.1f, 0.0f, 0.0f, 0.07f, false); // Roller ball joint. - roller_ball_joint_ = CreateFixedJoint(body_torso_.Get(), body_roller_.Get(), + roller_ball_joint_ = CreateFixedJoint(body_torso_.get(), body_roller_.get(), kRollerBallLinearStiffness, kRollerBallLinearDamping, 0, 0); base_pelvis_roller_anchor_offset_ = roller_ball_joint_->anchor1[1]; // Stand joint on our torso. stand_joint_ = - CreateFixedJoint(body_torso_.Get(), stand_body_.Get(), 100, 1, 200, 10); + CreateFixedJoint(body_torso_.get(), stand_body_.get(), 100, 1, 200, 10); // Roller motor. a_motor_roller_ = dJointCreateAMotor(scene->dynamics()->ode_world(), nullptr); @@ -1848,7 +1848,7 @@ void SpazNode::Step() { // for (Object::Ref** body = bodies; *body != nullptr; body++) { for (auto* body : bodies) { - if (RigidBody* bodyptr = body->Get()) { + if (RigidBody* bodyptr = body->get()) { bodyptr->UpdateBlending(); } } @@ -1866,7 +1866,7 @@ void SpazNode::Step() { // FIXME: this should simply be an attr connection established on the // Python layer. - if (source_player_.Exists()) { + if (source_player_.exists()) { source_player_->SetPosition(Vector3f(p_torso)); } @@ -2251,7 +2251,7 @@ void SpazNode::Step() { &hair_ponytail_top_body_, &hair_ponytail_bottom_body_, nullptr}; float drag = 0.94f; for (Object::Ref** body = bodies2; *body != nullptr; body++) { - if ((**body).Exists()) { + if ((**body).exists()) { dBodyID b = (**body)->body(); const dReal* lVel = dBodyGetLinearVel(b); dBodySetLinearVel(b, lVel[0] * drag, lVel[1] * drag, lVel[2] * drag); @@ -2550,7 +2550,7 @@ void SpazNode::Step() { z *= 1.4f * run_gas_ + (1.0f - run_gas_) * 1.0f; dBodyGetRelPointPos(stand_body_->body(), step_separation, y, z, p_world); - assert(body_pelvis_.Exists()); + assert(body_pelvis_.exists()); dBodyGetPosRelPoint(body_pelvis_->body(), p_world[0], p_world[1], p_world[2], p_pelvis); left_leg_ik_joint_->anchor1[0] = p_pelvis[0]; @@ -2571,7 +2571,7 @@ void SpazNode::Step() { z *= 1.3f * run_gas_ + (1.0f - run_gas_) * 1.0f; dBodyGetRelPointPos(stand_body_->body(), -step_separation, y, z, p_world); - assert(body_pelvis_.Exists()); + assert(body_pelvis_.exists()); dBodyGetPosRelPoint(body_pelvis_->body(), p_world[0], p_world[1], p_world[2], p_pelvis); right_leg_ik_joint_->anchor1[0] = p_pelvis[0]; @@ -2694,8 +2694,8 @@ void SpazNode::Step() { left_arm_ik_joint_->angularDamping = 0; } else { bool haveHeldThing = false; - if (holding_something_ && hold_node_.Exists()) { - Node* a = hold_node_.Get(); + if (holding_something_ && hold_node_.exists()) { + Node* a = hold_node_.get(); RigidBody* b = a->GetRigidBody(hold_body_); if (b) { haveHeldThing = true; @@ -2717,7 +2717,7 @@ void SpazNode::Step() { dBodyGetRelPointPos(heldBody, hold_hand_offset_right_[0], hold_hand_offset_right_[1], hold_hand_offset_right_[2], p_world); - assert(body_torso_.Exists()); + assert(body_torso_.exists()); dBodyGetPosRelPoint(body_torso_->body(), p_world[0], p_world[1], p_world[2], p_torso2); jf->anchor1[0] = p_torso2[0]; @@ -2727,7 +2727,7 @@ void SpazNode::Step() { dBodyGetRelPointPos(heldBody, hold_hand_offset_left_[0], hold_hand_offset_left_[1], hold_hand_offset_left_[2], p_world); - assert(body_torso_.Exists()); + assert(body_torso_.exists()); dBodyGetPosRelPoint(body_torso_->body(), p_world[0], p_world[1], p_world[2], p_torso2); jf->anchor1[0] = p_torso2[0]; @@ -2790,7 +2790,7 @@ void SpazNode::Step() { p_world[1] += 0.13f; // Now translate back to torso space for setting our anchor. - assert(body_torso_.Exists()); + assert(body_torso_.exists()); dBodyGetPosRelPoint(body_torso_->body(), p_world[0], p_world[1], p_world[2], p_torso2); @@ -3270,7 +3270,7 @@ void SpazNode::Step() { // also add some force to what we're holding so popping out a bomb doesnt // send us spiraling down to death if (holding_something_) { - Node* a = hold_node_.Get(); + Node* a = hold_node_.get(); if (a) { float scale = 0.2f; RigidBody* b = a->GetRigidBody(hold_body_); @@ -3665,7 +3665,7 @@ void SpazNode::Step() { } if (punch_ > 0) { - if (!body_punch_.Exists() && since_last_punch > 80 && !knockout_) { + if (!body_punch_.exists() && since_last_punch > 80 && !knockout_) { body_punch_ = Object::New( kPunchBodyID, &punch_part_, RigidBody::Type::kGeomOnly, RigidBody::Shape::kSphere, RigidBody::kCollideRegion, @@ -3673,7 +3673,7 @@ void SpazNode::Step() { body_punch_->SetDimensions(0.25f); } - if (body_punch_.Exists()) { + if (body_punch_.exists()) { // Move the punch body to the end of our punching arm. dBodyID fist_body = punch_right_ ? lower_right_arm_body_->body() : lower_left_arm_body_->body(); @@ -3688,7 +3688,7 @@ void SpazNode::Step() { } } else { - if (body_punch_.Exists()) { + if (body_punch_.exists()) { body_punch_.Clear(); } } @@ -3753,7 +3753,7 @@ void SpazNode::Step() { // ( we need to check have_thrown_ because otherwise we'll always think // we're throwing at game-time 0 since throw_start_ inits to that.) if (have_thrown_ && scene()->time() - throw_start_ < 50) { - Node* a = hold_node_.Get(); + Node* a = hold_node_.get(); if (a) { RigidBody* b = a->GetRigidBody(hold_body_); if (b) { @@ -3831,11 +3831,11 @@ void SpazNode::Step() { } else { // If we're no longer holding something and our throw is over, clear any ref // we might have. - if (!holding_something_ && hold_node_.Exists()) hold_node_.Clear(); + if (!holding_something_ && hold_node_.exists()) hold_node_.Clear(); } if (pickup_ == kPickupCooldown - 4) { - if (!body_pickup_.Exists()) { + if (!body_pickup_.exists()) { body_pickup_ = Object::New( kPickupBodyID, &pickup_part_, RigidBody::Type::kGeomOnly, RigidBody::Shape::kSphere, RigidBody::kCollideRegion, @@ -3843,12 +3843,12 @@ void SpazNode::Step() { body_pickup_->SetDimensions(0.7f); } } else { - if (body_pickup_.Exists()) { + if (body_pickup_.exists()) { body_pickup_.Clear(); } } - if (body_pickup_.Exists()) { + if (body_pickup_.exists()) { // A unit vector forward. dVector3 f; float z = 0.3f; @@ -4104,9 +4104,9 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, float* add_color) { // Set up shading. if (shading) { - c->SetTexture(color_texture_.Exists() ? color_texture_->texture_data() + c->SetTexture(color_texture_.exists() ? color_texture_->texture_data() : nullptr); - c->SetColorizeTexture(color_mask_texture_.Exists() + c->SetColorizeTexture(color_mask_texture_.exists() ? color_mask_texture_->texture_data() : nullptr); c->SetColorizeColor(color_[0], color_[1], color_[2]); @@ -4149,13 +4149,13 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (head_mesh_.Exists()) { + if (head_mesh_.exists()) { c->DrawMeshAsset(head_mesh_->mesh_data()); } } // Hair tuft 1. - if (hair_front_right_body_.Exists()) { + if (hair_front_right_body_.exists()) { { auto xf = c->ScopedTransform(); hair_front_right_body_->ApplyToRenderComponent(c); @@ -4182,7 +4182,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, } // Hair tuft 2. - if (hair_front_left_body_.Exists()) { + if (hair_front_left_body_.exists()) { { auto xf = c->ScopedTransform(); hair_front_left_body_->ApplyToRenderComponent(c); @@ -4192,7 +4192,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, } // Hair tuft 3. - if (hair_ponytail_top_body_.Exists()) { + if (hair_ponytail_top_body_.exists()) { { auto xf = c->ScopedTransform(); hair_ponytail_top_body_->ApplyToRenderComponent(c); @@ -4204,7 +4204,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, } // Hair tuft 4. - if (hair_ponytail_bottom_body_.Exists()) { + if (hair_ponytail_bottom_body_.exists()) { { auto xf = c->ScopedTransform(); hair_ponytail_bottom_body_->ApplyToRenderComponent(c); @@ -4222,7 +4222,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (torso_mesh_.Exists()) { + if (torso_mesh_.exists()) { c->DrawMeshAsset(torso_mesh_->mesh_data()); } } @@ -4234,7 +4234,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (pelvis_mesh_.Exists()) { + if (pelvis_mesh_.exists()) { c->DrawMeshAsset(pelvis_mesh_->mesh_data()); } } @@ -4276,7 +4276,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (upper_arm_mesh_.Exists()) { + if (upper_arm_mesh_.exists()) { c->DrawMeshAsset(upper_arm_mesh_->mesh_data()); } } @@ -4294,7 +4294,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (forearm_mesh_.Exists() && !flippers_) { + if (forearm_mesh_.exists() && !flippers_) { c->DrawMeshAsset(forearm_mesh_->mesh_data()); } } @@ -4308,7 +4308,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (hand_mesh_.Exists() && !flippers_) { + if (hand_mesh_.exists() && !flippers_) { c->DrawMeshAsset(hand_mesh_->mesh_data()); } } @@ -4338,7 +4338,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (upper_leg_mesh_.Exists()) { + if (upper_leg_mesh_.exists()) { c->DrawMeshAsset(upper_leg_mesh_->mesh_data()); } } @@ -4350,7 +4350,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (lower_leg_mesh_.Exists()) { + if (lower_leg_mesh_.exists()) { c->DrawMeshAsset(lower_leg_mesh_->mesh_data()); } } @@ -4361,7 +4361,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (toes_mesh_.Exists()) { + if (toes_mesh_.exists()) { c->DrawMeshAsset(toes_mesh_->mesh_data()); } } @@ -4402,7 +4402,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (upper_arm_mesh_.Exists()) { + if (upper_arm_mesh_.exists()) { c->DrawMeshAsset(upper_arm_mesh_->mesh_data()); } } @@ -4421,7 +4421,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); } - if (forearm_mesh_.Exists() && !flippers_) { + if (forearm_mesh_.exists() && !flippers_) { c->DrawMeshAsset(forearm_mesh_->mesh_data()); } } @@ -4435,7 +4435,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (hand_mesh_.Exists() && !flippers_) { + if (hand_mesh_.exists() && !flippers_) { c->DrawMeshAsset(hand_mesh_->mesh_data()); } } @@ -4465,7 +4465,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, } if (death_scale != 1.0f) c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); - if (upper_leg_mesh_.Exists()) + if (upper_leg_mesh_.exists()) c->DrawMeshAsset(upper_leg_mesh_->mesh_data()); } @@ -4476,7 +4476,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, c->Scale(-1.0f, 1.0f, 1.0f); if (death_scale != 1.0f) c->Scale(death_scale, death_scale, 0.5f + death_scale * 0.5f); - if (lower_leg_mesh_.Exists()) { + if (lower_leg_mesh_.exists()) { c->DrawMeshAsset(lower_leg_mesh_->mesh_data()); } } @@ -4490,7 +4490,7 @@ void SpazNode::DrawBodyParts(base::ObjectComponent* c, bool shading, if (death_scale != 1.0f) { c->Scale(death_scale, death_scale, death_scale); } - if (toes_mesh_.Exists()) { + if (toes_mesh_.exists()) { c->DrawMeshAsset(toes_mesh_->mesh_data()); } } @@ -4832,7 +4832,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { bool flash = (scenetime - mini_billboard_1_start_time_ < 200 && render_frame_count % 6 < 3); if (!flash) { - c.SetTexture(mini_billboard_1_texture_.Exists() + c.SetTexture(mini_billboard_1_texture_.exists() ? mini_billboard_1_texture_->texture_data() : nullptr); } @@ -4858,7 +4858,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { bool flash = (scenetime - mini_billboard_2_start_time_ < 200 && render_frame_count % 6 < 3); if (!flash) { - c.SetTexture(mini_billboard_2_texture_.Exists() + c.SetTexture(mini_billboard_2_texture_.exists() ? mini_billboard_2_texture_->texture_data() : nullptr); } @@ -4883,7 +4883,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { bool flash = (scenetime - mini_billboard_3_start_time_ < 200 && render_frame_count % 6 < 3); if (!flash) { - c.SetTexture(mini_billboard_3_texture_.Exists() + c.SetTexture(mini_billboard_3_texture_.exists() ? mini_billboard_3_texture_->texture_data() : nullptr); } @@ -4903,7 +4903,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { { // Icon base::SimpleComponent c(frame_def->overlay_3d_pass()); c.SetTransparent(true); - c.SetTexture(counter_texture_.Exists() ? counter_texture_->texture_data() + c.SetTexture(counter_texture_.exists() ? counter_texture_->texture_data() : nullptr); { auto xf = c.ScopedTransform(); @@ -5012,7 +5012,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { base::SimpleComponent c(frame_def->overlay_3d_pass()); c.SetTransparent(true); c.SetColor(1, 1, 1, o); - c.SetTexture(billboard_texture_.Exists() + c.SetTexture(billboard_texture_.exists() ? billboard_texture_->texture_data() : nullptr); { @@ -5329,7 +5329,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { // Update and draw shadows. if (!g_core->HeadlessMode()) { - if (FullShadowSet* full_shadows = full_shadow_set_.Get()) { + if (FullShadowSet* full_shadows = full_shadow_set_.get()) { full_shadows->torso_shadow_.SetPosition( Vector3f(dBodyGetPosition(body_torso_->body()))); full_shadows->head_shadow_.SetPosition( @@ -5379,7 +5379,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) { 0.3f, sc); DrawShadow(full_shadows->upper_right_arm_shadow_, 0.08f * death_scale, 0.5f, sc); - } else if (SimpleShadowSet* simple_shadows = simple_shadow_set_.Get()) { + } else if (SimpleShadowSet* simple_shadows = simple_shadow_set_.get()) { simple_shadows->shadow_.SetPosition( Vector3f(dBodyGetPosition(body_pelvis_->body()))); DrawShadow(simple_shadows->shadow_, 0.2f * death_scale, 2.0f, sc); @@ -5581,8 +5581,8 @@ auto SpazNode::CollideCallback(dContact* c, int count, if (colliding_body->part() == &limbs_part_lower_) { // Drop friction if lower arms are hitting upper legs. - if ((colliding_body == lower_left_arm_body_.Get() - || colliding_body == lower_right_arm_body_.Get()) + if ((colliding_body == lower_left_arm_body_.get() + || colliding_body == lower_right_arm_body_.get()) && !shattered_) { for (int i = 0; i < count; i++) { c[i].surface.mu = 0.0f; @@ -5593,8 +5593,8 @@ auto SpazNode::CollideCallback(dContact* c, int count, float stiffness = 10.0f; float damping = 1.0f; - if (colliding_body == left_toes_body_.Get() - || colliding_body == right_toes_body_.Get()) { + if (colliding_body == left_toes_body_.get() + || colliding_body == right_toes_body_.get()) { stiffness *= kToesCollideStiffness; damping *= kToesCollideDamping; @@ -5603,8 +5603,8 @@ auto SpazNode::CollideCallback(dContact* c, int count, c[i].surface.mu *= 0.1f; } } - if (colliding_body == lower_right_leg_body_.Get() - || colliding_body == lower_left_leg_body_.Get()) { + if (colliding_body == lower_right_leg_body_.get() + || colliding_body == lower_left_leg_body_.get()) { stiffness *= kLowerLegCollideStiffness; damping *= kLowerLegCollideDamping; } @@ -5624,8 +5624,8 @@ auto SpazNode::CollideCallback(dContact* c, int count, // If we're punching, lets crank up stiffness on our punching hand // so it looks like its responding to stuff its hitting. if (punch_ && !dead_) { - if ((colliding_body == lower_right_arm_body_.Get() && punch_right_) - || (colliding_body == lower_left_arm_body_.Get() && !punch_right_)) { + if ((colliding_body == lower_right_arm_body_.get() && punch_right_) + || (colliding_body == lower_left_arm_body_.get() && !punch_right_)) { stiffness *= 200.0f; damping *= 20.0f; } @@ -5641,8 +5641,8 @@ auto SpazNode::CollideCallback(dContact* c, int count, float stiffness = 10; float damping = 1; float erp, cfm; - if (colliding_body == upper_right_leg_body_.Get() - || colliding_body == upper_left_leg_body_.Get()) { + if (colliding_body == upper_right_leg_body_.get() + || colliding_body == upper_left_leg_body_.get()) { stiffness *= kUpperLegCollideStiffness; damping *= kUpperLegCollideDamping; } @@ -5736,7 +5736,7 @@ auto SpazNode::CollideCallback(dContact* c, int count, // Keep track of when stuff is hitting our head, so we know when to calc // damage from head whiplash. - if (colliding_body == body_head_.Get() + if (colliding_body == body_head_.get() && opposing_body->part()->node() != this && opposing_body->can_cause_impact_damage()) { last_head_collide_time_ = scene()->time(); @@ -5914,67 +5914,67 @@ auto SpazNode::GetRigidBody(int id) -> RigidBody* { // Ewwww this should be automatic. switch (id) { case kHeadBodyID: - return body_head_.Get(); + return body_head_.get(); break; case kTorsoBodyID: - return body_torso_.Get(); + return body_torso_.get(); break; case kPunchBodyID: - return body_punch_.Get(); + return body_punch_.get(); break; case kPickupBodyID: - return body_pickup_.Get(); + return body_pickup_.get(); break; case kPelvisBodyID: - return body_pelvis_.Get(); + return body_pelvis_.get(); break; case kRollerBodyID: - return body_roller_.Get(); + return body_roller_.get(); break; case kStandBodyID: - return stand_body_.Get(); + return stand_body_.get(); break; case kUpperRightArmBodyID: - return upper_right_arm_body_.Get(); + return upper_right_arm_body_.get(); break; case kLowerRightArmBodyID: - return lower_right_arm_body_.Get(); + return lower_right_arm_body_.get(); break; case kUpperLeftArmBodyID: - return upper_left_arm_body_.Get(); + return upper_left_arm_body_.get(); break; case kLowerLeftArmBodyID: - return lower_left_arm_body_.Get(); + return lower_left_arm_body_.get(); break; case kUpperRightLegBodyID: - return upper_right_leg_body_.Get(); + return upper_right_leg_body_.get(); break; case kLowerRightLegBodyID: - return lower_right_leg_body_.Get(); + return lower_right_leg_body_.get(); break; case kUpperLeftLegBodyID: - return upper_left_leg_body_.Get(); + return upper_left_leg_body_.get(); break; case kLowerLeftLegBodyID: - return lower_left_leg_body_.Get(); + return lower_left_leg_body_.get(); break; case kLeftToesBodyID: - return left_toes_body_.Get(); + return left_toes_body_.get(); break; case kRightToesBodyID: - return right_toes_body_.Get(); + return right_toes_body_.get(); break; case kHairFrontRightBodyID: - return hair_front_right_body_.Get(); + return hair_front_right_body_.get(); break; case kHairFrontLeftBodyID: - return hair_front_left_body_.Get(); + return hair_front_left_body_.get(); break; case kHairPonyTailTopBodyID: - return hair_ponytail_top_body_.Get(); + return hair_ponytail_top_body_.get(); break; case kHairPonyTailBottomBodyID: - return hair_ponytail_bottom_body_.Get(); + return hair_ponytail_bottom_body_.get(); break; default: g_core->Log(LogName::kBa, LogLevel::kError, @@ -6004,7 +6004,7 @@ void SpazNode::GetRigidBodyPickupLocations(int id, float* obj, float* character, } void SpazNode::DropHeldObject() { if (holding_something_) { - if (hold_node_.Exists()) { + if (hold_node_.exists()) { assert(pickup_joint_.IsAlive()); pickup_joint_.Kill(); } @@ -6014,7 +6014,7 @@ void SpazNode::DropHeldObject() { hold_body_ = 0; // Dispatch user messages last now that all is in place. - if (hold_node_.Exists()) { + if (hold_node_.exists()) { hold_node_->DispatchDroppedMessage(this); } DispatchDropMessage(); @@ -6023,7 +6023,7 @@ void SpazNode::DropHeldObject() { void SpazNode::CreateHair() { // Assume all already exists in this case. - if (hair_front_right_body_.Exists()) return; + if (hair_front_right_body_.exists()) return; // Front right tuft. hair_front_right_body_ = @@ -6034,7 +6034,7 @@ void SpazNode::CreateHair() { hair_front_right_body_->SetDimensions(0.07f, 0.13f, 0, 0, 0, 0, 0.01f); hair_front_right_joint_ = - CreateFixedJoint(body_head_.Get(), hair_front_right_body_.Get(), 0, 0, 0, + CreateFixedJoint(body_head_.get(), hair_front_right_body_.get(), 0, 0, 0, 0, -0.17f, 0.19f, 0.18f, 0, -0.08f, -0.12f); // Rotate it right a bit. @@ -6049,7 +6049,7 @@ void SpazNode::CreateHair() { hair_front_left_body_->SetDimensions(0.04f, 0.13f, 0, 0.07f, 0.13f, 0, 0.01f); hair_front_left_joint_ = - CreateFixedJoint(body_head_.Get(), hair_front_left_body_.Get(), 0, 0, 0, + CreateFixedJoint(body_head_.get(), hair_front_left_body_.get(), 0, 0, 0, 0, 0.13f, 0.11f, 0.13f, 0, -0.08f, -0.12f); // Rotate it left a bit. @@ -6064,7 +6064,7 @@ void SpazNode::CreateHair() { hair_ponytail_top_body_->SetDimensions(0.09f, 0.1f, 0, 0, 0, 0, 0.01f); hair_ponytail_top_joint_ = - CreateFixedJoint(body_head_.Get(), hair_ponytail_top_body_.Get(), 0, 0, 0, + CreateFixedJoint(body_head_.get(), hair_ponytail_top_body_.get(), 0, 0, 0, 0, 0, 0.3f, -0.21f, 0, -0.01f, 0.1f); // rotate it up a bit.. dQFromAxisAndAngle(hair_ponytail_top_joint_->qrel, 1, 0, 0, 1.1f); @@ -6078,7 +6078,7 @@ void SpazNode::CreateHair() { hair_ponytail_bottom_body_->SetDimensions(0.09f, 0.13f, 0, 0, 0, 0, 0.01f); hair_ponytail_bottom_joint_ = CreateFixedJoint( - hair_ponytail_top_body_.Get(), hair_ponytail_bottom_body_.Get(), 0, 0, 0, + hair_ponytail_top_body_.get(), hair_ponytail_bottom_body_.get(), 0, 0, 0, 0, 0, 0.01f, -0.1f, 0, -0.01f, 0.12f); // Set joint values. @@ -6613,7 +6613,7 @@ auto SpazNode::GetPositionCenter() const -> std::vector { } auto SpazNode::GetPunchPosition() const -> std::vector { - if (!body_punch_.Exists()) { + if (!body_punch_.exists()) { BA_LOG_PYTHON_TRACE_ONCE( "WARNING: querying spaz punch_position without punch body"); return {0.0f, 0.0f, 0.0f}; @@ -6627,7 +6627,7 @@ auto SpazNode::GetPunchPosition() const -> std::vector { } auto SpazNode::GetPunchVelocity() const -> std::vector { - if (!body_punch_.Exists()) { + if (!body_punch_.exists()) { BA_LOG_PYTHON_TRACE_ONCE( "WARNING: querying spaz punch_velocity without punch body"); return {0.0f, 0.0f, 0.0f}; @@ -6645,7 +6645,7 @@ auto SpazNode::GetPunchVelocity() const -> std::vector { } auto SpazNode::GetPunchMomentumLinear() const -> std::vector { - if (!body_punch_.Exists()) { + if (!body_punch_.exists()) { BA_LOG_PYTHON_TRACE_ONCE( "WARNING: querying spaz punch_velocity without punch body"); return {0.0f, 0.0f, 0.0f}; @@ -6794,7 +6794,7 @@ void SpazNode::SetHoldNode(Node* val) { dJointCreateFixed(scene()->dynamics()->ode_world(), nullptr)); pickup_joint_.SetJoint(j, scene()); - pickup_joint_.AttachToBodies(body_torso_.Get(), b); + pickup_joint_.AttachToBodies(body_torso_.get(), b); dJointSetFixed(j); dJointSetFixedSpringMode(j, 1, 1, true); dJointSetFixedAnchor(j, 0, hold_height, hold_forward, false); diff --git a/src/ballistica/scene_v1/node/spaz_node.h b/src/ballistica/scene_v1/node/spaz_node.h index a0534787..ddd41490 100644 --- a/src/ballistica/scene_v1/node/spaz_node.h +++ b/src/ballistica/scene_v1/node/spaz_node.h @@ -54,19 +54,19 @@ class SpazNode : public Node { auto counter_text() const -> std::string { return counter_text_; } void set_counter_text(const std::string& val) { counter_text_ = val; } auto mini_billboard_1_texture() const -> SceneTexture* { - return mini_billboard_1_texture_.Get(); + return mini_billboard_1_texture_.get(); } void set_mini_billboard_1_texture(SceneTexture* val) { mini_billboard_1_texture_ = val; } auto mini_billboard_2_texture() const -> SceneTexture* { - return mini_billboard_2_texture_.Get(); + return mini_billboard_2_texture_.get(); } void set_mini_billboard_2_texture(SceneTexture* val) { mini_billboard_2_texture_ = val; } auto mini_billboard_3_texture() const -> SceneTexture* { - return mini_billboard_3_texture_.Get(); + return mini_billboard_3_texture_.get(); } void set_mini_billboard_3_texture(SceneTexture* val) { mini_billboard_3_texture_ = val; @@ -108,13 +108,13 @@ class SpazNode : public Node { mini_billboard_3_end_time_ = val; } auto billboard_texture() const -> SceneTexture* { - return billboard_texture_.Get(); + return billboard_texture_.get(); } void set_billboard_texture(SceneTexture* val) { billboard_texture_ = val; } auto billboard_opacity() const -> float { return billboard_opacity_; } void set_billboard_opacity(float val) { billboard_opacity_ = val; } auto counter_texture() const -> SceneTexture* { - return counter_texture_.Get(); + return counter_texture_.get(); } void set_counter_texture(SceneTexture* val) { counter_texture_ = val; } auto invincible() const -> bool { return invincible_; } @@ -131,7 +131,7 @@ class SpazNode : public Node { return boxing_gloves_flashing_; } void set_boxing_gloves_flashing(bool val) { boxing_gloves_flashing_ = val; } - auto source_player() const -> Player* { return source_player_.Get(); } + auto source_player() const -> Player* { return source_player_.get(); } void set_source_player(Player* val) { source_player_ = val; } auto frozen() const -> bool { return frozen_; } void SetFrozen(bool val); @@ -168,7 +168,7 @@ class SpazNode : public Node { auto GetPosition() const -> std::vector; auto hold_body() const -> int { return hold_body_; } void set_hold_body(int val) { hold_body_ = val; } - auto hold_node() const -> Node* { return hold_node_.Get(); } + auto hold_node() const -> Node* { return hold_node_.get(); } void SetHoldNode(Node* val); auto GetJumpSounds() const -> std::vector; void SetJumpSounds(const std::vector& vals); @@ -184,29 +184,29 @@ class SpazNode : public Node { return RefsToPointers(fall_sounds_); } void SetFallSounds(const std::vector& vals); - auto color_texture() const -> SceneTexture* { return color_texture_.Get(); } + auto color_texture() const -> SceneTexture* { return color_texture_.get(); } void set_color_texture(SceneTexture* val) { color_texture_ = val; } auto color_mask_texture() const -> SceneTexture* { - return color_mask_texture_.Get(); + return color_mask_texture_.get(); } void set_color_mask_texture(SceneTexture* val) { color_mask_texture_ = val; } - auto head_mesh() const -> SceneMesh* { return head_mesh_.Get(); } + auto head_mesh() const -> SceneMesh* { return head_mesh_.get(); } void set_head_mesh(SceneMesh* val) { head_mesh_ = val; } - auto torso_mesh() const -> SceneMesh* { return torso_mesh_.Get(); } + auto torso_mesh() const -> SceneMesh* { return torso_mesh_.get(); } void set_torso_mesh(SceneMesh* val) { torso_mesh_ = val; } - auto pelvis_mesh() const -> SceneMesh* { return pelvis_mesh_.Get(); } + auto pelvis_mesh() const -> SceneMesh* { return pelvis_mesh_.get(); } void set_pelvis_mesh(SceneMesh* val) { pelvis_mesh_ = val; } - auto upper_arm_mesh() const -> SceneMesh* { return upper_arm_mesh_.Get(); } + auto upper_arm_mesh() const -> SceneMesh* { return upper_arm_mesh_.get(); } void set_upper_arm_mesh(SceneMesh* val) { upper_arm_mesh_ = val; } - auto forearm_mesh() const -> SceneMesh* { return forearm_mesh_.Get(); } + auto forearm_mesh() const -> SceneMesh* { return forearm_mesh_.get(); } void set_forearm_mesh(SceneMesh* val) { forearm_mesh_ = val; } - auto hand_mesh() const -> SceneMesh* { return hand_mesh_.Get(); } + auto hand_mesh() const -> SceneMesh* { return hand_mesh_.get(); } void set_hand_mesh(SceneMesh* val) { hand_mesh_ = val; } - auto upper_leg_mesh() const -> SceneMesh* { return upper_leg_mesh_.Get(); } + auto upper_leg_mesh() const -> SceneMesh* { return upper_leg_mesh_.get(); } void set_upper_leg_mesh(SceneMesh* val) { upper_leg_mesh_ = val; } - auto lower_leg_mesh() const -> SceneMesh* { return lower_leg_mesh_.Get(); } + auto lower_leg_mesh() const -> SceneMesh* { return lower_leg_mesh_.get(); } void set_lower_leg_mesh(SceneMesh* val) { lower_leg_mesh_ = val; } - auto toes_mesh() const -> SceneMesh* { return toes_mesh_.Get(); } + auto toes_mesh() const -> SceneMesh* { return toes_mesh_.get(); } void set_toes_mesh(SceneMesh* val) { toes_mesh_ = val; } auto billboard_cross_out() const -> bool { return billboard_cross_out_; } void set_billboard_cross_out(bool val) { billboard_cross_out_ = val; } diff --git a/src/ballistica/scene_v1/node/terrain_node.cc b/src/ballistica/scene_v1/node/terrain_node.cc index 1a61de32..2d1d4e7a 100644 --- a/src/ballistica/scene_v1/node/terrain_node.cc +++ b/src/ballistica/scene_v1/node/terrain_node.cc @@ -102,7 +102,7 @@ TerrainNode::~TerrainNode() { // If we've got a collision-mesh, this is a good time to mark // it as used since it may be getting opened up to pruning // without our reference. - if (collision_mesh_.Exists()) { + if (collision_mesh_.exists()) { collision_mesh_->collision_mesh_data()->set_last_used_time( g_core->GetAppTimeMillisecs()); } @@ -121,7 +121,7 @@ void TerrainNode::set_mesh(SceneMesh* val) { mesh_ = val; } void TerrainNode::set_collision_mesh(SceneCollisionMesh* val) { // if we had an old one, mark its last-used time so caching works properly.. - if (collision_mesh_.Exists()) { + if (collision_mesh_.exists()) { collision_mesh_->collision_mesh_data()->set_last_used_time( g_core->GetAppTimeMillisecs()); } @@ -130,14 +130,14 @@ void TerrainNode::set_collision_mesh(SceneCollisionMesh* val) { // remove any existing.. RemoveFromBGDynamics(); - if (collision_mesh_.Exists()) { + if (collision_mesh_.exists()) { uint32_t flags = bumper_ ? RigidBody::kIsBumper : 0; flags |= RigidBody::kIsTerrain; body_ = Object::New( 0, &terrain_part_, RigidBody::Type::kGeomOnly, RigidBody::Shape::kTrimesh, RigidBody::kCollideBackground, RigidBody::kCollideAll ^ RigidBody::kCollideBackground, - collision_mesh_.Get(), flags); + collision_mesh_.get(), flags); body_->set_can_cause_impact_damage(true); // also ship it to the BG-Dynamics thread.. @@ -191,7 +191,7 @@ void TerrainNode::SetReflection(const std::string& val) { void TerrainNode::SetBumper(bool val) { bumper_ = val; - if (body_.Exists()) { + if (body_.exists()) { uint32_t is_bumper{RigidBody::kIsBumper}; if (bumper_) { body_->set_flags(body_->flags() | is_bumper); // on @@ -202,9 +202,9 @@ void TerrainNode::SetBumper(bool val) { } void TerrainNode::AddToBGDynamics() { - assert(bg_dynamics_collision_mesh_ == nullptr && collision_mesh_.Exists() + assert(bg_dynamics_collision_mesh_ == nullptr && collision_mesh_.exists() && !bumper_ && affect_bg_dynamics_); - bg_dynamics_collision_mesh_ = collision_mesh_.Get(); + bg_dynamics_collision_mesh_ = collision_mesh_.get(); #if !BA_HEADLESS_BUILD g_base->bg_dynamics->AddTerrain( bg_dynamics_collision_mesh_->collision_mesh_data()); @@ -222,7 +222,7 @@ void TerrainNode::RemoveFromBGDynamics() { } void TerrainNode::Draw(base::FrameDef* frame_def) { - if (!mesh_.Exists()) { + if (!mesh_.exists()) { return; } if (vr_only_ && !g_core->vr_mode()) { @@ -232,7 +232,7 @@ void TerrainNode::Draw(base::FrameDef* frame_def) { : background_ ? frame_def->beauty_pass_bg() : frame_def->beauty_pass()); c.SetWorldSpace(true); - if (color_texture_.Exists()) { + if (color_texture_.exists()) { c.SetTexture(color_texture_->texture_data()); } if (lighting_) { diff --git a/src/ballistica/scene_v1/node/terrain_node.h b/src/ballistica/scene_v1/node/terrain_node.h index 0350e693..b9c6de1b 100644 --- a/src/ballistica/scene_v1/node/terrain_node.h +++ b/src/ballistica/scene_v1/node/terrain_node.h @@ -47,12 +47,12 @@ class TerrainNode : public Node { void setLighting(bool val) { lighting_ = val; } auto color() const -> const std::vector& { return color_; } void SetColor(const std::vector& vals); - auto mesh() const -> SceneMesh* { return mesh_.Get(); } + auto mesh() const -> SceneMesh* { return mesh_.get(); } void set_mesh(SceneMesh* m); - auto color_texture() const -> SceneTexture* { return color_texture_.Get(); } + auto color_texture() const -> SceneTexture* { return color_texture_.get(); } void SetColorTexture(SceneTexture* val); auto collision_mesh() const -> SceneCollisionMesh* { - return collision_mesh_.Get(); + return collision_mesh_.get(); } void set_collision_mesh(SceneCollisionMesh* val); auto materials() const -> std::vector; diff --git a/src/ballistica/scene_v1/node/texture_sequence_node.cc b/src/ballistica/scene_v1/node/texture_sequence_node.cc index 26829350..417e69dc 100644 --- a/src/ballistica/scene_v1/node/texture_sequence_node.cc +++ b/src/ballistica/scene_v1/node/texture_sequence_node.cc @@ -54,7 +54,7 @@ auto TextureSequenceNode::output_texture() const -> SceneTexture* { return nullptr; } assert(index_ < static_cast(input_textures_.size())); - return input_textures_[index_].Get(); + return input_textures_[index_].get(); } void TextureSequenceNode::Step() { diff --git a/src/ballistica/scene_v1/python/class/python_class_activity_data.cc b/src/ballistica/scene_v1/python/class/python_class_activity_data.cc index c04960dc..2ed089b3 100644 --- a/src/ballistica/scene_v1/python/class/python_class_activity_data.cc +++ b/src/ballistica/scene_v1/python/class/python_class_activity_data.cc @@ -14,7 +14,7 @@ namespace ballistica::scene_v1 { auto PythonClassActivityData::nb_bool(PythonClassActivityData* self) -> int { - return self->host_activity_->Exists(); + return self->host_activity_->exists(); } PyNumberMethods PythonClassActivityData::as_number_; @@ -50,7 +50,7 @@ auto PythonClassActivityData::Create(HostActivity* host_activity) -> PyObject* { } auto PythonClassActivityData::GetHostActivity() const -> HostActivity* { - HostActivity* host_activity = host_activity_->Get(); + HostActivity* host_activity = host_activity_->get(); if (!host_activity) throw Exception( "Invalid ActivityData; this activity has probably been expired and " @@ -63,7 +63,7 @@ auto PythonClassActivityData::tp_repr(PythonClassActivityData* self) BA_PYTHON_TRY; return Py_BuildValue( "s", (std::string("host_activity_->Get()) + " >") + + Utils::PtrToString(self->host_activity_->get()) + " >") .c_str()); BA_PYTHON_CATCH; } @@ -106,7 +106,7 @@ auto PythonClassActivityData::Exists(PythonClassActivityData* self) -> PyObject* { BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - HostActivity* host_activity = self->host_activity_->Get(); + HostActivity* host_activity = self->host_activity_->get(); if (host_activity) { Py_RETURN_TRUE; } else { @@ -120,7 +120,7 @@ auto PythonClassActivityData::MakeForeground(PythonClassActivityData* self) -> PyObject* { BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - HostActivity* a = self->host_activity_->Get(); + HostActivity* a = self->host_activity_->get(); if (!a) { throw Exception("Invalid activity.", PyExcType::kActivityNotFound); } @@ -140,7 +140,7 @@ auto PythonClassActivityData::Start(PythonClassActivityData* self) BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - HostActivity* a = self->host_activity_->Get(); + HostActivity* a = self->host_activity_->get(); if (!a) { throw Exception("Invalid activity data.", PyExcType::kActivityNotFound); } @@ -154,7 +154,7 @@ auto PythonClassActivityData::Expire(PythonClassActivityData* self) -> PyObject* { BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - HostActivity* a = self->host_activity_->Get(); + HostActivity* a = self->host_activity_->get(); // The Python side may have stuck around after our c++ side was // torn down; that's ok. @@ -174,7 +174,7 @@ auto PythonClassActivityData::Context(PythonClassActivityData* self) -> PyObject* { BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - HostActivity* a = self->host_activity_->Get(); + HostActivity* a = self->host_activity_->get(); if (!a) { throw Exception("Activity is not valid."); } diff --git a/src/ballistica/scene_v1/python/class/python_class_base_timer.cc b/src/ballistica/scene_v1/python/class/python_class_base_timer.cc index 7a5ce867..07b3f311 100644 --- a/src/ballistica/scene_v1/python/class/python_class_base_timer.cc +++ b/src/ballistica/scene_v1/python/class/python_class_base_timer.cc @@ -95,7 +95,7 @@ auto PythonClassBaseTimer::tp_new(PyTypeObject* type, PyObject* args, self->timer_id_ = SceneV1Context::Current().NewTimer( TimeType::kBase, static_cast(length * 1000.0), static_cast(repeat), - Object::New(call_obj).Get()); + Object::New(call_obj).get()); self->have_timer_ = true; return reinterpret_cast(self); diff --git a/src/ballistica/scene_v1/python/class/python_class_input_device.cc b/src/ballistica/scene_v1/python/class/python_class_input_device.cc index eda254a4..25f66ff8 100644 --- a/src/ballistica/scene_v1/python/class/python_class_input_device.cc +++ b/src/ballistica/scene_v1/python/class/python_class_input_device.cc @@ -5,6 +5,7 @@ #include #include "ballistica/base/input/device/input_device.h" +#include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" #include "ballistica/scene_v1/support/scene_v1_input_device_delegate.h" #include "ballistica/shared/foundation/event_loop.h" @@ -110,7 +111,7 @@ auto PythonClassInputDevice::Create(SceneV1InputDeviceDelegate* input_device) auto PythonClassInputDevice::GetInputDevice() const -> SceneV1InputDeviceDelegate* { - SceneV1InputDeviceDelegate* input_device = input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* input_device = input_device_delegate_->get(); if (!input_device) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -120,7 +121,7 @@ auto PythonClassInputDevice::GetInputDevice() const auto PythonClassInputDevice::tp_repr(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); int input_device_id = d ? d->input_device().index() : -1; std::string dname = d ? d->input_device().GetDeviceName() : "invalid device"; return Py_BuildValue("s", @@ -131,7 +132,7 @@ auto PythonClassInputDevice::tp_repr(PythonClassInputDevice* self) } auto PythonClassInputDevice::nb_bool(PythonClassInputDevice* self) -> int { - return self->input_device_delegate_->Exists(); + return self->input_device_delegate_->exists(); } PyNumberMethods PythonClassInputDevice::as_number_; @@ -179,7 +180,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, assert(PyUnicode_Check(attr)); // NOLINT (signed bitwise ops) const char* s = PyUnicode_AsUTF8(attr); if (!strcmp(s, "player")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -189,7 +190,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, } Py_RETURN_NONE; } else if (!strcmp(s, "allows_configuring")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -199,7 +200,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, Py_RETURN_FALSE; } } else if (!strcmp(s, "allows_configuring_in_system_settings")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -209,7 +210,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, Py_RETURN_FALSE; } } else if (!strcmp(s, "has_meaningful_button_names")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -219,38 +220,38 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, Py_RETURN_FALSE; } } else if (!strcmp(s, "client_id")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } return PyLong_FromLong(d->GetClientID()); } else if (!strcmp(s, "name")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } return PyUnicode_FromString(d->input_device().GetDeviceName().c_str()); } else if (!strcmp(s, "unique_identifier")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } return PyUnicode_FromString( d->input_device().GetPersistentIdentifier().c_str()); } else if (!strcmp(s, "id")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } return PyLong_FromLong(d->input_device().index()); } else if (!strcmp(s, "instance_number")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } return PyLong_FromLong(d->input_device().device_number()); } else if (!strcmp(s, "is_controller_app")) { - auto* d = self->input_device_delegate_->Get(); + auto* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -260,7 +261,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, Py_RETURN_FALSE; } } else if (!strcmp(s, "is_remote_client")) { - auto* delegate = self->input_device_delegate_->Get(); + auto* delegate = self->input_device_delegate_->get(); if (!delegate) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -270,7 +271,7 @@ auto PythonClassInputDevice::tp_getattro(PythonClassInputDevice* self, Py_RETURN_FALSE; } } else if (!strcmp(s, "is_test_input")) { - auto* delegate = self->input_device_delegate_->Get(); + auto* delegate = self->input_device_delegate_->get(); if (!delegate) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -308,7 +309,7 @@ auto PythonClassInputDevice::tp_setattro(PythonClassInputDevice* self, auto PythonClassInputDevice::DetachFromPlayer(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -320,7 +321,7 @@ auto PythonClassInputDevice::DetachFromPlayer(PythonClassInputDevice* self) auto PythonClassInputDevice::GetDefaultPlayerName(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -331,7 +332,7 @@ auto PythonClassInputDevice::GetDefaultPlayerName(PythonClassInputDevice* self) auto PythonClassInputDevice::GetPlayerProfiles(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -354,7 +355,7 @@ auto PythonClassInputDevice::GetV1AccountName(PythonClassInputDevice* self, const_cast(kwlist), &full)) { return nullptr; } - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -367,7 +368,7 @@ auto PythonClassInputDevice::IsAttachedToPlayer(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; SceneV1InputDeviceDelegate* input_device = - self->input_device_delegate_->Get(); + self->input_device_delegate_->get(); if (!input_device) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -381,7 +382,7 @@ auto PythonClassInputDevice::IsAttachedToPlayer(PythonClassInputDevice* self) auto PythonClassInputDevice::Exists(PythonClassInputDevice* self) -> PyObject* { BA_PYTHON_TRY; - if (self->input_device_delegate_->Exists()) { + if (self->input_device_delegate_->exists()) { Py_RETURN_TRUE; } Py_RETURN_FALSE; @@ -400,7 +401,7 @@ auto PythonClassInputDevice::GetAxisName(PythonClassInputDevice* self, return nullptr; } SceneV1InputDeviceDelegate* input_device = - self->input_device_delegate_->Get(); + self->input_device_delegate_->get(); if (!input_device) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -420,7 +421,7 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self, const_cast(kwlist), &id)) { return nullptr; } - SceneV1InputDeviceDelegate* d = self->input_device_delegate_->Get(); + SceneV1InputDeviceDelegate* d = self->input_device_delegate_->get(); if (!d) { throw Exception(PyExcType::kInputDeviceNotFound); } @@ -437,7 +438,7 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self, PythonRef results = g_base->python->objs() .Get(base::BasePython::ObjID::kLstrFromJsonCall) .Call(args2); - if (!results.Exists()) { + if (!results.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Error creating Lstr from raw button name: '" + bname + "'"); PythonRef args3(Py_BuildValue("(s)", "?"), PythonRef::kSteal); @@ -445,7 +446,7 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self, .Get(base::BasePython::ObjID::kLstrFromJsonCall) .Call(args3); } - if (!results.Exists()) { + if (!results.exists()) { throw Exception("Internal error creating Lstr."); } return results.NewRef(); diff --git a/src/ballistica/scene_v1/python/class/python_class_material.cc b/src/ballistica/scene_v1/python/class/python_class_material.cc index ca9986a3..bb758060 100644 --- a/src/ballistica/scene_v1/python/class/python_class_material.cc +++ b/src/ballistica/scene_v1/python/class/python_class_material.cc @@ -147,7 +147,7 @@ void PythonClassMaterial::Delete(Object::Ref* m) { assert(g_base->InLogicThread()); // If we're the py-object for a material, clear them out. - if (m->Exists()) { + if (m->exists()) { assert((*m)->py_object() != nullptr); (*m)->set_py_object(nullptr); } @@ -187,7 +187,7 @@ auto PythonClassMaterial::tp_getattro(PythonClassMaterial* self, PyObject* attr) const char* s = PyUnicode_AsUTF8(attr); if (!strcmp(s, ATTR_LABEL)) { - Material* material = self->material_->Get(); + Material* material = self->material_->get(); if (!material) { throw Exception("Invalid Material.", PyExcType::kNotFound); } @@ -232,7 +232,7 @@ auto PythonClassMaterial::Dir(PythonClassMaterial* self) -> PyObject* { for (const char** name = extra_dir_attrs; *name != nullptr; name++) { PyList_Append( dir_list, - PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).Get()); + PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).get()); } PyList_Sort(dir_list); return dir_list; @@ -258,7 +258,7 @@ auto PythonClassMaterial::AddActions(PythonClassMaterial* self, PyObject* args, DoAddConditions(conditions_obj, &conditions); } - Material* m = self->material_->Get(); + Material* m = self->material_->get(); if (!m) { throw Exception("Invalid Material.", PyExcType::kNotFound); } @@ -541,7 +541,7 @@ void DoAddConditions(PyObject* cond_obj, Object::Ref c2_prev; for (Py_ssize_t i = 0; i < (size - 1); i += 2) { c2 = Object::New(); - if (c2_prev.Exists()) { + if (c2_prev.exists()) { c2->left_child = c2_prev; } else { DoAddConditions(PyTuple_GET_ITEM(cond_obj, i), &c2->left_child); diff --git a/src/ballistica/scene_v1/python/class/python_class_material.h b/src/ballistica/scene_v1/python/class/python_class_material.h index fc452860..217e60e6 100644 --- a/src/ballistica/scene_v1/python/class/python_class_material.h +++ b/src/ballistica/scene_v1/python/class/python_class_material.h @@ -19,7 +19,7 @@ class PythonClassMaterial : public PythonClass { static PyTypeObject type_obj; auto GetMaterial(bool doraise = true) const -> Material* { - Material* m = material_->Get(); + Material* m = material_->get(); if ((!m) && doraise) throw Exception("Invalid Material"); return m; } diff --git a/src/ballistica/scene_v1/python/class/python_class_node.cc b/src/ballistica/scene_v1/python/class/python_class_node.cc index 4d548cbb..043feec1 100644 --- a/src/ballistica/scene_v1/python/class/python_class_node.cc +++ b/src/ballistica/scene_v1/python/class/python_class_node.cc @@ -6,6 +6,7 @@ #include #include +#include "ballistica/base/logic/logic.h" #include "ballistica/scene_v1/python/scene_v1_python.h" #include "ballistica/scene_v1/support/scene.h" #include "ballistica/scene_v1/support/session_stream.h" @@ -63,7 +64,7 @@ void PythonClassNode::SetupType(PyTypeObject* cls) { auto PythonClassNode::Create(Node* node) -> PyObject* { // Make sure we only have one python ref per node. if (node) { - assert(!node->has_py_ref()); + assert(!node->HasPyRef()); } s_create_empty_ = true; // Prevent class from erroring on create. @@ -80,7 +81,7 @@ auto PythonClassNode::Create(Node* node) -> PyObject* { } auto PythonClassNode::GetNode(bool doraise) const -> Node* { - Node* n = node_->Get(); + Node* n = node_->get(); if (!n && doraise) { throw Exception(PyExcType::kNodeNotFound); } @@ -133,7 +134,7 @@ void PythonClassNode::tp_dealloc(PythonClassNode* self) { auto PythonClassNode::tp_repr(PythonClassNode* self) -> PyObject* { BA_PYTHON_TRY; - Node* node = self->node_->Get(); + Node* node = self->node_->get(); return Py_BuildValue( "s", std::string("node_->Get(); + Node* node = self->node_->get(); const char* attr_name = PyUnicode_AsUTF8(attr); if (node && node->HasAttribute(attr_name)) { return SceneV1Python::GetNodeAttr(node, attr_name); @@ -164,7 +165,7 @@ auto PythonClassNode::tp_getattro(PythonClassNode* self, PyObject* attr) auto PythonClassNode::Exists(PythonClassNode* self) -> PyObject* { BA_PYTHON_TRY; - if (self->node_->Exists()) { + if (self->node_->exists()) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; @@ -175,7 +176,7 @@ auto PythonClassNode::Exists(PythonClassNode* self) -> PyObject* { auto PythonClassNode::GetNodeType(PythonClassNode* self) -> PyObject* { BA_PYTHON_TRY; - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (!node) { throw Exception(PyExcType::kNodeNotFound); } @@ -187,7 +188,7 @@ auto PythonClassNode::GetNodeType(PythonClassNode* self) -> PyObject* { auto PythonClassNode::GetName(PythonClassNode* self) -> PyObject* { BA_PYTHON_TRY; - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (!node) { throw Exception(PyExcType::kNodeNotFound); } @@ -206,7 +207,7 @@ auto PythonClassNode::GetDelegate(PythonClassNode* self, PyObject* args, args, keywds, "O|p", const_cast(kwlist), &tp_obj, &doraise)) { return nullptr; } - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (!node) { throw Exception(PyExcType::kNodeNotFound); } @@ -249,7 +250,7 @@ auto PythonClassNode::Delete(PythonClassNode* self, PyObject* args, args, keywds, "|i", const_cast(kwlist), &ignore_missing)) { return nullptr; } - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (!node) { if (!ignore_missing) { throw Exception(PyExcType::kNodeNotFound); @@ -274,7 +275,7 @@ auto PythonClassNode::HandleMessage(PythonClassNode* self, PyObject* args) SceneV1Python::DoBuildNodeMessage(args, 0, &b, &user_message_obj); // Should we fail if the node doesn't exist?? - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (node) { HostActivity* host_activity = node->context_ref().GetHostActivity(); if (!host_activity) { @@ -303,7 +304,7 @@ auto PythonClassNode::AddDeathAction(PythonClassNode* self, PyObject* args) if (!PyArg_ParseTuple(args, "O", &call_obj)) { return nullptr; } - Node* n = self->node_->Get(); + Node* n = self->node_->get(); if (!n) { throw Exception(PyExcType::kNodeNotFound); } @@ -323,7 +324,7 @@ auto PythonClassNode::ConnectAttr(PythonClassNode* self, PyObject* args) -> PyObject* { BA_PYTHON_TRY; PyObject* dst_node_obj; - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (!node) { throw Exception(PyExcType::kNodeNotFound); } @@ -362,14 +363,14 @@ auto PythonClassNode::Dir(PythonClassNode* self) -> PyObject* { assert(PyList_Check(dir_list)); // ..now grab all this guy's BA attributes and add them in. - Node* node = self->node_->Get(); + Node* node = self->node_->get(); if (node) { std::list attrs; node->ListAttributes(&attrs); for (auto& attr : attrs) { PyList_Append(dir_list, PythonRef(PyUnicode_FromString(attr.c_str()), PythonRef::kSteal) - .Get()); + .get()); } } PyList_Sort(dir_list); @@ -378,7 +379,7 @@ auto PythonClassNode::Dir(PythonClassNode* self) -> PyObject* { } auto PythonClassNode::nb_bool(PythonClassNode* self) -> int { - return self->node_->Exists(); + return self->node_->exists(); } auto PythonClassNode::tp_setattro(PythonClassNode* self, PyObject* attr, @@ -387,7 +388,7 @@ auto PythonClassNode::tp_setattro(PythonClassNode* self, PyObject* attr, // FIXME: do we need to support other attr types? assert(PyUnicode_Check(attr)); - Node* n = self->node_->Get(); + Node* n = self->node_->get(); if (!n) { throw Exception(PyExcType::kNodeNotFound); } diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_collision_mesh.cc b/src/ballistica/scene_v1/python/class/python_class_scene_collision_mesh.cc index 7887e3e3..964549c0 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_collision_mesh.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_collision_mesh.cc @@ -17,7 +17,7 @@ auto PythonClassSceneCollisionMesh::tp_repr(PythonClassSceneCollisionMesh* self) auto&& m = *self->collision_mesh_; return Py_BuildValue( "s", (std::string("name() + "\"") : "(empty ref)") + ">") + + (m.exists() ? ("\"" + m->name() + "\"") : "(empty ref)") + ">") .c_str()); BA_PYTHON_CATCH; } @@ -58,7 +58,7 @@ auto PythonClassSceneCollisionMesh::Create(SceneCollisionMesh* collision_mesh) auto PythonClassSceneCollisionMesh::GetCollisionMesh(bool doraise) const -> SceneCollisionMesh* { - SceneCollisionMesh* collision_mesh = collision_mesh_->Get(); + SceneCollisionMesh* collision_mesh = collision_mesh_->get(); if (!collision_mesh && doraise) { throw Exception("Invalid CollisionMesh.", PyExcType::kNotFound); } diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_data_asset.cc b/src/ballistica/scene_v1/python/class/python_class_scene_data_asset.cc index 6455465a..cd34041c 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_data_asset.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_data_asset.cc @@ -16,7 +16,7 @@ auto PythonClassSceneDataAsset::tp_repr(PythonClassSceneDataAsset* self) auto&& m = *self->data_; return Py_BuildValue( "s", (std::string("name() + "\"") : "(empty ref)") + ">") + + (m.exists() ? ("\"" + m->name() + "\"") : "(empty ref)") + ">") .c_str()); BA_PYTHON_CATCH; } @@ -54,7 +54,7 @@ auto PythonClassSceneDataAsset::Create(SceneDataAsset* data) -> PyObject* { } auto PythonClassSceneDataAsset::GetData(bool doraise) const -> SceneDataAsset* { - SceneDataAsset* data = data_->Get(); + SceneDataAsset* data = data_->get(); if (!data && doraise) { throw Exception("Invalid Data.", PyExcType::kNotFound); } @@ -108,7 +108,7 @@ void PythonClassSceneDataAsset::tp_dealloc(PythonClassSceneDataAsset* self) { auto PythonClassSceneDataAsset::GetValue(PythonClassSceneDataAsset* self) -> PyObject* { BA_PYTHON_TRY; - SceneDataAsset* data = self->data_->Get(); + SceneDataAsset* data = self->data_->get(); if (data == nullptr) { throw Exception("Invalid data object.", PyExcType::kNotFound); } @@ -116,7 +116,7 @@ auto PythonClassSceneDataAsset::GetValue(PythonClassSceneDataAsset* self) base::DataAsset* datadata = data->data_data(); datadata->Load(); datadata->set_last_used_time(g_core->GetAppTimeMillisecs()); - PyObject* obj = datadata->object().Get(); + PyObject* obj = datadata->object().get(); assert(obj); Py_INCREF(obj); return obj; diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_mesh.cc b/src/ballistica/scene_v1/python/class/python_class_scene_mesh.cc index f191d68b..910988c9 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_mesh.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_mesh.cc @@ -15,7 +15,7 @@ auto PythonClassSceneMesh::tp_repr(PythonClassSceneMesh* self) -> PyObject* { auto&& m = *(self->mesh_); return Py_BuildValue( "s", (std::string("name() + "\"") : "(empty ref)") + ">") + + (m.exists() ? ("\"" + m->name() + "\"") : "(empty ref)") + ">") .c_str()); BA_PYTHON_CATCH; } @@ -53,7 +53,7 @@ auto PythonClassSceneMesh::Create(SceneMesh* mesh) -> PyObject* { } auto PythonClassSceneMesh::GetMesh(bool doraise) const -> SceneMesh* { - SceneMesh* mesh = mesh_->Get(); + SceneMesh* mesh = mesh_->get(); if (!mesh && doraise) { throw Exception("Invalid mesh.", PyExcType::kNotFound); } diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_sound.cc b/src/ballistica/scene_v1/python/class/python_class_scene_sound.cc index e34ce7ae..80b414c3 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_sound.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_sound.cc @@ -5,6 +5,7 @@ #include #include +#include "ballistica/base/logic/logic.h" #include "ballistica/scene_v1/assets/scene_sound.h" #include "ballistica/scene_v1/support/scene.h" #include "ballistica/shared/foundation/event_loop.h" @@ -36,7 +37,7 @@ auto PythonClassSceneSound::tp_repr(PythonClassSceneSound* self) -> PyObject* { auto&& m = *(self->sound_); return Py_BuildValue( "s", (std::string("name() + "\"") : "(empty ref)") + ">") + + (m.exists() ? ("\"" + m->name() + "\"") : "(empty ref)") + ">") .c_str()); BA_PYTHON_CATCH; } @@ -55,7 +56,7 @@ auto PythonClassSceneSound::Create(SceneSound* sound) -> PyObject* { } auto PythonClassSceneSound::GetSound(bool doraise) const -> SceneSound* { - SceneSound* sound = sound_->Get(); + SceneSound* sound = sound_->get(); if (!sound && doraise) { throw Exception("Invalid Sound.", PyExcType::kNotFound); } diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_texture.cc b/src/ballistica/scene_v1/python/class/python_class_scene_texture.cc index 0457b798..ccb77b68 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_texture.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_texture.cc @@ -16,7 +16,7 @@ auto PythonClassSceneTexture::tp_repr(PythonClassSceneTexture* self) auto&& t = *(self->texture_); return Py_BuildValue( "s", (std::string("name() + "\"") : "(empty ref)") + ">") + + (t.exists() ? ("\"" + t->name() + "\"") : "(empty ref)") + ">") .c_str()); BA_PYTHON_CATCH; } @@ -58,7 +58,7 @@ auto PythonClassSceneTexture::Create(SceneTexture* texture) -> PyObject* { } auto PythonClassSceneTexture::GetTexture(bool doraise) const -> SceneTexture* { - SceneTexture* texture = texture_->Get(); + SceneTexture* texture = texture_->get(); if (!texture && doraise) { throw Exception("Invalid Texture.", PyExcType::kNotFound); } diff --git a/src/ballistica/scene_v1/python/class/python_class_scene_timer.cc b/src/ballistica/scene_v1/python/class/python_class_scene_timer.cc index 4ec0a8ed..50b98617 100644 --- a/src/ballistica/scene_v1/python/class/python_class_scene_timer.cc +++ b/src/ballistica/scene_v1/python/class/python_class_scene_timer.cc @@ -101,7 +101,7 @@ auto PythonClassSceneTimer::tp_new(PyTypeObject* type, PyObject* args, self->timer_id_ = SceneV1Context::Current().NewTimer( TimeType::kSim, static_cast(length * 1000.0), static_cast(repeat), - Object::New(call_obj).Get()); + Object::New(call_obj).get()); self->have_timer_ = true; return reinterpret_cast(self); diff --git a/src/ballistica/scene_v1/python/class/python_class_session_data.cc b/src/ballistica/scene_v1/python/class/python_class_session_data.cc index f26a87bf..c7e2785b 100644 --- a/src/ballistica/scene_v1/python/class/python_class_session_data.cc +++ b/src/ballistica/scene_v1/python/class/python_class_session_data.cc @@ -13,7 +13,7 @@ namespace ballistica::scene_v1 { auto PythonClassSessionData::nb_bool(PythonClassSessionData* self) -> int { - return self->session_->Exists(); + return self->session_->exists(); } PyNumberMethods PythonClassSessionData::as_number_; @@ -49,7 +49,7 @@ auto PythonClassSessionData::Create(Session* session) -> PyObject* { } auto PythonClassSessionData::GetSession() const -> Session* { - Session* session = session_->Get(); + Session* session = session_->get(); if (!session) { throw Exception("Invalid SessionData.", PyExcType::kSessionNotFound); } @@ -60,7 +60,7 @@ auto PythonClassSessionData::Context(PythonClassSessionData* self) -> PyObject* { BA_PYTHON_TRY; BA_PRECONDITION(g_base->InLogicThread()); - Session* s = self->session_->Get(); + Session* s = self->session_->get(); if (!s) { throw Exception("Session is not valid."); } @@ -73,7 +73,7 @@ auto PythonClassSessionData::tp_repr(PythonClassSessionData* self) -> PyObject* { BA_PYTHON_TRY; return Py_BuildValue("s", (std::string("session_->Get()) + " >") + + Utils::PtrToString(self->session_->get()) + " >") .c_str()); BA_PYTHON_CATCH; } @@ -115,7 +115,7 @@ void PythonClassSessionData::tp_dealloc(PythonClassSessionData* self) { auto PythonClassSessionData::Exists(PythonClassSessionData* self) -> PyObject* { BA_PYTHON_TRY; - Session* sgc = self->session_->Get(); + Session* sgc = self->session_->get(); if (sgc) { Py_RETURN_TRUE; } else { diff --git a/src/ballistica/scene_v1/python/class/python_class_session_player.cc b/src/ballistica/scene_v1/python/class/python_class_session_player.cc index e5d55e6c..f3bfd936 100644 --- a/src/ballistica/scene_v1/python/class/python_class_session_player.cc +++ b/src/ballistica/scene_v1/python/class/python_class_session_player.cc @@ -5,6 +5,7 @@ #include #include +#include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" #include "ballistica/scene_v1/python/scene_v1_python.h" #include "ballistica/scene_v1/support/host_session.h" @@ -20,7 +21,7 @@ namespace ballistica::scene_v1 { #pragma ide diagnostic ignored "RedundantCast" auto PythonClassSessionPlayer::nb_bool(PythonClassSessionPlayer* self) -> int { - return self->player_->Exists(); + return self->player_->exists(); } PyNumberMethods PythonClassSessionPlayer::as_number_; @@ -121,7 +122,7 @@ void PythonClassSessionPlayer::SetupType(PyTypeObject* cls) { auto PythonClassSessionPlayer::Create(Player* player) -> PyObject* { // Make sure we only have one python ref per material. if (player) { - assert(!player->has_py_ref()); + assert(!player->HasPyRef()); } s_create_empty_ = true; // Prevent class from erroring on create. assert(TypeIsSetUp(&type_obj)); @@ -137,7 +138,7 @@ auto PythonClassSessionPlayer::Create(Player* player) -> PyObject* { } auto PythonClassSessionPlayer::GetPlayer(bool doraise) const -> Player* { - Player* player = player_->Get(); + Player* player = player_->get(); if ((!player) && doraise) { throw Exception("Invalid SessionPlayer.", PyExcType::kSessionPlayerNotFound); @@ -148,7 +149,7 @@ auto PythonClassSessionPlayer::GetPlayer(bool doraise) const -> Player* { auto PythonClassSessionPlayer::tp_repr(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; - Player* p = self->player_->Get(); + Player* p = self->player_->get(); int player_id = p ? p->id() : -1; std::string p_name = p ? p->GetName() : "invalid"; return Py_BuildValue("s", @@ -218,7 +219,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, const char* s = PyUnicode_AsUTF8(attr); if (!strcmp(s, ATTR_IN_GAME)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -233,13 +234,13 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, Py_RETURN_TRUE; } } else if (!strcmp(s, ATTR_ID)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } return PyLong_FromLong(p->id()); } else if (!strcmp(s, ATTR_INPUT_DEVICE)) { - Player* player = self->player_->Get(); + Player* player = self->player_->get(); if (!player) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -249,7 +250,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, } throw Exception(PyExcType::kInputDeviceNotFound); } else if (!strcmp(s, ATTR_SESSIONTEAM)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -259,14 +260,14 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, PyErr_SetString( g_base->python->objs() .Get(base::BasePython::ObjID::kSessionTeamNotFoundError) - .Get(), + .get(), "SessionTeam does not exist."); return nullptr; } Py_INCREF(team); return team; } else if (!strcmp(s, ATTR_CHARACTER)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -279,7 +280,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, Py_INCREF(obj); return obj; } else if (!strcmp(s, ATTR_COLOR)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -292,7 +293,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, Py_INCREF(obj); return obj; } else if (!strcmp(s, ATTR_HIGHLIGHT)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -305,7 +306,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self, Py_INCREF(obj); return obj; } else if (!strcmp(s, ATTR_ACTIVITYPLAYER)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -338,7 +339,7 @@ auto PythonClassSessionPlayer::tp_setattro(PythonClassSessionPlayer* self, const char* s = PyUnicode_AsUTF8(attr); if (!strcmp(s, ATTR_ACTIVITYPLAYER)) { - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -365,7 +366,7 @@ auto PythonClassSessionPlayer::GetName(PythonClassSessionPlayer* self, const_cast(kwlist), &full, &icon)) { return nullptr; } - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -378,7 +379,7 @@ auto PythonClassSessionPlayer::Exists(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - if (self->player_->Exists()) { + if (self->player_->exists()) { Py_RETURN_TRUE; } Py_RETURN_FALSE; @@ -405,7 +406,7 @@ auto PythonClassSessionPlayer::SetName(PythonClassSessionPlayer* self, std::string full_name = (full_name_obj == Py_None) ? name : g_base->python->GetPyLString(full_name_obj); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -418,7 +419,7 @@ auto PythonClassSessionPlayer::ResetInput(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -440,7 +441,7 @@ auto PythonClassSessionPlayer::AssignInputCall(PythonClassSessionPlayer* self, &call_obj)) { return nullptr; } - Player* player = self->player_->Get(); + Player* player = self->player_->get(); if (!player) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -473,7 +474,7 @@ auto PythonClassSessionPlayer::RemoveFromGame(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* player = self->player_->Get(); + Player* player = self->player_->get(); if (!player) { throw Exception(PyExcType::kSessionPlayerNotFound); } else { @@ -492,7 +493,7 @@ auto PythonClassSessionPlayer::GetTeam(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -508,7 +509,7 @@ auto PythonClassSessionPlayer::GetV1AccountID(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -536,7 +537,7 @@ auto PythonClassSessionPlayer::SetData(PythonClassSessionPlayer* self, &character_obj, &color_obj, &highlight_obj)) { return nullptr; } - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -553,7 +554,7 @@ auto PythonClassSessionPlayer::GetIconInfo(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -582,7 +583,7 @@ auto PythonClassSessionPlayer::SetIconInfo(PythonClassSessionPlayer* self, &tint_texture_name_obj, &tint_color_obj, &tint2_color_obj)) { return nullptr; } - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -612,7 +613,7 @@ auto PythonClassSessionPlayer::SetActivity(PythonClassSessionPlayer* self, const_cast(kwlist), &activity_obj)) { return nullptr; } - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -638,7 +639,7 @@ auto PythonClassSessionPlayer::SetNode(PythonClassSessionPlayer* self, const_cast(kwlist), &node_obj)) { return nullptr; } - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -658,7 +659,7 @@ auto PythonClassSessionPlayer::GetIcon(PythonClassSessionPlayer* self) -> PyObject* { BA_PYTHON_TRY; assert(g_base->InLogicThread()); - Player* p = self->player_->Get(); + Player* p = self->player_->get(); if (!p) { throw Exception(PyExcType::kSessionPlayerNotFound); } @@ -688,7 +689,7 @@ auto PythonClassSessionPlayer::Dir(PythonClassSessionPlayer* self) for (const char** name = extra_dir_attrs; *name != nullptr; name++) { PyList_Append( dir_list, - PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).Get()); + PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).get()); } PyList_Sort(dir_list); return dir_list; diff --git a/src/ballistica/scene_v1/python/methods/python_methods_networking.cc b/src/ballistica/scene_v1/python/methods/python_methods_networking.cc index 573ee93a..e46b5d63 100644 --- a/src/ballistica/scene_v1/python/methods/python_methods_networking.cc +++ b/src/ballistica/scene_v1/python/methods/python_methods_networking.cc @@ -539,11 +539,11 @@ static auto PyGetConnectionToHostInfo2(PyObject* self, PyObject* args, g_core->python->objs().Get(core::CorePython::ObjID::kEmptyTuple); auto keywds = PythonRef::Stolen(Py_BuildValue( "{sssisOsO}", "name", hc->party_name().c_str(), "build_number", - hc->build_number(), "address", addr_obj.Get(), "port", port_obj.Get())); + hc->build_number(), "address", addr_obj.get(), "port", port_obj.get())); auto result = g_scene_v1->python->objs() .Get(SceneV1Python::ObjID::kHostInfoClass) .Call(args, keywds); - if (!result.Exists()) { + if (!result.exists()) { throw Exception("Failed to instantiate HostInfo.", PyExcType::kRuntime); } return result.HandOver(); @@ -650,7 +650,7 @@ static auto PyGetClientPublicDeviceUUID(PyObject* self, PyObject* args, } // Connections should always be valid refs. - assert(connection->second.Exists()); + assert(connection->second.exists()); // Old clients don't assign this; it will be empty. if (connection->second->public_device_id().empty()) { 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 2a972b9b..ebac53d2 100644 --- a/src/ballistica/scene_v1/python/methods/python_methods_scene.cc +++ b/src/ballistica/scene_v1/python/methods/python_methods_scene.cc @@ -99,7 +99,7 @@ static auto PyTimer(PyObject* self, PyObject* args, PyObject* keywds) SceneV1Context::Current().NewTimer( TimeType::kSim, static_cast(length * 1000.0), static_cast(repeat), - Object::New(call_obj).Get()); + Object::New(call_obj).get()); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -208,7 +208,7 @@ static auto PyBaseTimer(PyObject* self, PyObject* args, PyObject* keywds) SceneV1Context::Current().NewTimer( TimeType::kBase, static_cast(length * 1000.0), static_cast(repeat), - Object::New(call_obj).Get()); + Object::New(call_obj).get()); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -541,7 +541,7 @@ static auto PyNewActivity(PyObject* self, PyObject* args, PyObject* keywds) settings = g_core->python->objs() .Get(core::CorePython::ObjID::kShallowCopyCall) .Call(args2); - if (!settings.Exists()) { + if (!settings.exists()) { throw Exception("Unable to shallow-copy settings."); } } else { @@ -552,7 +552,7 @@ static auto PyNewActivity(PyObject* self, PyObject* args, PyObject* keywds) if (!hs) { throw Exception("No HostSession found.", PyExcType::kContext); } - return hs->NewHostActivity(activity_type_obj, settings.Get()); + return hs->NewHostActivity(activity_type_obj, settings.get()); BA_PYTHON_CATCH; } @@ -1347,7 +1347,7 @@ static auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) "id", id_val), PythonRef::kSteal); // This increments ref. - PyList_Append(py_player_list.Get(), py_player.Get()); + PyList_Append(py_player_list.get(), py_player.get()); } } } @@ -1393,11 +1393,11 @@ static auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) ? PlayerSpec(spec->valuestring).GetDisplayString().c_str() : "", "spec_string", (spec && spec->valuestring) ? spec->valuestring : "", - "players", py_player_list.Get(), "client_id", client_id_ref.Get(), - "account_id", account_id_ref.Get()), + "players", py_player_list.get(), "client_id", client_id_ref.get(), + "account_id", account_id_ref.get()), PythonRef::kSteal); - PyList_Append(py_client_list.Get(), - py_client.Get()); // this increments ref + PyList_Append(py_client_list.get(), + py_client.get()); // this increments ref } return py_client_list.NewRef(); BA_PYTHON_CATCH; diff --git a/src/ballistica/scene_v1/python/scene_v1_python.cc b/src/ballistica/scene_v1/python/scene_v1_python.cc index 0149a238..13bbef38 100644 --- a/src/ballistica/scene_v1/python/scene_v1_python.cc +++ b/src/ballistica/scene_v1/python/scene_v1_python.cc @@ -637,7 +637,7 @@ auto SceneV1Python::IsPyHostActivity(PyObject* o) -> bool { int result = PyObject_IsInstance(o, g_scene_v1->python->objs() .Get(SceneV1Python::ObjID::kActivityClass) - .Get()); + .get()); if (result == -1) { result = 0; PyErr_Clear(); @@ -702,9 +702,9 @@ auto SceneV1Python::GetPyNodes(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -743,9 +743,9 @@ auto SceneV1Python::GetPyMaterials(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -785,9 +785,9 @@ auto SceneV1Python::GetPySceneTextures(PyObject* o) throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -827,9 +827,9 @@ auto SceneV1Python::GetPySceneMeshes(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -844,7 +844,7 @@ auto SceneV1Python::IsPyPlayer(PyObject* o) -> bool { int result = PyObject_IsInstance( o, - g_scene_v1->python->objs().Get(SceneV1Python::ObjID::kPlayerClass).Get()); + g_scene_v1->python->objs().Get(SceneV1Python::ObjID::kPlayerClass).get()); if (result == -1) { result = 0; PyErr_Clear(); @@ -897,7 +897,7 @@ auto SceneV1Python::ValidatedPackageAssetName(PyObject* package, if (!PyObject_IsInstance(package, g_scene_v1->python->objs() .Get(SceneV1Python::ObjID::kAssetPackageClass) - .Get())) { + .get())) { throw Exception("Object is not an AssetPackage.", PyExcType::kType); } @@ -905,15 +905,15 @@ auto SceneV1Python::ValidatedPackageAssetName(PyObject* package, // Now validate that its context is current... PythonRef context_obj(PyObject_GetAttrString(package, "context_ref"), PythonRef::kSteal); - if (!context_obj.Exists() - || !(PyObject_IsInstance(context_obj.Get(), + if (!context_obj.exists() + || !(PyObject_IsInstance(context_obj.get(), reinterpret_cast( &base::PythonClassContextRef::type_obj)))) { throw Exception("Asset package context_ref not found.", PyExcType::kNotFound); } auto* pycontext = - reinterpret_cast(context_obj.Get()); + reinterpret_cast(context_obj.get()); auto* ctargetref = pycontext->context_ref().Get(); if (!ctargetref) { throw Exception("Asset package context_ref does not exist.", @@ -928,14 +928,14 @@ auto SceneV1Python::ValidatedPackageAssetName(PyObject* package, // Ok; now pull the package id... PythonRef package_id(PyObject_GetAttrString(package, "package_id"), PythonRef::kSteal); - if (!PyUnicode_Check(package_id.Get())) { + if (!PyUnicode_Check(package_id.get())) { throw Exception("Got non-string AssetPackage ID.", PyExcType::kType); } // TODO(ericf): make sure the package is valid for this context, // and return a fully qualified name with the package included. - printf("would give %s:%s\n", PyUnicode_AsUTF8(package_id.Get()), name); + printf("would give %s:%s\n", PyUnicode_AsUTF8(package_id.get()), name); return name; } @@ -969,9 +969,9 @@ auto SceneV1Python::GetPySceneSounds(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -1012,9 +1012,9 @@ auto SceneV1Python::GetPySceneCollisionMeshes(PyObject* o) throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.Get())); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + auto size = static_cast(PySequence_Fast_GET_SIZE(sequence.get())); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(size); assert(vals.size() == size); for (size_t i = 0; i < size; i++) { @@ -1030,7 +1030,7 @@ auto SceneV1Python::IsPySession(PyObject* o) -> bool { int result = PyObject_IsInstance( o, g_scene_v1->python->objs() .Get(SceneV1Python::ObjID::kSceneV1SessionClass) - .Get()); + .get()); if (result == -1) { PyErr_Clear(); result = 0; @@ -1128,18 +1128,18 @@ auto SceneV1Python::FilterChatMessage(std::string* message, int client_id) PythonRef result = objs().Get(ObjID::kFilterChatMessageCall).Call(args); // If something went wrong, just allow all messages through verbatim. - if (!result.Exists()) { + if (!result.exists()) { return true; } // If they returned None, they want to ignore the message. - if (result.Get() == Py_None) { + if (result.get() == Py_None) { return false; } // Replace the message string with whatever they gave us. try { - *message = g_base->python->GetPyLString(result.Get()); + *message = g_base->python->GetPyLString(result.get()); } catch (const std::exception& e) { g_core->Log( LogName::kBa, LogLevel::kError, @@ -1384,7 +1384,7 @@ auto SceneV1Python::HandleCapturedKeyReleaseCall(const SDL_Keysym& keysym) auto SceneV1Python::HandleCapturedKeyPress(const SDL_Keysym& keysym) -> bool { assert(g_base->InLogicThread()); - if (!keyboard_capture_call_.Exists()) { + if (!keyboard_capture_call_.exists()) { return false; } base::ScopedSetContext ssc(nullptr); @@ -1409,7 +1409,7 @@ auto SceneV1Python::HandleCapturedKeyPress(const SDL_Keysym& keysym) -> bool { } auto SceneV1Python::HandleCapturedKeyRelease(const SDL_Keysym& keysym) -> bool { assert(g_base->InLogicThread()); - if (!keyboard_capture_call_.Exists()) { + if (!keyboard_capture_call_.exists()) { return false; } base::ScopedSetContext ssc(nullptr); @@ -1438,7 +1438,7 @@ auto SceneV1Python::HandleCapturedJoystickEvent(const SDL_Event& event, -> bool { assert(g_base->InLogicThread()); assert(input_device != nullptr); - if (!joystick_capture_call_.Exists()) { + if (!joystick_capture_call_.exists()) { return false; } // This currently only works with the scene_v1 input-device classes. diff --git a/src/ballistica/scene_v1/support/client_input_device.h b/src/ballistica/scene_v1/support/client_input_device.h index 9b9a295e..4408e5b6 100644 --- a/src/ballistica/scene_v1/support/client_input_device.h +++ b/src/ballistica/scene_v1/support/client_input_device.h @@ -24,7 +24,7 @@ class ClientInputDevice : public base::InputDevice { InputCommand(type, value); } auto connection_to_client() const -> ConnectionToClient* { - return connection_to_client_.Get(); + return connection_to_client_.get(); } auto remote_device_id() const { return remote_device_id_; } diff --git a/src/ballistica/scene_v1/support/client_input_device_delegate.cc b/src/ballistica/scene_v1/support/client_input_device_delegate.cc index 9f63cde2..56d49636 100644 --- a/src/ballistica/scene_v1/support/client_input_device_delegate.cc +++ b/src/ballistica/scene_v1/support/client_input_device_delegate.cc @@ -13,13 +13,13 @@ namespace ballistica::scene_v1 { void ClientInputDeviceDelegate::StoreClientDeviceInfo( ClientInputDevice* device) { - assert(!connection_to_client_.Exists()); + assert(!connection_to_client_.exists()); connection_to_client_ = device->connection_to_client(); remote_device_id_ = device->remote_device_id(); } void ClientInputDeviceDelegate::AttachToLocalPlayer(Player* player) { - if (ConnectionToClient* c = connection_to_client_.Get()) { + if (ConnectionToClient* c = connection_to_client_.get()) { // Send a new-style message with a 32 bit player-id. // (added during protocol 29; not always present) { @@ -52,7 +52,7 @@ void ClientInputDeviceDelegate::AttachToLocalPlayer(Player* player) { void ClientInputDeviceDelegate::DetachFromPlayer() { // Tell the client that their device is no longer attached to a player. - if (ConnectionToClient* c = connection_to_client_.Get()) { + if (ConnectionToClient* c = connection_to_client_.get()) { std::vector data(2); data[0] = BA_MESSAGE_DETACH_REMOTE_PLAYER; data[1] = static_cast_check_fit(remote_device_id_); @@ -62,7 +62,7 @@ void ClientInputDeviceDelegate::DetachFromPlayer() { } auto ClientInputDeviceDelegate::GetClientID() const -> int { - if (ConnectionToClient* c = connection_to_client_.Get()) { + if (ConnectionToClient* c = connection_to_client_.get()) { return c->id(); } else { g_core->Log( @@ -75,7 +75,7 @@ auto ClientInputDeviceDelegate::GetClientID() const -> int { auto ClientInputDeviceDelegate::GetPublicV1AccountID() const -> std::string { assert(g_base->InLogicThread()); - if (connection_to_client_.Exists()) { + if (connection_to_client_.exists()) { return connection_to_client_->peer_public_account_id(); } return ""; @@ -83,7 +83,7 @@ auto ClientInputDeviceDelegate::GetPublicV1AccountID() const -> std::string { auto ClientInputDeviceDelegate::GetAccountName(bool full) const -> std::string { assert(g_base->InLogicThread()); - if (connection_to_client_.Exists()) { + if (connection_to_client_.exists()) { if (full) { return connection_to_client_->peer_spec().GetDisplayString(); } else { @@ -94,7 +94,7 @@ auto ClientInputDeviceDelegate::GetAccountName(bool full) const -> std::string { } auto ClientInputDeviceDelegate::GetPlayerProfiles() const -> PyObject* { - if (connection_to_client_.Exists()) { + if (connection_to_client_.exists()) { return connection_to_client_->GetPlayerProfiles(); } return nullptr; diff --git a/src/ballistica/scene_v1/support/client_input_device_delegate.h b/src/ballistica/scene_v1/support/client_input_device_delegate.h index ba0c9b5a..eede216f 100644 --- a/src/ballistica/scene_v1/support/client_input_device_delegate.h +++ b/src/ballistica/scene_v1/support/client_input_device_delegate.h @@ -14,7 +14,7 @@ class ClientInputDeviceDelegate : public SceneV1InputDeviceDelegate { void AttachToLocalPlayer(Player* player) override; void DetachFromPlayer() override; auto connection_to_client() const -> ConnectionToClient* { - return connection_to_client_.Get(); + return connection_to_client_.get(); } void StoreClientDeviceInfo(ClientInputDevice* device); diff --git a/src/ballistica/scene_v1/support/client_session.cc b/src/ballistica/scene_v1/support/client_session.cc index 63759afa..a63a4ef3 100644 --- a/src/ballistica/scene_v1/support/client_session.cc +++ b/src/ballistica/scene_v1/support/client_session.cc @@ -56,7 +56,7 @@ auto ClientSession::DoesFillScreen() const -> bool { // Look for any scene that has something that covers the background. // NOLINTNEXTLINE(readability-use-anyofallof) for (const auto& scene : scenes_) { - if ((scene.Exists()) && (*scene).has_bg_cover()) { + if ((scene.exists()) && (*scene).has_bg_cover()) { return true; } } @@ -70,7 +70,7 @@ void ClientSession::Draw(base::FrameDef* f) { // in a host-session we draw session first followed by activities // (that should be the same order in both cases, but just something to keep // in mind...) - if (i.Exists()) { + if (i.exists()) { i->Draw(f); } } @@ -249,7 +249,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { offset += 4; int body_count = current_cmd_[offset++]; Node* n = - (node_id < nodes_.size()) ? nodes_[node_id].Get() : nullptr; + (node_id < nodes_.size()) ? nodes_[node_id].get() : nullptr; for (int j = 0; j < body_count; j++) { int bodyid = current_cmd_[offset++]; uint16_t body_data_len; @@ -319,7 +319,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(scenes_.size()) < (id + 1)) { scenes_.resize(static_cast(id) + 1); } - assert(!scenes_[id].Exists()); + assert(!scenes_[id].exists()); scenes_[id] = Object::New(starttime); scenes_[id]->set_stream_id(id); break; @@ -358,7 +358,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(nodes_.size()) < (id + 1)) { nodes_.resize(static_cast(id) + 1); } - assert(!nodes_[id].Exists()); + assert(!nodes_[id].exists()); { base::ScopedSetContext ssc(this); nodes_[id] = scene->NewNode(node_type->name(), "", nullptr); @@ -416,7 +416,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(materials_.size()) < (id + 1)) { materials_.resize(static_cast(id) + 1); } - assert(!materials_[id].Exists()); + assert(!materials_[id].exists()); materials_[id] = Object::New("", scene); materials_[id]->stream_id_ = id; break; @@ -459,7 +459,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(textures_.size()) < (id + 1)) { textures_.resize(static_cast(id) + 1); } - assert(!textures_[id].Exists()); + assert(!textures_[id].exists()); textures_[id] = Object::New(name, scene); textures_[id]->set_stream_id(id); break; @@ -485,7 +485,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(meshes_.size()) < (id + 1)) { meshes_.resize(static_cast(id) + 1); } - assert(!meshes_[id].Exists()); + assert(!meshes_[id].exists()); meshes_[id] = Object::New(name, scene); meshes_[id]->set_stream_id(id); break; @@ -510,7 +510,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(sounds_.size()) < (id + 1)) { sounds_.resize(static_cast(id) + 1); } - assert(!sounds_[id].Exists()); + assert(!sounds_[id].exists()); sounds_[id] = Object::New(name, scene); sounds_[id]->set_stream_id(id); break; @@ -536,7 +536,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (static_cast(collision_meshes_.size()) < (id + 1)) { collision_meshes_.resize(static_cast(id) + 1); } - assert(!collision_meshes_[id].Exists()); + assert(!collision_meshes_[id].exists()); collision_meshes_[id] = Object::New(name, scene); collision_meshes_[id]->set_stream_id(id); break; @@ -551,7 +551,7 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { int id = ReadInt32(); Node* n = GetNode(id); n->scene()->DeleteNode(n); - assert(!nodes_[id].Exists()); + assert(!nodes_[id].exists()); break; } case SessionCommand::kSetNodeAttrFloat: { @@ -883,7 +883,7 @@ ClientSession::~ClientSession() = default; void ClientSession::OnScreenSizeChange() { // Let all our scenes know. for (auto&& i : scenes_) { - if (Scene* sg = i.Get()) { + if (Scene* sg = i.get()) { sg->OnScreenSizeChange(); } } @@ -892,7 +892,7 @@ void ClientSession::OnScreenSizeChange() { void ClientSession::LanguageChanged() { // Let all our scenes know. for (auto&& i : scenes_) { - if (Scene* sg = i.Get()) { + if (Scene* sg = i.get()) { sg->LanguageChanged(); } } @@ -902,7 +902,7 @@ auto ClientSession::GetScene(int id) const -> Scene* { if (id < 0 || id >= static_cast(scenes_.size())) { throw Exception("Invalid scene id"); } - Scene* sg = scenes_[id].Get(); + Scene* sg = scenes_[id].get(); if (!sg) { throw Exception("Invalid scene id"); } @@ -912,7 +912,7 @@ auto ClientSession::GetNode(int id) const -> Node* { if (id < 0 || id >= static_cast(nodes_.size())) { throw Exception("Invalid node (out of range)"); } - Node* n = nodes_[id].Get(); + Node* n = nodes_[id].get(); if (!n) { throw Exception("Invalid node id (empty slot)"); } @@ -922,7 +922,7 @@ auto ClientSession::GetMaterial(int id) const -> Material* { if (id < 0 || id >= static_cast(materials_.size())) { throw Exception("Invalid material (out of range)"); } - Material* n = materials_[id].Get(); + Material* n = materials_[id].get(); if (!n) { throw Exception("Invalid material id (empty slot)"); } @@ -932,7 +932,7 @@ auto ClientSession::GetTexture(int id) const -> SceneTexture* { if (id < 0 || id >= static_cast(textures_.size())) { throw Exception("Invalid texture (out of range)"); } - SceneTexture* n = textures_[id].Get(); + SceneTexture* n = textures_[id].get(); if (!n) { throw Exception("Invalid texture id (empty slot)"); } @@ -942,7 +942,7 @@ auto ClientSession::GetMesh(int id) const -> SceneMesh* { if (id < 0 || id >= static_cast(meshes_.size())) { throw Exception("Invalid mesh (out of range)"); } - SceneMesh* n = meshes_[id].Get(); + SceneMesh* n = meshes_[id].get(); if (!n) { throw Exception("Invalid mesh id (empty slot)"); } @@ -952,7 +952,7 @@ auto ClientSession::GetSound(int id) const -> SceneSound* { if (id < 0 || id >= static_cast(sounds_.size())) { throw Exception("Invalid sound (out of range)"); } - SceneSound* n = sounds_[id].Get(); + SceneSound* n = sounds_[id].get(); if (!n) { throw Exception("Invalid sound id (empty slot)"); } @@ -962,7 +962,7 @@ auto ClientSession::GetCollisionMesh(int id) const -> SceneCollisionMesh* { if (id < 0 || id >= static_cast(collision_meshes_.size())) { throw Exception("Invalid collision_mesh (out of range)"); } - SceneCollisionMesh* n = collision_meshes_[id].Get(); + SceneCollisionMesh* n = collision_meshes_[id].get(); if (!n) { throw Exception("Invalid collision_mesh id (empty slot)"); } @@ -1074,7 +1074,7 @@ void ClientSession::GetCorrectionMessages( bool blend, std::vector >* messages) { std::vector message; for (auto&& i : scenes_) { - if (Scene* sg = i.Get()) { + if (Scene* sg = i.get()) { message = sg->GetCorrectionMessage(blend); // A correction packet of size 4 is empty; ignore it. if (message.size() > 4) { @@ -1087,7 +1087,7 @@ void ClientSession::GetCorrectionMessages( void ClientSession::DumpFullState(SessionStream* out) { // Add all scenes. for (auto&& i : scenes()) { - if (Scene* sg = i.Get()) { + if (Scene* sg = i.get()) { sg->Dump(out); } } @@ -1096,36 +1096,36 @@ void ClientSession::DumpFullState(SessionStream* out) { // (but *not* their components, which may reference the nodes that we haven't // made yet) for (auto&& i : materials()) { - if (Material* m = i.Get()) { + if (Material* m = i.get()) { out->AddMaterial(m); } } // Add all media. for (auto&& i : textures()) { - if (SceneTexture* t = i.Get()) { + if (SceneTexture* t = i.get()) { out->AddTexture(t); } } for (auto&& i : meshes()) { - if (SceneMesh* s = i.Get()) { + if (SceneMesh* s = i.get()) { out->AddMesh(s); } } for (auto&& i : sounds()) { - if (SceneSound* s = i.Get()) { + if (SceneSound* s = i.get()) { out->AddSound(s); } } for (auto&& i : collision_meshes()) { - if (SceneCollisionMesh* s = i.Get()) { + if (SceneCollisionMesh* s = i.get()) { out->AddCollisionMesh(s); } } // Add all scene nodes. for (auto&& i : scenes()) { - if (Scene* sg = i.Get()) { + if (Scene* sg = i.get()) { sg->DumpNodes(out); } } @@ -1133,7 +1133,7 @@ void ClientSession::DumpFullState(SessionStream* out) { // Now fill out materials since we know all the nodes/etc. that they // refer to exist. for (auto&& i : materials()) { - if (Material* m = i.Get()) { + if (Material* m = i.get()) { m->DumpComponents(out); } } diff --git a/src/ballistica/scene_v1/support/client_session_net.h b/src/ballistica/scene_v1/support/client_session_net.h index 7a6a213f..90761cbf 100644 --- a/src/ballistica/scene_v1/support/client_session_net.h +++ b/src/ballistica/scene_v1/support/client_session_net.h @@ -15,7 +15,7 @@ class ClientSessionNet : public ClientSession { ClientSessionNet(); ~ClientSessionNet() override; auto connection_to_host() const -> ConnectionToHost* { - return connection_to_host_.Get(); + return connection_to_host_.get(); } void SetConnectionToHost(ConnectionToHost* c); void HandleSessionMessage(const std::vector& buffer) override; diff --git a/src/ballistica/scene_v1/support/host_activity.cc b/src/ballistica/scene_v1/support/host_activity.cc index 951d9b1d..a5942202 100644 --- a/src/ballistica/scene_v1/support/host_activity.cc +++ b/src/ballistica/scene_v1/support/host_activity.cc @@ -36,7 +36,7 @@ HostActivity::HostActivity(HostSession* host_session) { // If there's an output stream, add to it. if (SessionStream* out = host_session->GetSceneStream()) { - out->AddScene(scene_.Get()); + out->AddScene(scene_.get()); } } } @@ -52,41 +52,41 @@ HostActivity::~HostActivity() { // (should wipe out refs to our activity and prevent them from running without // a valid activity context) for (auto&& i : context_calls_) { - if (i.Exists()) { + if (i.exists()) { i->MarkDead(); } } // Mark all our media dead to clear it out of our output-stream cleanly for (auto&& i : textures_) { - if (i.second.Exists()) { + if (i.second.exists()) { i.second->MarkDead(); } } for (auto&& i : meshes_) { - if (i.second.Exists()) { + if (i.second.exists()) { i.second->MarkDead(); } } for (auto&& i : sounds_) { - if (i.second.Exists()) { + if (i.second.exists()) { i.second->MarkDead(); } } for (auto&& i : collision_meshes_) { - if (i.second.Exists()) { + if (i.second.exists()) { i.second->MarkDead(); } } for (auto&& i : materials_) { - if (i.Exists()) { + if (i.exists()) { i->MarkDead(); } } // If the host-session is outliving us, kill all the base-timers we created // in it. - if (auto* host_session = host_session_.Get()) { + if (auto* host_session = host_session_.get()) { for (auto timer_id : session_base_timer_ids_) { host_session->DeleteTimer(TimeType::kBase, timer_id); } @@ -117,7 +117,7 @@ HostActivity::~HostActivity() { } auto HostActivity::GetSceneStream() const -> SessionStream* { - if (!host_session_.Exists()) return nullptr; + if (!host_session_.exists()) return nullptr; return host_session_->GetSceneStream(); } @@ -134,9 +134,9 @@ void HostActivity::StepScene() { // Clear our player-positions for this step. // FIXME: Move this to scene and/or player node. - assert(host_session_.Exists()); + assert(host_session_.exists()); for (auto&& player : host_session_->players()) { - assert(player.Exists()); + assert(player.exists()); player->set_have_position(false); } @@ -176,7 +176,7 @@ void HostActivity::Start() { "HostActivity::Start() called for shutting-down activity."); return; } - auto* host_session = host_session_.Get(); + auto* host_session = host_session_.get(); if (!host_session) { g_core->Log(LogName::kBa, LogLevel::kError, "HostActivity::Start() called with dead session."); @@ -185,7 +185,7 @@ void HostActivity::Start() { // Create our step timer - gets called whenever scene should step. step_scene_timer_id_ = host_session->NewTimer(TimeType::kBase, kGameStepMilliseconds, true, - NewLambdaRunnable([this] { StepScene(); }).Get()); + NewLambdaRunnable([this] { StepScene(); }).get()); session_base_timer_ids_.push_back(step_scene_timer_id_); UpdateStepTimerLength(); } @@ -267,7 +267,7 @@ void HostActivity::UpdateStepTimerLength() { return; } auto* appmode = classic::ClassicAppMode::GetActiveOrFatal(); - auto* host_session = host_session_.Get(); + auto* host_session = host_session_.get(); if (!host_session) { return; } @@ -297,7 +297,7 @@ void HostActivity::HandleOutOfBoundsNodes() { int j = 0; for (auto&& i : scene()->out_of_bounds_nodes()) { j++; - Node* n = i.Get(); + Node* n = i.get(); if (n) { std::string dstr; PyObject* delegate = n->GetDelegate(); @@ -307,7 +307,7 @@ void HostActivity::HandleOutOfBoundsNodes() { g_core->Log(LogName::kBa, LogLevel::kWarning, " node #" + std::to_string(j) + ": type='" + n->type()->name() - + "' addr=" + Utils::PtrToString(i.Get()) + " name='" + + "' addr=" + Utils::PtrToString(i.get()) + " name='" + n->label() + "' delegate=" + dstr); } } @@ -316,7 +316,7 @@ void HostActivity::HandleOutOfBoundsNodes() { // Send out-of-bounds messages to newly out-of-bounds nodes. for (auto&& i : scene()->out_of_bounds_nodes()) { - Node* n = i.Get(); + Node* n = i.get(); if (n) { n->DispatchOutOfBoundsMessage(); } @@ -325,14 +325,14 @@ void HostActivity::HandleOutOfBoundsNodes() { void HostActivity::RegisterPyActivity(PyObject* pyActivityObj) { assert(pyActivityObj && pyActivityObj != Py_None); - assert(!py_activity_weak_ref_.Exists()); + assert(!py_activity_weak_ref_.exists()); // Store a python weak-ref to this activity. py_activity_weak_ref_.Steal(PyWeakref_NewRef(pyActivityObj, nullptr)); } auto HostActivity::GetPyActivity() const -> PyObject* { - PyObject* obj = py_activity_weak_ref_.Get(); + PyObject* obj = py_activity_weak_ref_.get(); if (!obj) { return Py_None; } @@ -340,11 +340,11 @@ auto HostActivity::GetPyActivity() const -> PyObject* { } auto HostActivity::GetHostSession() -> HostSession* { - return host_session_.Get(); + return host_session_.get(); } auto HostActivity::GetMutableScene() -> Scene* { - Scene* sg = scene_.Get(); + Scene* sg = scene_.get(); assert(sg); return sg; } @@ -361,13 +361,13 @@ void HostActivity::SetIsForeground(bool val) { // Also push it to clients. if (SessionStream* out = GetSceneStream()) { - out->SetForegroundScene(scene_.Get()); + out->SetForegroundScene(scene_.get()); } } } auto HostActivity::globals_node() const -> GlobalsNode* { - return globals_node_.Get(); + return globals_node_.get(); } auto HostActivity::NewSimTimer(millisecs_t length, bool repeat, @@ -404,7 +404,7 @@ auto HostActivity::NewBaseTimer(millisecs_t length, bool repeat, if (length < 0) { throw Exception("Timer length cannot be < 0"); } - auto* host_session = host_session_.Get(); + auto* host_session = host_session_.get(); if (!host_session) { BA_LOG_PYTHON_TRACE_ONCE( "WARNING: Creating session-time timer in activity but host is dead."); @@ -431,7 +431,7 @@ void HostActivity::DeleteBaseTimer(int timer_id) { if (shutting_down_) { return; } - if (auto* host_session = host_session_.Get()) { + if (auto* host_session = host_session_.get()) { host_session->DeleteTimer(TimeType::kBase, timer_id); } } @@ -460,7 +460,7 @@ void HostActivity::StepDisplayTime(millisecs_t time_advance) { } void HostActivity::PruneSessionBaseTimers() { - auto* host_session = host_session_.Get(); + auto* host_session = host_session_.get(); if (!host_session) { return; } @@ -501,7 +501,7 @@ void HostActivity::Draw(base::FrameDef* frame_def) { void HostActivity::DumpFullState(SessionStream* out) { // Add our scene. - if (scene_.Exists()) { + if (scene_.exists()) { scene_->Dump(out); } @@ -509,42 +509,42 @@ void HostActivity::DumpFullState(SessionStream* out) { // (but *not* their components, which may reference the nodes that we haven't // made yet) for (auto&& i : materials_) { - if (Material* m = i.Get()) { + if (Material* m = i.get()) { out->AddMaterial(m); } } // Add our media. for (auto&& i : textures_) { - if (SceneTexture* t = i.second.Get()) { + if (SceneTexture* t = i.second.get()) { out->AddTexture(t); } } for (auto&& i : sounds_) { - if (SceneSound* s = i.second.Get()) { + if (SceneSound* s = i.second.get()) { out->AddSound(s); } } for (auto&& i : meshes_) { - if (SceneMesh* s = i.second.Get()) { + if (SceneMesh* s = i.second.get()) { out->AddMesh(s); } } for (auto&& i : collision_meshes_) { - if (SceneCollisionMesh* m = i.second.Get()) { + if (SceneCollisionMesh* m = i.second.get()) { out->AddCollisionMesh(m); } } // Add scene's nodes. - if (scene_.Exists()) { + if (scene_.exists()) { scene_->DumpNodes(out); } // Ok, now we can fill out our materials since nodes/etc they reference // exists. for (auto&& i : materials_) { - if (Material* m = i.Get()) { + if (Material* m = i.get()) { m->DumpComponents(out); } } diff --git a/src/ballistica/scene_v1/support/host_activity.h b/src/ballistica/scene_v1/support/host_activity.h index f75927f6..85c2cfc0 100644 --- a/src/ballistica/scene_v1/support/host_activity.h +++ b/src/ballistica/scene_v1/support/host_activity.h @@ -45,8 +45,8 @@ class HostActivity : public SceneV1Context { void StepDisplayTime(millisecs_t time_advance); auto base_time() const -> millisecs_t { return base_time_; } auto scene() -> Scene* { - assert(scene_.Exists()); - return scene_.Get(); + assert(scene_.exists()); + return scene_.get(); } void Start(); diff --git a/src/ballistica/scene_v1/support/host_session.cc b/src/ballistica/scene_v1/support/host_session.cc index 6bed358a..25340fa2 100644 --- a/src/ballistica/scene_v1/support/host_session.cc +++ b/src/ballistica/scene_v1/support/host_session.cc @@ -46,7 +46,7 @@ HostSession::HostSession(PyObject* session_type_obj) // Create a timer to step our session scene. step_scene_timer_ = base_timers_.NewTimer(base_time_millisecs_, kGameStepMilliseconds, 0, -1, - NewLambdaRunnable([this] { StepScene(); }).Get()); + NewLambdaRunnable([this] { StepScene(); }).get()); // Set up our output-stream, which will go to a replay and/or the network. // We don't dump to a replay if we're doing the main menu; that replay @@ -62,8 +62,8 @@ HostSession::HostSession(PyObject* session_type_obj) // Make a scene for our session-level nodes, etc. scene_ = Object::New(0); - if (output_stream_.Exists()) { - output_stream_->AddScene(scene_.Get()); + if (output_stream_.exists()) { + output_stream_->AddScene(scene_.get()); } // Fade in from our current blackness. @@ -86,7 +86,7 @@ HostSession::HostSession(PyObject* session_type_obj) Python::ScopedCallLabel label("Session instantiation"); obj = session_type.Call(); } - if (!obj.Exists()) { + if (!obj.exists()) { throw Exception("Error creating game session: '" + session_type.Str() + "'"); } @@ -107,13 +107,13 @@ auto HostSession::GetHostSession() -> HostSession* { return this; } void HostSession::DestroyHostActivity(HostActivity* a) { BA_PRECONDITION(a); BA_PRECONDITION(a->GetHostSession() == this); - if (a == foreground_host_activity_.Get()) { + if (a == foreground_host_activity_.get()) { foreground_host_activity_.Clear(); } // Clear it from our activities list if its still on there. for (auto i = host_activities_.begin(); i < host_activities_.end(); i++) { - if (i->Get() == a) { + if (i->get() == a) { host_activities_.erase(i); return; } @@ -126,8 +126,8 @@ void HostSession::DestroyHostActivity(HostActivity* a) { } auto HostSession::GetMutableScene() -> Scene* { - assert(scene_.Exists()); - return scene_.Get(); + assert(scene_.exists()); + return scene_.get(); } void HostSession::DebugSpeedMultChanged() { @@ -206,7 +206,7 @@ auto HostSession::GetMesh(const std::string& name) -> Object::Ref { } auto HostSession::GetForegroundContext() -> base::ContextRef { - HostActivity* a = foreground_host_activity_.Get(); + HostActivity* a = foreground_host_activity_.get(); if (a) { return base::ContextRef(a); } @@ -229,7 +229,7 @@ void HostSession::RequestPlayer(SceneV1InputDeviceDelegate* device) { int player_id = next_player_id_++; auto player(Object::New(player_id, this)); players_.push_back(player); - device->AttachToLocalPlayer(player.Get()); + device->AttachToLocalPlayer(player.get()); // Ask the python layer to accept/deny this guy. bool accept; @@ -244,7 +244,7 @@ void HostSession::RequestPlayer(SceneV1InputDeviceDelegate* device) { if (accept) { player->set_accepted(true); } else { - RemovePlayer(player.Get()); + RemovePlayer(player.get()); } } @@ -268,7 +268,7 @@ void HostSession::RemovePlayer(Player* player) { // then the player will still try to remove themself from their session // as they are going down). for (auto i = players_.begin(); i != players_.end(); ++i) { - if (i->Get() == player) { + if (i->get() == player) { // Grab a ref to keep the player alive, pull him off the list, then call // his leaving callback. auto player2 = Object::Ref(*i); @@ -280,7 +280,7 @@ void HostSession::RemovePlayer(Player* player) { // Only make the callback for this player if they were accepted. if (player2->accepted()) { - IssuePlayerLeft(player2.Get()); + IssuePlayerLeft(player2.get()); } // Update our game roster with the departure. @@ -387,9 +387,9 @@ auto HostSession::NewHostActivity(PyObject* activity_type_obj, // First generate our C++ activity instance and point the context at it. auto activity(Object::New(this)); - AddHostActivity(activity.Get()); + AddHostActivity(activity.get()); - base::ScopedSetContext ssc(activity.Get()); + base::ScopedSetContext ssc(activity.get()); // Now instantiate the Python instance.. pass args if some were provided, or // an empty dict otherwise. @@ -401,18 +401,18 @@ auto HostSession::NewHostActivity(PyObject* activity_type_obj, } PythonRef result = activity_type.Call(args); - if (!result.Exists()) { + if (!result.exists()) { throw Exception("HostActivity creation failed"); } // If all went well, the python activity constructor should have called // register_activity(), so we should be able to get at the same python // activity we just instantiated through the c++ class. - if (activity->GetPyActivity() != result.Get()) { + if (activity->GetPyActivity() != result.get()) { throw Exception("Error on HostActivity construction"); } - PyObject* obj = result.Get(); + PyObject* obj = result.get(); Py_INCREF(obj); return obj; } @@ -431,7 +431,7 @@ auto HostSession::RegisterPyActivity(PyObject* activity_obj) -> HostActivity* { void HostSession::DecrementPlayerTimeOuts(millisecs_t millisecs) { for (auto&& i : players_) { - Player* player = i.Get(); + Player* player = i.get(); assert(player); if (player->time_out() < millisecs) { std::string kick_str = @@ -458,7 +458,7 @@ void HostSession::DecrementPlayerTimeOuts(millisecs_t millisecs) { void HostSession::ProcessPlayerTimeOuts() { millisecs_t real_time = g_core->GetAppTimeMillisecs(); - if (foreground_host_activity_.Exists() + if (foreground_host_activity_.exists() && foreground_host_activity_->game_speed() > 0.0 && !foreground_host_activity_->paused() && foreground_host_activity_->getAllowKickIdlePlayers() @@ -521,7 +521,7 @@ void HostSession::Update(int time_advance_millisecs, double time_advance) { // We can be killed at any time, so let's keep an eye out for that. WeakRef test_ref(this); - assert(test_ref.Exists()); + assert(test_ref.exists()); ProcessPlayerTimeOuts(); @@ -560,17 +560,17 @@ void HostSession::Update(int time_advance_millisecs, double time_advance) { output_stream->SetTime(base_time_millisecs_); } } - assert(test_ref.Exists()); + assert(test_ref.exists()); // Let our activities update too (iterate via weak-refs as this list may // change under us at any time). for (auto&& i : PointersToWeakRefs(RefsToPointers(host_activities_))) { - if (i.Exists()) { + if (i.exists()) { i->StepDisplayTime(time_advance_millisecs); - assert(test_ref.Exists()); + assert(test_ref.exists()); } } - assert(test_ref.Exists()); + assert(test_ref.exists()); // Periodically prune various dead refs. if (base_time_millisecs_ > next_prune_time_) { @@ -580,7 +580,7 @@ void HostSession::Update(int time_advance_millisecs, double time_advance) { PruneDeadRefs(&python_calls_); next_prune_time_ = base_time_millisecs_ + 5000; } - assert(test_ref.Exists()); + assert(test_ref.exists()); } auto HostSession::TimeToNextEvent() -> std::optional { @@ -609,24 +609,24 @@ HostSession::~HostSession() { // (should wipe out refs to our session and prevent them from running // without a valid session context). for (auto&& i : python_calls_) { - if (auto* j = i.Get()) { + if (auto* j = i.get()) { j->MarkDead(); } } // Mark all our media dead to clear it out of our output-stream cleanly. for (auto&& i : textures_) { - if (auto* j = i.second.Get()) { + if (auto* j = i.second.get()) { j->MarkDead(); } } for (auto&& i : meshes_) { - if (auto* j = i.second.Get()) { + if (auto* j = i.second.get()) { j->MarkDead(); } } for (auto&& i : sounds_) { - if (auto* j = i.second.Get()) { + if (auto* j = i.second.get()) { j->MarkDead(); } } @@ -709,7 +709,7 @@ auto HostSession::GetUnusedPlayerName(Player* p, const std::string& base_name) } bool name_found = false; for (auto&& j : players_) { - if ((j->GetName() == name_test) && (j.Get() != p)) { + if ((j->GetName() == name_test) && (j.get() != p)) { name_found = true; break; } @@ -722,29 +722,29 @@ auto HostSession::GetUnusedPlayerName(Player* p, const std::string& base_name) void HostSession::DumpFullState(SessionStream* out) { // Add session-scene. - if (scene_.Exists()) { + if (scene_.exists()) { scene_->Dump(out); } // Dump media associated with session-scene. for (auto&& i : textures_) { - if (SceneTexture* t = i.second.Get()) { + if (SceneTexture* t = i.second.get()) { out->AddTexture(t); } } for (auto&& i : sounds_) { - if (SceneSound* s = i.second.Get()) { + if (SceneSound* s = i.second.get()) { out->AddSound(s); } } for (auto&& i : meshes_) { - if (SceneMesh* s = i.second.Get()) { + if (SceneMesh* s = i.second.get()) { out->AddMesh(s); } } // Dump session-scene's nodes. - if (scene_.Exists()) { + if (scene_.exists()) { scene_->DumpNodes(out); } @@ -759,7 +759,7 @@ void HostSession::GetCorrectionMessages( std::vector message; // Grab correction for session scene (though there shouldn't be one). - if (scene_.Exists()) { + if (scene_.exists()) { message = scene_->GetCorrectionMessage(blend); if (message.size() > 4) { // A correction packet of size 4 is empty; ignore it. @@ -769,7 +769,7 @@ void HostSession::GetCorrectionMessages( // Now do same for activity scenes. for (auto&& i : host_activities_) { - if (HostActivity* ha = i.Get()) { + if (HostActivity* ha = i.get()) { if (Scene* sg = ha->scene()) { message = sg->GetCorrectionMessage(blend); if (message.size() > 4) { diff --git a/src/ballistica/scene_v1/support/host_session.h b/src/ballistica/scene_v1/support/host_session.h index cf53cccf..def8b782 100644 --- a/src/ballistica/scene_v1/support/host_session.h +++ b/src/ballistica/scene_v1/support/host_session.h @@ -21,7 +21,7 @@ class HostSession : public Session { ~HostSession() override; // Return a borrowed python ref. - auto GetSessionPyObj() const -> PyObject* { return session_py_obj_.Get(); } + auto GetSessionPyObj() const -> PyObject* { return session_py_obj_.get(); } // Set focus to a Context (it must belong to this session). void SetForegroundHostActivity(HostActivity* sgc); @@ -74,11 +74,11 @@ class HostSession : public Session { auto GetHostSession() -> HostSession* override; auto GetMutableScene() -> Scene* override; auto scene() -> Scene* { - assert(scene_.Exists()); - return scene_.Get(); + assert(scene_.exists()); + return scene_.get(); } void RegisterContextCall(base::PythonContextCall* call) override; - auto GetSceneStream() const -> SessionStream* { return output_stream_.Get(); } + auto GetSceneStream() const -> SessionStream* { return output_stream_.get(); } auto is_main_menu() const -> bool { return is_main_menu_; } // fixme remove this diff --git a/src/ballistica/scene_v1/support/player.cc b/src/ballistica/scene_v1/support/player.cc index 78c929c1..2db8aa63 100644 --- a/src/ballistica/scene_v1/support/player.cc +++ b/src/ballistica/scene_v1/support/player.cc @@ -29,7 +29,7 @@ Player::~Player() { assert(g_base->InLogicThread()); // If we have an input-device driving us, detach it. - if (auto* delegate = input_device_delegate_.Get()) { + if (auto* delegate = input_device_delegate_.get()) { delegate->DetachFromPlayer(); } @@ -60,7 +60,7 @@ auto Player::GetName(bool full, bool icon) const -> std::string { } auto Player::GetHostActivity() const -> HostActivity* { - return host_activity_.Get(); + return host_activity_.get(); } void Player::SetHostActivity(HostActivity* a) { @@ -69,7 +69,7 @@ void Player::SetHostActivity(HostActivity* a) { // Make sure we get pulled out of one activity before being added to another. if (a && in_activity_) { std::string old_name = - host_activity_.Exists() + host_activity_.exists() ? PythonRef(host_activity_->GetPyActivity(), PythonRef::kAcquire) .Str() : ""; @@ -112,7 +112,7 @@ void Player::SetPyTeam(PyObject* team) { } auto Player::GetPyTeam() -> PyObject* { - PyObject* obj = py_team_weak_ref_.Get(); + PyObject* obj = py_team_weak_ref_.get(); if (!obj) { return Py_None; } @@ -128,22 +128,22 @@ void Player::SetPyCharacter(PyObject* character) { } auto Player::GetPyCharacter() -> PyObject* { - return py_character_.Exists() ? py_character_.Get() : Py_None; + return py_character_.exists() ? py_character_.get() : Py_None; } void Player::SetPyColor(PyObject* c) { py_color_.Acquire(c); } auto Player::GetPyColor() -> PyObject* { - return py_color_.Exists() ? py_color_.Get() : Py_None; + return py_color_.exists() ? py_color_.get() : Py_None; } void Player::SetPyHighlight(PyObject* c) { py_highlight_.Acquire(c); } auto Player::GetPyHighlight() -> PyObject* { - return py_highlight_.Exists() ? py_highlight_.Get() : Py_None; + return py_highlight_.exists() ? py_highlight_.get() : Py_None; } void Player::SetPyActivityPlayer(PyObject* c) { py_activityplayer_.Acquire(c); } auto Player::GetPyActivityPlayer() -> PyObject* { - return py_activityplayer_.Exists() ? py_activityplayer_.Get() : Py_None; + return py_activityplayer_.exists() ? py_activityplayer_.get() : Py_None; } auto Player::GetPyRef(bool new_ref) -> PyObject* { @@ -345,17 +345,17 @@ void Player::RunInput(InputType type, float value) { } auto j = calls_.find(static_cast(type)); - if (j != calls_.end() && j->second.Exists()) { + if (j != calls_.end() && j->second.exists()) { if (type == InputType::kRun) { PythonRef args( Py_BuildValue("(f)", std::min(1.0f, std::max(0.0f, value))), PythonRef::kSteal); - j->second->Run(args.Get()); + j->second->Run(args.get()); } else if (type == InputType::kLeftRight || type == InputType::kUpDown) { PythonRef args( Py_BuildValue("(f)", std::min(1.0f, std::max(-1.0f, value))), PythonRef::kSteal); - j->second->Run(args.Get()); + j->second->Run(args.get()); } else { j->second->Run(); } @@ -363,7 +363,7 @@ void Player::RunInput(InputType type, float value) { } auto Player::GetHostSession() const -> HostSession* { - return host_session_.Get(); + return host_session_.get(); } void Player::SetName(const std::string& name, const std::string& full_name, @@ -408,7 +408,7 @@ void Player::set_input_device_delegate( auto Player::GetPublicV1AccountID() const -> std::string { assert(g_base->InLogicThread()); - if (input_device_delegate_.Exists()) { + if (input_device_delegate_.exists()) { return input_device_delegate_->GetPublicV1AccountID(); } return ""; diff --git a/src/ballistica/scene_v1/support/player.h b/src/ballistica/scene_v1/support/player.h index 653db317..990825c3 100644 --- a/src/ballistica/scene_v1/support/player.h +++ b/src/ballistica/scene_v1/support/player.h @@ -43,7 +43,7 @@ class Player : public Object { /// The player node for the current activity. auto node() const -> Node* { assert(g_base->InLogicThread()); - return node_.Get(); + return node_.get(); } /// Set the player node for the current activity. void set_node(Node* node) { @@ -70,7 +70,7 @@ class Player : public Object { void set_has_py_data(bool has) { has_py_data_ = has; } auto input_device_delegate() const -> SceneV1InputDeviceDelegate* { - return input_device_delegate_.Get(); + return input_device_delegate_.get(); } void set_input_device_delegate(SceneV1InputDeviceDelegate* input_device); @@ -87,7 +87,7 @@ class Player : public Object { void SetHostActivity(HostActivity* host_activity); auto GetHostActivity() const -> HostActivity*; - auto has_py_ref() -> bool { return (py_ref_ != nullptr); } + auto HasPyRef() -> bool { return (py_ref_ != nullptr); } void SetIcon(const std::string& tex_name, const std::string& tint_tex_name, const std::vector& tint_color, diff --git a/src/ballistica/scene_v1/support/scene.cc b/src/ballistica/scene_v1/support/scene.cc index e67a8996..0293ad79 100644 --- a/src/ballistica/scene_v1/support/scene.cc +++ b/src/ballistica/scene_v1/support/scene.cc @@ -24,7 +24,7 @@ namespace ballistica::scene_v1 { auto Scene::GetSceneStream() const -> SessionStream* { - return output_stream_.Get(); + return output_stream_.get(); } void Scene::SetMapBounds(float xmin, float ymin, float zmin, float xmax, @@ -64,21 +64,21 @@ Scene::~Scene() { dynamics_.Clear(); // If we were associated with an output-stream, inform it of our demise. - if (output_stream_.Exists()) { + if (output_stream_.exists()) { output_stream_->RemoveScene(this); } } void Scene::PlaySoundAtPosition(SceneSound* sound, float volume, float x, float y, float z, bool host_only) { - if (output_stream_.Exists() && !host_only) { + if (output_stream_.exists() && !host_only) { output_stream_->PlaySoundAtPosition(sound, volume, x, y, z); } g_base->audio->PlaySoundAtPosition(sound->GetSoundData(), volume, x, y, z); } void Scene::PlaySound(SceneSound* sound, float volume, bool host_only) { - if (output_stream_.Exists() && !host_only) { + if (output_stream_.exists() && !host_only) { output_stream_->PlaySound(sound, volume); } g_base->audio->PlaySound(sound->GetSoundData(), volume); @@ -132,7 +132,7 @@ void Scene::SetPlayerNode(int id, PlayerNode* n) { player_nodes_[id] = n; } auto Scene::GetPlayerNode(int id) -> PlayerNode* { auto i = player_nodes_.find(id); if (i != player_nodes_.end()) { - return i->second.Get(); + return i->second.get(); } return nullptr; } @@ -147,7 +147,7 @@ void Scene::Step() { in_step_ = true; last_step_real_time_ = g_core->GetAppTimeMillisecs(); for (auto&& i : nodes_) { - Node* node = i.Get(); + Node* node = i.get(); node->Step(); // Now that it's stepped, pump new values to any nodes it's connected to. @@ -158,7 +158,7 @@ void Scene::Step() { bool is_foreground = (appmode->GetForegroundScene() == this); // Add a step command to the output stream. - if (output_stream_.Exists()) { + if (output_stream_.exists()) { output_stream_->StepScene(this); } @@ -203,7 +203,7 @@ void Scene::DeleteNode(Node* node) { // Sanity test to make sure it dies when we ask. #if BA_DEBUG_BUILD Object::WeakRef temp_weak_ref(node); - BA_PRECONDITION(temp_weak_ref.Exists()); + BA_PRECONDITION(temp_weak_ref.exists()); #endif // Copy a strong ref to this node to keep it alive until we've wiped it from @@ -215,7 +215,7 @@ void Scene::DeleteNode(Node* node) { // Sanity test: at this point the node should be dead. #if BA_DEBUG_BUILD - if (temp_weak_ref.Exists()) { + if (temp_weak_ref.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Node still exists after ref release!!"); } @@ -227,7 +227,7 @@ void Scene::DeleteNode(Node* node) { i->Run(); } for (auto&& i : dependent_nodes) { - Node* node2 = i.Get(); + Node* node2 = i.get(); if (node2) { node2->scene()->DeleteNode(node2); } @@ -280,11 +280,11 @@ auto Scene::NewNode(const std::string& type_string, const std::string& name, throw Exception("Invalid node type: '" + type_string + "'"); } auto node = Object::CompleteDeferred(i->second->Create(this)); - assert(node.Exists()); + assert(node.exists()); node->AddToScene(this); node->set_label(name); node->SetDelegate(delegate); - return node.Get(); // NOLINT + return node.get(); // NOLINT } void Scene::Dump(SessionStream* stream) { @@ -306,7 +306,7 @@ void Scene::DumpNodes(SessionStream* out) { // We have to do this all at once before setting attrs since any node // can refer to any other in an attr set. for (auto&& i : nodes_) { - Node* node = i.Get(); + Node* node = i.get(); assert(node); // Add the node. @@ -317,7 +317,7 @@ void Scene::DumpNodes(SessionStream* out) { // Now go through and set *most* node attr values. for (auto&& i1 : nodes_) { - Node* node = i1.Get(); + Node* node = i1.get(); assert(node); // Now we need to set *all* of its attrs in order. @@ -413,7 +413,7 @@ void Scene::DumpNodes(SessionStream* out) { // Now run through all nodes once more and add an OnCreate() call // so they can do any post-create setup they need to. for (auto&& i : nodes_) { - Node* node = i.Get(); + Node* node = i.get(); assert(node); out->NodeOnCreate(node); } @@ -425,13 +425,13 @@ void Scene::DumpNodes(SessionStream* out) { // And lastly re-establish node attribute-connections. for (auto&& i : nodes_) { - Node* node = i.Get(); + Node* node = i.get(); assert(node); for (auto&& j : node->attribute_connections()) { - assert(j.Exists()); - Node* src_node = j->src_node.Get(); + assert(j.exists()); + Node* src_node = j->src_node.get(); assert(src_node); - Node* dst_node = j->dst_node.Get(); + Node* dst_node = j->dst_node.get(); assert(dst_node); NodeAttributeUnbound* src_attr = src_node->type()->GetAttribute(j->src_attr_index); @@ -457,7 +457,7 @@ auto Scene::GetCorrectionMessage(bool blended) -> std::vector { std::vector dynamic_bodies; for (auto&& i : nodes_) { - Node* n = i.Get(); + Node* n = i.get(); assert(n); if (n && !n->parts().empty()) { dynamic_bodies.clear(); diff --git a/src/ballistica/scene_v1/support/scene.h b/src/ballistica/scene_v1/support/scene.h index 6cdf1891..3be4f5e2 100644 --- a/src/ballistica/scene_v1/support/scene.h +++ b/src/ballistica/scene_v1/support/scene.h @@ -7,7 +7,6 @@ #include #include -#include "ballistica/base/logic/logic.h" #include "ballistica/scene_v1/node/node.h" #include "ballistica/shared/foundation/object.h" @@ -36,8 +35,8 @@ class Scene : public Object { void AddOutOfBoundsNode(Node* n) { out_of_bounds_nodes_.emplace_back(n); } auto IsOutOfBounds(float x, float y, float z) -> bool; auto dynamics() const -> Dynamics* { - assert(dynamics_.Exists()); - return dynamics_.Get(); + assert(dynamics_.exists()); + return dynamics_.get(); } auto in_step() const -> bool { return in_step_; } void SetMapBounds(float x, float y, float z, float X, float Y, float Z); diff --git a/src/ballistica/scene_v1/support/scene_v1_context.cc b/src/ballistica/scene_v1/support/scene_v1_context.cc index 2e9ac626..e0ecc026 100644 --- a/src/ballistica/scene_v1/support/scene_v1_context.cc +++ b/src/ballistica/scene_v1/support/scene_v1_context.cc @@ -45,7 +45,7 @@ auto SceneV1Context::GetContextDescription() -> std::string { if (HostActivity* ha = GetAsHostActivity()) { // Return our Python activity class description if possible. PythonRef ha_obj(ha->GetPyActivity(), PythonRef::kAcquire); - if (ha_obj.Get() != Py_None) { + if (ha_obj.get() != Py_None) { return ha_obj.Str(); } } 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 b93175d8..298c1d7f 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 @@ -24,7 +24,7 @@ SceneV1InputDeviceDelegate::SceneV1InputDeviceDelegate() = default; SceneV1InputDeviceDelegate::~SceneV1InputDeviceDelegate() { assert(g_base->InLogicThread()); - assert(!player_.Exists()); + assert(!player_.exists()); // Release our Python ref to ourself if we have one. if (py_ref_) { Py_DECREF(py_ref_); @@ -55,7 +55,7 @@ std::optional SceneV1InputDeviceDelegate::GetPlayerPosition() { } auto SceneV1InputDeviceDelegate::AttachedToPlayer() const -> bool { - return player_.Exists() || remote_player_.Exists(); + return player_.exists() || remote_player_.exists(); } void SceneV1InputDeviceDelegate::RequestPlayer() { @@ -64,13 +64,13 @@ void SceneV1InputDeviceDelegate::RequestPlayer() { auto* appmode = classic::ClassicAppMode::GetActive(); BA_PRECONDITION_FATAL(appmode); - if (player_.Exists()) { + if (player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::RequestPlayer()" " called with already-existing player"); return; } - if (remote_player_.Exists()) { + if (remote_player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::RequestPlayer() called with already-existing " "remote-player"); @@ -100,14 +100,14 @@ void SceneV1InputDeviceDelegate::RequestPlayer() { // When the host-session tells us to attach to a player void SceneV1InputDeviceDelegate::AttachToLocalPlayer(Player* player) { - if (player_.Exists()) { + if (player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::AttachToLocalPlayer() called with already " "existing " "player"); return; } - if (remote_player_.Exists()) { + if (remote_player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::AttachToLocalPlayer() called with already " "existing " @@ -121,14 +121,14 @@ void SceneV1InputDeviceDelegate::AttachToLocalPlayer(Player* player) { void SceneV1InputDeviceDelegate::AttachToRemotePlayer( ConnectionToHost* connection_to_host, int remote_player_id) { assert(connection_to_host); - if (player_.Exists()) { + if (player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::AttachToRemotePlayer()" " called with already existing " "player"); return; } - if (remote_player_.Exists()) { + if (remote_player_.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "InputDevice::AttachToRemotePlayer()" " called with already existing " @@ -141,7 +141,7 @@ void SceneV1InputDeviceDelegate::AttachToRemotePlayer( void SceneV1InputDeviceDelegate::DetachFromPlayer() { // Handle local player. - if (auto* player = player_.Get()) { + if (auto* player = player_.get()) { // NOTE: we now remove the player instantly instead of pushing // a call to do it; otherwise its possible that someone tries // to access the player's inputdevice before the call goes @@ -154,7 +154,7 @@ void SceneV1InputDeviceDelegate::DetachFromPlayer() { } // Handle remote player. - if (auto* connection_to_host = remote_player_.Get()) { + if (auto* connection_to_host = remote_player_.get()) { std::vector data(2); data[0] = BA_MESSAGE_REMOVE_REMOTE_PLAYER; data[1] = static_cast_check_fit(input_device().index()); @@ -170,9 +170,9 @@ std::string SceneV1InputDeviceDelegate::DescribeAttachedTo() const { } void SceneV1InputDeviceDelegate::InputCommand(InputType type, float value) { - if (Player* p = player_.Get()) { + if (Player* p = player_.get()) { p->InputCommand(type, value); - } else if (remote_player_.Exists()) { + } else if (remote_player_.exists()) { // Add to existing buffer of input-commands. { size_t size = remote_input_commands_buffer_.size(); @@ -195,10 +195,10 @@ void SceneV1InputDeviceDelegate::InputCommand(InputType type, float value) { } void SceneV1InputDeviceDelegate::ShipBufferIfFull() { - assert(remote_player_.Exists()); + assert(remote_player_.exists()); auto* appmode = classic::ClassicAppMode::GetSingleton(); - ConnectionToHost* hc = remote_player_.Get(); + ConnectionToHost* hc = remote_player_.get(); // Ship the buffer once it gets big enough or once enough time has passed. millisecs_t real_time = g_core->GetAppTimeMillisecs(); @@ -217,13 +217,13 @@ void SceneV1InputDeviceDelegate::ShipBufferIfFull() { auto SceneV1InputDeviceDelegate::GetClientID() const -> int { return -1; } void SceneV1InputDeviceDelegate::Update() { - if (remote_player_.Exists()) { + if (remote_player_.exists()) { ShipBufferIfFull(); } } auto SceneV1InputDeviceDelegate::GetRemotePlayer() const -> ConnectionToHost* { - return remote_player_.Get(); + return remote_player_.get(); } auto SceneV1InputDeviceDelegate::GetPyInputDevice(bool new_ref) -> PyObject* { diff --git a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.h b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.h index 0a67bafc..08e6571e 100644 --- a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.h +++ b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.h @@ -27,7 +27,7 @@ class SceneV1InputDeviceDelegate : public base::InputDeviceDelegate { void DetachFromPlayer() override; void Update() override; - auto GetPlayer() const -> Player* { return player_.Get(); } + auto GetPlayer() const -> Player* { return player_.get(); } auto GetRemotePlayer() const -> ConnectionToHost*; auto remote_player_id() const -> int { return remote_player_id_; } diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 65d9032e..d266ee16 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 = 22118; +const int kEngineBuildNumber = 22123; const char* kEngineVersion = "1.7.37"; const int kEngineApiVersion = 9; diff --git a/src/ballistica/shared/foundation/feature_set_native_component.cc b/src/ballistica/shared/foundation/feature_set_native_component.cc index a7be300d..783fe54c 100644 --- a/src/ballistica/shared/foundation/feature_set_native_component.cc +++ b/src/ballistica/shared/foundation/feature_set_native_component.cc @@ -41,7 +41,7 @@ auto FeatureSetNativeComponent::BaseImportThroughPythonModule( // Grab the wrapper to our C++ pointer from the module. auto fs_data_obj = PythonRef::StolenSoft( PyObject_GetAttrString(module, kFeatureSetDataAttrName)); - if (!fs_data_obj.Exists()) { + if (!fs_data_obj.exists()) { FatalError("Did not find expected feature-set data in module " + std::string(modulename)); } diff --git a/src/ballistica/shared/foundation/object.h b/src/ballistica/shared/foundation/object.h index 5a4aef46..ad75ac81 100644 --- a/src/ballistica/shared/foundation/object.h +++ b/src/ballistica/shared/foundation/object.h @@ -188,7 +188,7 @@ class Object { } } - auto Exists() const -> bool { return (obj_ != nullptr); } + auto exists() const -> bool { return obj_ != nullptr; } void Clear() { Release(); } @@ -205,7 +205,7 @@ class Object { public: /// Convenience wrapper for Object::IsValidManagedObject. auto IsValidManagedObject() const -> bool { - if (auto* obj = Get()) { + if (auto* obj = get()) { return Object::IsValidManagedObject(obj); } return false; @@ -213,17 +213,16 @@ class Object { /// Convenience wrapper for Object::IsValidUnmanagedObject. auto IsValidUnmanagedObject() const -> bool { - if (auto* obj = Get()) { + if (auto* obj = get()) { return Object::IsValidUnmanagedObject(obj); } return false; } // Return a pointer or nullptr. - auto Get() const -> T* { - // Yes, reinterpret_cast is evil, but we make sure - // we only operate on cases where this is valid - // (see Acquire()). + auto get() const -> T* { + // Yes, reinterpret_cast is evil, but we make sure we only operate on + // cases where this is valid (see Acquire()). return reinterpret_cast(obj_); } @@ -258,37 +257,37 @@ class Object { /// Compare to a pointer of any compatible type. template auto operator==(U* ptr) -> bool { - return (Get() == ptr); + return (get() == ptr); } /// Compare to a pointer of any compatible type. template auto operator!=(U* ptr) -> bool { - return (Get() != ptr); + return (get() != ptr); } /// Compare to a strong ref of any compatible type. template auto operator==(const Ref& ref) -> bool { - return (Get() == ref.Get()); + return (get() == ref.get()); } /// Compare to a strong ref to a compatible type. template auto operator!=(const Ref& ref) -> bool { - return (Get() != ref.Get()); + return (get() != ref.get()); } /// Compare to a weak ref of any compatible type. template auto operator==(const WeakRef& ref) -> bool { - return (Get() == ref.Get()); + return (get() == ref.get()); } /// Compare to a weak ref of any compatible type. template auto operator!=(const WeakRef& ref) -> bool { - return (Get() != ref.Get()); + return (get() != ref.get()); } /// Assign from our exact type. Note: it might seem like our template @@ -297,7 +296,7 @@ class Object { /// piecewise assignment operator gets selected as the best match for /// our exact type and we crash horrifically. auto operator=(const WeakRef& ref) -> WeakRef& { - *this = ref.Get(); + *this = ref.get(); return *this; } @@ -321,7 +320,7 @@ class Object { /// Assign from a strong ref of any compatible type. template auto operator=(const Ref& ref) -> WeakRef& { - *this = ref.Get(); + *this = ref.get(); return *this; } @@ -329,7 +328,7 @@ class Object { /// type which has its own overload). template auto operator=(const WeakRef& ref) -> WeakRef& { - *this = ref.Get(); + *this = ref.get(); return *this; } @@ -345,7 +344,7 @@ class Object { /// this extra verbosity is good; we're tossing around a mix of pointers /// and strong-refs and weak-refs so it's good to be aware exactly where /// refs are being added/etc. - explicit WeakRef(const WeakRef& ref) { *this = ref.Get(); } + explicit WeakRef(const WeakRef& ref) { *this = ref.get(); } /// Create from a pointer of any compatible type. template @@ -408,15 +407,15 @@ class Object { class Ref { public: ~Ref() { Release(); } - auto Get() const -> T* { return obj_; } + auto get() const -> T* { return obj_; } - auto Exists() const -> bool { return (obj_ != nullptr); } + auto exists() const -> bool { return obj_ != nullptr; } void Clear() { Release(); } /// Convenience wrapper for Object::IsValidManagedObject. auto IsValidManagedObject() const -> bool { - if (auto* obj = Get()) { + if (auto* obj = get()) { return Object::IsValidManagedObject(obj); } return false; @@ -447,25 +446,25 @@ class Object { /// Compare to a pointer of any compatible type. template auto operator==(U* ptr) -> bool { - return (Get() == ptr); + return (get() == ptr); } /// Compare to a pointer of any compatible type. template auto operator!=(U* ptr) -> bool { - return (Get() != ptr); + return (get() != ptr); } /// Compare to a strong ref of any compatible type. template auto operator==(const Ref& ref) -> bool { - return (Get() == ref.Get()); + return (get() == ref.get()); } /// Compare to a strong ref of any compatible type. template auto operator!=(const Ref& ref) -> bool { - return (Get() != ref.Get()); + return (get() != ref.get()); } // Note: we don't need to include comparisons to weak-refs because that @@ -478,7 +477,7 @@ class Object { /// piecewise assignment operator gets selected as the best match for /// our exact type and we crash horrifically. auto operator=(const Ref& ref) -> Ref& { - *this = ref.Get(); + *this = ref.get(); return *this; } @@ -496,14 +495,14 @@ class Object { /// type which has its own overload). template auto operator=(const Ref& ref) -> Ref& { - *this = ref.Get(); + *this = ref.get(); return *this; } /// Assign from a weak ref to any compatible type. template auto operator=(const WeakRef& ref) -> Ref& { - *this = ref.Get(); + *this = ref.get(); return *this; } @@ -519,7 +518,7 @@ class Object { /// verbosity is good; we're tossing around a mix of pointers and /// strong-refs and weak-refs so it's good to be aware exactly where /// refs are being added/etc. - explicit Ref(const Ref& ref) { *this = ref.Get(); } + explicit Ref(const Ref& ref) { *this = ref.get(); } /// Create from a compatible pointer. template @@ -768,7 +767,7 @@ auto RefsToPointers(const std::vector >& refs) // Let's just access the memory directly; potentially faster? T** p = &(ptrs[0]); for (size_t i = 0; i < refs_size; i++) { - p[i] = refs[i].Get(); + p[i] = refs[i].get(); } } return ptrs; @@ -778,7 +777,7 @@ auto RefsToPointers(const std::vector >& refs) template void PruneDeadRefs(T* list) { for (typename T::iterator i = list->begin(); i != list->end();) { - if (!i->Exists()) { + if (!i->exists()) { i = list->erase(i); } else { i++; @@ -790,7 +789,7 @@ void PruneDeadRefs(T* list) { template void PruneDeadMapRefs(T* map) { for (typename T::iterator i = map->begin(); i != map->end();) { - if (!i->second.Exists()) { + if (!i->second.exists()) { typename T::iterator i_next = i; i_next++; map->erase(i); diff --git a/src/ballistica/shared/generic/snapshot.h b/src/ballistica/shared/generic/snapshot.h index c5591c92..222f1ea5 100644 --- a/src/ballistica/shared/generic/snapshot.h +++ b/src/ballistica/shared/generic/snapshot.h @@ -15,7 +15,7 @@ class Snapshot : public Object { public: explicit Snapshot(T* data) : data_{data} { assert(data); } ~Snapshot() { delete data_; } - auto* Get() const { return data_; } + auto* get() const { return data_; } private: const T* data_; diff --git a/src/ballistica/shared/python/python.cc b/src/ballistica/shared/python/python.cc index 46a341d1..7baf914a 100644 --- a/src/ballistica/shared/python/python.cc +++ b/src/ballistica/shared/python/python.cc @@ -224,9 +224,9 @@ auto Python::GetPyFloats(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.Get()); - PyObject** py_objects = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.get()); + PyObject** py_objects = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(static_cast(size)); assert(vals.size() == size); for (Py_ssize_t i = 0; i < size; i++) { @@ -243,9 +243,9 @@ auto Python::GetPyStringSequence(PyObject* o) -> std::list { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.Get()); - PyObject** py_objects = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.get()); + PyObject** py_objects = PySequence_Fast_ITEMS(sequence.get()); std::list vals; for (Py_ssize_t i = 0; i < size; i++) { vals.emplace_back(Python::GetPyString(py_objects[i])); @@ -262,9 +262,9 @@ auto GetPyIntsT(PyObject* o) -> std::vector { throw Exception("Object is not a sequence.", PyExcType::kType); } PythonRef sequence(PySequence_Fast(o, "Not a sequence."), PythonRef::kSteal); - assert(sequence.Exists()); - Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.Get()); - PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.Get()); + assert(sequence.exists()); + Py_ssize_t size = PySequence_Fast_GET_SIZE(sequence.get()); + PyObject** pyobjs = PySequence_Fast_ITEMS(sequence.get()); std::vector vals(static_cast(size)); assert(vals.size() == size); for (Py_ssize_t i = 0; i < size; i++) { @@ -307,7 +307,7 @@ auto Python::StringList(const std::list& values) -> PythonRef { for (auto&& value : values) { PyObject* item{PyUnicode_FromString(value.c_str())}; assert(item); - PyList_SET_ITEM(pylist.Get(), i, item); + PyList_SET_ITEM(pylist.get(), i, item); ++i; } return pylist; @@ -324,7 +324,7 @@ auto Python::GetPythonFileLocation(bool pretty) -> std::string { const char* path; auto code_obj = PythonRef::Stolen(reinterpret_cast(PyFrame_GetCode(f))); - auto* code = reinterpret_cast(code_obj.Get()); + auto* code = reinterpret_cast(code_obj.get()); assert(code); if (code && code->co_filename) { assert(PyUnicode_Check(code->co_filename)); diff --git a/src/ballistica/shared/python/python_command.cc b/src/ballistica/shared/python/python_command.cc index 46bd8d31..2078d0f0 100644 --- a/src/ballistica/shared/python/python_command.cc +++ b/src/ballistica/shared/python/python_command.cc @@ -54,7 +54,7 @@ auto PythonCommand::operator=(const std::string& src) -> PythonCommand& { void PythonCommand::CompileForExec() { assert(Python::HaveGIL()); - assert(file_code_obj_.Get() == nullptr); + assert(file_code_obj_.get() == nullptr); PyObject* o = Py_CompileString(command_.c_str(), file_name_.c_str(), Py_file_input); if (o == nullptr) { @@ -69,7 +69,7 @@ void PythonCommand::CompileForExec() { void PythonCommand::CompileForEval(bool print_errors) { assert(Python::HaveGIL()); - assert(eval_code_obj_.Get() == nullptr); + assert(eval_code_obj_.get() == nullptr); PyObject* o = Py_CompileString(command_.c_str(), file_name_.c_str(), Py_eval_input); if (o == nullptr) { @@ -89,10 +89,10 @@ PythonCommand::~PythonCommand() { dead_ = true; } auto PythonCommand::CanEval() -> bool { assert(Python::HaveGIL()); - if (!eval_code_obj_.Get()) { + if (!eval_code_obj_.get()) { CompileForEval(false); } - if (!eval_code_obj_.Get()) { + if (!eval_code_obj_.get()) { PyErr_Clear(); return false; } @@ -114,21 +114,21 @@ auto PythonCommand::Exec(bool print_errors, PyObject* globals, PyObject* locals) if (globals == nullptr) { globals = core::g_core->python->objs() .Get(core::CorePython::ObjID::kMainDict) - .Get(); + .get(); } if (locals == nullptr) { locals = core::g_core->python->objs() .Get(core::CorePython::ObjID::kMainDict) - .Get(); + .get(); } - if (!file_code_obj_.Get()) { + if (!file_code_obj_.get()) { CompileForExec(); assert(!dead_); } - if (file_code_obj_.Get()) { + if (file_code_obj_.get()) { PUSH_PYCOMMAND(this); - PyObject* v = PyEval_EvalCode(file_code_obj_.Get(), globals, locals); + PyObject* v = PyEval_EvalCode(file_code_obj_.get(), globals, locals); POP_PYCOMMAND(); // Technically the Python call could have killed us; @@ -175,25 +175,25 @@ auto PythonCommand::Eval(bool print_errors, PyObject* globals, PyObject* locals) assert(core::g_core); globals = core::g_core->python->objs() .Get(core::CorePython::ObjID::kMainDict) - .Get(); + .get(); } if (locals == nullptr) { assert(core::g_core); locals = core::g_core->python->objs() .Get(core::CorePython::ObjID::kMainDict) - .Get(); + .get(); } assert(PyDict_Check(globals)); assert(PyDict_Check(locals)); - if (!eval_code_obj_.Get()) { + if (!eval_code_obj_.get()) { CompileForEval(print_errors); assert(!dead_); } // Attempt to compile for eval if necessary. - if (!eval_code_obj_.Get()) { + if (!eval_code_obj_.get()) { if (print_errors) { // Save/restore error or it can mess with context print calls. BA_PYTHON_ERROR_SAVE; @@ -213,7 +213,7 @@ auto PythonCommand::Eval(bool print_errors, PyObject* globals, PyObject* locals) return {}; } PUSH_PYCOMMAND(this); - PyObject* v = PyEval_EvalCode(eval_code_obj_.Get(), globals, locals); + PyObject* v = PyEval_EvalCode(eval_code_obj_.get(), globals, locals); POP_PYCOMMAND(); assert(!dead_); if (v == nullptr) { diff --git a/src/ballistica/shared/python/python_object_set.cc b/src/ballistica/shared/python/python_object_set.cc index 8f6b4509..29196efc 100644 --- a/src/ballistica/shared/python/python_object_set.cc +++ b/src/ballistica/shared/python/python_object_set.cc @@ -31,7 +31,7 @@ void PythonObjectSetBase::StoreObj(int id, PyObject* pyobj) { if (g_buildconfig.debug_build()) { // Assuming we're setting everything once // (make sure we don't accidentally overwrite things we don't intend to). - if (objs_[id].Exists()) { + if (objs_[id].exists()) { throw Exception("Python::StoreObj() called twice for id '" + std::to_string(id) + "' (existing val: '" + objs_[id].Str() + "')."); @@ -39,7 +39,7 @@ void PythonObjectSetBase::StoreObj(int id, PyObject* pyobj) { // Also make sure we're not storing an object that's already been stored. for (auto&& i : objs_) { - if (i.Get() != nullptr && i.Get() == pyobj) { + if (i.get() != nullptr && i.get() == pyobj) { g_core->Log(LogName::kBa, LogLevel::kWarning, "Python::StoreObj() called twice for same ptr; id=" + std::to_string(id) + "."); @@ -65,19 +65,19 @@ void PythonObjectSetBase::StoreObjCallable(int id, PyObject* pyobj) { void PythonObjectSetBase::StoreObj(int id, const char* expr, PyObject* context) { auto obj = PythonCommand(expr, "").Eval(false, context, context); - if (!obj.Exists()) { + if (!obj.exists()) { FatalError("Unable to get value: '" + std::string(expr) + "'."); } - StoreObj(id, obj.Get()); + StoreObj(id, obj.get()); } void PythonObjectSetBase::StoreObjCallable(int id, const char* expr, PyObject* context) { auto obj = PythonCommand(expr, "").Eval(false, context, context); - if (!obj.Exists()) { + if (!obj.exists()) { throw Exception("Unable to get value: '" + std::string(expr) + "'."); } - StoreObjCallable(id, obj.Get()); + StoreObjCallable(id, obj.get()); } void PythonObjectSetBase::PushObjCall(int id) const { diff --git a/src/ballistica/shared/python/python_object_set.h b/src/ballistica/shared/python/python_object_set.h index 32075412..7908acfb 100644 --- a/src/ballistica/shared/python/python_object_set.h +++ b/src/ballistica/shared/python/python_object_set.h @@ -3,6 +3,8 @@ #ifndef BALLISTICA_SHARED_PYTHON_PYTHON_OBJECT_SET_H_ #define BALLISTICA_SHARED_PYTHON_PYTHON_OBJECT_SET_H_ +#include + #include #include @@ -24,7 +26,7 @@ class PythonObjectSetBase { auto Obj(int id) const -> const PythonRef& { assert(id >= 0); assert(id < static_cast(objs_.size())); - assert(objs_[id].Exists()); + assert(objs_[id].exists()); return objs_[id]; } @@ -32,7 +34,7 @@ class PythonObjectSetBase { auto ObjExists(int id) const -> bool { assert(id >= 0); assert(id < static_cast(objs_.size())); - return objs_[static_cast(id)].Exists(); + return objs_[static_cast(id)].exists(); } /// Push a call to a preset obj to the logic thread. diff --git a/src/ballistica/shared/python/python_ref.cc b/src/ballistica/shared/python/python_ref.cc index 2ea62d33..7a368ca2 100644 --- a/src/ballistica/shared/python/python_ref.cc +++ b/src/ballistica/shared/python/python_ref.cc @@ -140,15 +140,15 @@ auto PythonRef::Str() const -> std::string { } auto s = PythonRef::Stolen(str_obj); assert(PyUnicode_Check(str_obj)); // NOLINT (signed with bitwise) - return PyUnicode_AsUTF8(s.Get()); + return PyUnicode_AsUTF8(s.get()); } auto PythonRef::Repr() const -> std::string { assert(Python::HaveGIL()); ThrowIfUnset(); auto s = PythonRef::Stolen(PyObject_Repr(obj_)); - assert(PyUnicode_Check(s.Get())); // NOLINT (signed with bitwise) - return PyUnicode_AsUTF8(s.Get()); + assert(PyUnicode_Check(s.get())); // NOLINT (signed with bitwise) + return PyUnicode_AsUTF8(s.get()); } auto PythonRef::Type() const -> PythonRef { @@ -239,7 +239,7 @@ auto PythonRef::ValueAsDouble() const -> double { auto PythonRef::GetAttr(const char* name) const -> PythonRef { assert(Python::HaveGIL()); ThrowIfUnset(); - PyObject* val = PyObject_GetAttrString(Get(), name); + PyObject* val = PyObject_GetAttrString(get(), name); if (!val) { PyErr_Clear(); throw Exception("Attribute not found: '" + std::string(name) + "'.", @@ -335,7 +335,7 @@ auto PythonRef::Call(const Vector2f& val, bool print_errors) const -> PythonRef { assert(Python::HaveGIL()); PythonRef args(Py_BuildValue("((ff))", val.x, val.y), PythonRef::kSteal); - return Call(args.Get(), nullptr, print_errors); + return Call(args.get(), nullptr, print_errors); } PythonRef::~PythonRef() { Release(); } diff --git a/src/ballistica/shared/python/python_ref.h b/src/ballistica/shared/python/python_ref.h index 9d195427..fea453f2 100644 --- a/src/ballistica/shared/python/python_ref.h +++ b/src/ballistica/shared/python/python_ref.h @@ -7,7 +7,7 @@ #include #include -#include "ballistica/shared/ballistica.h" +#include "ballistica/shared/ballistica.h" // IWYU pragma: keep. namespace ballistica { @@ -75,8 +75,8 @@ class PythonRef { /// reference of ours is cleared to match. auto operator=(const PythonRef& other) -> PythonRef& { assert(this != &other); // Shouldn't be self-assigning. - if (other.Exists()) { - Acquire(other.Get()); + if (other.exists()) { + Acquire(other.get()); } else { Release(); } @@ -87,7 +87,7 @@ class PythonRef { /// (so basically the 'is' keyword in Python). /// Note that two unreferenced PythonRefs will be equal. auto operator==(const PythonRef& other) const -> bool { - return (Get() == other.Get()); + return (get() == other.get()); } auto operator!=(const PythonRef& other) const -> bool { return !(*this == other); @@ -129,7 +129,7 @@ class PythonRef { } /// Return the underlying PyObject pointer. - auto Get() const -> PyObject* { return obj_; } + auto get() const -> PyObject* { return obj_; } /// Return the underlying PyObject pointer. Throws an Exception if not set. auto operator*() const -> PyObject* { @@ -144,7 +144,7 @@ class PythonRef { auto NewRef() const -> PyObject*; /// Return whether we are pointing to a PyObject. - auto Exists() const -> bool { return obj_ != nullptr; } + auto exists() const -> bool { return obj_ != nullptr; } /// Return a ref to an attribute on our PyObject or throw an Exception. auto GetAttr(const char* name) const -> PythonRef; @@ -196,7 +196,7 @@ class PythonRef { bool print_errors = true) const -> PythonRef; auto Call(const PythonRef& args, const PythonRef& keywds = PythonRef(), bool print_errors = true) const -> PythonRef { - return Call(args.Get(), keywds.Get(), print_errors); + return Call(args.get(), keywds.get(), print_errors); } auto Call(bool print_errors = true) const -> PythonRef; diff --git a/src/ballistica/ui_v1/python/class/python_class_ui_mesh.cc b/src/ballistica/ui_v1/python/class/python_class_ui_mesh.cc index c062708a..acef9658 100644 --- a/src/ballistica/ui_v1/python/class/python_class_ui_mesh.cc +++ b/src/ballistica/ui_v1/python/class/python_class_ui_mesh.cc @@ -43,7 +43,7 @@ auto PythonClassUIMesh::Create(const Object::Ref& mesh) auto PythonClassUIMesh::tp_repr(PythonClassUIMesh* self) -> PyObject* { BA_PYTHON_TRY; - base::MeshAsset* s = self->mesh_->Get(); + base::MeshAsset* s = self->mesh_->get(); return Py_BuildValue( "s", (std::string("GetName()) + "'>").c_str()); BA_PYTHON_CATCH; diff --git a/src/ballistica/ui_v1/python/class/python_class_ui_sound.cc b/src/ballistica/ui_v1/python/class/python_class_ui_sound.cc index 9ee315e8..96fff73b 100644 --- a/src/ballistica/ui_v1/python/class/python_class_ui_sound.cc +++ b/src/ballistica/ui_v1/python/class/python_class_ui_sound.cc @@ -44,7 +44,7 @@ auto PythonClassUISound::Create(const Object::Ref& sound) auto PythonClassUISound::tp_repr(PythonClassUISound* self) -> PyObject* { BA_PYTHON_TRY; - base::SoundAsset* s = self->sound_->Get(); + base::SoundAsset* s = self->sound_->get(); return Py_BuildValue( "s", (std::string("GetName()) + "'>").c_str()); BA_PYTHON_CATCH; @@ -91,7 +91,7 @@ auto PythonClassUISound::Play(PythonClassUISound* self, PyObject* args, const_cast(kwlist), &volume)) { return nullptr; } - base::SoundAsset* s = self->sound_->Get(); + base::SoundAsset* s = self->sound_->get(); auto play_id = g_base->audio->PlaySound(s, volume); if (play_id) { self->playing_ = true; diff --git a/src/ballistica/ui_v1/python/class/python_class_ui_texture.cc b/src/ballistica/ui_v1/python/class/python_class_ui_texture.cc index b60c1008..39bc36d9 100644 --- a/src/ballistica/ui_v1/python/class/python_class_ui_texture.cc +++ b/src/ballistica/ui_v1/python/class/python_class_ui_texture.cc @@ -43,7 +43,7 @@ auto PythonClassUITexture::Create( auto PythonClassUITexture::tp_repr(PythonClassUITexture* self) -> PyObject* { BA_PYTHON_TRY; - base::TextureAsset* s = self->texture_->Get(); + base::TextureAsset* s = self->texture_->get(); return Py_BuildValue( "s", (std::string("GetName()) + "'>").c_str()); BA_PYTHON_CATCH; diff --git a/src/ballistica/ui_v1/python/class/python_class_widget.cc b/src/ballistica/ui_v1/python/class/python_class_widget.cc index 2d65621d..70c67789 100644 --- a/src/ballistica/ui_v1/python/class/python_class_widget.cc +++ b/src/ballistica/ui_v1/python/class/python_class_widget.cc @@ -7,13 +7,14 @@ #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/logic/logic.h" #include "ballistica/shared/foundation/event_loop.h" +#include "ballistica/shared/foundation/macros.h" #include "ballistica/shared/generic/utils.h" #include "ballistica/ui_v1/widget/container_widget.h" namespace ballistica::ui_v1 { auto PythonClassWidget::nb_bool(PythonClassWidget* self) -> int { - return self->widget_->Exists(); + return self->widget_->exists(); } PyNumberMethods PythonClassWidget::as_number_; @@ -67,7 +68,7 @@ void PythonClassWidget::SetupType(PyTypeObject* cls) { auto PythonClassWidget::Create(Widget* widget) -> PyObject* { // Make sure we only have one Python ref per Widget. if (widget) { - assert(!widget->has_py_ref()); + assert(!widget->HasPyRef()); } assert(TypeIsSetUp(&type_obj)); @@ -84,7 +85,7 @@ auto PythonClassWidget::Create(Widget* widget) -> PyObject* { } auto PythonClassWidget::GetWidget() const -> Widget* { - Widget* w = widget_->Get(); + Widget* w = widget_->get(); if (!w) { throw Exception("Invalid Widget", PyExcType::kReference); } @@ -102,7 +103,7 @@ auto PythonClassWidget::tp_getattro(PythonClassWidget* self, PyObject* attr) const char* s = PyUnicode_AsUTF8(attr); if (!strcmp(s, ATTR_TRANSITIONING_OUT)) { - Widget* w = self->widget_->Get(); + Widget* w = self->widget_->get(); if (!w) { throw Exception("Invalid Widget", PyExcType::kReference); } @@ -136,7 +137,7 @@ auto PythonClassWidget::tp_setattro(PythonClassWidget* self, PyObject* attr, auto PythonClassWidget::tp_repr(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + Widget* w = self->widget_->get(); return Py_BuildValue("s", (std::string("GetWidgetTypeName() : "") + "' widget " + Utils::PtrToString(w) + ">") @@ -178,7 +179,8 @@ void PythonClassWidget::tp_dealloc(PythonClassWidget* self) { auto PythonClassWidget::Exists(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (w) { Py_RETURN_TRUE; } else { @@ -189,7 +191,8 @@ auto PythonClassWidget::Exists(PythonClassWidget* self) -> PyObject* { auto PythonClassWidget::GetWidgetType(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } @@ -199,7 +202,8 @@ auto PythonClassWidget::GetWidgetType(PythonClassWidget* self) -> PyObject* { auto PythonClassWidget::Activate(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } @@ -210,7 +214,8 @@ auto PythonClassWidget::Activate(PythonClassWidget* self) -> PyObject* { auto PythonClassWidget::GetChildren(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } @@ -224,7 +229,7 @@ auto PythonClassWidget::GetChildren(PythonClassWidget* self) -> PyObject* { if (cw) { #pragma clang diagnostic pop for (auto&& i : cw->widgets()) { - assert(i.Exists()); + assert(i.exists()); PyList_Append(py_list, i->BorrowPyRef()); } } @@ -234,20 +239,15 @@ auto PythonClassWidget::GetChildren(PythonClassWidget* self) -> PyObject* { auto PythonClassWidget::GetSelectedChild(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } - auto* cw = dynamic_cast(w); - - // Clion seems to think dynamic_casting a Widget* to a ContainerWidget* - // will always succeed. Go home Clion; you're drunk. -#pragma clang diagnostic push -#pragma ide diagnostic ignored "ConstantConditionsOC" - if (cw) { -#pragma clang diagnostic pop - Widget* selected_widget = cw->selected_widget(); - if (selected_widget) return selected_widget->NewPyRef(); + if (auto* cw = dynamic_cast(w)) { + if (Widget* selected_widget = cw->selected_widget()) { + return selected_widget->NewPyRef(); + } } Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -256,7 +256,8 @@ auto PythonClassWidget::GetSelectedChild(PythonClassWidget* self) -> PyObject* { auto PythonClassWidget::GetScreenSpaceCenter(PythonClassWidget* self) -> PyObject* { BA_PYTHON_TRY; - Widget* w = self->widget_->Get(); + BA_PRECONDITION(g_base->InLogicThread()); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } @@ -281,6 +282,7 @@ auto PythonClassWidget::GetScreenSpaceCenter(PythonClassWidget* self) auto PythonClassWidget::Delete(PythonClassWidget* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; + BA_PRECONDITION(g_base->InLogicThread()); int ignore_missing = true; static const char* kwlist[] = {"ignore_missing", nullptr}; if (!PyArg_ParseTupleAndKeywords( @@ -291,7 +293,7 @@ auto PythonClassWidget::Delete(PythonClassWidget* self, PyObject* args, // Defer any user code triggered by selects/etc until the end. base::UI::OperationContext ui_op_context; - Widget* w = self->widget_->Get(); + Widget* w = self->widget_->get(); if (!w) { if (!ignore_missing) { throw Exception(PyExcType::kWidgetNotFound); @@ -316,13 +318,14 @@ auto PythonClassWidget::AddDeleteCallback(PythonClassWidget* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; + BA_PRECONDITION(g_base->InLogicThread()); PyObject* call_obj; static const char* kwlist[] = {"call", nullptr}; if (!PyArg_ParseTupleAndKeywords(args, keywds, "O", const_cast(kwlist), &call_obj)) { return nullptr; } - Widget* w = self->widget_->Get(); + Widget* w = self->widget_->get(); if (!w) { throw Exception(PyExcType::kWidgetNotFound); } @@ -342,7 +345,7 @@ auto PythonClassWidget::Dir(PythonClassWidget* self) -> PyObject* { for (const char** name = extra_dir_attrs; *name != nullptr; name++) { PyList_Append( dir_list, - PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).Get()); + PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).get()); } PyList_Sort(dir_list); return dir_list; 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 075c4e3d..3f8650b1 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 @@ -151,50 +151,52 @@ static PyMethodDef PyGetMeshDef = { static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* label_obj = Py_None; - PyObject* parent_obj = Py_None; - PyObject* edit_obj = Py_None; - ContainerWidget* parent_widget = nullptr; - PyObject* on_activate_call_obj = Py_None; - PyObject* color_obj = Py_None; - PyObject* down_widget_obj = Py_None; - Widget* down_widget = nullptr; - PyObject* up_widget_obj = Py_None; - Widget* up_widget = nullptr; - PyObject* left_widget_obj = Py_None; - Widget* left_widget = nullptr; - PyObject* right_widget_obj = Py_None; - Widget* right_widget = nullptr; - PyObject* texture_obj = Py_None; - PyObject* tint_texture_obj = Py_None; - PyObject* text_scale_obj = Py_None; - PyObject* textcolor_obj = Py_None; - PyObject* enable_sound_obj = Py_None; - PyObject* mesh_transparent_obj = Py_None; - PyObject* mesh_opaque_obj = Py_None; - PyObject* repeat_obj = Py_None; - PyObject* scale_obj = Py_None; - PyObject* transition_delay_obj = Py_None; - PyObject* on_select_call_obj = Py_None; - PyObject* button_type_obj = Py_None; - PyObject* extra_touch_border_scale_obj = Py_None; - PyObject* selectable_obj = Py_None; - PyObject* show_buffer_top_obj = Py_None; - PyObject* icon_obj = Py_None; - PyObject* icon_scale_obj = Py_None; - PyObject* icon_tint_obj = Py_None; - PyObject* icon_color_obj = Py_None; - PyObject* autoselect_obj = Py_None; - PyObject* mask_texture_obj = Py_None; - PyObject* tint_color_obj = Py_None; - PyObject* tint2_color_obj = Py_None; - PyObject* text_flatness_obj = Py_None; - PyObject* text_res_scale_obj = Py_None; - PyObject* enabled_obj = Py_None; + PyObject* parent_obj{Py_None}; + PyObject* id_obj{Py_None}; + PyObject* size_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* label_obj{Py_None}; + PyObject* edit_obj{Py_None}; + ContainerWidget* parent_widget{}; + PyObject* on_activate_call_obj{Py_None}; + PyObject* color_obj{Py_None}; + PyObject* down_widget_obj{Py_None}; + Widget* down_widget{}; + PyObject* up_widget_obj{Py_None}; + Widget* up_widget{}; + PyObject* left_widget_obj{Py_None}; + Widget* left_widget{}; + PyObject* right_widget_obj{Py_None}; + Widget* right_widget{}; + PyObject* texture_obj{Py_None}; + PyObject* tint_texture_obj{Py_None}; + PyObject* text_scale_obj{Py_None}; + PyObject* textcolor_obj{Py_None}; + PyObject* enable_sound_obj{Py_None}; + PyObject* mesh_transparent_obj{Py_None}; + PyObject* mesh_opaque_obj{Py_None}; + PyObject* repeat_obj{Py_None}; + PyObject* scale_obj{Py_None}; + PyObject* transition_delay_obj{Py_None}; + PyObject* on_select_call_obj{Py_None}; + PyObject* button_type_obj{Py_None}; + PyObject* extra_touch_border_scale_obj{Py_None}; + PyObject* selectable_obj{Py_None}; + PyObject* show_buffer_top_obj{Py_None}; + PyObject* icon_obj{Py_None}; + PyObject* icon_scale_obj{Py_None}; + PyObject* icon_tint_obj{Py_None}; + PyObject* icon_color_obj{Py_None}; + PyObject* autoselect_obj{Py_None}; + PyObject* mask_texture_obj{Py_None}; + PyObject* tint_color_obj{Py_None}; + PyObject* tint2_color_obj{Py_None}; + PyObject* text_flatness_obj{Py_None}; + PyObject* text_res_scale_obj{Py_None}; + PyObject* enabled_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", + "id", "size", "position", "on_activate_call", @@ -232,9 +234,9 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) "enabled", nullptr}; if (!PyArg_ParseTupleAndKeywords( - args, keywds, "|OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", - const_cast(kwlist), &edit_obj, &parent_obj, &size_obj, - &pos_obj, &on_activate_call_obj, &label_obj, &color_obj, + args, keywds, "|OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", + const_cast(kwlist), &edit_obj, &parent_obj, &id_obj, + &size_obj, &pos_obj, &on_activate_call_obj, &label_obj, &color_obj, &down_widget_obj, &up_widget_obj, &left_widget_obj, &right_widget_obj, &texture_obj, &text_scale_obj, &textcolor_obj, &enable_sound_obj, &mesh_transparent_obj, &mesh_opaque_obj, &repeat_obj, &scale_obj, @@ -258,7 +260,7 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref b; if (edit_obj != Py_None) { b = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!b.Exists()) { + if (!b.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -275,11 +277,14 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) } // Set applicable values. + if (id_obj != Py_None) { + b->set_id(Python::GetPyString(id_obj)); + } if (label_obj != Py_None) { b->set_text(g_base->python->GetPyLString(label_obj)); } if (on_activate_call_obj != Py_None) { - b->set_on_activate_call(on_activate_call_obj); + b->SetOnActivateCall(on_activate_call_obj); } if (down_widget_obj != Py_None) { @@ -287,14 +292,14 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) if (!down_widget) { throw Exception("Invalid down widget.", PyExcType::kWidgetNotFound); } - b->set_down_widget(down_widget); + b->SetDownWidget(down_widget); } if (up_widget_obj != Py_None) { up_widget = UIV1Python::GetPyWidget(up_widget_obj); if (!up_widget) { throw Exception("Invalid up widget.", PyExcType::kWidgetNotFound); } - b->set_up_widget(up_widget); + b->SetUpWidget(up_widget); } if (autoselect_obj != Py_None) { b->set_auto_select(Python::GetPyBool(autoselect_obj)); @@ -304,14 +309,14 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) if (!left_widget) { throw Exception("Invalid left widget.", PyExcType::kWidgetNotFound); } - b->set_left_widget(left_widget); + b->SetLeftWidget(left_widget); } if (right_widget_obj != Py_None) { right_widget = UIV1Python::GetPyWidget(right_widget_obj); if (!right_widget) { throw Exception("Invalid right widget.", PyExcType::kWidgetNotFound); } - b->set_right_widget(right_widget); + b->SetRightWidget(right_widget); } if (mesh_transparent_obj != Py_None) { b->SetMeshTransparent( @@ -398,7 +403,7 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) if (c.size() != 3) { throw Exception("Expected 3 floats for color.", PyExcType::kValue); } - b->SetColor(c[0], c[1], c[2]); + b->set_color(c[0], c[1], c[2]); } if (textcolor_obj != Py_None) { std::vector c = Python::GetPyFloats(textcolor_obj); @@ -445,7 +450,7 @@ static auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) // If making a new widget add it at the end. if (edit_obj == Py_None) { - g_ui_v1->AddWidget(b.Get(), parent_widget); + g_ui_v1->AddWidget(b.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -464,6 +469,7 @@ static PyMethodDef PyButtonWidgetDef = { "buttonwidget(*,\n" " edit: bauiv1.Widget | None = None,\n" " parent: bauiv1.Widget | None = None,\n" + " id: str | None = None,\n" " size: Sequence[float] | None = None,\n" " position: Sequence[float] | None = None,\n" " on_activate_call: Callable | None = None,\n" @@ -514,25 +520,27 @@ static PyMethodDef PyButtonWidgetDef = { static auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* text_obj = Py_None; - PyObject* value_obj = Py_None; - PyObject* on_value_change_call_obj = Py_None; - PyObject* on_select_call_obj = Py_None; - PyObject* scale_obj = Py_None; - PyObject* is_radio_button_obj = Py_None; - PyObject* maxwidth_obj = Py_None; - PyObject* parent_obj = Py_None; - PyObject* edit_obj = Py_None; - ContainerWidget* parent_widget = nullptr; - PyObject* text_scale_obj = Py_None; - PyObject* textcolor_obj = Py_None; - PyObject* autoselect_obj = Py_None; - PyObject* color_obj = Py_None; + PyObject* size_obj{Py_None}; + PyObject* id_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* text_obj{Py_None}; + PyObject* value_obj{Py_None}; + PyObject* on_value_change_call_obj{Py_None}; + PyObject* on_select_call_obj{Py_None}; + PyObject* scale_obj{Py_None}; + PyObject* is_radio_button_obj{Py_None}; + PyObject* maxwidth_obj{Py_None}; + PyObject* parent_obj{Py_None}; + PyObject* edit_obj{Py_None}; + ContainerWidget* parent_widget{}; + PyObject* text_scale_obj{Py_None}; + PyObject* textcolor_obj{Py_None}; + PyObject* autoselect_obj{Py_None}; + PyObject* color_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", + "id", "size", "position", "text", @@ -548,11 +556,11 @@ static auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) "color", nullptr}; if (!PyArg_ParseTupleAndKeywords( - args, keywds, "|OOOOOOOOOOOOOOO", const_cast(kwlist), - &edit_obj, &parent_obj, &size_obj, &pos_obj, &text_obj, &value_obj, - &on_value_change_call_obj, &on_select_call_obj, &text_scale_obj, - &textcolor_obj, &scale_obj, &is_radio_button_obj, &maxwidth_obj, - &autoselect_obj, &color_obj)) { + args, keywds, "|OOOOOOOOOOOOOOOO", const_cast(kwlist), + &edit_obj, &parent_obj, &id_obj, &size_obj, &pos_obj, &text_obj, + &value_obj, &on_value_change_call_obj, &on_select_call_obj, + &text_scale_obj, &textcolor_obj, &scale_obj, &is_radio_button_obj, + &maxwidth_obj, &autoselect_obj, &color_obj)) { return nullptr; } @@ -568,7 +576,7 @@ static auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -585,6 +593,9 @@ static auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) } // Set applicable values. + if (id_obj != Py_None) { + widget->set_id(Python::GetPyString(id_obj)); + } if (size_obj != Py_None) { Point2D p = Python::GetPyPoint2D(size_obj); widget->SetWidth(p.x); @@ -642,7 +653,7 @@ static auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) // if making a new widget add it at the end if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -689,26 +700,26 @@ static PyMethodDef PyCheckBoxWidgetDef = { static auto PyImageWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* texture_obj = Py_None; - PyObject* tint_texture_obj = Py_None; - ContainerWidget* parent_widget = nullptr; - PyObject* parent_obj = Py_None; - PyObject* edit_obj = Py_None; - PyObject* color_obj = Py_None; - PyObject* tint_color_obj = Py_None; - PyObject* tint2_color_obj = Py_None; - PyObject* opacity_obj = Py_None; - PyObject* mesh_transparent_obj = Py_None; - PyObject* mesh_opaque_obj = Py_None; - PyObject* has_alpha_channel_obj = Py_None; - PyObject* transition_delay_obj = Py_None; - PyObject* draw_controller_obj = Py_None; - PyObject* tilt_scale_obj = Py_None; - PyObject* mask_texture_obj = Py_None; - PyObject* radial_amount_obj = Py_None; - PyObject* draw_controller_mult_obj = Py_None; + PyObject* size_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* texture_obj{Py_None}; + PyObject* tint_texture_obj{Py_None}; + ContainerWidget* parent_widget{}; + PyObject* parent_obj{Py_None}; + PyObject* edit_obj{Py_None}; + PyObject* color_obj{Py_None}; + PyObject* tint_color_obj{Py_None}; + PyObject* tint2_color_obj{Py_None}; + PyObject* opacity_obj{Py_None}; + PyObject* mesh_transparent_obj{Py_None}; + PyObject* mesh_opaque_obj{Py_None}; + PyObject* has_alpha_channel_obj{Py_None}; + PyObject* transition_delay_obj{Py_None}; + PyObject* draw_controller_obj{Py_None}; + PyObject* tilt_scale_obj{Py_None}; + PyObject* mask_texture_obj{Py_None}; + PyObject* radial_amount_obj{Py_None}; + PyObject* draw_controller_mult_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", @@ -752,7 +763,7 @@ static auto PyImageWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref b; if (edit_obj != Py_None) { b = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!b.Exists()) + if (!b.exists()) throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } else { @@ -844,7 +855,7 @@ static auto PyImageWidget(PyObject* self, PyObject* args, PyObject* keywds) // if making a new widget add it at the end if (edit_obj == Py_None) { - g_ui_v1->AddWidget(b.Get(), parent_widget); + g_ui_v1->AddWidget(b.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -953,7 +964,7 @@ static auto PyColumnWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -1029,7 +1040,7 @@ static auto PyColumnWidget(PyObject* self, PyObject* args, PyObject* keywds) // If making a new widget, add it at the end. if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -1078,38 +1089,38 @@ static PyMethodDef PyColumnWidgetDef = { static auto PyContainerWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* background_obj = Py_None; - PyObject* selected_child_obj = Py_None; - PyObject* transition_obj = Py_None; - PyObject* cancel_button_obj = Py_None; - PyObject* start_button_obj = Py_None; - PyObject* root_selectable_obj = Py_None; - PyObject* on_activate_call_obj = Py_None; - PyObject* claims_left_right_obj = Py_None; - PyObject* claims_up_down_obj = Py_None; - PyObject* claims_tab_obj = Py_None; - PyObject* selection_loops_obj = Py_None; - PyObject* selection_loops_to_parent_obj = Py_None; - PyObject* scale_obj = Py_None; - PyObject* on_outside_click_call_obj = Py_None; - PyObject* print_list_exit_instructions_obj = Py_None; - PyObject* single_depth_obj = Py_None; - PyObject* visible_child_obj = Py_None; - PyObject* stack_offset_obj = Py_None; - PyObject* scale_origin_stack_offset_obj = Py_None; - PyObject* color_obj = Py_None; - PyObject* on_cancel_call_obj = Py_None; - PyObject* click_activate_obj = Py_None; - PyObject* always_highlight_obj = Py_None; - PyObject* parent_obj = Py_None; + PyObject* size_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* background_obj{Py_None}; + PyObject* selected_child_obj{Py_None}; + PyObject* transition_obj{Py_None}; + PyObject* cancel_button_obj{Py_None}; + PyObject* start_button_obj{Py_None}; + PyObject* root_selectable_obj{Py_None}; + PyObject* on_activate_call_obj{Py_None}; + PyObject* claims_left_right_obj{Py_None}; + PyObject* claims_up_down_obj{Py_None}; + PyObject* claims_tab_obj{Py_None}; + PyObject* selection_loops_obj{Py_None}; + PyObject* selection_loops_to_parent_obj{Py_None}; + PyObject* scale_obj{Py_None}; + PyObject* on_outside_click_call_obj{Py_None}; + PyObject* print_list_exit_instructions_obj{Py_None}; + PyObject* single_depth_obj{Py_None}; + PyObject* visible_child_obj{Py_None}; + PyObject* stack_offset_obj{Py_None}; + PyObject* scale_origin_stack_offset_obj{Py_None}; + PyObject* color_obj{Py_None}; + PyObject* on_cancel_call_obj{Py_None}; + PyObject* click_activate_obj{Py_None}; + PyObject* always_highlight_obj{Py_None}; + PyObject* parent_obj{Py_None}; ContainerWidget* parent_widget; - PyObject* edit_obj = Py_None; - PyObject* selectable_obj = Py_None; - PyObject* toolbar_visibility_obj = Py_None; - PyObject* on_select_call_obj = Py_None; - PyObject* claim_outside_clicks_obj = Py_None; + PyObject* edit_obj{Py_None}; + PyObject* selectable_obj{Py_None}; + PyObject* toolbar_visibility_obj{Py_None}; + PyObject* on_select_call_obj{Py_None}; + PyObject* claim_outside_clicks_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", @@ -1172,7 +1183,7 @@ static auto PyContainerWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -1189,7 +1200,7 @@ static auto PyContainerWidget(PyObject* self, PyObject* args, PyObject* keywds) PyExcType::kWidgetNotFound); } widget = Object::New(); - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Set applicable values. @@ -1468,7 +1479,7 @@ static auto PyRowWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -1517,7 +1528,7 @@ static auto PyRowWidget(PyObject* self, PyObject* args, PyObject* keywds) // If making a new widget, add it to the parent. if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -1620,7 +1631,7 @@ static auto PyScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent edit widget.", PyExcType::kWidgetNotFound); } @@ -1697,7 +1708,7 @@ static auto PyScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) // If making a new widget add it at the end. if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -1748,24 +1759,24 @@ static auto PyHScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* background_obj = Py_None; - PyObject* selected_child_obj = Py_None; - PyObject* capture_arrows_obj = Py_None; - PyObject* on_select_call_obj = Py_None; - PyObject* parent_obj = Py_None; - PyObject* edit_obj = Py_None; - PyObject* center_small_content_obj = Py_None; - ContainerWidget* parent_widget = nullptr; - PyObject* color_obj = Py_None; - PyObject* highlight_obj = Py_None; - PyObject* border_opacity_obj = Py_None; - PyObject* simple_culling_h_obj = Py_None; - PyObject* claims_left_right_obj = Py_None; - PyObject* claims_up_down_obj = Py_None; - PyObject* claims_tab_obj = Py_None; - PyObject* autoselect_obj = Py_None; + PyObject* size_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* background_obj{Py_None}; + PyObject* selected_child_obj{Py_None}; + PyObject* capture_arrows_obj{Py_None}; + PyObject* on_select_call_obj{Py_None}; + PyObject* parent_obj{Py_None}; + PyObject* edit_obj{Py_None}; + PyObject* center_small_content_obj{Py_None}; + ContainerWidget* parent_widget{}; + PyObject* color_obj{Py_None}; + PyObject* highlight_obj{Py_None}; + PyObject* border_opacity_obj{Py_None}; + PyObject* simple_culling_h_obj{Py_None}; + PyObject* claims_left_right_obj{Py_None}; + PyObject* claims_up_down_obj{Py_None}; + PyObject* claims_tab_obj{Py_None}; + PyObject* autoselect_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", @@ -1807,7 +1818,7 @@ static auto PyHScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) Object::Ref widget; if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent edit widget.", PyExcType::kWidgetNotFound); } @@ -1879,7 +1890,7 @@ static auto PyHScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) // if making a new widget add it at the end if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -1927,47 +1938,47 @@ static PyMethodDef PyHScrollWidgetDef = { static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* size_obj = Py_None; - PyObject* pos_obj = Py_None; - PyObject* text_obj = Py_None; - PyObject* v_align_obj = Py_None; - PyObject* h_align_obj = Py_None; - PyObject* editable_obj = Py_None; - PyObject* padding_obj = Py_None; - PyObject* on_return_press_call_obj = Py_None; - PyObject* on_activate_call_obj = Py_None; - PyObject* selectable_obj = Py_None; - PyObject* max_chars_obj = Py_None; - PyObject* color_obj = Py_None; - PyObject* click_activate_obj = Py_None; - PyObject* on_select_call_obj = Py_None; - PyObject* maxwidth_obj = Py_None; - PyObject* max_height_obj = Py_None; - PyObject* scale_obj = Py_None; - PyObject* corner_scale_obj = Py_None; - PyObject* always_highlight_obj = Py_None; - PyObject* draw_controller_obj = Py_None; - PyObject* description_obj = Py_None; - PyObject* transition_delay_obj = Py_None; - PyObject* flatness_obj = Py_None; - PyObject* shadow_obj = Py_None; - PyObject* big_obj = Py_None; - PyObject* parent_obj = Py_None; - ContainerWidget* parent_widget = nullptr; - PyObject* edit_obj = Py_None; - PyObject* query_obj = Py_None; - PyObject* autoselect_obj = Py_None; - PyObject* rotate_obj = Py_None; - PyObject* enabled_obj = Py_None; - PyObject* force_internal_editing_obj = Py_None; - PyObject* always_show_carat_obj = Py_None; - PyObject* extra_touch_border_scale_obj = Py_None; - PyObject* res_scale_obj = Py_None; - PyObject* query_max_chars_obj = Py_None; - PyObject* query_description_obj = Py_None; - PyObject* adapter_finished_obj = Py_None; - PyObject* glow_type_obj = Py_None; - PyObject* allow_clear_button_obj = Py_None; + PyObject* size_obj{Py_None}; + PyObject* pos_obj{Py_None}; + PyObject* text_obj{Py_None}; + PyObject* v_align_obj{Py_None}; + PyObject* h_align_obj{Py_None}; + PyObject* editable_obj{Py_None}; + PyObject* padding_obj{Py_None}; + PyObject* on_return_press_call_obj{Py_None}; + PyObject* on_activate_call_obj{Py_None}; + PyObject* selectable_obj{Py_None}; + PyObject* max_chars_obj{Py_None}; + PyObject* color_obj{Py_None}; + PyObject* click_activate_obj{Py_None}; + PyObject* on_select_call_obj{Py_None}; + PyObject* maxwidth_obj{Py_None}; + PyObject* max_height_obj{Py_None}; + PyObject* scale_obj{Py_None}; + PyObject* corner_scale_obj{Py_None}; + PyObject* always_highlight_obj{Py_None}; + PyObject* draw_controller_obj{Py_None}; + PyObject* description_obj{Py_None}; + PyObject* transition_delay_obj{Py_None}; + PyObject* flatness_obj{Py_None}; + PyObject* shadow_obj{Py_None}; + PyObject* big_obj{Py_None}; + PyObject* parent_obj{Py_None}; + ContainerWidget* parent_widget{}; + PyObject* edit_obj{Py_None}; + PyObject* query_obj{Py_None}; + PyObject* autoselect_obj{Py_None}; + PyObject* rotate_obj{Py_None}; + PyObject* enabled_obj{Py_None}; + PyObject* force_internal_editing_obj{Py_None}; + PyObject* always_show_carat_obj{Py_None}; + PyObject* extra_touch_border_scale_obj{Py_None}; + PyObject* res_scale_obj{Py_None}; + PyObject* query_max_chars_obj{Py_None}; + PyObject* query_description_obj{Py_None}; + PyObject* adapter_finished_obj{Py_None}; + PyObject* glow_type_obj{Py_None}; + PyObject* allow_clear_button_obj{Py_None}; static const char* kwlist[] = {"edit", "parent", @@ -2036,7 +2047,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) // Handle query special cases first. if (query_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(query_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -2045,7 +2056,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) if (query_max_chars_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(query_max_chars_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -2054,7 +2065,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) if (query_description_obj != Py_None) { widget = dynamic_cast( UIV1Python::GetPyWidget(query_description_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -2069,7 +2080,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) if (edit_obj != Py_None) { widget = dynamic_cast(UIV1Python::GetPyWidget(edit_obj)); - if (!widget.Exists()) { + if (!widget.exists()) { throw Exception("Invalid or nonexistent widget.", PyExcType::kWidgetNotFound); } @@ -2154,11 +2165,11 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) if (h_align_obj != Py_None) { std::string halign = Python::GetPyString(h_align_obj); if (halign == "left") { - widget->set_halign(TextWidget::HAlign::kLeft); + widget->SetHAlign(TextWidget::HAlign::kLeft); } else if (halign == "center") { - widget->set_halign(TextWidget::HAlign::kCenter); + widget->SetHAlign(TextWidget::HAlign::kCenter); } else if (halign == "right") { - widget->set_halign(TextWidget::HAlign::kRight); + widget->SetHAlign(TextWidget::HAlign::kRight); } else { throw Exception("Invalid halign.", PyExcType::kValue); } @@ -2166,11 +2177,11 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) if (v_align_obj != Py_None) { std::string valign = Python::GetPyString(v_align_obj); if (valign == "top") { - widget->set_valign(TextWidget::VAlign::kTop); + widget->SetVAlign(TextWidget::VAlign::kTop); } else if (valign == "center") { - widget->set_valign(TextWidget::VAlign::kCenter); + widget->SetVAlign(TextWidget::VAlign::kCenter); } else if (valign == "bottom") { - widget->set_valign(TextWidget::VAlign::kBottom); + widget->SetVAlign(TextWidget::VAlign::kBottom); } else { throw Exception("Invalid valign.", PyExcType::kValue); } @@ -2197,13 +2208,13 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) widget->set_draw_control_parent(dcw); } if (on_return_press_call_obj != Py_None) { - widget->set_on_return_press_call(on_return_press_call_obj); + widget->SetOnReturnPressCall(on_return_press_call_obj); } if (on_select_call_obj != Py_None) { widget->SetOnSelectCall(on_select_call_obj); } if (on_activate_call_obj != Py_None) { - widget->set_on_activate_call(on_activate_call_obj); + widget->SetOnActivateCall(on_activate_call_obj); } if (selectable_obj != Py_None) widget->set_selectable(Python::GetPyBool(selectable_obj)); @@ -2245,7 +2256,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) } else { throw Exception("Invalid glow_type: " + glow_type_s, PyExcType::kValue); } - widget->set_glow_type(glow_type); + widget->SetGlowType(glow_type); } if (allow_clear_button_obj != Py_None) { widget->set_allow_clear_button(Python::GetPyBool(allow_clear_button_obj)); @@ -2253,7 +2264,7 @@ static auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) // If making a new widget, add it at the end. if (edit_obj == Py_None) { - g_ui_v1->AddWidget(widget.Get(), parent_widget); + g_ui_v1->AddWidget(widget.get(), parent_widget); } // Run any calls built up by UI callbacks. @@ -2327,16 +2338,16 @@ static auto PyWidgetCall(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - PyObject* edit_obj = Py_None; - PyObject* down_widget_obj = Py_None; - PyObject* up_widget_obj = Py_None; - PyObject* left_widget_obj = Py_None; - PyObject* right_widget_obj = Py_None; - PyObject* show_buffer_top_obj = Py_None; - PyObject* show_buffer_bottom_obj = Py_None; - PyObject* show_buffer_left_obj = Py_None; - PyObject* show_buffer_right_obj = Py_None; - PyObject* autoselect_obj = Py_None; + PyObject* edit_obj{Py_None}; + PyObject* down_widget_obj{Py_None}; + PyObject* up_widget_obj{Py_None}; + PyObject* left_widget_obj{Py_None}; + PyObject* right_widget_obj{Py_None}; + PyObject* show_buffer_top_obj{Py_None}; + PyObject* show_buffer_bottom_obj{Py_None}; + PyObject* show_buffer_left_obj{Py_None}; + PyObject* show_buffer_right_obj{Py_None}; + PyObject* autoselect_obj{Py_None}; static const char* kwlist[] = {"edit", "up_widget", @@ -2364,7 +2375,7 @@ static auto PyWidgetCall(PyObject* self, PyObject* args, PyObject* keywds) // before we return. base::UI::OperationContext ui_op_context; - Widget* widget = nullptr; + Widget* widget{}; if (edit_obj != Py_None) { widget = UIV1Python::GetPyWidget(edit_obj); } @@ -2378,28 +2389,28 @@ static auto PyWidgetCall(PyObject* self, PyObject* args, PyObject* keywds) if (!down_widget) { throw Exception("Invalid down widget.", PyExcType::kWidgetNotFound); } - widget->set_down_widget(down_widget); + widget->SetDownWidget(down_widget); } if (up_widget_obj != Py_None) { Widget* up_widget = UIV1Python::GetPyWidget(up_widget_obj); if (!up_widget) { throw Exception("Invalid up widget.", PyExcType::kWidgetNotFound); } - widget->set_up_widget(up_widget); + widget->SetUpWidget(up_widget); } if (left_widget_obj != Py_None) { Widget* left_widget = UIV1Python::GetPyWidget(left_widget_obj); if (!left_widget) { throw Exception("Invalid left widget.", PyExcType::kWidgetNotFound); } - widget->set_left_widget(left_widget); + widget->SetLeftWidget(left_widget); } if (right_widget_obj != Py_None) { Widget* right_widget = UIV1Python::GetPyWidget(right_widget_obj); if (!right_widget) { throw Exception("Invalid right widget.", PyExcType::kWidgetNotFound); } - widget->set_right_widget(right_widget); + widget->SetRightWidget(right_widget); } if (show_buffer_top_obj != Py_None) { widget->set_show_buffer_top(Python::GetPyFloat(show_buffer_top_obj)); diff --git a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.h b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.h index 3c50f6c6..150e2a79 100644 --- a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.h +++ b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.h @@ -3,9 +3,9 @@ #ifndef BALLISTICA_UI_V1_PYTHON_METHODS_PYTHON_METHODS_UI_V1_H_ #define BALLISTICA_UI_V1_PYTHON_METHODS_PYTHON_METHODS_UI_V1_H_ -#include +#include -#include "ballistica/shared/ballistica.h" +#include namespace ballistica::ui_v1 { diff --git a/src/ballistica/ui_v1/python/ui_v1_python.cc b/src/ballistica/ui_v1/python/ui_v1_python.cc index fe4a8a0a..9826ca8e 100644 --- a/src/ballistica/ui_v1/python/ui_v1_python.cc +++ b/src/ballistica/ui_v1/python/ui_v1_python.cc @@ -141,7 +141,7 @@ void UIV1Python::InvokeQuitWindow(QuitType quit_type) { g_base->audio->SafePlaySysSound(base::SysSoundID::kSwish); auto py_enum = g_base->python->PyQuitType(quit_type); - auto args = PythonRef::Stolen(Py_BuildValue("(O)", py_enum.Get())); + auto args = PythonRef::Stolen(Py_BuildValue("(O)", py_enum.get())); objs().Get(UIV1Python::ObjID::kQuitWindowCall).Call(args); // If we have a keyboard, give it UI ownership. diff --git a/src/ballistica/ui_v1/ui_v1.cc b/src/ballistica/ui_v1/ui_v1.cc index c90ba578..f6b2c517 100644 --- a/src/ballistica/ui_v1/ui_v1.cc +++ b/src/ballistica/ui_v1/ui_v1.cc @@ -83,12 +83,12 @@ bool UIV1FeatureSet::PartyIconVisible() { } void UIV1FeatureSet::SetAccountState(bool signed_in, const std::string& name) { - assert(root_widget_.Exists()); + assert(root_widget_.exists()); root_widget_->SetAccountState(signed_in, name); } void UIV1FeatureSet::SetSquadSizeLabel(int num) { - assert(root_widget_.Exists()); + assert(root_widget_.exists()); root_widget_->SetSquadSizeLabel(num); } @@ -104,7 +104,7 @@ void UIV1FeatureSet::Draw(base::FrameDef* frame_def) { base::RenderPass* overlay_flat_pass = frame_def->GetOverlayFlatPass(); // Draw interface elements. - auto* root_widget = root_widget_.Get(); + auto* root_widget = root_widget_.get(); if (root_widget && root_widget->HasChildren()) { // Draw our opaque and transparent parts separately. This way we can @@ -175,9 +175,9 @@ void UIV1FeatureSet::OnActivate() { root_widget_ = rw; rw->SetWidth(g_base->graphics->screen_virtual_width()); rw->SetHeight(g_base->graphics->screen_virtual_height()); - rw->SetScreenWidget(sw.Get()); + rw->SetScreenWidget(sw.get()); rw->Setup(); - rw->SetOverlayWidget(ow.Get()); + rw->SetOverlayWidget(ow.get()); // Plug in all values we're storing. // rw->SetSquadSizeLabel(party_icon_number_); @@ -203,8 +203,8 @@ void UIV1FeatureSet::AddWidget(Widget* w, ContainerWidget* parent) { // have lost focus will not get stuck running or whatnot. We should come // up with a more generalized way to track this sort of focus as this is a // bit hacky, but it works for now. - auto* screen_root_widget = screen_root_widget_.Get(); - auto* overlay_root_widget = overlay_root_widget_.Get(); + auto* screen_root_widget = screen_root_widget_.get(); + auto* overlay_root_widget = overlay_root_widget_.get(); if ((screen_root_widget && !screen_root_widget->HasChildren() && parent == screen_root_widget) || (overlay_root_widget && !overlay_root_widget->HasChildren() @@ -217,7 +217,7 @@ void UIV1FeatureSet::AddWidget(Widget* w, ContainerWidget* parent) { void UIV1FeatureSet::OnScreenSizeChange() { // This gets called by the native layer as window is resized/etc. - if (root_widget_.Exists()) { + if (root_widget_.exists()) { root_widget_->SetWidth(g_base->graphics->screen_virtual_width()); root_widget_->SetHeight(g_base->graphics->screen_virtual_height()); } @@ -230,7 +230,7 @@ void UIV1FeatureSet::OnScreenChange() { // We allow OnScreenSizeChange() to handle size changes but *do* handle // UIScale changes here. - if (auto* root_widget = root_widget_.Get()) { + if (auto* root_widget = root_widget_.get()) { root_widget->OnUIScaleChange(); } } @@ -251,7 +251,7 @@ void UIV1FeatureSet::OnLanguageChange() { Widget* UIV1FeatureSet::GetRootWidget() { return root_widget(); } auto UIV1FeatureSet::SendWidgetMessage(const base::WidgetMessage& m) -> int { - if (!root_widget_.Exists()) { + if (!root_widget_.exists()) { return false; } return root_widget_->HandleMessage(m); diff --git a/src/ballistica/ui_v1/ui_v1.h b/src/ballistica/ui_v1/ui_v1.h index e1493e31..13c86b5c 100644 --- a/src/ballistica/ui_v1/ui_v1.h +++ b/src/ballistica/ui_v1/ui_v1.h @@ -103,16 +103,16 @@ class UIV1FeatureSet : public FeatureSetNativeComponent, // Return the root widget containing all windows & dialogs. Whenever this // contains children, the UI is considered to be in focus auto screen_root_widget() -> ui_v1::ContainerWidget* { - return screen_root_widget_.Get(); + return screen_root_widget_.get(); } auto overlay_root_widget() -> ui_v1::ContainerWidget* { - return overlay_root_widget_.Get(); + return overlay_root_widget_.get(); } // Return the absolute root widget; this includes persistent UI bits such // as the top/bottom bars - auto root_widget() -> ui_v1::RootWidget* { return root_widget_.Get(); } + auto root_widget() -> ui_v1::RootWidget* { return root_widget_.get(); } // void Reset() override; // Add a widget to a container. If a parent is provided, the widget is diff --git a/src/ballistica/ui_v1/widget/button_widget.cc b/src/ballistica/ui_v1/widget/button_widget.cc index eff91625..4b236184 100644 --- a/src/ballistica/ui_v1/widget/button_widget.cc +++ b/src/ballistica/ui_v1/widget/button_widget.cc @@ -20,8 +20,8 @@ ButtonWidget::ButtonWidget() static_cast(g_base->logic->display_time() * 1000.0)} { text_ = Object::New(); set_text("Button"); - text_->set_valign(TextWidget::VAlign::kCenter); - text_->set_halign(TextWidget::HAlign::kCenter); + text_->SetVAlign(TextWidget::VAlign::kCenter); + text_->SetHAlign(TextWidget::HAlign::kCenter); text_->SetWidth(0.0f); text_->SetHeight(0.0f); } @@ -30,7 +30,7 @@ ButtonWidget::~ButtonWidget() = default; void ButtonWidget::SetTextResScale(float val) { text_->set_res_scale(val); } -void ButtonWidget::set_on_activate_call(PyObject* call_obj) { +void ButtonWidget::SetOnActivateCall(PyObject* call_obj) { on_activate_call_ = Object::New(call_obj); } @@ -100,7 +100,7 @@ auto ButtonWidget::GetMult(millisecs_t current_time) const -> float { 0.8f + std::abs(sinf(static_cast(current_time) * 0.006467f)) * 0.2f; - if (!texture_.Exists()) { + if (!texture_.exists()) { mult *= 1.7f; } else { // Let's make custom textures pulsate brighter since they can be dark/etc. @@ -134,7 +134,7 @@ void ButtonWidget::Draw(base::RenderPass* pass, bool draw_transparent) { auto* device = g_base->ui->GetUIInputDevice(); // If there's an explicit user-set icon we always show. - if (icon_.Exists()) { + if (icon_.exists()) { show_icons = true; } @@ -202,15 +202,15 @@ void ButtonWidget::Draw(base::RenderPass* pass, bool draw_transparent) { bool do_draw_mesh; // Normal buttons draw in both transparent and opaque passes. - if (!texture_.Exists()) { + if (!texture_.exists()) { do_draw_mesh = true; } else { // If we're supplying any custom meshes, draw whichever is provided. - if (mesh_opaque_.Exists() || mesh_transparent_.Exists()) { - if (draw_transparent && mesh_transparent_.Exists()) { + if (mesh_opaque_.exists() || mesh_transparent_.exists()) { + if (draw_transparent && mesh_transparent_.exists()) { do_draw_mesh = true; custom_mesh = mesh_transparent_; - } else if ((!draw_transparent) && mesh_opaque_.Exists()) { + } else if ((!draw_transparent) && mesh_opaque_.exists()) { do_draw_mesh = true; custom_mesh = mesh_opaque_; } else { @@ -229,7 +229,7 @@ void ButtonWidget::Draw(base::RenderPass* pass, bool draw_transparent) { // We currently only support non-1.0 opacity values when using // custom textures and no custom opaque mesh. - assert(opacity_ == 1.0f || (texture_.Exists() && !mesh_opaque_.Exists())); + assert(opacity_ == 1.0f || (texture_.exists() && !mesh_opaque_.exists())); c.SetColor(mult * color_red_, mult * color_green_, mult * color_blue_, opacity_); @@ -241,24 +241,24 @@ void ButtonWidget::Draw(base::RenderPass* pass, bool draw_transparent) { base::MeshAsset* mesh; // Custom button texture. - if (texture_.Exists()) { - if (!custom_mesh.Exists()) { + if (texture_.exists()) { + if (!custom_mesh.exists()) { mesh = g_base->assets->SysMesh(base::SysMeshID::kImage1x1); } else { - mesh = custom_mesh.Get(); + mesh = custom_mesh.get(); } if (texture_->loaded() && mesh->loaded() - && (!mask_texture_.Exists() || mask_texture_->loaded()) - && (!tint_texture_.Exists() || tint_texture_->loaded())) { + && (!mask_texture_.exists() || mask_texture_->loaded()) + && (!tint_texture_.exists() || tint_texture_->loaded())) { c.SetTexture(texture_); - if (tint_texture_.Exists()) { - c.SetColorizeTexture(tint_texture_.Get()); + if (tint_texture_.exists()) { + c.SetColorizeTexture(tint_texture_.get()); c.SetColorizeColor(tint_color_red_, tint_color_green_, tint_color_blue_); c.SetColorizeColor2(tint2_color_red_, tint2_color_green_, tint2_color_blue_); } - c.SetMaskTexture(mask_texture_.Get()); + c.SetMaskTexture(mask_texture_.get()); } else { do_draw = false; } @@ -384,7 +384,7 @@ void ButtonWidget::Draw(base::RenderPass* pass, bool draw_transparent) { c.SetTexture( g_base->assets->SysTexture(base::SysTextureID::kBombButton)); } - } else if (icon_.Exists()) { + } else if (icon_.exists()) { c.SetColor(icon_color_red_ * (icon_tint_ * (1.7f * mult * (color_red_)) + (1.0f - icon_tint_) * mult), @@ -563,7 +563,7 @@ void ButtonWidget::DoActivate(bool is_repeat) { g_base->audio->SafePlaySysSound(base::SysSoundID::kSwish3); } } - if (auto* call = on_activate_call_.Get()) { + if (auto* call = on_activate_call_.get()) { // If we're being activated as part of a ui-operation (a click or other // such event) then run at the end of that operation to avoid mucking // with volatile UI. diff --git a/src/ballistica/ui_v1/widget/button_widget.h b/src/ballistica/ui_v1/widget/button_widget.h index e6d1f510..0ec3d44b 100644 --- a/src/ballistica/ui_v1/widget/button_widget.h +++ b/src/ballistica/ui_v1/widget/button_widget.h @@ -19,7 +19,7 @@ class ButtonWidget : public Widget { void set_height(float height) { height_ = height; } auto GetWidth() -> float override; auto GetHeight() -> float override; - void SetColor(float r, float g, float b) { + void set_color(float r, float g, float b) { color_set_ = true; color_red_ = r; color_green_ = g; @@ -58,10 +58,10 @@ class ButtonWidget : public Widget { auto set_text_scale(float val) { text_scale_ = val; } void SetTexture(base::TextureAsset* t); void SetMaskTexture(base::TextureAsset* t); - void SetTintTexture(base::TextureAsset* val); + void SetTintTexture(base::TextureAsset* t); void SetIcon(base::TextureAsset* t); - auto icon() const -> base::TextureAsset* { return icon_.Get(); } - void set_on_activate_call(PyObject* call_obj); + auto icon() const { return icon_.get(); } + void SetOnActivateCall(PyObject* call_obj); void Activate() override; auto IsSelectable() -> bool override { return selectable_; } auto GetWidgetTypeName() -> std::string override { return "button"; } diff --git a/src/ballistica/ui_v1/widget/check_box_widget.cc b/src/ballistica/ui_v1/widget/check_box_widget.cc index 8c1df280..dd4c1696 100644 --- a/src/ballistica/ui_v1/widget/check_box_widget.cc +++ b/src/ballistica/ui_v1/widget/check_box_widget.cc @@ -18,8 +18,8 @@ namespace ballistica::ui_v1 { CheckBoxWidget::CheckBoxWidget() { SetText("CheckBox"); text_.set_owner_widget(this); - text_.set_valign(TextWidget::VAlign::kCenter); - text_.set_halign(TextWidget::HAlign::kLeft); + text_.SetVAlign(TextWidget::VAlign::kCenter); + text_.SetHAlign(TextWidget::HAlign::kLeft); } CheckBoxWidget::~CheckBoxWidget() = default; @@ -246,7 +246,7 @@ void CheckBoxWidget::Activate() { checked_ = !checked_; check_dirty_ = true; last_change_time_ = g_core->GetAppTimeMillisecs(); - if (auto* call = on_value_change_call_.Get()) { + if (auto* call = on_value_change_call_.get()) { PythonRef args(Py_BuildValue("(O)", checked_ ? Py_True : Py_False), PythonRef::kSteal); diff --git a/src/ballistica/ui_v1/widget/container_widget.cc b/src/ballistica/ui_v1/widget/container_widget.cc index 8edd9d3f..e227d4f8 100644 --- a/src/ballistica/ui_v1/widget/container_widget.cc +++ b/src/ballistica/ui_v1/widget/container_widget.cc @@ -330,7 +330,7 @@ auto ContainerWidget::HandleMessage(const base::WidgetMessage& m) -> bool { claimed = true; } } - if (!claimed && start_button_.Exists()) { + if (!claimed && start_button_.exists()) { claimed = true; start_button_->Activate(); } @@ -344,10 +344,10 @@ auto ContainerWidget::HandleMessage(const base::WidgetMessage& m) -> bool { } } if (!claimed) { - if (cancel_button_.Exists()) { + if (cancel_button_.exists()) { claimed = true; cancel_button_->Activate(); - } else if (auto* call = on_cancel_call_.Get()) { + } else if (auto* call = on_cancel_call_.get()) { claimed = true; // Schedule this to run immediately after any current UI @@ -630,7 +630,7 @@ auto ContainerWidget::HandleMessage(const base::WidgetMessage& m) -> bool { } // Call our outside-click callback if unclaimed. - if (!claimed && on_outside_click_call_.Exists()) { + if (!claimed && on_outside_click_call_.exists()) { // Schedule this to run immediately after any current UI traversal. on_outside_click_call_->ScheduleInUIOperation(); } @@ -822,7 +822,7 @@ void ContainerWidget::Draw(base::RenderPass* pass, bool draw_transparent) { // the draw loop, but we can push a call to do it. Object::WeakRef weakref(this); g_base->logic->event_loop()->PushCall([weakref] { - Widget* w = weakref.Get(); + Widget* w = weakref.get(); if (w) { g_ui_v1->DeleteWidget(w); } @@ -879,7 +879,7 @@ void ContainerWidget::Draw(base::RenderPass* pass, bool draw_transparent) { // draw loop, but we can set up an event to do it. Object::WeakRef weakref(this); g_base->logic->event_loop()->PushCall([weakref] { - Widget* w = weakref.Get(); + Widget* w = weakref.get(); if (w) { g_ui_v1->DeleteWidget(w); } @@ -989,7 +989,7 @@ void ContainerWidget::Draw(base::RenderPass* pass, bool draw_transparent) { s = std::min((1.0f - amt) * 4.0f, 2.5f) + amt * 1.0f; } c.SetColor(red_ * s, green_ * s, blue_ * s, alpha_); - c.SetTexture(tex_.Get()); + c.SetTexture(tex_.get()); { auto xf = c.ScopedTransform(); c.Translate(bg_center_x_, bg_center_y_); @@ -1069,7 +1069,7 @@ void ContainerWidget::TransformPointFromChild(float* x, float* y, void ContainerWidget::Activate() { last_activate_time_millisecs_ = static_cast(g_base->logic->display_time() * 1000.0); - if (auto* call = on_activate_call_.Get()) { + if (auto* call = on_activate_call_.get()) { // Schedule this to run immediately after any current UI traversal. call->ScheduleInUIOperation(); } @@ -1111,7 +1111,7 @@ void ContainerWidget::AddWidget(Widget* w) { } // Select actions we run above may trigger user code which may kill us. - if (!weakthis.Exists()) { + if (!weakthis.exists()) { return; } @@ -1134,7 +1134,7 @@ void ContainerWidget::SetCancelButton(ButtonWidget* button) { assert(button); if (!button->is_color_set()) { - button->SetColor(0.7f, 0.4f, 0.34f); + button->set_color(0.7f, 0.4f, 0.34f); button->set_text_color(0.9f, 0.9f, 1.0f, 1.0f); } cancel_button_ = button; @@ -1149,7 +1149,7 @@ void ContainerWidget::SetCancelButton(ButtonWidget* button) { void ContainerWidget::SetStartButton(ButtonWidget* button) { assert(button); if (!button->is_color_set()) { - button->SetColor(0.2f, 0.8f, 0.55f); + button->set_color(0.2f, 0.8f, 0.55f); } start_button_ = button; @@ -1397,7 +1397,7 @@ void ContainerWidget::SelectWidget(Widget* w, SelectionCause c) { if (w == nullptr) { if (selected_widget_) { prev_selected_widget_ = selected_widget_; - selected_widget_->SetSelected(false, SelectionCause::NONE); + selected_widget_->SetSelected(false, SelectionCause::kNone); selected_widget_ = nullptr; } } else { @@ -1408,16 +1408,16 @@ void ContainerWidget::SelectWidget(Widget* w, SelectionCause c) { return; } for (auto& widget : widgets_) { - if (&(*widget) == w) { + if (widget.get() == w) { Widget* prev_selected_widget = selected_widget_; // Deactivate old selected widget. if (selected_widget_) { - selected_widget_->SetSelected(false, SelectionCause::NONE); + selected_widget_->SetSelected(false, SelectionCause::kNone); selected_widget_ = nullptr; } - if ((*widget).IsSelectable()) { - (*widget).SetSelected(true, c); + if (widget->IsSelectable()) { + widget->SetSelected(true, c); selected_widget_ = &(*widget); // Store the old one as prev-selected if its not the one we're @@ -1451,7 +1451,7 @@ void ContainerWidget::SetSelected(bool s, SelectionCause cause) { // next/prev snaps our sub-selection to our first or last widget. if (s) { if (selection_loops_to_parent()) { - if (cause == SelectionCause::NEXT_SELECTED) { + if (cause == SelectionCause::kNextSelected) { for (auto& widget : widgets_) { if ((*widget).IsSelectable()) { ShowWidget(&(*widget)); @@ -1459,7 +1459,7 @@ void ContainerWidget::SetSelected(bool s, SelectionCause cause) { break; } } - } else if (cause == SelectionCause::PREV_SELECTED) { + } else if (cause == SelectionCause::kPrevSelected) { for (auto i = widgets_.rbegin(); i != widgets_.rend(); i++) { if ((**i).IsSelectable()) { ShowWidget(&(**i)); @@ -1482,14 +1482,14 @@ auto ContainerWidget::GetClosestLeftWidget(float our_x, float our_y, float x, y; float closest_val = 9999.0f; for (auto i = widgets_.begin(); i != widgets_.end(); i++) { - assert(i->Exists()); + assert(i->exists()); (**i).GetCenter(&x, &y); float slope = std::abs(x - our_x) / (std::max(0.001f, std::abs(y - our_y))); slope = std::min( slope, AUTO_SELECT_SLOPE_CLAMP); // Beyond this, just go by distance. float slope_weighted = AUTO_SELECT_SLOPE_WEIGHT * slope + (1.0f - AUTO_SELECT_SLOPE_WEIGHT) * 1.0f; - if (i->Get() != ignore_widget && x < our_x && slope > AUTO_SELECT_MIN_SLOPE + if (i->get() != ignore_widget && x < our_x && slope > AUTO_SELECT_MIN_SLOPE && (**i).IsSelectable() && (**i).IsSelectableViaKeys()) { // Take distance diff and multiply by our slope. float xdist = x - our_x; @@ -1499,7 +1499,7 @@ auto ContainerWidget::GetClosestLeftWidget(float our_x, float our_y, dist / std::max(0.001f, slope_weighted + AUTO_SELECT_SLOPE_OFFSET); if (val < closest_val || w == nullptr) { closest_val = val; - w = i->Get(); + w = i->get(); } } } @@ -1512,14 +1512,14 @@ auto ContainerWidget::GetClosestRightWidget(float our_x, float our_y, float x, y; float closest_val = 9999.0f; for (auto i = widgets_.begin(); i != widgets_.end(); i++) { - assert(i->Exists()); + assert(i->exists()); (**i).GetCenter(&x, &y); float slope = std::abs(x - our_x) / (std::max(0.001f, std::abs(y - our_y))); slope = std::min( slope, AUTO_SELECT_SLOPE_CLAMP); // beyond this, just go by distance float slopeWeighted = AUTO_SELECT_SLOPE_WEIGHT * slope + (1.0f - AUTO_SELECT_SLOPE_WEIGHT) * 1.0f; - if (i->Get() != ignore_widget && x > our_x && slope > AUTO_SELECT_MIN_SLOPE + if (i->get() != ignore_widget && x > our_x && slope > AUTO_SELECT_MIN_SLOPE && (**i).IsSelectable() && (**i).IsSelectableViaKeys()) { // Take distance diff and multiply by our slope. float xDist = x - our_x; @@ -1529,7 +1529,7 @@ auto ContainerWidget::GetClosestRightWidget(float our_x, float our_y, dist / std::max(0.001f, slopeWeighted + AUTO_SELECT_SLOPE_OFFSET); if (val < closest_val || w == nullptr) { closest_val = val; - w = i->Get(); + w = i->get(); } } } @@ -1542,14 +1542,14 @@ auto ContainerWidget::GetClosestUpWidget(float our_x, float our_y, float x, y; float closest_val = 9999.0f; for (auto i = widgets_.begin(); i != widgets_.end(); i++) { - assert(i->Exists()); + assert(i->exists()); (**i).GetCenter(&x, &y); float slope = std::abs(y - our_y) / (std::max(0.001f, std::abs(x - our_x))); slope = std::min( slope, AUTO_SELECT_SLOPE_CLAMP); // Beyond this, just go by distance. float slopeWeighted = AUTO_SELECT_SLOPE_WEIGHT * slope + (1.0f - AUTO_SELECT_SLOPE_WEIGHT) * 1.0f; - if (i->Get() != ignoreWidget && y > our_y && slope > AUTO_SELECT_MIN_SLOPE + if (i->get() != ignoreWidget && y > our_y && slope > AUTO_SELECT_MIN_SLOPE && (**i).IsSelectable() && (**i).IsSelectableViaKeys()) { // Take distance diff and multiply by our slope. float xDist = x - our_x; @@ -1559,7 +1559,7 @@ auto ContainerWidget::GetClosestUpWidget(float our_x, float our_y, dist / std::max(0.001f, slopeWeighted + AUTO_SELECT_SLOPE_OFFSET); if (val < closest_val || w == nullptr) { closest_val = val; - w = i->Get(); + w = i->get(); } } } @@ -1572,14 +1572,14 @@ auto ContainerWidget::GetClosestDownWidget(float our_x, float our_y, float x, y; float closest_val = 9999.0f; for (auto i = widgets_.begin(); i != widgets_.end(); i++) { - assert(i->Exists()); + assert(i->exists()); (**i).GetCenter(&x, &y); float slope = std::abs(y - our_y) / (std::max(0.001f, std::abs(x - our_x))); slope = std::min( slope, AUTO_SELECT_SLOPE_CLAMP); // Beyond this, just go by distance. float slopeWeighted = AUTO_SELECT_SLOPE_WEIGHT * slope + (1.0f - AUTO_SELECT_SLOPE_WEIGHT) * 1.0f; - if (i->Get() != ignoreWidget && y < our_y && slope > AUTO_SELECT_MIN_SLOPE + if (i->get() != ignoreWidget && y < our_y && slope > AUTO_SELECT_MIN_SLOPE && (**i).IsSelectable() && (**i).IsSelectableViaKeys()) { // Take distance diff and multiply by our slope. float xDist = x - our_x; @@ -1589,7 +1589,7 @@ auto ContainerWidget::GetClosestDownWidget(float our_x, float our_y, dist / std::max(0.001f, slopeWeighted + AUTO_SELECT_SLOPE_OFFSET); if (val < closest_val || w == nullptr) { closest_val = val; - w = i->Get(); + w = i->get(); } } } @@ -1897,7 +1897,7 @@ void ContainerWidget::SelectNextWidget() { return; } if ((**i).IsSelectable() && (**i).IsSelectableViaKeys()) { - SelectWidget(&(**i), SelectionCause::NEXT_SELECTED); + SelectWidget(&(**i), SelectionCause::kNextSelected); g_base->audio->SafePlaySysSound(base::SysSoundID::kTap); return; } @@ -1985,7 +1985,7 @@ void ContainerWidget::SelectPrevWidget() { } if ((**i).IsSelectable() && (**i).IsSelectableViaKeys()) { - SelectWidget(&(**i), SelectionCause::PREV_SELECTED); + SelectWidget(&(**i), SelectionCause::kPrevSelected); g_base->audio->SafePlaySysSound(base::SysSoundID::kTap); return; } @@ -1995,7 +1995,7 @@ void ContainerWidget::SelectPrevWidget() { auto ContainerWidget::HasKeySelectableChild() const -> bool { for (auto i = widgets_.begin(); i != widgets_.end(); i++) { - assert(i->Exists()); + assert(i->exists()); if ((**i).IsSelectable() && (**i).IsSelectableViaKeys()) { return true; } @@ -2025,7 +2025,7 @@ void ContainerWidget::MarkForUpdate() { void ContainerWidget::OnLanguageChange() { for (auto&& widget : widgets_) { - if (widget.Exists()) { + if (widget.exists()) { widget->OnLanguageChange(); } } diff --git a/src/ballistica/ui_v1/widget/container_widget.h b/src/ballistica/ui_v1/widget/container_widget.h index db30a439..f2a864ee 100644 --- a/src/ballistica/ui_v1/widget/container_widget.h +++ b/src/ballistica/ui_v1/widget/container_widget.h @@ -38,7 +38,7 @@ class ContainerWidget : public Widget { // Set a widget to selected (must already have been added to dialog). Pass // nullptr to deselect widgets. - void SelectWidget(Widget* w, SelectionCause s = SelectionCause::NONE); + void SelectWidget(Widget* w, SelectionCause s = SelectionCause::kNone); void ReselectLastSelectedWidget(); void ShowWidget(Widget* w); void set_background(bool enable) { background_ = enable; } diff --git a/src/ballistica/ui_v1/widget/image_widget.cc b/src/ballistica/ui_v1/widget/image_widget.cc index ccaed69e..011a6a46 100644 --- a/src/ballistica/ui_v1/widget/image_widget.cc +++ b/src/ballistica/ui_v1/widget/image_widget.cc @@ -43,10 +43,10 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { float b = 0; float t = b + height_; - if (texture_.Exists()) { + if (texture_.exists()) { if (texture_->loaded() - && ((!tint_texture_.Exists()) || tint_texture_->loaded()) - && ((!mask_texture_.Exists()) || mask_texture_->loaded())) { + && ((!tint_texture_.exists()) || tint_texture_->loaded()) + && ((!mask_texture_.exists()) || mask_texture_->loaded())) { if (image_dirty_) { image_width_ = r - l; image_height_ = t - b; @@ -56,11 +56,11 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { } Object::Ref mesh_opaque_used; - if (mesh_opaque_.Exists()) { + if (mesh_opaque_.exists()) { mesh_opaque_used = mesh_opaque_; } Object::Ref mesh_transparent_used; - if (mesh_transparent_.Exists()) { + if (mesh_transparent_.exists()) { mesh_transparent_used = mesh_transparent_; } @@ -68,7 +68,7 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { bool draw_radial_transparent = false; // If no meshes were provided, use default image meshes. - if ((!mesh_opaque_.Exists()) && (!mesh_transparent_.Exists())) { + if ((!mesh_opaque_.exists()) && (!mesh_transparent_.exists())) { if (has_alpha_channel_) { if (radial_amount_ < 1.0f) { draw_radial_transparent = true; @@ -96,7 +96,7 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { // Opaque portion may get drawn transparent or opaque depending on our // global opacity. - if (mesh_opaque_used.Exists() || draw_radial_opaque) { + if (mesh_opaque_used.exists() || draw_radial_opaque) { bool should_draw = false; bool should_draw_transparent = false; @@ -116,29 +116,29 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { c.SetColor(color_red_ * db, color_green_ * db, color_blue_ * db, opacity_); c.SetTexture(texture_); - if (tint_texture_.Exists()) { - c.SetColorizeTexture(tint_texture_.Get()); + if (tint_texture_.exists()) { + c.SetColorizeTexture(tint_texture_.get()); c.SetColorizeColor(tint_color_red_, tint_color_green_, tint_color_blue_); c.SetColorizeColor2(tint2_color_red_, tint2_color_green_, tint2_color_blue_); } - c.SetMaskTexture(mask_texture_.Get()); + c.SetMaskTexture(mask_texture_.get()); { auto xf = c.ScopedTransform(); c.Translate(image_center_x_ + extra_offs_x, image_center_y_ + extra_offs_y); c.Scale(image_width_, image_height_, 1.0f); if (draw_radial_opaque) { - if (!radial_mesh_.Exists()) { + if (!radial_mesh_.exists()) { radial_mesh_ = Object::NewDeferred(); } base::Graphics::DrawRadialMeter(&(*radial_mesh_), radial_amount_); c.Scale(0.5f, 0.5f, 1.0f); - c.DrawMesh(radial_mesh_.Get()); + c.DrawMesh(radial_mesh_.get()); } else { - c.DrawMeshAsset(mesh_opaque_used.Get()); + c.DrawMeshAsset(mesh_opaque_used.get()); } } c.Submit(); @@ -146,35 +146,35 @@ void ImageWidget::Draw(base::RenderPass* pass, bool draw_transparent) { } // Always-transparent portion. - if ((mesh_transparent_used.Exists() || draw_radial_transparent) + if ((mesh_transparent_used.exists() || draw_radial_transparent) && draw_transparent) { base::SimpleComponent c(pass); c.SetTransparent(true); c.SetColor(color_red_ * db, color_green_ * db, color_blue_ * db, opacity_); c.SetTexture(texture_); - if (tint_texture_.Exists()) { - c.SetColorizeTexture(tint_texture_.Get()); + if (tint_texture_.exists()) { + c.SetColorizeTexture(tint_texture_.get()); c.SetColorizeColor(tint_color_red_, tint_color_green_, tint_color_blue_); c.SetColorizeColor2(tint2_color_red_, tint2_color_green_, tint2_color_blue_); } - c.SetMaskTexture(mask_texture_.Get()); + c.SetMaskTexture(mask_texture_.get()); { auto xf = c.ScopedTransform(); c.Translate(image_center_x_ + extra_offs_x, image_center_y_ + extra_offs_y); c.Scale(image_width_, image_height_, 1.0f); if (draw_radial_transparent) { - if (!radial_mesh_.Exists()) { + if (!radial_mesh_.exists()) { radial_mesh_ = Object::New(); } base::Graphics::DrawRadialMeter(&(*radial_mesh_), radial_amount_); c.Scale(0.5f, 0.5f, 1.0f); - c.DrawMesh(radial_mesh_.Get()); + c.DrawMesh(radial_mesh_.get()); } else { - c.DrawMeshAsset(mesh_transparent_used.Get()); + c.DrawMeshAsset(mesh_transparent_used.get()); } } c.Submit(); diff --git a/src/ballistica/ui_v1/widget/root_widget.cc b/src/ballistica/ui_v1/widget/root_widget.cc index 7a45b458..bac662c8 100644 --- a/src/ballistica/ui_v1/widget/root_widget.cc +++ b/src/ballistica/ui_v1/widget/root_widget.cc @@ -3,7 +3,6 @@ #include "ballistica/ui_v1/widget/root_widget.h" #include -#include #include #include "ballistica/base/app_mode/app_mode.h" @@ -106,6 +105,7 @@ struct RootWidget::Text { Object::Ref widget; float x{}; float y{}; + bool visible{true}; }; struct RootWidget::ImageDef { @@ -116,6 +116,9 @@ struct RootWidget::ImageDef { float height{32.0f}; float depth_min{}; float depth_max{1.0f}; + float color_r{1.0f}; + float color_g{1.0f}; + float color_b{1.0f}; std::string img; }; @@ -124,6 +127,7 @@ struct RootWidget::Image { Object::Ref widget; float x{}; float y{}; + bool visible{true}; }; RootWidget::RootWidget() { @@ -287,6 +291,7 @@ void RootWidget::AddMeter_(MeterType type, float h_align, float r, float g, break; } } + // Icon on side. { ImageDef imgd; @@ -625,7 +630,42 @@ void RootWidget::Setup() { b.pre_buffer = 25.0f; b.allow_in_game = false; inbox_button_ = AddButton_(b); + bottom_left_buttons_.push_back(inbox_button_); + + // Inbox count circle backing. + { + ImageDef imgd; + imgd.button = inbox_button_; + imgd.x = 18.0f; + imgd.y = 24.0f; + imgd.width = 32.0f; + imgd.height = 32.0f; + imgd.img = "circle"; + imgd.depth_min = 0.3f; + imgd.color_r = 1.0f; + imgd.color_g = 0.0f; + imgd.color_b = 0.0f; + auto* img = AddImage_(imgd); + inbox_count_backing_ = img; + } + // Inbox count number. + { + TextDef td; + td.button = inbox_button_; + td.width = 24.0f; + td.text = "2"; + td.x = 17.0f; + td.y = 24.0f; + td.scale = 0.8f; + td.flatness = 1.0f; + td.shadow = 0.0f; + td.depth_min = 0.3f; + td.color_r = 1.0f; + td.color_g = 1.0f; + td.color_b = 1.0f; + inbox_count_text_ = AddText_(td); + } } // Achievements button. @@ -846,7 +886,7 @@ void RootWidget::Draw(base::RenderPass* pass, bool transparent) { millisecs_t time_diff = std::min(millisecs_t{100}, current_time - update_time_); - StepPositions_(static_cast(time_diff)); + StepChildWidgets_(static_cast(time_diff)); update_time_ = current_time; } ContainerWidget::Draw(pass, transparent); @@ -872,7 +912,7 @@ auto RootWidget::AddButton_(const ButtonDef& def) -> RootWidget::Button* { b.allow_in_game = def.allow_in_game; b.allow_in_main_menu = def.allow_in_main_menu; b.widget = Object::New(); - b.widget->SetColor(def.color_r, def.color_g, def.color_b); + b.widget->set_color(def.color_r, def.color_g, def.color_b); b.widget->set_opacity(def.opacity); b.widget->set_auto_select(true); b.widget->set_text(def.label); @@ -888,9 +928,9 @@ auto RootWidget::AddButton_(const ButtonDef& def) -> RootWidget::Button* { assert(screen_stack_widget_ != nullptr); assert(b.v_align != VAlign::kCenter); if (b.v_align == VAlign::kTop) { - b.widget->set_down_widget(screen_stack_widget_); + b.widget->SetDownWidget(screen_stack_widget_); } else { - b.widget->set_up_widget(screen_stack_widget_); + b.widget->SetUpWidget(screen_stack_widget_); } // We wanna prevent anyone from redirecting these to point to outside // widgets since we'll probably outlive those outside widgets. @@ -898,21 +938,21 @@ auto RootWidget::AddButton_(const ButtonDef& def) -> RootWidget::Button* { if (!def.img.empty()) { base::Assets::AssetListLock lock; - b.widget->SetTexture(g_base->assets->GetTexture(def.img).Get()); + b.widget->SetTexture(g_base->assets->GetTexture(def.img).get()); } if (!def.mesh_transparent.empty()) { base::Assets::AssetListLock lock; b.widget->SetMeshTransparent( - g_base->assets->GetMesh(def.mesh_transparent).Get()); + g_base->assets->GetMesh(def.mesh_transparent).get()); } if (!def.mesh_opaque.empty()) { base::Assets::AssetListLock lock; - b.widget->SetMeshOpaque(g_base->assets->GetMesh(def.mesh_opaque).Get()); + b.widget->SetMeshOpaque(g_base->assets->GetMesh(def.mesh_opaque).get()); } if (def.call != UIV1Python::ObjID::kEmptyCall) { - b.widget->set_on_activate_call(g_ui_v1->python->objs().Get(def.call).Get()); + b.widget->SetOnActivateCall(g_ui_v1->python->objs().Get(def.call).get()); } - AddWidget(b.widget.Get()); + AddWidget(b.widget.get()); return &b; } @@ -924,8 +964,8 @@ auto RootWidget::AddText_(const TextDef& def) -> RootWidget::Text* { t.widget = Object::New(); t.widget->SetWidth(0.0f); t.widget->SetHeight(0.0f); - t.widget->set_halign(TextWidget::HAlign::kCenter); - t.widget->set_valign(TextWidget::VAlign::kCenter); + t.widget->SetHAlign(TextWidget::HAlign::kCenter); + t.widget->SetVAlign(TextWidget::VAlign::kCenter); t.widget->SetText(def.text); t.widget->set_max_width(def.width); t.widget->set_center_scale(def.scale); @@ -933,11 +973,11 @@ auto RootWidget::AddText_(const TextDef& def) -> RootWidget::Text* { t.widget->set_shadow(def.shadow); t.widget->set_flatness(def.flatness); t.widget->set_depth_range(def.depth_min, def.depth_max); - assert(def.button->widget.Exists()); - t.widget->set_draw_control_parent(def.button->widget.Get()); + assert(def.button->widget.exists()); + t.widget->set_draw_control_parent(def.button->widget.get()); t.x = def.x; t.y = def.y; - AddWidget(t.widget.Get()); + AddWidget(t.widget.get()); return &t; } @@ -952,13 +992,14 @@ auto RootWidget::AddImage_(const ImageDef& def) -> RootWidget::Image* { img.widget->set_depth_range(def.depth_min, def.depth_max); if (!def.img.empty()) { base::Assets::AssetListLock lock; - img.widget->SetTexture(g_base->assets->GetTexture(def.img).Get()); + img.widget->SetTexture(g_base->assets->GetTexture(def.img).get()); } - assert(def.button->widget.Exists()); - img.widget->set_draw_control_parent(def.button->widget.Get()); + img.widget->set_color(def.color_r, def.color_g, def.color_b); + assert(def.button->widget.exists()); + img.widget->set_draw_control_parent(def.button->widget.get()); img.x = def.x - def.width * 0.5f; img.y = def.y - def.height * 0.5f; - AddWidget(img.widget.Get()); + AddWidget(img.widget.get()); return &img; } @@ -981,13 +1022,13 @@ void RootWidget::UpdateForFocusedWindow_(Widget* widget) { MarkForUpdate(); } -void RootWidget::StepPositions_(float dt) { +void RootWidget::StepChildWidgets_(float dt) { // Hitches tend to break our math and cause buttons to overshoot on // their transitions in and then back up. So let's limit our max dt // to about what ~30fps would give us. dt = std::min(dt, 1000.0f / 30.0f); - if (!positions_dirty_) { + if (!child_widgets_dirty_) { return; } @@ -1085,9 +1126,9 @@ void RootWidget::StepPositions_(float dt) { if (&b == back_button_) { // Whenever back button is enabled, left on account button should go // to it; otherwise it goes nowhere. - Widget* ab = account_button_->widget.Get(); + Widget* ab = account_button_->widget.get(); ab->set_neighbors_locked(false); - ab->set_left_widget(b.enabled ? back_button_->widget.Get() : ab); + ab->SetLeftWidget(b.enabled ? back_button_->widget.get() : ab); account_button_->widget->set_neighbors_locked(true); } @@ -1153,7 +1194,7 @@ void RootWidget::StepPositions_(float dt) { b->widget->ty() + base_scale_ * b->scale * (b->height * 0.5f + t.y); t.widget->set_translate(x, y); t.widget->set_scale(base_scale_ * b->scale); - t.widget->set_visible_in_container(!b->fully_offscreen); + t.widget->set_visible_in_container(!b->fully_offscreen && t.visible); } for (Image& img : images_) { @@ -1165,10 +1206,10 @@ void RootWidget::StepPositions_(float dt) { b->widget->ty() + base_scale_ * b->scale * (b->height * 0.5f + img.y); img.widget->set_translate(x, y); img.widget->set_scale(base_scale_ * b->scale); - img.widget->set_visible_in_container(!b->fully_offscreen); + img.widget->set_visible_in_container(!b->fully_offscreen && img.visible); } - positions_dirty_ = have_dirty; + child_widgets_dirty_ = have_dirty; } void RootWidget::UpdateLayout() { @@ -1198,11 +1239,11 @@ void RootWidget::UpdateLayout() { overlay_stack_widget_->SetWidth(width()); overlay_stack_widget_->SetHeight(height()); } - positions_dirty_ = true; + child_widgets_dirty_ = true; // Run an immediate step to update things; (avoids jumpy positions if // resizing game window)) - StepPositions_(0.0f); + StepChildWidgets_(0.0f); } void RootWidget::OnUIScaleChange() { MarkForUpdate(); } @@ -1249,32 +1290,32 @@ void RootWidget::SetOverlayWidget(StackWidget* w) { auto RootWidget::GetSpecialWidget(const std::string& s) const -> Widget* { if (s == "squad_button") { - return squad_button_ ? squad_button_->widget.Get() : nullptr; + return squad_button_ ? squad_button_->widget.get() : nullptr; } else if (s == "back_button") { - return back_button_ ? back_button_->widget.Get() : nullptr; + return back_button_ ? back_button_->widget.get() : nullptr; } else if (s == "account_button") { - return account_button_ ? account_button_->widget.Get() : nullptr; + return account_button_ ? account_button_->widget.get() : nullptr; } else if (s == "achievements_button") { - return achievements_button_ ? achievements_button_->widget.Get() : nullptr; + return achievements_button_ ? achievements_button_->widget.get() : nullptr; } else if (s == "inbox_button") { - return inbox_button_ ? inbox_button_->widget.Get() : nullptr; + return inbox_button_ ? inbox_button_->widget.get() : nullptr; } else if (s == "settings_button") { - return settings_button_ ? settings_button_->widget.Get() : nullptr; + return settings_button_ ? settings_button_->widget.get() : nullptr; } else if (s == "store_button") { - return store_button_ ? store_button_->widget.Get() : nullptr; + return store_button_ ? store_button_->widget.get() : nullptr; } else if (s == "get_tokens_button") { - return get_tokens_button_ ? get_tokens_button_->widget.Get() : nullptr; + return get_tokens_button_ ? get_tokens_button_->widget.get() : nullptr; } else if (s == "inventory_button") { - return inventory_button_ ? inventory_button_->widget.Get() : nullptr; + return inventory_button_ ? inventory_button_->widget.get() : nullptr; } else if (s == "tickets_meter") { - return tickets_meter_button_ ? tickets_meter_button_->widget.Get() + return tickets_meter_button_ ? tickets_meter_button_->widget.get() : nullptr; } else if (s == "tokens_meter") { - return tokens_meter_button_ ? tokens_meter_button_->widget.Get() : nullptr; + return tokens_meter_button_ ? tokens_meter_button_->widget.get() : nullptr; } else if (s == "trophy_meter") { - return trophy_meter_button_ ? trophy_meter_button_->widget.Get() : nullptr; + return trophy_meter_button_ ? trophy_meter_button_->widget.get() : nullptr; } else if (s == "level_meter") { - return level_meter_button_ ? level_meter_button_->widget.Get() : nullptr; + return level_meter_button_ ? level_meter_button_->widget.get() : nullptr; } else if (s == "overlay_stack") { return overlay_stack_widget_; } @@ -1283,8 +1324,8 @@ auto RootWidget::GetSpecialWidget(const std::string& s) const -> Widget* { void RootWidget::SetAccountState(bool signed_in, const std::string& name) { if (account_name_text_) { - auto* w{account_name_text_->widget.Get()}; - auto* wb{account_button_->widget.Get()}; + auto* w{account_name_text_->widget.get()}; + auto* wb{account_button_->widget.get()}; assert(w); assert(wb); @@ -1293,20 +1334,20 @@ void RootWidget::SetAccountState(bool signed_in, const std::string& name) { w->set_color(0.0f, 0.4f, 0.1f, 1.0f); w->set_shadow(0.2f); w->set_flatness(1.0f); - wb->SetColor(0.8f, 1.2f, 0.8f); + wb->set_color(0.8f, 1.2f, 0.8f); } else { w->SetText("{\"r\":\"notSignedInText\"}"); w->set_color(1.0f, 0.2f, 0.2f, 1.0f); w->set_shadow(0.5f); w->set_flatness(1.0f); - wb->SetColor(0.45f, 0.4f, 0.4f); + wb->set_color(0.45f, 0.4f, 0.4f); } } } void RootWidget::SetSquadSizeLabel(int val) { if (squad_size_text_) { - auto* w{squad_size_text_->widget.Get()}; + auto* w{squad_size_text_->widget.get()}; assert(w); w->SetText(std::to_string(val)); if (val > 0) { @@ -1368,4 +1409,19 @@ void RootWidget::SetXPText(const std::string& val) { xp_text_->widget->SetText(val); } +void RootWidget::SetInboxCountText(const std::string& val) { + assert(inbox_count_text_); + + inbox_count_text_->widget->SetText(val); + + auto backing_was_visible{inbox_count_backing_->visible}; + auto backing_is_visible = (val != "" && val != "0"); + + if (backing_was_visible != backing_is_visible) { + inbox_count_backing_->visible = backing_is_visible; + inbox_count_text_->visible = backing_is_visible; + child_widgets_dirty_ = true; + } +} + } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/root_widget.h b/src/ballistica/ui_v1/widget/root_widget.h index 0b93492c..bf0ad9ff 100644 --- a/src/ballistica/ui_v1/widget/root_widget.h +++ b/src/ballistica/ui_v1/widget/root_widget.h @@ -46,6 +46,7 @@ class RootWidget : public ContainerWidget { void SetAchievementPercentText(const std::string& val); void SetLevelText(const std::string& val); void SetXPText(const std::string& val); + void SetInboxCountText(const std::string& val); private: struct ButtonDef; @@ -60,7 +61,7 @@ class RootWidget : public ContainerWidget { auto AddButton_(const ButtonDef& def) -> Button*; auto AddText_(const TextDef& def) -> Text*; auto AddImage_(const ImageDef& def) -> Image*; - void StepPositions_(float dt); + void StepChildWidgets_(float dt); void AddMeter_(MeterType type, float h_align, float r, float g, float b, bool plus, const std::string& s); ToolbarVisibility toolbar_visibility_{ToolbarVisibility::kInGame}; @@ -75,7 +76,7 @@ class RootWidget : public ContainerWidget { std::vector top_right_buttons_; std::vector bottom_left_buttons_; std::vector bottom_right_buttons_; - bool positions_dirty_{true}; + bool child_widgets_dirty_{true}; bool in_main_menu_{}; Button* back_button_{}; Button* account_button_{}; @@ -92,6 +93,7 @@ class RootWidget : public ContainerWidget { Button* squad_button_{}; Button* level_meter_button_{}; Image* trophy_icon_{}; + Image* inbox_count_backing_{}; Text* squad_size_text_{}; Text* account_name_text_{}; Text* tickets_meter_text_{}; @@ -100,6 +102,7 @@ class RootWidget : public ContainerWidget { Text* achievement_percent_text_{}; Text* level_text_{}; Text* xp_text_{}; + Text* inbox_count_text_{}; }; } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/text_widget.cc b/src/ballistica/ui_v1/widget/text_widget.cc index 543fa255..c4a3fde0 100644 --- a/src/ballistica/ui_v1/widget/text_widget.cc +++ b/src/ballistica/ui_v1/widget/text_widget.cc @@ -47,11 +47,11 @@ TextWidget::TextWidget() { TextWidget::~TextWidget() = default; -void TextWidget::set_on_return_press_call(PyObject* call_tuple) { +void TextWidget::SetOnReturnPressCall(PyObject* call_tuple) { on_return_press_call_ = Object::New(call_tuple); } -void TextWidget::set_on_activate_call(PyObject* call_tuple) { +void TextWidget::SetOnActivateCall(PyObject* call_tuple) { on_activate_call_ = Object::New(call_tuple); } @@ -227,7 +227,7 @@ void TextWidget::Draw(base::RenderPass* pass, bool draw_transparent) { { auto xf = c.ScopedTransform(); c.Translate(bound_l, bound_b, 0.1f); - c.DrawMesh(highlight_mesh_.Get()); + c.DrawMesh(highlight_mesh_.get()); } } } @@ -343,7 +343,7 @@ void TextWidget::Draw(base::RenderPass* pass, bool draw_transparent) { // Apply subs/resources to get our actual text if need be. UpdateTranslation_(); - if (!text_group_.Exists()) { + if (!text_group_.exists()) { text_group_ = Object::New(); } if (text_group_dirty_) { @@ -597,7 +597,7 @@ void TextWidget::Activate() { last_activate_time_millisecs_ = static_cast(g_base->logic->display_time() * 1000.0); - if (auto* call = on_activate_call_.Get()) { + if (auto* call = on_activate_call_.get()) { // Schedule this to run immediately after any current UI traversal. call->ScheduleInUIOperation(); } @@ -631,9 +631,9 @@ void TextWidget::InvokeStringEditor_() { assert(g_base->InLogicThread()); // If there's already a valid edit attached to us, do nothing. - if (string_edit_adapter_.Exists() + if (string_edit_adapter_.exists() && !g_base->python->CanPyStringEditAdapterBeReplaced( - string_edit_adapter_.Get())) { + string_edit_adapter_.get())) { return; } @@ -643,7 +643,7 @@ void TextWidget::InvokeStringEditor_() { auto result = g_ui_v1->python->objs() .Get(UIV1Python::ObjID::kTextWidgetStringEditAdapterClass) .Call(args); - if (!result.Exists()) { + if (!result.exists()) { g_core->Log(LogName::kBa, LogLevel::kError, "Error invoking string edit dialog."); return; @@ -651,7 +651,7 @@ void TextWidget::InvokeStringEditor_() { // If this new one is already marked replacable, it means it wasn't able // to register as the active one, so we can ignore it. - if (g_base->python->CanPyStringEditAdapterBeReplaced(result.Get())) { + if (g_base->python->CanPyStringEditAdapterBeReplaced(result.get())) { return; } @@ -663,9 +663,9 @@ void TextWidget::InvokeStringEditor_() { // explicitly wants us to use our own. if (g_base->platform->HaveStringEditor() && !g_ui_v1->always_use_internal_on_screen_keyboard()) { - g_base->platform->InvokeStringEditor(string_edit_adapter_.Get()); + g_base->platform->InvokeStringEditor(string_edit_adapter_.get()); } else { - g_ui_v1->python->InvokeStringEditor(string_edit_adapter_.Get()); + g_ui_v1->python->InvokeStringEditor(string_edit_adapter_.get()); } } @@ -724,7 +724,7 @@ auto TextWidget::HandleMessage(const base::WidgetMessage& m) -> bool { parent_widget()->SelectWidget(nullptr); return true; } else { - if (auto* call = on_return_press_call_.Get()) { + if (auto* call = on_return_press_call_.get()) { claimed = true; // Schedule this to run immediately after any current UI traversal. call->ScheduleInUIOperation(); @@ -968,4 +968,25 @@ auto TextWidget::GetTextWidth() -> float { void TextWidget::OnLanguageChange() { text_translation_dirty_ = true; } +void TextWidget::SetHAlign(HAlign a) { + if (alignment_h_ != a) { + text_group_dirty_ = true; + } + alignment_h_ = a; +} +void TextWidget::SetVAlign(VAlign a) { + if (alignment_v_ != a) { + text_group_dirty_ = true; + } + alignment_v_ = a; +} + +void TextWidget::SetGlowType(GlowType glow_type) { + if (glow_type == glow_type_) { + return; + } + glow_type_ = glow_type; + highlight_dirty_ = true; +} + } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/text_widget.h b/src/ballistica/ui_v1/widget/text_widget.h index 76d0c6f3..faecb5d2 100644 --- a/src/ballistica/ui_v1/widget/text_widget.h +++ b/src/ballistica/ui_v1/widget/text_widget.h @@ -11,7 +11,7 @@ namespace ballistica::ui_v1 { -// widget for drawing static text as well as text input +/// Widget for drawing static text as well as text input. class TextWidget : public Widget { public: TextWidget(); @@ -28,18 +28,8 @@ class TextWidget : public Widget { auto IsSelectable() -> bool override { return (enabled_ && (editable_ || selectable_)); } - void set_halign(HAlign a) { - if (alignment_h_ != a) { - text_group_dirty_ = true; - } - alignment_h_ = a; - } - void set_valign(VAlign a) { - if (alignment_v_ != a) { - text_group_dirty_ = true; - } - alignment_v_ = a; - } + void SetHAlign(HAlign a); + void SetVAlign(VAlign a); void set_max_width(float m) { max_width_ = m; } void set_max_height(float m) { max_height_ = m; } void set_rotate(float val) { rotate_ = val; } @@ -60,8 +50,8 @@ class TextWidget : public Widget { auto always_show_carat() const -> bool { return always_show_carat_; } void set_always_show_carat(bool val) { always_show_carat_ = val; } void set_click_activate(bool enabled) { click_activate_ = enabled; } - void set_on_return_press_call(PyObject* call_tuple); - void set_on_activate_call(PyObject* call_tuple); + void SetOnReturnPressCall(PyObject* call_tuple); + void SetOnActivateCall(PyObject* call_tuple); void set_center_scale(float val) { center_scale_ = val; } auto editable() const -> bool { return editable_; } void Activate() override; @@ -89,13 +79,7 @@ class TextWidget : public Widget { void set_extra_touch_border_scale(float scale) { extra_touch_border_scale_ = scale; } - void set_glow_type(GlowType glow_type) { - if (glow_type == glow_type_) { - return; - } - glow_type_ = glow_type; - highlight_dirty_ = true; - } + void SetGlowType(GlowType glow_type); private: auto ScaleAdjustedX_(float x) -> float; diff --git a/src/ballistica/ui_v1/widget/widget.cc b/src/ballistica/ui_v1/widget/widget.cc index a03ffd42..8a101315 100644 --- a/src/ballistica/ui_v1/widget/widget.cc +++ b/src/ballistica/ui_v1/widget/widget.cc @@ -79,7 +79,7 @@ void Widget::SetSelected(bool s, SelectionCause cause) { return; } selected_ = s; - if (selected_ && on_select_call_.Exists()) { + if (selected_ && on_select_call_.exists()) { // Schedule this to run immediately after any current UI traversal. on_select_call_->ScheduleInUIOperation(); } @@ -202,7 +202,7 @@ void Widget::ScreenPointToWidget(float* x, float* y) const { #endif // BA_DEBUG_BUILD || BA_TEST_BUILD } -auto Widget::GetPyWidget(bool new_ref) -> PyObject* { +auto Widget::GetPyWidget_(bool new_ref) -> PyObject* { assert(g_base->InLogicThread()); if (py_ref_ == nullptr) { py_ref_ = PythonClassWidget::Create(this); @@ -234,4 +234,24 @@ void Widget::Activate() {} auto Widget::IsTransitioningOut() const -> bool { return false; } +void Widget::SetRightWidget(Widget* w) { + BA_PRECONDITION(!neighbors_locked_); + right_widget_ = w; +} + +void Widget::SetLeftWidget(Widget* w) { + BA_PRECONDITION(!neighbors_locked_); + left_widget_ = w; +} + +void Widget::SetUpWidget(Widget* w) { + BA_PRECONDITION(!neighbors_locked_); + up_widget_ = w; +} + +void Widget::SetDownWidget(Widget* w) { + BA_PRECONDITION(!neighbors_locked_); + down_widget_ = w; +} + } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/widget/widget.h b/src/ballistica/ui_v1/widget/widget.h index af04706a..61b3fccd 100644 --- a/src/ballistica/ui_v1/widget/widget.h +++ b/src/ballistica/ui_v1/widget/widget.h @@ -16,9 +16,9 @@ namespace ballistica::ui_v1 { // Base class for interface widgets. class Widget : public Object { public: - // Only relevant for direct children of the main stack widget. - // Note that these are bitmask values so that internal root elements can - // specific the entire set of visibilities they apply to. + /// Only relevant for direct children of the main stack widget. Note that + /// these are bitmask values so that internal root elements can specific + /// the entire set of visibilities they apply to. enum class ToolbarVisibility { kInherit = 0, // For popups and whatnot - leave toolbar as-is. kMenuMinimal = 1, // Squad and back buttons. @@ -39,47 +39,49 @@ class Widget : public Object { Widget(); ~Widget() override; - // Activate the widget. + /// Activate the widget. virtual void Activate(); - // Draw the widget. - // Widgets are drawn in 2 passes. The first is a front-to-back pass where - // opaque parts should be drawn and the second is back-to-front where - // transparent stuff should be drawn. + /// Draw the widget. + /// + /// Widgets are drawn in 2 passes. The first is a front-to-back pass where + /// opaque parts should be drawn and the second is back-to-front where + /// transparent stuff should be drawn. virtual void Draw(base::RenderPass* pass, bool transparent); - // Send a message to the widget; returns whether it was handled. + /// Send a message to the widget; returns whether it was handled. virtual auto HandleMessage(const base::WidgetMessage& m) -> bool; - // Whether the widget (or its children) is selectable in any way. + /// Whether the widget (or its children) is selectable in any way. virtual auto IsSelectable() -> bool; - // Whether the widget can be selected by default with direction/tab - // presses. + /// Whether the widget can be selected by default with direction/tab + /// presses. virtual auto IsSelectableViaKeys() -> bool; - // Is the widget currently accepting input? - // (containers transitioning out may return false here, etc). + /// Is the widget currently accepting input? + /// (containers transitioning out may return false here, etc). virtual auto IsAcceptingInput() const -> bool; void SetOnSelectCall(PyObject* call_obj); void AddOnDeleteCall(PyObject* call_obj); - // Globally select this widget. + /// Globally select this widget. void GlobalSelect(); - // Show this widget if possible (by scrolling to it, etc). + /// Show this widget if possible (by scrolling to it, etc). void Show(); - // Returns true if the widget is the currently selected child of its parent - // this does not mean that the parent is selected, however. + /// Returns true if the widget is the currently selected child of its + /// parent. Note that this does not mean that the parent is selected, + /// however. auto selected() const -> bool { return selected_; } - // Returns true if the widget hierarchy is selected (all of its parents). + /// Returns true if the widget hierarchy is selected (all of its parents). auto IsHierarchySelected() const -> bool; - // Only really applicable to container widgets. + /// Only really applicable to container widgets. void SetToolbarVisibility(ToolbarVisibility v); auto toolbar_visibility() const -> ToolbarVisibility { return toolbar_visibility_; @@ -89,33 +91,21 @@ class Widget : public Object { virtual auto GetWidth() -> float { return 0.0f; } virtual auto GetHeight() -> float { return 0.0f; } - // If this widget is in a container, return it. + /// If this widget is in a container, return it. auto parent_widget() const -> ContainerWidget* { return parent_widget_; } - // Return the container_widget containing this widget, or the owner-widget - // if there is no parent. + /// Return the container_widget containing this widget, or the + /// owner-widget if there is no parent. auto GetOwnerWidget() const -> Widget*; - auto down_widget() const -> Widget* { return down_widget_.Get(); } - void set_down_widget(Widget* w) { - BA_PRECONDITION(!neighbors_locked_); - down_widget_ = w; - } - auto up_widget() const -> Widget* { return up_widget_.Get(); } - void set_up_widget(Widget* w) { - BA_PRECONDITION(!neighbors_locked_); - up_widget_ = w; - } - auto left_widget() const -> Widget* { return left_widget_.Get(); } - void set_left_widget(Widget* w) { - BA_PRECONDITION(!neighbors_locked_); - left_widget_ = w; - } - auto right_widget() const -> Widget* { return right_widget_.Get(); } - void set_right_widget(Widget* w) { - BA_PRECONDITION(!neighbors_locked_); - right_widget_ = w; - } + auto down_widget() const -> Widget* { return down_widget_.get(); } + void SetDownWidget(Widget* w); + auto up_widget() const -> Widget* { return up_widget_.get(); } + void SetUpWidget(Widget* w); + auto left_widget() const -> Widget* { return left_widget_.get(); } + void SetLeftWidget(Widget* w); + auto right_widget() const -> Widget* { return right_widget_.get(); } + void SetRightWidget(Widget* w); void set_auto_select(bool enable) { auto_select_ = enable; } auto auto_select() const -> bool { return auto_select_; } @@ -151,7 +141,7 @@ class Widget : public Object { virtual auto GetWidgetTypeName() -> std::string { return "widget"; } virtual auto HasChildren() const -> bool { return false; } - enum class SelectionCause { NEXT_SELECTED, PREV_SELECTED, NONE }; + enum class SelectionCause : uint8_t { kNextSelected, kPrevSelected, kNone }; void set_translate(float x, float y) { tx_ = x; @@ -161,15 +151,15 @@ class Widget : public Object { stack_offset_x_ = x; stack_offset_y_ = y; } - auto tx() const -> float { return tx_; } - auto ty() const -> float { return ty_; } + auto tx() const { return tx_; } + auto ty() const { return ty_; } // Positional offset used when this widget is part of a stack. - auto stack_offset_x() const -> float { return stack_offset_x_; } - auto stack_offset_y() const -> float { return stack_offset_y_; } + auto stack_offset_x() const { return stack_offset_x_; } + auto stack_offset_y() const { return stack_offset_y_; } // Overall scale of the widget. - auto scale() const -> float { return scale_; } + auto scale() const { return scale_; } void set_scale(float s) { scale_ = s; } // Return the widget's center in its parent's space. @@ -185,7 +175,7 @@ class Widget : public Object { // buttons). Ideally we'd probably want to extend the parent mechanism for // this, but this works for now. auto draw_control_parent() const -> Widget* { - return draw_control_parent_.Get(); + return draw_control_parent_.get(); } void set_draw_control_parent(Widget* w) { draw_control_parent_ = w; } @@ -209,10 +199,10 @@ class Widget : public Object { auto show_buffer_left() const -> float { return show_buffer_left_; } auto show_buffer_right() const -> float { return show_buffer_right_; } - auto NewPyRef() -> PyObject* { return GetPyWidget(true); } - auto BorrowPyRef() -> PyObject* { return GetPyWidget(false); } + auto NewPyRef() -> PyObject* { return GetPyWidget_(true); } + auto BorrowPyRef() -> PyObject* { return GetPyWidget_(false); } - auto has_py_ref() -> bool { return (py_ref_ != nullptr); } + auto HasPyRef() -> bool { return (py_ref_ != nullptr); } // For use by containers to flag widgets as invisible (for drawing // efficiency). @@ -236,13 +226,34 @@ class Widget : public Object { void set_simple_culling_bottom(float val) { simple_culling_bottom_ = val; } void set_simple_culling_top(float val) { simple_culling_top_ = val; } - private: - auto GetPyWidget(bool new_ref) -> PyObject*; + /// Should only be called by a widget's parent container. virtual void SetSelected(bool s, SelectionCause cause); - bool selected_{}; - bool visible_in_container_{true}; - bool neighbors_locked_{}; - bool auto_select_{}; + + /// Set widget ID; can be used to lookup particular widgets. + void set_id(const std::string& id) { + // It is caller's responsibility to only call us once before we are + // added to a parent widget. + assert(!id_.has_value()); + assert(parent_widget_ == nullptr); + + id_ = id; + } + auto id() const { return id_; } + + private: + auto GetPyWidget_(bool new_ref) -> PyObject*; + + std::optional id_; + Object::Ref on_select_call_; + std::vector > on_delete_calls_; + Object::WeakRef draw_control_parent_; + Object::WeakRef down_widget_; + Object::WeakRef up_widget_; + Object::WeakRef left_widget_; + Object::WeakRef right_widget_; + ContainerWidget* parent_widget_{}; + PyObject* py_ref_{}; + Widget* owner_widget_{}; ToolbarVisibility toolbar_visibility_{ToolbarVisibility::kMenuMinimalNoBack}; float simple_culling_h_{-1.0f}; float simple_culling_v_{-1.0f}; @@ -254,14 +265,6 @@ class Widget : public Object { float show_buffer_bottom_{20.0f}; float show_buffer_left_{20.0f}; float show_buffer_right_{20.0f}; - Object::WeakRef draw_control_parent_; - Object::WeakRef down_widget_; - Object::WeakRef up_widget_; - Object::WeakRef left_widget_; - Object::WeakRef right_widget_; - ContainerWidget* parent_widget_{}; - PyObject* py_ref_{}; - Widget* owner_widget_{}; float tx_{}; float ty_{}; float stack_offset_x_{}; @@ -269,10 +272,10 @@ class Widget : public Object { float scale_{1.0f}; float depth_range_min_{}; float depth_range_max_{1.0f}; - Object::Ref on_select_call_; - std::vector > on_delete_calls_; - // FIXME: Should move container widget's functionality into ourself. - friend class ContainerWidget; + bool selected_{}; + bool visible_in_container_{true}; + bool neighbors_locked_{}; + bool auto_select_{}; }; } // namespace ballistica::ui_v1 diff --git a/tools/batools/dummymodule.py b/tools/batools/dummymodule.py index 5b98372f..1da29cae 100755 --- a/tools/batools/dummymodule.py +++ b/tools/batools/dummymodule.py @@ -892,6 +892,8 @@ class Generator: '# pylint: disable=redefined-outer-name\n' '# pylint: disable=invalid-name\n' '# pylint: disable=no-value-for-parameter\n' + '# pylint: disable=unused-import\n' + '# pylint: disable=too-many-positional-arguments\n' '\n' 'from __future__ import annotations\n' '\n' diff --git a/tools/batools/metabuild.py b/tools/batools/metabuild.py index 0e845ae5..37c8a564 100644 --- a/tools/batools/metabuild.py +++ b/tools/batools/metabuild.py @@ -99,7 +99,7 @@ def gen_binding_code(projroot: str, in_path: str, out_path: str) -> None: '\n' "// Grab the 'values' list that the binding code created.\n" 'auto bindvals = ctx.DictGetItem("values");\n' - 'if (!bindvals.Exists() || !PyList_Check(*bindvals)) {\n' + 'if (!bindvals.exists() || !PyList_Check(*bindvals)) {\n' ' FatalError("Error binding required Python objects.");\n' '}\n' '\n' @@ -115,7 +115,7 @@ def gen_binding_code(projroot: str, in_path: str, out_path: str) -> None: ) ccode += ( f'{storecmd}(ObjID::{entry[1]},' - f' PyList_GET_ITEM(bindvals.Get(), {i}));\n' + f' PyList_GET_ITEM(bindvals.get(), {i}));\n' ) ccode += '}\n'