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
12namespace yaze {
13namespace zelda3 {
14
19enum class ResourceType {
20 kSprite,
21 kRoom,
23 kItem,
26 kMusic,
31};
32
36std::string ResourceTypeToString(ResourceType type);
37
41ResourceType StringToResourceType(const std::string& type_str);
42
57 public:
58 using LabelMap = std::unordered_map<std::string, std::string>;
59 using ProjectLabels = std::unordered_map<std::string, LabelMap>;
60
62
67
79 std::string GetLabel(ResourceType type, int id) const;
80
84 std::string GetLabel(const std::string& type_str, int id) const;
85
89 void SetProjectLabel(ResourceType type, int id, const std::string& label);
90
94 void ClearProjectLabel(ResourceType type, int id);
95
99 bool HasProjectLabel(ResourceType type, int id) const;
100
104 std::string GetVanillaLabel(ResourceType type, int id) const;
105
109 std::string GetHMagicLabel(ResourceType type, int id) const;
110
111 // =========================================================================
112 // Hyrule Magic Naming Toggle
113 // =========================================================================
114
118 void SetPreferHMagicNames(bool prefer) { prefer_hmagic_ = prefer; }
119
123 bool PreferHMagicNames() const { return prefer_hmagic_; }
124
125 // =========================================================================
126 // ZScream DefaultNames.txt Import/Export
127 // =========================================================================
128
140 absl::Status ImportFromZScreamFormat(const std::string& content);
141
146 std::string ExportToZScreamFormat() const;
147
148 // =========================================================================
149 // Utility Methods
150 // =========================================================================
151
155 int GetResourceCount(ResourceType type) const;
156
161
166
171
172 private:
173 // Project-specific label overrides (owned by YazeProject)
175
176 // Whether to prefer Hyrule Magic sprite names
177 bool prefer_hmagic_ = true;
178
179 // Parse a single line in ZScream format
180 bool ParseZScreamLine(const std::string& line, const std::string& section,
181 int& line_index);
182};
183
184// ============================================================================
185// Global Provider Instance
186// ============================================================================
187
195
199inline std::string GetSpriteLabel(int id) {
201}
202
206inline std::string GetRoomLabel(int id) {
208}
209
213inline std::string GetItemLabel(int id) {
215}
216
220inline std::string GetEntranceLabel(int id) {
222}
223
227inline std::string GetOverlordLabel(int id) {
229}
230
234inline std::string GetOverworldMapLabel(int id) {
236}
237
241inline std::string GetMusicLabel(int id) {
243}
244
248inline std::string GetRoomTagLabel(int id) {
250}
251
252} // namespace zelda3
253} // namespace yaze
254
255#endif // YAZE_ZELDA3_RESOURCE_LABELS_H
256
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
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 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)
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.