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>

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)
 
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.
 
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
 
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 56 of file resource_labels.h.

Member Typedef Documentation

◆ LabelMap

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

Definition at line 58 of file resource_labels.h.

◆ ProjectLabels

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

Definition at line 59 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 66 of file resource_labels.h.

References project_labels_.

◆ GetLabel() [1/2]

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

Get a label for a resource by type and ID.

Parameters
typeThe resource type
idThe numeric ID of the resource
Returns
The resolved label string

Resolution order:

  1. Project-specific label if set
  2. Hyrule Magic label if prefer_hmagic_ is true
  3. Vanilla/default label

Definition at line 96 of file resource_labels.cc.

References GetHMagicLabel(), GetVanillaLabel(), yaze::zelda3::kSprite, prefer_hmagic_, project_labels_, and yaze::zelda3::ResourceTypeToString().

Referenced by ExportToZScreamFormat(), yaze::zelda3::GetEntranceLabel(), yaze::zelda3::GetItemLabel(), GetLabel(), yaze::zelda3::GetMusicLabel(), yaze::zelda3::GetOverlordLabel(), yaze::zelda3::GetOverworldMapLabel(), yaze::zelda3::GetRoomLabel(), yaze::zelda3::GetRoomTagLabel(), yaze::zelda3::GetSpriteLabel(), and yaze::zelda3::ResolveSpriteName().

Here is the call graph for this function:

◆ 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 122 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 128 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 137 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 148 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 244 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 118 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 123 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 309 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 416 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:

◆ GetResourceCount()

◆ GetProjectLabelsForType()

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

Get all project labels for a given type.

Definition at line 287 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 299 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 170 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 349 of file resource_labels.cc.

References project_labels_.

Referenced by ImportFromZScreamFormat().

Member Data Documentation

◆ project_labels_

◆ prefer_hmagic_

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

Definition at line 177 of file resource_labels.h.

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


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