yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::CustomObjectManager Class Reference

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

Private Member Functions

 CustomObjectManager ()=default
 
absl::StatusOr< CustomObjectParseBinaryData (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
 

Detailed Description

Manages loading and caching of custom object binary files.

Definition at line 79 of file custom_object.h.

Constructor & Destructor Documentation

◆ CustomObjectManager()

yaze::zelda3::CustomObjectManager::CustomObjectManager ( )
privatedefault

Member Function Documentation

◆ Get()

◆ Initialize()

void yaze::zelda3::CustomObjectManager::Initialize ( const std::string & custom_objects_folder)

◆ SetObjectFileMap()

void yaze::zelda3::CustomObjectManager::SetObjectFileMap ( const std::unordered_map< int, std::vector< std::string > > & map)

◆ ClearObjectFileMap()

void yaze::zelda3::CustomObjectManager::ClearObjectFileMap ( )

◆ HasCustomFileMap()

bool yaze::zelda3::CustomObjectManager::HasCustomFileMap ( ) const
inline

Definition at line 96 of file custom_object.h.

References custom_file_map_.

◆ LoadObject()

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

Here is the call graph for this function:

◆ GetObjectInternal()

absl::StatusOr< std::shared_ptr< CustomObject > > yaze::zelda3::CustomObjectManager::GetObjectInternal ( int object_id,
int subtype )

◆ GetSubtypeCount()

int yaze::zelda3::CustomObjectManager::GetSubtypeCount ( int object_id) const

Definition at line 219 of file custom_object.cc.

References ResolveFileList().

Here is the call graph for this function:

◆ ReloadAll()

void yaze::zelda3::CustomObjectManager::ReloadAll ( )

Definition at line 256 of file custom_object.cc.

References cache_.

◆ AddObjectFile()

void yaze::zelda3::CustomObjectManager::AddObjectFile ( int object_id,
const std::string & filename )

◆ GetEffectiveFileList()

std::vector< std::string > yaze::zelda3::CustomObjectManager::GetEffectiveFileList ( int object_id) const

Definition at line 248 of file custom_object.cc.

References ResolveFileList().

Here is the call graph for this function:

◆ GetBasePath()

const std::string & yaze::zelda3::CustomObjectManager::GetBasePath ( ) const
inline

Definition at line 120 of file custom_object.h.

References base_path_.

◆ ResolveFilename()

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

Here is the call graph for this function:

◆ SnapshotState()

CustomObjectManager::State yaze::zelda3::CustomObjectManager::SnapshotState ( ) const

◆ RestoreState()

◆ ParseBinaryData()

absl::StatusOr< CustomObject > yaze::zelda3::CustomObjectManager::ParseBinaryData ( const std::vector< uint8_t > & data)
private

Definition at line 119 of file custom_object.cc.

References LOG_WARN, and yaze::zelda3::CustomObject::tiles.

Referenced by LoadObject().

◆ ResolveFileList()

const std::vector< std::string > * yaze::zelda3::CustomObjectManager::ResolveFileList ( int object_id) const
private

Member Data Documentation

◆ base_path_

std::string yaze::zelda3::CustomObjectManager::base_path_
private

Definition at line 134 of file custom_object.h.

Referenced by GetBasePath(), Initialize(), LoadObject(), RestoreState(), and SnapshotState().

◆ cache_

std::unordered_map<std::string, std::shared_ptr<CustomObject> > yaze::zelda3::CustomObjectManager::cache_
private

◆ custom_file_map_

std::unordered_map<int, std::vector<std::string> > yaze::zelda3::CustomObjectManager::custom_file_map_
private

◆ kSubtype1Filenames

const std::vector< std::string > yaze::zelda3::CustomObjectManager::kSubtype1Filenames
staticprivate
Initial value:
= {
"track_LR.bin",
"track_UD.bin",
"track_corner_TL.bin",
"track_corner_TR.bin",
"track_corner_BL.bin",
"track_corner_BR.bin",
"track_floor_UD.bin",
"track_floor_LR.bin",
"track_floor_corner_TL.bin",
"track_floor_corner_TR.bin",
"track_floor_corner_BL.bin",
"track_floor_corner_BR.bin",
"track_floor_any.bin",
"wall_sword_house.bin",
"track_any.bin",
"small_statue.bin",
}

Definition at line 139 of file custom_object.h.

Referenced by AddObjectFile(), and ResolveFileList().

◆ kSubtype2Filenames

const std::vector< std::string > yaze::zelda3::CustomObjectManager::kSubtype2Filenames
staticprivate
Initial value:
= {
"furnace.bin",
"firewood.bin",
"ice_chair.bin",
}

Definition at line 141 of file custom_object.h.

Referenced by AddObjectFile(), and ResolveFileList().


The documentation for this class was generated from the following files: