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 () |
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 |
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 37 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 42 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 60 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 66 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 86 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 181 of file custom_object.cc.
References 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 219 of file custom_object.cc.
References ResolveFileList().

| void yaze::zelda3::CustomObjectManager::ReloadAll | ( | ) |
Definition at line 256 of file custom_object.cc.
References cache_.
| void yaze::zelda3::CustomObjectManager::AddObjectFile | ( | int | object_id, |
| const std::string & | filename ) |
Definition at line 231 of file custom_object.cc.
References cache_, custom_file_map_, kSubtype1Filenames, and kSubtype2Filenames.
Referenced by yaze::editor::DungeonEditorV2::Load().
| std::vector< std::string > yaze::zelda3::CustomObjectManager::GetEffectiveFileList | ( | int | object_id | ) | const |
Definition at line 248 of file custom_object.cc.
References ResolveFileList().

|
inline |
Definition at line 120 of file custom_object.h.
References base_path_.
| std::string yaze::zelda3::CustomObjectManager::ResolveFilename | ( | int | object_id, |
| int | subtype ) const |
Definition at line 260 of file custom_object.cc.
References ResolveFileList().
Referenced by yaze::zelda3::ObjectTileEditor::CaptureObjectLayout().

| CustomObjectManager::State yaze::zelda3::CustomObjectManager::SnapshotState | ( | ) | const |
Definition at line 272 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 276 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 119 of file custom_object.cc.
References LOG_WARN, and yaze::zelda3::CustomObject::tiles.
Referenced by LoadObject().
|
private |
Definition at line 71 of file custom_object.cc.
References custom_file_map_, kSubtype1Filenames, and kSubtype2Filenames.
Referenced by GetEffectiveFileList(), GetObjectInternal(), GetSubtypeCount(), Initialize(), and ResolveFilename().
|
private |
Definition at line 134 of file custom_object.h.
Referenced by GetBasePath(), Initialize(), LoadObject(), RestoreState(), and SnapshotState().
|
private |
Definition at line 135 of file custom_object.h.
Referenced by AddObjectFile(), ClearObjectFileMap(), Initialize(), LoadObject(), ReloadAll(), RestoreState(), and SetObjectFileMap().
|
private |
Definition at line 136 of file custom_object.h.
Referenced by AddObjectFile(), ClearObjectFileMap(), HasCustomFileMap(), ResolveFileList(), RestoreState(), SetObjectFileMap(), and SnapshotState().
|
staticprivate |
Definition at line 139 of file custom_object.h.
Referenced by AddObjectFile(), and ResolveFileList().
|
staticprivate |
Definition at line 141 of file custom_object.h.
Referenced by AddObjectFile(), and ResolveFileList().