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

Unified interface for accessing resource labels with project overrides. More...

#include <resource_labels.h>

Collaboration diagram for yaze::zelda3::ResourceLabelProvider:

Public Types

using LabelMap = std::unordered_map<std::string, std::string>
 
using ProjectLabels = std::unordered_map<std::string, LabelMap>
 

Public Member Functions

 ResourceLabelProvider ()=default
 
void SetProjectLabels (ProjectLabels *labels)
 Set the project labels reference (typically from YazeProject)
 
void SetHackManifest (const core::HackManifest *manifest)
 Set the hack manifest reference for ASM-defined labels.
 
std::string GetLabel (ResourceType type, int id) const
 Get a label for a resource by type and ID.
 
std::string GetLabel (const std::string &type_str, int id) const
 Get a label using string type key (for compatibility)
 
void SetProjectLabel (ResourceType type, int id, const std::string &label)
 Set a project-specific label override.
 
void ClearProjectLabel (ResourceType type, int id)
 Clear a project-specific label (revert to default)
 
bool HasProjectLabel (ResourceType type, int id) const
 Check if a project-specific label exists.
 
std::string GetVanillaLabel (ResourceType type, int id) const
 Get the vanilla (default) label for a resource.
 
std::string GetHMagicLabel (ResourceType type, int id) const
 Get the Hyrule Magic label for a resource (sprites only)
 
void SetPreferHMagicNames (bool prefer)
 Set whether to prefer Hyrule Magic sprite names.
 
bool PreferHMagicNames () const
 Get whether Hyrule Magic names are preferred.
 
absl::Status ImportFromZScreamFormat (const std::string &content)
 Import labels from ZScream DefaultNames.txt format.
 
std::string ExportToZScreamFormat () const
 Export project labels to ZScream DefaultNames.txt format.
 
absl::Status ImportOracleSpriteRegistry (const std::string &csv_content)
 Import sprite labels from Oracle of Secrets registry.csv format.
 
int GetResourceCount (ResourceType type) const
 Get the count of resources for a given type.
 
const LabelMapGetProjectLabelsForType (ResourceType type) const
 Get all project labels for a given type.
 
void ClearAllProjectLabels ()
 Clear all project labels.
 
const ProjectLabelsGetAllProjectLabels () const
 Get all project labels (read-only)
 

Private Member Functions

bool ParseZScreamLine (const std::string &line, const std::string &section, int &line_index)
 

Private Attributes

ProjectLabelsproject_labels_ = nullptr
 
const core::HackManifesthack_manifest_ = nullptr
 
bool prefer_hmagic_ = true
 

Detailed Description

Unified interface for accessing resource labels with project overrides.

This class provides a centralized way to access resource labels (names) for various game resources. It supports:

  • Project-specific custom labels
  • Hyrule Magic naming convention toggle
  • Vanilla/default labels as fallback
  • Import/export from ZScream DefaultNames.txt format

Resolution Priority: Project Labels -> Hyrule Magic (if enabled) -> Vanilla

Definition at line 57 of file resource_labels.h.

Member Typedef Documentation

◆ LabelMap

using yaze::zelda3::ResourceLabelProvider::LabelMap = std::unordered_map<std::string, std::string>

Definition at line 59 of file resource_labels.h.

◆ ProjectLabels

using yaze::zelda3::ResourceLabelProvider::ProjectLabels = std::unordered_map<std::string, LabelMap>

Definition at line 60 of file resource_labels.h.

Constructor & Destructor Documentation

◆ ResourceLabelProvider()

yaze::zelda3::ResourceLabelProvider::ResourceLabelProvider ( )
default

Member Function Documentation

◆ SetProjectLabels()

void yaze::zelda3::ResourceLabelProvider::SetProjectLabels ( ProjectLabels * labels)
inline

Set the project labels reference (typically from YazeProject)

Definition at line 67 of file resource_labels.h.

References project_labels_.

◆ SetHackManifest()

void yaze::zelda3::ResourceLabelProvider::SetHackManifest ( const core::HackManifest * manifest)
inline

Set the hack manifest reference for ASM-defined labels.

Definition at line 72 of file resource_labels.h.

References hack_manifest_.

Referenced by yaze::project::YazeProject::TryLoadHackManifest().

◆ GetLabel() [1/2]

std::string yaze::zelda3::ResourceLabelProvider::GetLabel ( ResourceType type,
int id ) const

◆ GetLabel() [2/2]

std::string yaze::zelda3::ResourceLabelProvider::GetLabel ( const std::string & type_str,
int id ) const

Get a label using string type key (for compatibility)

Definition at line 174 of file resource_labels.cc.

References GetLabel(), and yaze::zelda3::StringToResourceType().

Here is the call graph for this function:

◆ SetProjectLabel()

void yaze::zelda3::ResourceLabelProvider::SetProjectLabel ( ResourceType type,
int id,
const std::string & label )

Set a project-specific label override.

Definition at line 180 of file resource_labels.cc.

References project_labels_, and yaze::zelda3::ResourceTypeToString().

Here is the call graph for this function:

◆ ClearProjectLabel()

void yaze::zelda3::ResourceLabelProvider::ClearProjectLabel ( ResourceType type,
int id )

Clear a project-specific label (revert to default)

