Manages loading and caching of custom object binary files. More...
#include <custom_object.h>

Classes | |
| struct | RuntimeContext |
| struct | State |
Public Member Functions | |
| void | Initialize (const std::string &custom_objects_folder) |
| void | SetObjectFileMap (const std::unordered_map< int, std::vector< std::string > > &map) |
| void | ClearObjectFileMap () |
| bool | HasCustomFileMap () const |
| void | ActivateRuntimeContext (uint64_t context_id, const State &state) |
| void | ActivateStandaloneContext () |
| void | RemoveRuntimeContext (uint64_t context_id) |
| std::optional< uint64_t > | active_runtime_context_id () const |
| absl::StatusOr< std::shared_ptr< CustomObject > > | LoadObject (const std::string &filename) |
| absl::StatusOr< std::shared_ptr< CustomObject > > | GetObjectInternal (int object_id, int subtype) |
| int | GetSubtypeCount (int object_id) const |
| void | ReloadAll () |
| std::vector< std::string > | GetEffectiveFileList (int object_id) const |
| const std::string & | GetBasePath () const |
| uint64_t | asset_generation () const |
| absl::StatusOr< CustomObjectSlotBinding > | ResolveSlotBinding (int object_id, int subtype) const |
| std::string | ResolveFilename (int object_id, int subtype) const |
| State | SnapshotState () const |
| void | RestoreState (const State &state) |
Static Public Member Functions | |
| static CustomObjectManager & | Get () |
| static int | RuntimeSubtypeCountForObject (int object_id) |
| static const std::array< int, 3 > & | RuntimeObjectIds () |
| static const std::vector< std::string > & | DefaultSubtypeFilenamesForObject (int object_id) |
Private Member Functions | |
| CustomObjectManager () | |
| RuntimeContext & | ActiveContext () |
| const RuntimeContext & | ActiveContext () const |
| uint64_t | NextAssetGeneration () |
| void | InvalidateCaches () |
| const std::vector< std::string > * | ResolveFileList (int object_id) const |
Private Attributes | |
| RuntimeContext | standalone_context_ |
| std::unordered_map< uint64_t, RuntimeContext > | runtime_contexts_ |
| std::optional< uint64_t > | active_runtime_context_id_ |
| uint64_t | next_asset_generation_ = 1 |
Static Private Attributes | |
| static const std::vector< std::string > | kSubtype1Filenames |
| static const std::vector< std::string > | kSubtype2Filenames |
| static const std::vector< std::string > | kSubtype54Filenames |
Manages loading and caching of custom object binary files.
Definition at line 136 of file custom_object.h.
|
private |
Definition at line 529 of file custom_object.cc.
References yaze::zelda3::CustomObjectManager::RuntimeContext::asset_generation, NextAssetGeneration(), and standalone_context_.

|
static |
Definition at line 524 of file custom_object.cc.
Referenced by yaze::editor::ObjectTileEditorPanel::AnalyzeSourceImpactSnapshot(), yaze::editor::EditorManager::ApplyCurrentProjectRuntimeContext(), yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext(), yaze::editor::ObjectTileEditorPanel::BuildSourceImpactProvenanceFingerprint(), yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), yaze::zelda3::draw_routines::CustomDraw(), yaze::editor::DungeonObjectSelector::DetachRuntimeContext(), yaze::zelda3::ObjectDrawer::DrawCustomObject(), yaze::editor::DungeonObjectSelector::DrawCustomObjectAssetBrowser(), yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser(), yaze::editor::workbench::DrawObjectSizeControls(), yaze::editor::DungeonObjectSelector::GetCustomObjectAssetStatus(), yaze::zelda3::ObjectDimensionTable::GetSelectionBounds(), yaze::editor::EditorManager::HandleSessionClosed(), yaze::editor::EditorManager::HandleSessionSwitched(), yaze::zelda3::HasActiveCustomObjectOverride(), yaze::zelda3::IsRoomObjectResizable(), yaze::zelda3::ObjectTileEditor::LoadCustomObjectLayout(), yaze::zelda3::ObjectGeometry::MeasureByObjectId(), yaze::cli::resources::CommandContext::RestoreProjectRuntimeContext(), yaze::editor::DungeonObjectSelector::SelectObject(), yaze::editor::DungeonEditorV2::SynchronizeCustomObjectAssets(), yaze::editor::DungeonObjectSelector::SynchronizeCustomObjectGeneration(), yaze::editor::TileObjectHandler::UpdateObjectsSize(), and yaze::zelda3::ObjectTileEditor::WriteBack().
| void yaze::zelda3::CustomObjectManager::Initialize | ( | const std::string & | custom_objects_folder | ) |
Definition at line 559 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::base_path, GetBasePath(), InvalidateCaches(), LOG_INFO, ResolveFileList(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext().

| void yaze::zelda3::CustomObjectManager::SetObjectFileMap | ( | const std::unordered_map< int, std::vector< std::string > > & | map | ) |
Definition at line 572 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::custom_file_map, InvalidateCaches(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext().

| void yaze::zelda3::CustomObjectManager::ClearObjectFileMap | ( | ) |
Definition at line 578 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::custom_file_map, InvalidateCaches(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext().

| bool yaze::zelda3::CustomObjectManager::HasCustomFileMap | ( | ) | const |
Definition at line 583 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::custom_file_map, and yaze::zelda3::CustomObjectManager::RuntimeContext::state.

| void yaze::zelda3::CustomObjectManager::ActivateRuntimeContext | ( | uint64_t | context_id, |
| const State & | state ) |
Definition at line 587 of file custom_object.cc.
References active_runtime_context_id_, yaze::zelda3::ObjectGeometry::ClearCache(), yaze::zelda3::ObjectGeometry::Get(), NextAssetGeneration(), and runtime_contexts_.
Referenced by yaze::editor::EditorManager::HandleSessionSwitched().

| void yaze::zelda3::CustomObjectManager::ActivateStandaloneContext | ( | ) |
Definition at line 600 of file custom_object.cc.
References active_runtime_context_id_.
Referenced by yaze::editor::EditorManager::HandleSessionSwitched().
| void yaze::zelda3::CustomObjectManager::RemoveRuntimeContext | ( | uint64_t | context_id | ) |
Definition at line 604 of file custom_object.cc.
References active_runtime_context_id_, and runtime_contexts_.
Referenced by yaze::editor::EditorManager::HandleSessionClosed().
|
inline |
Definition at line 162 of file custom_object.h.
References active_runtime_context_id_.
| absl::StatusOr< std::shared_ptr< CustomObject > > yaze::zelda3::CustomObjectManager::LoadObject | ( | const std::string & | filename | ) |
Definition at line 630 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::RuntimeContext::cache, GetBasePath(), yaze::zelda3::LoadCustomObjectAsset(), and LOG_ERROR.
Referenced by GetObjectInternal().

| absl::StatusOr< std::shared_ptr< CustomObject > > yaze::zelda3::CustomObjectManager::GetObjectInternal | ( | int | object_id, |
| int | subtype ) |
Definition at line 652 of file custom_object.cc.
References LoadObject(), ResolveFileList(), and RuntimeSubtypeCountForObject().
Referenced by yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), yaze::zelda3::draw_routines::CustomDraw(), yaze::editor::DungeonObjectSelector::GetCustomObjectAssetStatus(), yaze::zelda3::ObjectDimensionTable::GetSelectionBounds(), yaze::zelda3::HasActiveCustomObjectOverride(), and yaze::editor::DungeonObjectSelector::SelectObject().

| int yaze::zelda3::CustomObjectManager::GetSubtypeCount | ( | int | object_id | ) | const |
Definition at line 667 of file custom_object.cc.
References ResolveFileList(), and RuntimeSubtypeCountForObject().
Referenced by yaze::zelda3::IsRoomObjectResizable().

|
static |
Definition at line 678 of file custom_object.cc.
References DefaultSubtypeFilenamesForObject().
Referenced by yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser(), yaze::editor::workbench::DrawObjectSizeControls(), yaze::editor::DungeonCanvasViewer::DrawRoomCanvasOverlays(), GetObjectInternal(), GetSubtypeCount(), yaze::editor::IsDungeonCustomObjectRuntimeSlot(), yaze::zelda3::ObjectTileEditor::LoadCustomObjectLayout(), ResolveFilename(), ResolveSlotBinding(), yaze::editor::DungeonObjectSelector::SelectObject(), and yaze::zelda3::ObjectTileEditor::WriteBack().

|
static |
| void yaze::zelda3::CustomObjectManager::ReloadAll | ( | ) |
Definition at line 710 of file custom_object.cc.
References InvalidateCaches().

| std::vector< std::string > yaze::zelda3::CustomObjectManager::GetEffectiveFileList | ( | int | object_id | ) | const |
Definition at line 687 of file custom_object.cc.
References ResolveFileList().

|
static |
Definition at line 696 of file custom_object.cc.
References kSubtype1Filenames, kSubtype2Filenames, and kSubtype54Filenames.
Referenced by ResolveSlotBinding(), RuntimeSubtypeCountForObject(), yaze::editor::anonymous_namespace{editor_manager.cc}::SeedLegacyTrackObjectMapping(), and yaze::cli::resources::anonymous_namespace{command_context.cc}::SeedLegacyTrackObjectMapping().
| const std::string & yaze::zelda3::CustomObjectManager::GetBasePath | ( | ) | const |
Definition at line 765 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::base_path, and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by Initialize(), and LoadObject().

| uint64_t yaze::zelda3::CustomObjectManager::asset_generation | ( | ) | const |
Definition at line 769 of file custom_object.cc.
References ActiveContext(), and yaze::zelda3::CustomObjectManager::RuntimeContext::asset_generation.
Referenced by yaze::editor::DungeonObjectSelector::DetachRuntimeContext(), yaze::zelda3::ObjectGeometry::MeasureByObjectId(), yaze::editor::DungeonEditorV2::SynchronizeCustomObjectAssets(), and yaze::editor::DungeonObjectSelector::SynchronizeCustomObjectGeneration().

| absl::StatusOr< CustomObjectSlotBinding > yaze::zelda3::CustomObjectManager::ResolveSlotBinding | ( | int | object_id, |
| int | subtype ) const |
Definition at line 714 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::custom_file_map, DefaultSubtypeFilenamesForObject(), yaze::zelda3::CustomObjectSlotBinding::filename, yaze::zelda3::kConfiguredFilename, yaze::zelda3::kConfiguredSlotUnmapped, yaze::zelda3::kDefaultFilename, yaze::zelda3::CustomObjectSlotBinding::origin, RuntimeSubtypeCountForObject(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by ResolveFilename().

| std::string yaze::zelda3::CustomObjectManager::ResolveFilename | ( | int | object_id, |
| int | subtype ) const |
Definition at line 741 of file custom_object.cc.
References ResolveFileList(), ResolveSlotBinding(), and RuntimeSubtypeCountForObject().
Referenced by yaze::zelda3::ObjectTileEditor::CaptureObjectLayout().

| CustomObjectManager::State yaze::zelda3::CustomObjectManager::SnapshotState | ( | ) | const |
Definition at line 756 of file custom_object.cc.
References ActiveContext(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext().

| void yaze::zelda3::CustomObjectManager::RestoreState | ( | const State & | state | ) |
Definition at line 760 of file custom_object.cc.
References ActiveContext(), InvalidateCaches(), and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by yaze::cli::resources::CommandContext::RestoreProjectRuntimeContext().

|
private |
Definition at line 533 of file custom_object.cc.
References active_runtime_context_id_, runtime_contexts_, and standalone_context_.
Referenced by asset_generation(), ClearObjectFileMap(), GetBasePath(), HasCustomFileMap(), Initialize(), InvalidateCaches(), LoadObject(), ResolveFileList(), ResolveSlotBinding(), RestoreState(), SetObjectFileMap(), and SnapshotState().
|
private |
Definition at line 540 of file custom_object.cc.
References active_runtime_context_id_, runtime_contexts_, and standalone_context_.
|
private |
Definition at line 548 of file custom_object.cc.
References next_asset_generation_.
Referenced by ActivateRuntimeContext(), CustomObjectManager(), and InvalidateCaches().
|
private |
Definition at line 552 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::ObjectGeometry::ClearCache(), yaze::zelda3::ObjectGeometry::Get(), and NextAssetGeneration().
Referenced by ClearObjectFileMap(), Initialize(), ReloadAll(), RestoreState(), and SetObjectFileMap().

|
private |
Definition at line 611 of file custom_object.cc.
References ActiveContext(), yaze::zelda3::CustomObjectManager::State::custom_file_map, kSubtype1Filenames, kSubtype2Filenames, kSubtype54Filenames, and yaze::zelda3::CustomObjectManager::RuntimeContext::state.
Referenced by GetEffectiveFileList(), GetObjectInternal(), GetSubtypeCount(), Initialize(), and ResolveFilename().

|
private |
Definition at line 225 of file custom_object.h.
Referenced by ActiveContext(), ActiveContext(), and CustomObjectManager().
|
private |
Definition at line 226 of file custom_object.h.
Referenced by ActivateRuntimeContext(), ActiveContext(), ActiveContext(), and RemoveRuntimeContext().
|
private |
Definition at line 227 of file custom_object.h.
Referenced by ActivateRuntimeContext(), ActivateStandaloneContext(), active_runtime_context_id(), ActiveContext(), ActiveContext(), and RemoveRuntimeContext().
|
private |
Definition at line 228 of file custom_object.h.
Referenced by NextAssetGeneration().
|
staticprivate |
Definition at line 231 of file custom_object.h.
Referenced by DefaultSubtypeFilenamesForObject(), and ResolveFileList().
|
staticprivate |
Definition at line 233 of file custom_object.h.
Referenced by DefaultSubtypeFilenamesForObject(), and ResolveFileList().
|
staticprivate |
Definition at line 235 of file custom_object.h.
Referenced by DefaultSubtypeFilenamesForObject(), and ResolveFileList().