renaming a few methods for updated project snake_case policy

This commit is contained in:
Eric Froemling 2024-12-03 21:44:48 -08:00
parent d75683cefd
commit 8cbcfa771f
No known key found for this signature in database
198 changed files with 1873 additions and 1740 deletions

74
.efrocachemap generated
View File

@ -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"
}

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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'

View File

@ -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.
"""

View File

@ -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,

View File

@ -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()

View File

@ -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

View File

@ -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),

View File

@ -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<TextGroup>();
hello_text_group_->SetText("Potato!");
}

View File

@ -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<int>(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<int>(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<int>(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<int>(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<T>(i->second.Get());
return Object::Ref<T>(i->second.get());
} else {
auto d(Object::New<T>(file_name));
(*c_list)[file_name] = d;
{
Asset::LockGuard lock(d.Get());
Asset::LockGuard lock(d.get());
have_pending_loads_[static_cast<int>(d->GetAssetType())] = true;
MarkAssetForLoad(d.Get());
MarkAssetForLoad(d.get());
}
d->set_last_used_time(g_core->GetAppTimeMillisecs());
return Object::Ref<T>(d);
@ -490,14 +490,14 @@ auto Assets::GetTexture(TextPacker* packer) -> Object::Ref<TextureAsset> {
const std::string& hash(packer->hash());
auto i = text_textures_.find(hash);
if (i != text_textures_.end()) {
return Object::Ref<TextureAsset>(i->second.Get());
return Object::Ref<TextureAsset>(i->second.get());
} else {
auto d{Object::New<TextureAsset>(packer)};
text_textures_[hash] = d;
{
Asset::LockGuard lock(d.Get());
Asset::LockGuard lock(d.get());
have_pending_loads_[static_cast<int>(d->GetAssetType())] = true;
MarkAssetForLoad(d.Get());
MarkAssetForLoad(d.get());
}
d->set_last_used_time(g_core->GetAppTimeMillisecs());
return Object::Ref<TextureAsset>(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<TextureAsset>(i->second.Get());
return Object::Ref<TextureAsset>(i->second.get());
} else {
auto d(Object::New<TextureAsset>(url));
qr_textures_[url] = d;
{
Asset::LockGuard lock(d.Get());
Asset::LockGuard lock(d.get());
have_pending_loads_[static_cast<int>(d->GetAssetType())] = true;
MarkAssetForLoad(d.Get());
MarkAssetForLoad(d.get());
}
d->set_last_used_time(g_core->GetAppTimeMillisecs());
return Object::Ref<TextureAsset>(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<TextureAsset>(i->second.Get());
return Object::Ref<TextureAsset>(i->second.get());
} else {
auto d(Object::New<TextureAsset>(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<int>(d->GetAssetType())] = true;
MarkAssetForLoad(d.Get());
MarkAssetForLoad(d.get());
}
d->set_last_used_time(g_core->GetAppTimeMillisecs());
return Object::Ref<TextureAsset>(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<TextureAsset>(i->second.Get());
return Object::Ref<TextureAsset>(i->second.get());
} else {
static std::set<std::string>* quality_map_medium = nullptr;
static std::set<std::string>* quality_map_high = nullptr;
@ -594,9 +594,9 @@ auto Assets::GetTexture(const std::string& file_name)
auto d(Object::New<TextureAsset>(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<int>(d->GetAssetType())] = true;
MarkAssetForLoad(d.Get());
MarkAssetForLoad(d.get());
}
d->set_last_used_time(g_core->GetAppTimeMillisecs());
return Object::Ref<TextureAsset>(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<size_t>(id) < system_textures_.size());
return system_textures_[static_cast<int>(id)].Get();
return system_textures_[static_cast<int>(id)].get();
}
auto Assets::SysCubeMapTexture(SysCubeMapTextureID id) -> TextureAsset* {
assert(asset_loads_allowed_ && sys_assets_loaded_);
assert(g_base->InLogicThread());
assert(static_cast<size_t>(id) < system_cube_map_textures_.size());
return system_cube_map_textures_[static_cast<int>(id)].Get();
return system_cube_map_textures_[static_cast<int>(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<int>(id)].Get();
return system_sounds_[static_cast<int>(id)].get();
}
auto Assets::SysMesh(SysMeshID id) -> MeshAsset* {
assert(asset_loads_allowed_ && sys_assets_loaded_);
assert(g_base->InLogicThread());
assert(static_cast<size_t>(id) < system_meshes_.size());
return system_meshes_[static_cast<int>(id)].Get();
return system_meshes_[static_cast<int>(id)].get();
}
} // namespace ballistica::base

View File

@ -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>* asset_ref_ptr) {

View File

@ -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_ + "'.");
}
}

View File

@ -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<VertexObjectFull>().swap(vertices_);
std::vector<uint8_t>().swap(indices8_);
std::vector<uint16_t>().swap(indices16_);

View File

@ -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<VertexObjectFull>& {
return vertices_;
@ -53,7 +53,6 @@ class MeshAsset : public Asset {
std::vector<uint8_t> indices8_;
std::vector<uint16_t> indices16_;
std::vector<uint32_t> indices32_;
friend class MeshAssetRendererData;
BA_DISALLOW_CLASS_COPIES(MeshAsset);
};

View File

@ -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;
}

View File

@ -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_; }

View File

@ -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<SoundAsset>* 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();

View File

@ -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<std::string> {
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;
}

View File

@ -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<SpriteMesh>();
if (ds->spark_vertices.exists()) {
if (!sparks_mesh_.exists()) sparks_mesh_ = Object::New<SpriteMesh>();
sparks_mesh_->SetIndexData(ds->spark_indices);
sparks_mesh_->SetData(
Object::Ref<MeshBuffer<VertexSprite>>(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<SpriteMesh>();
if (!lights_mesh_.exists()) lights_mesh_ = Object::New<SpriteMesh>();
lights_mesh_->SetIndexData(ds->light_indices);
lights_mesh_->SetData(
Object::Ref<MeshBuffer<VertexSprite>>(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<SpriteMesh>();
}
shadows_mesh_->SetIndexData(ds->shadow_indices);
@ -228,7 +228,7 @@ void BGDynamics::Draw(FrameDef* frame_def) {
Object::Ref<MeshBuffer<VertexSprite>>(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<MeshIndexedSmokeFull>();
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<MeshIndexedSimpleFull>();
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();
}
}

View File

@ -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<Object*>(tendril_indices.Get()),
static_cast<Object*>(tendril_vertices.Get()),
static_cast<Object*>(fuse_indices.Get()),
static_cast<Object*>(fuse_vertices.Get()),
static_cast<Object*>(shadow_indices.Get()),
static_cast<Object*>(shadow_vertices.Get()),
static_cast<Object*>(light_indices.Get()),
static_cast<Object*>(light_vertices.Get()),
static_cast<Object*>(spark_indices.Get()),
static_cast<Object*>(spark_vertices.Get())}) {
for (Object* o : {static_cast<Object*>(tendril_indices.get()),
static_cast<Object*>(tendril_vertices.get()),
static_cast<Object*>(fuse_indices.get()),
static_cast<Object*>(fuse_vertices.get()),
static_cast<Object*>(shadow_indices.get()),
static_cast<Object*>(shadow_vertices.get()),
static_cast<Object*>(light_indices.get()),
static_cast<Object*>(light_vertices.get()),
static_cast<Object*>(spark_indices.get()),
static_cast<Object*>(spark_vertices.get())}) {
if (o) {
o->SetThreadOwnership(Object::ThreadOwnership::kClassDefault);
}

View File

@ -85,7 +85,7 @@ class BGDynamicsServer::Terrain {
}
auto GetCollisionMesh() const -> CollisionMeshAsset* {
return collision_mesh_->Get();
return collision_mesh_->get();
}
~Terrain() {

View File

@ -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);

View File

@ -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"

View File

@ -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_);
}

View File

@ -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) {

View File

@ -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.

View File

@ -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<MeshIndexBuffer32*>(buffer->Get()); \
indices32 = static_cast<MeshIndexBuffer32*>(buffer->get()); \
assert(indices32&& indices32 \
== dynamic_cast<MeshIndexBuffer32*>(buffer->Get())); \
== dynamic_cast<MeshIndexBuffer32*>(buffer->get())); \
} else { \
indices16 = static_cast<MeshIndexBuffer16*>(buffer->Get()); \
indices16 = static_cast<MeshIndexBuffer16*>(buffer->get()); \
assert(indices16&& indices16 \
== dynamic_cast<MeshIndexBuffer16*>(buffer->Get())); \
== dynamic_cast<MeshIndexBuffer16*>(buffer->get())); \
} \
index_size++; \
buffer++
#define GET_BUFFER(TYPE, VAR) \
assert(buffer != buffers.end()); \
auto* VAR = static_cast<TYPE*>(buffer->Get()); \
assert(VAR&& VAR == dynamic_cast<TYPE*>(buffer->Get())); \
auto* VAR = static_cast<TYPE*>(buffer->get()); \
assert(VAR&& VAR == dynamic_cast<TYPE*>(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<RenderTargetGL*>(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());

View File

@ -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<TextGroup>();
}
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<TextGroup>();
}
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<TextGroup>();
}
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<Camera>();
}
@ -599,13 +599,13 @@ auto Graphics::GetGraphicsSettingsSnapshot() -> Snapshot<GraphicsSettings>* {
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<SpriteMesh>();
}
shadow_blotch_mesh_->SetIndexData(Object::New<MeshIndexBuffer16>(
@ -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<SpriteMesh>();
}
shadow_blotch_soft_mesh_->SetIndexData(Object::New<MeshIndexBuffer16>(
@ -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<SpriteMesh>();
}
shadow_blotch_soft_obj_mesh_->SetIndexData(Object::New<MeshIndexBuffer16>(
@ -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<GraphicsClientContext>* 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;
}

View File

@ -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<GraphicsSettings>*;
@ -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; }

View File

@ -22,7 +22,7 @@ class MeshIndexed : public MeshIndexedBase {
auto data() const -> const Object::Ref<MeshBuffer<DATA>>& { return data_; }
auto IsValid() const -> bool override {
if (!data_.Exists() || data_->elements.empty()
if (!data_.exists() || data_->elements.empty()
|| !MeshIndexedBase::IsValid()) {
return false;
}

View File

@ -22,11 +22,11 @@ class MeshIndexedBase : public Mesh {
}
void SetIndexData(const Object::Ref<MeshIndexBuffer32>& 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<MeshIndexBuffer16>& 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();
}

View File

@ -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;
}

View File

@ -61,8 +61,8 @@ void TextMesh::SetText(const std::string& text_in, HAlign alignment_h,
}
auto vertices(Object::New<MeshBuffer<VertexDualTextureFull>>(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;

View File

@ -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<int>(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<int>(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();

View File

@ -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_; }

View File

@ -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;

View File

@ -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:

View File

@ -6,9 +6,8 @@
#include <vector>
#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<TextureAsset>& texture) {
assert(texture.Exists());
PutTexture(texture.Get());
assert(texture.exists());
PutTexture(texture.get());
}
void PutCubeMapTexture(TextureAsset* texture) {

View File

@ -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<TextGroup>();
mesh_dirty = true;
}

View File

@ -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.

View File

@ -29,7 +29,7 @@ class TextGroup : public Object {
auto GetElementTexture(int index) const -> TextureAsset* {
assert(index < static_cast<int>(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),

View File

@ -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_;

View File

@ -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<InputDevice> input_device_;

View File

@ -68,16 +68,16 @@ auto Input::GetInputDevice(int id) -> InputDevice* {
if (id < 0 || id >= static_cast<int>(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<InputDevice>(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<InputDevice*> vals;
if (!g_core->HeadlessMode()) {
for (auto& input_device : input_devices_) {
if (input_device.Exists()) {
auto* js = dynamic_cast<JoystickInput*>(input_device.Get());
if (input_device.exists()) {
auto* js = dynamic_cast<JoystickInput*>(input_device.get());
if (js && js->GetDeviceName() == name) {
vals.push_back(js);
}
@ -498,8 +498,8 @@ auto Input::GetConfigurableGamePads() -> std::vector<InputDevice*> {
std::vector<InputDevice*> vals;
if (!g_core->HeadlessMode()) {
for (auto& input_device : input_devices_) {
if (input_device.Exists()) {
auto* js = dynamic_cast<JoystickInput*>(input_device.Get());
if (input_device.exists()) {
auto* js = dynamic_cast<JoystickInput*>(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<Object::Ref<InputDevice> > 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();
}
}

View File

@ -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());

View File

@ -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();
}

View File

@ -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<std::string> {
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<std::string> vals(static_cast<size_t>(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 <typename T>
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<bool>(PyObject_IsInstance(obj, enum_class_obj));
}
@ -418,7 +418,7 @@ template <typename T>
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<int>(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<int>(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,

View File

@ -97,7 +97,7 @@ auto PythonClassAppTimer::tp_new(PyTypeObject* type, PyObject* args,
self->timer_id_ = g_base->logic->NewAppTimer(
static_cast<microsecs_t>(length * 1000000.0), repeat,
Object::New<Runnable, PythonContextCallRunnable>(call_obj).Get());
Object::New<Runnable, PythonContextCallRunnable>(call_obj).get());
self->have_timer_ = true;

View File

@ -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(
("<ba.ContextCall call="
+ (*(self->context_call_))->GetObjectDescription() + ">")

View File

@ -105,7 +105,7 @@ auto PythonClassDisplayTimer::tp_new(PyTypeObject* type, PyObject* args,
}
self->timer_id_ = g_base->logic->NewDisplayTimer(
static_cast<microsecs_t>(length * 1000000.0), repeat,
Object::New<Runnable, PythonContextCallRunnable>(call_obj).Get());
Object::New<Runnable, PythonContextCallRunnable>(call_obj).get());
self->have_timer_ = true;

View File

@ -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;

View File

@ -46,7 +46,7 @@ auto PythonClassSimpleSound::Create(const Object::Ref<SoundAsset>& 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("<Ballistica SimpleSound '") + (s->GetName()) + "'>")
.c_str());
@ -94,7 +94,7 @@ auto PythonClassSimpleSound::Play(PythonClassSimpleSound* self, PyObject* args,
const_cast<char**>(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;

View File

@ -396,7 +396,7 @@ static auto PyAppTimer(PyObject* self, PyObject* args, PyObject* keywds)
}
g_base->logic->NewAppTimer(
static_cast<microsecs_t>(length * 1000000.0), false,
Object::New<Runnable, PythonContextCallRunnable>(call_obj).Get());
Object::New<Runnable, PythonContextCallRunnable>(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<microsecs_t>(length * 1000000.0), false,
Object::New<Runnable, PythonContextCallRunnable>(call_obj).Get());
Object::New<Runnable, PythonContextCallRunnable>(call_obj).get());
Py_RETURN_NONE;
BA_PYTHON_CATCH;
}

View File

@ -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;

View File

@ -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;

View File

@ -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<PythonContextCall> 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<PythonContextCall> 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<PythonContextCall> 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);
}));
}

View File

@ -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_; }

View File

@ -15,7 +15,7 @@ class PythonContextCallRunnable : public Runnable {
: call(Object::New<PythonContextCall>(o)) {}
Object::Ref<PythonContextCall> call;
void Run() override {
assert(call.Exists());
assert(call.exists());
call->Run();
}
~PythonContextCallRunnable() override = default;

View File

@ -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 <typename F>
static auto New(seconds_t length, bool repeat, const F& lambda) {
return Object::New<AppTimer>(length, repeat,
NewLambdaRunnable<F>(lambda).Get());
NewLambdaRunnable<F>(lambda).get());
}
void SetLength(seconds_t length) {

View File

@ -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<Context>& target)
: context_prev_(g_base->CurrentContext()) {
g_base->context_ref->SetTarget(target.Get());
g_base->context_ref->SetTarget(target.get());
}
ScopedSetContext::ScopedSetContext(Context* target)

View File

@ -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<T*>(target_.Get());
return dynamic_cast<T*>(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);

View File

@ -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 <typename F>
static auto New(seconds_t length, bool repeat, const F& lambda) {
return Object::New<DisplayTimer>(length, repeat,
NewLambdaRunnable<F>(lambda).Get());
NewLambdaRunnable<F>(lambda).get());
}
void SetLength(seconds_t length) {

View File

@ -34,9 +34,9 @@ void Repeater::PostInit_() {
auto weak_this = Object::WeakRef<Repeater>(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.

View File

@ -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<Repeater>(initial_delay, repeat_delay,
NewLambdaRunnable<F>(lambda).Get());
NewLambdaRunnable<F>(lambda).get());
// We need to run this bit *after* constructing our obj since it creates
// a strong ref.
rep->PostInit_();

View File

@ -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);
}

View File

@ -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<TextGroup>();
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<Button_>(
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());
}
}

View File

@ -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<TextGroup>();
dev_console_button_txt_->SetText("dev");
}

View File

@ -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* {

View File

@ -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<int>(PyLong_AsLong(ret_val.Get()));
return static_cast<int>(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<float>(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<float>(PyLong_AsLong(ret_val.get()));
} else {
throw Exception(
"Non float/int returned from GetControllerFloatValue call.",
PyExcType::kType);
}
}
return static_cast<float>(PyFloat_AsDouble(ret_val.Get()));
return static_cast<float>(PyFloat_AsDouble(ret_val.get()));
}
auto ClassicPython::BuildPublicPartyStateVal() -> PyObject* {

View File

@ -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<char**>(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<char**>(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)",

View File

@ -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<microsecs_t> 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<scene_v1::HostSession*>(foreground_session_.Get());
dynamic_cast<scene_v1::HostSession*>(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<Object::Ref<scene_v1::Session> > 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

View File

@ -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<std::pair<millisecs_t, scene_v1::PlayerSpec> > banned_players_;
std::optional<float> idle_exit_minutes_{};
std::optional<uint32_t> internal_music_play_id_{};

View File

@ -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;

View File

@ -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<int>(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);
}

View File

@ -3,7 +3,6 @@
#ifndef BALLISTICA_SCENE_V1_ASSETS_SCENE_ASSET_H_
#define BALLISTICA_SCENE_V1_ASSETS_SCENE_ASSET_H_
#include <list>
#include <string>
#include <unordered_map>
@ -23,8 +22,8 @@ static auto GetAsset(std::unordered_map<std::string, Object::WeakRef<T> >* 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<T>(i->second.Get());
if (i != list->end() && i->second.exists()) {
return Object::Ref<T>(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) {

View File

@ -4,6 +4,7 @@
#include <string>
#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(); }

View File

@ -5,7 +5,6 @@
#include <string>
#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";

View File

@ -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

View File

@ -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";

View File

@ -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(); }

View File

@ -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();

View File

@ -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(); }

View File

@ -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();

View File

@ -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(); }

View File

@ -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();

View File

@ -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(); }

View File

@ -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();

View File

@ -8,6 +8,7 @@
#include <vector>
#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<ConnectionToClient*> 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<int>& 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<uint8_t>& 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<uint8_t>& 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;

View File

@ -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*;

View File

@ -285,7 +285,7 @@ void ConnectionToClient::HandleGamePacket(const std::vector<uint8_t>& 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<int>(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;
}
}

View File

@ -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);

View File

@ -253,7 +253,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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;

View File

@ -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<Collision>(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);

View File

@ -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_;

View File

@ -24,7 +24,7 @@ void ImpactSoundMaterialAction::Flatten(char** buffer,
for (int i = 0; i < sound_count; i++) {
Utils::EmbedInt32NBO(buffer,
static_cast_check_fit<int32_t>(
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<MaterialAction>& 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;
}

View File

@ -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<MaterialComponent>& 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());
}
}

View File

@ -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) {

View File

@ -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);
}

Some files were not shown because too many files have changed in this diff Show More