Manages loading and caching of custom object binary files. More...
#include <custom_object.h>
Classes | |
| 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 |
| 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 () |
| void | AddObjectFile (int object_id, const std::string &filename) |
| std::vector< std::string > | GetEffectiveFileList (int object_id) const |
| const std::string & | GetBasePath () 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 const std::vector< std::string > & | DefaultSubtypeFilenamesForObject (int object_id) |
Private Member Functions | |
| CustomObjectManager ()=default | |
| absl::StatusOr< CustomObject > | ParseBinaryData (const std::vector< uint8_t > &data) |
| const std::vector< std::string > * | ResolveFileList (int object_id) const |
| bool | IsCornerAliasOverrideEnabled (int resolved_index) const |
Private Attributes | |
| std::string | base_path_ |
| std::unordered_map< std::string, std::shared_ptr< CustomObject > > | cache_ |
| std::unordered_map< int, std::vector< std::string > > | custom_file_map_ |
Static Private Attributes | |
| static const std::vector< std::string > | kSubtype1Filenames |
| static const std::vector< std::string > | kSubtype2Filenames |
Manages loading and caching of custom object binary files.
Definition at line 79 of file custom_object.h.
|
privatedefault |
|
static |
Definition at line 64 of file custom_object.cc.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext(), yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), yaze::zelda3::draw_routines::CustomDraw(), yaze::zelda3::ObjectDrawer::DrawCustomObject(), yaze::editor::DungeonObjectSelector::DrawNewCustomObjectDialog(), yaze::zelda3::ObjectDrawer::DrawObject(), yaze::editor::DungeonObjectSelector::DrawObjectAssetBrowser(), yaze::editor::DungeonObjectSelector::EnsureCustomObjectsInitialized(), yaze::zelda3::ObjectDimensionTable::GetSelectionBounds(), yaze::editor::DungeonEditorV2::Load(), yaze::editor::EditorManager::LoadProjectWithRom(), yaze::editor::EditorManager::LoadRom(), yaze::cli::resources::CommandContext::RestoreProjectRuntimeContext(), and yaze::zelda3::ObjectTileEditor::WriteBack().
| void yaze::zelda3::CustomObjectManager::Initialize | ( | const std::string & | custom_objects_folder | ) |
Definition at line 69 of file custom_object.cc.
References base_path_, cache_, LOG_INFO, LOG_WARN, and ResolveFileList().
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext(), yaze::editor::DungeonObjectSelector::EnsureCustomObjectsInitialized(), yaze::editor::DungeonEditorV2::Load(), and yaze::editor::EditorManager::LoadProjectWithRom().

| void yaze::zelda3::CustomObjectManager::SetObjectFileMap | ( | const std::unordered_map< int, std::vector< std::string > > & | map | ) |
Definition at line 87 of file custom_object.cc.
References cache_, and custom_file_map_.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext(), and yaze::editor::EditorManager::LoadProjectWithRom().
| void yaze::zelda3::CustomObjectManager::ClearObjectFileMap | ( | ) |
Definition at line 93 of file custom_object.cc.
References cache_, and custom_file_map_.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext(), yaze::editor::EditorManager::LoadProjectWithRom(), and yaze::editor::EditorManager::LoadRom().
|
inline |
Definition at line 96 of file custom_object.h.
References custom_file_map_.
| absl::StatusOr< std::shared_ptr< CustomObject > > yaze::zelda3::CustomObjectManager::LoadObject | ( | const std::string & | filename | ) |
Definition at line 141 of file custom_object.cc.
References base_path_, cache_, LOG_ERROR, and ParseBinaryData().
Referenced by GetObjectInternal().

| absl::StatusOr< std::shared_ptr< CustomObject > > yaze::zelda3::CustomObjectManager::GetObjectInternal | ( | int | object_id, |
| int | subtype ) |
Definition at line 236 of file custom_object.cc.
References IsCornerAliasOverrideEnabled(), LoadObject(), and ResolveFileList().
Referenced by yaze::zelda3::ObjectTileEditor::CaptureObjectLayout(), yaze::zelda3::draw_routines::CustomDraw(), yaze::zelda3::ObjectDrawer::DrawObject(), and yaze::zelda3::ObjectDimensionTable::GetSelectionBounds().