Definition at line 189 of file resource_labels.cc.

References project_labels_, and yaze::zelda3::ResourceTypeToString().

Here is the call graph for this function:

◆ HasProjectLabel()

bool yaze::zelda3::ResourceLabelProvider::HasProjectLabel ( ResourceType type,
int id ) const

Check if a project-specific label exists.

Definition at line 200 of file resource_labels.cc.

References project_labels_, and yaze::zelda3::ResourceTypeToString().

Here is the call graph for this function:

◆ GetVanillaLabel()

◆ GetHMagicLabel()

std::string yaze::zelda3::ResourceLabelProvider::GetHMagicLabel ( ResourceType type,
int id ) const

Get the Hyrule Magic label for a resource (sprites only)

Definition at line 296 of file resource_labels.cc.

References yaze::zelda3::kSprite, yaze::zelda3::kSpriteNameCount, and yaze::zelda3::kSpriteNames.

Referenced by GetLabel().

◆ SetPreferHMagicNames()

void yaze::zelda3::ResourceLabelProvider::SetPreferHMagicNames ( bool prefer)
inline

Set whether to prefer Hyrule Magic sprite names.

Definition at line 126 of file resource_labels.h.

References prefer_hmagic_.

Referenced by yaze::zelda3::SetPreferHmagicSpriteNames().

◆ PreferHMagicNames()

bool yaze::zelda3::ResourceLabelProvider::PreferHMagicNames ( ) const
inline

Get whether Hyrule Magic names are preferred.

Definition at line 131 of file resource_labels.h.

References prefer_hmagic_.

Referenced by yaze::zelda3::PreferHmagicSpriteNames().

◆ ImportFromZScreamFormat()

absl::Status yaze::zelda3::ResourceLabelProvider::ImportFromZScreamFormat ( const std::string & content)

Import labels from ZScream DefaultNames.txt format.

Parameters
contentThe file content to parse
Returns
Status indicating success or parse errors

Parses sections:

  • [Sprites Names] -> sprite labels
  • [Rooms Names] -> room labels
  • [Chests Items] -> item labels
  • [Tags Names] -> room_tag labels

Definition at line 361 of file resource_labels.cc.

References ParseZScreamLine(), and project_labels_.

Here is the call graph for this function:

◆ ExportToZScreamFormat()

std::string yaze::zelda3::ResourceLabelProvider::ExportToZScreamFormat ( ) const

Export project labels to ZScream DefaultNames.txt format.

Returns
The formatted file content

Definition at line 468 of file resource_labels.cc.

References GetLabel(), GetResourceCount(), yaze::zelda3::kItem, yaze::zelda3::kRoom, yaze::zelda3::kRoomTag, and yaze::zelda3::kSprite.

Here is the call graph for this function:

◆ ImportOracleSpriteRegistry()

absl::Status yaze::zelda3::ResourceLabelProvider::ImportOracleSpriteRegistry ( const std::string & csv_content)

Import sprite labels from Oracle of Secrets registry.csv format.

Parameters
csv_contentThe CSV file content (name,id,paths,group,notes,allow_dupe)
Returns
Status indicating success or parse errors

CSV format: name,id,paths,group,notes,allow_dupe Example: Sprite_Manhandla,$88,Sprites/Bosses/manhandla.asm,manhandla,,

Definition at line 510 of file resource_labels.cc.

References yaze::zelda3::name, and project_labels_.

Referenced by yaze::cli::handlers::anonymous_namespace{dungeon_commands.cc}::MaybeLoadSpriteRegistry().

◆ GetResourceCount()

◆ GetProjectLabelsForType()

const ResourceLabelProvider::LabelMap * yaze::zelda3::ResourceLabelProvider::GetProjectLabelsForType ( ResourceType type) const

Get all project labels for a given type.

Definition at line 339 of file resource_labels.cc.

References project_labels_, and yaze::zelda3::ResourceTypeToString().

Here is the call graph for this function:

◆ ClearAllProjectLabels()

void yaze::zelda3::ResourceLabelProvider::ClearAllProjectLabels ( )

Clear all project labels.

Definition at line 351 of file resource_labels.cc.

References project_labels_.

◆ GetAllProjectLabels()

const ProjectLabels * yaze::zelda3::ResourceLabelProvider::GetAllProjectLabels ( ) const
inline

Get all project labels (read-only)

Definition at line 188 of file resource_labels.h.

References project_labels_.

◆ ParseZScreamLine()

bool yaze::zelda3::ResourceLabelProvider::ParseZScreamLine ( const std::string & line,
const std::string & section,
int & line_index )
private

Definition at line 401 of file resource_labels.cc.

References project_labels_.

Referenced by ImportFromZScreamFormat().

Member Data Documentation

◆ project_labels_

◆ hack_manifest_

const core::HackManifest* yaze::zelda3::ResourceLabelProvider::hack_manifest_ = nullptr
private

Definition at line 195 of file resource_labels.h.

Referenced by GetLabel(), and SetHackManifest().

◆ prefer_hmagic_

bool yaze::zelda3::ResourceLabelProvider::prefer_hmagic_ = true
private

Definition at line 198 of file resource_labels.h.

Referenced by GetLabel(), PreferHMagicNames(), and SetPreferHMagicNames().


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