6#include <unordered_map>
8#include "absl/status/status.h"
9#include "absl/strings/str_format.h"
10#include "absl/strings/strip.h"
19std::string
TrimCopy(
const std::string& value) {
20 return std::string(absl::StripAsciiWhitespace(value));
24 const std::string hex_upper = absl::StrFormat(
"%X",
id);
27 absl::StrFormat(
"0x%x",
id),
28 absl::StrFormat(
"0x%s", hex_upper),
29 absl::StrFormat(
"0X%s", hex_upper),
30 absl::StrFormat(
"$%s", hex_upper),
31 absl::StrFormat(
"0x%02X",
id),
32 absl::StrFormat(
"0x%03X",
id),
33 absl::StrFormat(
"0x%04X",
id),
34 absl::StrFormat(
"$%02X",
id),
39 const std::unordered_map<std::string, std::string>& labels,
int id) {
41 const auto it = labels.find(key);
42 if (it != labels.end() && !it->second.empty()) {
50 std::unordered_map<std::string, std::string>& labels,
int id) {
56std::string
LabelWithId(
const char* prefix,
int id,
const std::string& label,
58 const std::string id_text = width <= 2 ? absl::StrFormat(
"0x%02X",
id)
59 : absl::StrFormat(
"0x%04X",
id);
61 return absl::StrFormat(
"%s %s", prefix, id_text);
63 return absl::StrFormat(
"%s %s %s", prefix, id_text, label);
68 return "Special World";
111 const int clamped_state = std::clamp(game_state, 0, 2);
112 const int music_id = map.
area_music(clamped_state);
113 if (std::string project_label =
115 !project_label.empty()) {
116 return LabelWithId(
"Music", music_id, project_label);
124 const std::string& project_type,
126 if (std::string project_label =
128 !project_label.empty()) {
129 return project_label;
137 const std::string& type,
int id) {
145 return LookupResourceLabel(type_it->second,
id);
149 const std::string& type,
int id,
150 const std::string& label) {
152 return absl::FailedPreconditionError(
"No project is open");
155 const std::string trimmed = TrimCopy(label);
157 EraseResourceLabelKeys(labels,
id);
158 if (!trimmed.empty()) {
159 labels[std::to_string(
id)] = trimmed;
164 return project->
Save();
166 return absl::OkStatus();
174 metadata.
world = std::clamp(metadata.
map_id / 0x40, 0, 2);
181 if (std::string project_label =
183 !project_label.empty()) {
210 ProjectOrProviderLabel(project,
"graphics",
226 ProjectOrProviderLabel(project,
"graphics",
237 ProjectOrProviderLabel(project,
"graphics",
244 metadata.
music_label = MusicLabelForState(*map, project, game_state);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Represents a single Overworld map screen.
auto animated_gfx() const
auto area_graphics() const
auto sprite_graphics(int i) const
auto area_palette() const
auto area_music(int i) const
auto main_palette() const
auto sprite_palette(int i) const
static OverworldVersion GetVersion(const Rom &rom)
Detect ROM version from ASM marker byte.
Represents the full Overworld data, light and dark world.
auto overworld_map(int i) const
std::string GetLabel(ResourceType type, int id) const
Get a label for a resource by type and ID.
Editors are the view controllers for the application.
absl::Status RenameProjectResourceLabel(project::YazeProject *project, const std::string &type, int id, const std::string &label)
OverworldMapMetadata BuildOverworldMapMetadata(const zelda3::Overworld &overworld, const Rom *rom, const project::YazeProject *project, int map_id, int game_state)
std::string GetProjectResourceLabel(const project::YazeProject *project, const std::string &type, int id)
ResourceType
Enumeration of all supported resource types for labeling.
constexpr int kSpecialWorldMapIdStart
constexpr int kNumOverworldMaps
AreaSizeEnum
Area size enumeration for v3+ ROMs.
@ kZSCustomV2
Parent system, BG colors, main palettes.
@ kZSCustomV1
Basic features, expanded pointers.
@ kVanilla
0xFF in ROM, no ZScream ASM applied
@ kZSCustomV3
Area enum, wide/tall areas, all features.
constexpr int kDarkWorldMapIdStart
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.
Modern project structure with comprehensive settings consolidation.
bool project_opened() const
void InitializeResourceLabelProvider()
Initialize the global ResourceLabelProvider with this project's labels.
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > resource_labels