| int yaze::zelda3::CustomObjectManager::GetSubtypeCount | ( | int | object_id | ) | const |
Definition at line 260 of file custom_object.cc.
References ResolveFileList().

| void yaze::zelda3::CustomObjectManager::ReloadAll | ( | ) |
Definition at line 307 of file custom_object.cc.
References cache_.
| void yaze::zelda3::CustomObjectManager::AddObjectFile | ( | int | object_id, |
| const std::string & | filename ) |
Definition at line 272 of file custom_object.cc.
References cache_, custom_file_map_, and DefaultSubtypeFilenamesForObject().
Referenced by yaze::editor::DungeonEditorV2::Load().

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

|
static |
Definition at line 296 of file custom_object.cc.
References kSubtype1Filenames, and kSubtype2Filenames.
Referenced by AddObjectFile(), yaze::editor::anonymous_namespace{editor_manager.cc}::SeedLegacyTrackObjectMapping(), and yaze::cli::resources::anonymous_namespace{command_context.cc}::SeedLegacyTrackObjectMapping().
|
inline |
Definition at line 125 of file custom_object.h.
References base_path_.
| std::string yaze::zelda3::CustomObjectManager::ResolveFilename | ( | int | object_id, |
| int | subtype ) const |
Definition at line 311 of file custom_object.cc.
References ResolveFileList().
Referenced by yaze::zelda3::ObjectTileEditor::CaptureObjectLayout().

| CustomObjectManager::State yaze::zelda3::CustomObjectManager::SnapshotState | ( | ) | const |
Definition at line 324 of file custom_object.cc.
References yaze::zelda3::CustomObjectManager::State::base_path, base_path_, and custom_file_map_.
Referenced by yaze::cli::resources::CommandContext::ApplyProjectRuntimeContext().
| void yaze::zelda3::CustomObjectManager::RestoreState | ( | const State & | state | ) |
Definition at line 328 of file custom_object.cc.
References yaze::zelda3::CustomObjectManager::State::base_path, base_path_, cache_, yaze::zelda3::CustomObjectManager::State::custom_file_map, and custom_file_map_.
Referenced by yaze::cli::resources::CommandContext::RestoreProjectRuntimeContext().
|
private |
Definition at line 174 of file custom_object.cc.
References LOG_WARN, and yaze::zelda3::CustomObject::tiles.
Referenced by LoadObject().
|
private |
Definition at line 98 of file custom_object.cc.
References custom_file_map_, kSubtype1Filenames, and kSubtype2Filenames.
Referenced by GetEffectiveFileList(), GetObjectInternal(), GetSubtypeCount(), Initialize(), and ResolveFilename().
|
private |
Definition at line 113 of file custom_object.cc.
References base_path_, and custom_file_map_.
Referenced by GetObjectInternal().
|
private |
Definition at line 142 of file custom_object.h.
Referenced by GetBasePath(), Initialize(), IsCornerAliasOverrideEnabled(), LoadObject(), RestoreState(), and SnapshotState().
|
private |
Definition at line 143 of file custom_object.h.
Referenced by AddObjectFile(), ClearObjectFileMap(), Initialize(), LoadObject(), ReloadAll(), RestoreState(), and SetObjectFileMap().
|
private |
Definition at line 144 of file custom_object.h.
Referenced by AddObjectFile(), ClearObjectFileMap(), HasCustomFileMap(), IsCornerAliasOverrideEnabled(), ResolveFileList(), RestoreState(), SetObjectFileMap(), and SnapshotState().
|
staticprivate |
Definition at line 147 of file custom_object.h.
Referenced by DefaultSubtypeFilenamesForObject(), and ResolveFileList().
|
staticprivate |
Definition at line 149 of file custom_object.h.
Referenced by DefaultSubtypeFilenamesForObject(), and ResolveFileList().