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 }
76
88 std::string GetLabel(ResourceType type, int id) const;
89
93 std::string GetLabel(const std::string& type_str, int id) const;
94
98 void SetProjectLabel(ResourceType type, int id, const std::string& label);
99
103 void ClearProjectLabel(ResourceType type, int id);
104
108 bool HasProjectLabel(ResourceType type, int id) const;
109
113 std::string GetVanillaLabel(ResourceType type, int id) const;
114
118 std::string GetHMagicLabel(ResourceType type, int id) const;
119
120 // =========================================================================
121 // Hyrule Magic Naming Toggle
122 // =========================================================================
123
127 void SetPreferHMagicNames(bool prefer) { prefer_hmagic_ = prefer; }
128
132 bool PreferHMagicNames() const { return prefer_hmagic_; }
133
134 // =========================================================================
135 // ZScream DefaultNames.txt Import/Export
136 // =========================================================================
137
149 absl::Status ImportFromZScreamFormat(const std::string& content);
150
155 std::string ExportToZScreamFormat() const;
156
165 absl::Status ImportOracleSpriteRegistry(const std::string& csv_content);
166
167 // =========================================================================
168 // Utility Methods
169 // =========================================================================
170
174 int GetResourceCount(ResourceType type) const;
175
180
185
190
191 private:
192 // Project-specific label overrides (owned by YazeProject)
194
195 // Hack manifest reference (owned by YazeProject)
197
198 // Whether to prefer Hyrule Magic sprite names
199 bool prefer_hmagic_ = true;
200
201 // Parse a single line in ZScream format
202 bool ParseZScreamLine(const std::string& line, const std::string& section,
203 int& line_index);
204};
205
206// ============================================================================
207// Global Provider Instance
208// ============================================================================
209
217
221inline std::string GetSpriteLabel(int id) {
223}
224
228inline std::string GetRoomLabel(int id) {
230}
231
235inline std::string GetItemLabel(int id) {
237}
238
242inline std::string GetEntranceLabel(int id) {
244}
245
249inline std::string GetOverlordLabel(int id) {
251}
252
256inline std::string GetOverworldMapLabel(int id) {
258}
259
263inline std::string GetMusicLabel(int id) {
265}
266
270inline std::string GetRoomTagLabel(int id) {
272}
273
274} // namespace zelda3
275} // namespace yaze
276
277#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.
const core::HackManifest * hack_manifest() const
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.