yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
resource_labels.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_RESOURCE_LABELS_H
2#define YAZE_ZELDA3_RESOURCE_LABELS_H
3
4#include <cstdint>
5#include <functional>
6#include <string>
7#include <unordered_map>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "core/hack_manifest.h"
12
13namespace yaze {
14namespace zelda3 {
15
20enum class ResourceType {
21 kSprite,
22 kRoom,
24 kItem,
27 kMusic,
32};
33
37std::string ResourceTypeToString(ResourceType type);
38
42ResourceType StringToResourceType(const std::string& type_str);
43
58 public:
59 using LabelMap = std::unordered_map<std::string, std::string>;
60 using ProjectLabels = std::unordered_map<std::string, LabelMap>;
61
63
68
72 void SetHackManifest(const core::HackManifest* manifest) {
73 hack_manifest_ = manifest;
74 }
75
87 std::string GetLabel(ResourceType type, int id) const;
88
92 std::string GetLabel(const std::string& type_str, int id) const;
93
97 void SetProjectLabel(ResourceType type, int id, const std::string& label);
98
102 void ClearProjectLabel(ResourceType type, int id);
103
107 bool HasProjectLabel(ResourceType type, int id) const;
108
112 std::string GetVanillaLabel(ResourceType type, int id) const;
113
117 std::string GetHMagicLabel(ResourceType type, int id) const;
118
119 // =========================================================================
120 // Hyrule Magic Naming Toggle
121 // =========================================================================
122
126 void SetPreferHMagicNames(bool prefer) { prefer_hmagic_ = prefer; }
127
131 bool PreferHMagicNames() const { return prefer_hmagic_; }
132
133 // =========================================================================
134 // ZScream DefaultNames.txt Import/Export
135 // =========================================================================
136
148 absl::Status ImportFromZScreamFormat(const std::string& content);
149
154 std::string ExportToZScreamFormat() const;
155
164 absl::Status ImportOracleSpriteRegistry(const std::string& csv_content);
165
166 // =========================================================================
167 // Utility Methods
168 // =========================================================================
169
173 int GetResourceCount(ResourceType type) const;
174
179
184
189
190 private:
191 // Project-specific label overrides (owned by YazeProject)
193
194 // Hack manifest reference (owned by YazeProject)
196
197 // Whether to prefer Hyrule Magic sprite names
198 bool prefer_hmagic_ = true;
199
200 // Parse a single line in ZScream format
201 bool ParseZScreamLine(const std::string& line, const std::string& section,
202 int& line_index);
203};
204
205// ============================================================================
206// Global Provider Instance
207// ============================================================================
208
216
220inline std::string GetSpriteLabel(int id) {
222}
223
227inline std::string GetRoomLabel(int id) {
229}
230
234inline std::string GetItemLabel(int id) {
236}
237
241inline std::string GetEntranceLabel(int id) {
243}
244
248inline std::string GetOverlordLabel(int id) {
250}
251
255inline std::string GetOverworldMapLabel(int id) {
257}
258
262inline std::string GetMusicLabel(int id) {
264}
265
269inline std::string GetRoomTagLabel(int id) {
271}
272
273} // namespace zelda3
274} // namespace yaze
275
276#endif // YAZE_ZELDA3_RESOURCE_LABELS_H
Loads and queries the hack manifest JSON for yaze-ASM integration.
Unified interface for accessing resource labels with project overrides.
std::string ExportToZScreamFormat() const
Export project labels to ZScream DefaultNames.txt format.
void SetProjectLabel(ResourceType type, int id, const std::string &label)
Set a project-specific label override.
bool HasProjectLabel(ResourceType type, int id) const
Check if a project-specific label exists.
const ProjectLabels * GetAllProjectLabels() const
Get all project labels (read-only)
void ClearAllProjectLabels()
Clear all project labels.
int GetResourceCount(ResourceType type) const
Get the count of resources for a given type.
std::unordered_map< std::string, std::string > LabelMap
const core::HackManifest * hack_manifest_
bool PreferHMagicNames() const
Get whether Hyrule Magic names are preferred.
std::string GetLabel(ResourceType type, int id) const
Get a label for a resource by type and ID.
bool ParseZScreamLine(const std::string &line, const std::string &section, int &line_index)
void SetPreferHMagicNames(bool prefer)
Set whether to prefer Hyrule Magic sprite names.
std::unordered_map< std::string, LabelMap > ProjectLabels
absl::Status ImportFromZScreamFormat(const std::string &content)
Import labels from ZScream DefaultNames.txt format.
std::string GetVanillaLabel(ResourceType type, int id) const
Get the vanilla (default) label for a resource.
const LabelMap * GetProjectLabelsForType(ResourceType type) const
Get all project labels for a given type.
std::string GetHMagicLabel(ResourceType type, int id) const
Get the Hyrule Magic label for a resource (sprites only)
void SetHackManifest(const core::HackManifest *manifest)
Set the hack manifest reference for ASM-defined labels.
void SetProjectLabels(ProjectLabels *labels)
Set the project labels reference (typically from YazeProject)
void ClearProjectLabel(ResourceType type, int id)
Clear a project-specific label (revert to default)
absl::Status ImportOracleSpriteRegistry(const std::string &csv_content)
Import sprite labels from Oracle of Secrets registry.csv format.
ResourceType
Enumeration of all supported resource types for labeling.
std::string GetRoomTagLabel(int id)
Convenience function to get a room tag label.
std::string GetSpriteLabel(int id)
Convenience function to get a sprite label.
std::string GetEntranceLabel(int id)
Convenience function to get an entrance label.
std::string GetRoomLabel(int id)
Convenience function to get a room label.
std::string GetOverlordLabel(int id)
Convenience function to get an overlord label.
std::string GetItemLabel(int id)
Convenience function to get an item label.
std::string GetOverworldMapLabel(int id)
Convenience function to get an overworld map label.
std::string ResourceTypeToString(ResourceType type)
Convert ResourceType enum to string key for storage.
ResourceType StringToResourceType(const std::string &type_str)
Convert string key to ResourceType enum.
std::string GetMusicLabel(int id)
Convenience function to get a music track label.
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.