yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
zelda3_labels.cc
Go to the documentation of this file.
2
3#include <cstddef>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
8#include "zelda3/common.h"
12
13namespace yaze::zelda3 {
14
15// Room names - reuse existing kRoomNames array
16const std::vector<std::string>& Zelda3Labels::GetRoomNames() {
17 static std::vector<std::string> room_names;
18 if (room_names.empty()) {
19 for (const auto& name : kRoomNames) {
20 room_names.emplace_back(name);
21 }
22 }
23 return room_names;
24}
25
26// Entrance names - reuse existing kEntranceNames array
27const std::vector<std::string>& Zelda3Labels::GetEntranceNames() {
28 static std::vector<std::string> entrance_names;
29 if (entrance_names.empty()) {
30 for (const auto& name : kEntranceNames) {
31 entrance_names.emplace_back(name);
32 }
33 }
34 return entrance_names;
35}
36
37// Sprite names - reuse existing kSpriteDefaultNames array
38const std::vector<std::string>& Zelda3Labels::GetSpriteNames() {
39 static std::vector<std::string> sprite_names;
40 if (sprite_names.empty()) {
41 for (const auto& name : kSpriteDefaultNames) {
42 sprite_names.push_back(name);
43 }
44 }
45 return sprite_names;
46}
47
48// Overlord names - reuse existing kOverlordNames array
49const std::vector<std::string>& Zelda3Labels::GetOverlordNames() {
50 static std::vector<std::string> overlord_names;
51 if (overlord_names.empty()) {
52 for (const auto& name : kOverlordNames) {
53 overlord_names.push_back(name);
54 }
55 }
56 return overlord_names;
57}
58
59// Overworld map names (64 Light World + 64 Dark World + 32 Special Areas)
60const std::vector<std::string>& Zelda3Labels::GetOverworldMapNames() {
61 static const std::vector<std::string> map_names = {
62 // Light World (0x00-0x3F)
63 "Lost Woods", "Master Sword Pedestal", "Castle Courtyard", "Link's House",
64 "Eastern Palace", "Desert Palace", "Hyrule Castle", "Witch's Hut",
65 "Kakariko Village", "Death Mountain", "Tower of Hera", "Spectacle Rock",
66 "Graveyard", "Sanctuary", "Lake Hylia", "Desert of Mystery",
67 "Eastern Ruins", "Zora's Domain", "Catfish", "Dam", "Potion Shop",
68 "Kakariko Well", "Blacksmith", "Sick Kid", "Library", "Mushroom",
69 "Magic Bat", "Fairy Fountain", "Fortune Teller", "Lake Shop", "Bomb Shop",
70 "Cave 45", "Checkerboard Cave", "Mini Moldorm Cave", "Ice Rod Cave",
71 "Bonk Rocks", "Bottle Merchant", "Sahasrahla's Hut", "Chicken House",
72 "Aginah's Cave", "Dam Exterior", "Mimic Cave Exterior", "Waterfall Fairy",
73 "Pyramid", "Fat Fairy", "Spike Cave", "Hookshot Cave", "Graveyard Ledge",
74 "Dark Lumberjacks", "Bumper Cave", "Skull Woods 1", "Skull Woods 2",
75 "Skull Woods 3", "Skull Woods 4", "Skull Woods 5", "Skull Woods 6",
76 "Skull Woods 7", "Skull Woods 8", "Ice Palace Exterior",
77 "Misery Mire Exterior", "Palace of Darkness Exterior",
78 "Swamp Palace Exterior", "Turtle Rock Exterior", "Thieves' Town Exterior",
79
80 // Dark World (0x40-0x7F)
81 "Dark Woods", "Dark Chapel", "Dark Castle", "Dark Shields", "Dark Palace",
82 "Dark Desert", "Dark Castle Gate", "Dark Witch", "Dark Village",
83 "Dark Mountain", "Dark Tower", "Dark Rocks", "Dark Graveyard",
84 "Dark Sanctuary", "Dark Lake", "Dark Desert South", "Dark Eastern",
85 "Dark Zora", "Dark Catfish", "Dark Dam", "Dark Shop", "Dark Well",
86 "Dark Blacksmith", "Dark Sick Kid", "Dark Library", "Dark Mushroom",
87 "Dark Bat", "Dark Fountain", "Dark Fortune", "Dark Lake Shop",
88 "Dark Bomb Shop", "Dark Cave 45", "Dark Checker", "Dark Mini Moldorm",
89 "Dark Ice Rod", "Dark Bonk", "Dark Bottle", "Dark Sahasrahla",
90 "Dark Chicken", "Dark Aginah", "Dark Dam Exit", "Dark Mimic Exit",
91 "Dark Waterfall", "Pyramid Top", "Dark Fat Fairy", "Dark Spike Cave",
92 "Dark Hookshot", "Dark Graveyard Ledge", "Lumberjack House",
93 "Dark Bumper", "Skull Woods A", "Skull Woods B", "Skull Woods C",
94 "Skull Woods D", "Skull Woods E", "Skull Woods F", "Skull Woods G",
95 "Skull Woods H", "Ice Palace Entry", "Misery Mire Entry",
96 "Palace of Darkness Entry", "Swamp Palace Entry", "Turtle Rock Entry",
97 "Thieves' Town Entry",
98
99 // Special Areas (0x80-0x9F)
100 "Special Area 1", "Special Area 2", "Special Area 3", "Special Area 4",
101 "Special Area 5", "Special Area 6", "Special Area 7", "Special Area 8",
102 "Special Area 9", "Special Area 10", "Special Area 11", "Special Area 12",
103 "Special Area 13", "Special Area 14", "Special Area 15",
104 "Special Area 16", "Special Area 17", "Special Area 18",
105 "Special Area 19", "Special Area 20", "Special Area 21",
106 "Special Area 22", "Special Area 23", "Special Area 24",
107 "Special Area 25", "Special Area 26", "Special Area 27",
108 "Special Area 28", "Special Area 29", "Special Area 30",
109 "Special Area 31", "Special Area 32"};
110 return map_names;
111}
112
113// Item names (complete item list)
114const std::vector<std::string>& Zelda3Labels::GetItemNames() {
115 static const std::vector<std::string> item_names = {
116 "None",
117 "Fighter Sword",
118 "Master Sword",
119 "Tempered Sword",
120 "Golden Sword",
121 "Fighter Shield",
122 "Fire Shield",
123 "Mirror Shield",
124 "Fire Rod",
125 "Ice Rod",
126 "Hammer",
127 "Hookshot",
128 "Bow",
129 "Boomerang",
130 "Powder",
131 "Bee Badge",
132 "Bombos Medallion",
133 "Ether Medallion",
134 "Quake Medallion",
135 "Lamp",
136 "Shovel",
137 "Flute",
138 "Somaria Cane",
139 "Bottle",
140 "Heart Piece",
141 "Byrna Cane",
142 "Cape",
143 "Mirror",
144 "Power Glove",
145 "Titan Mitt",
146 "Book of Mudora",
147 "Zora Flippers",
148 "Moon Pearl",
149 "Crystal",
150 "Bug Net",
151 "Blue Mail",
152 "Red Mail",
153 "Key",
154 "Compass",
155 "Heart Container",
156 "Bomb",
157 "3 Bombs",
158 "Mushroom",
159 "Red Boomerang",
160 "Red Potion",
161 "Green Potion",
162 "Blue Potion",
163 "Red Potion (Refill)",
164 "Green Potion (Refill)",
165 "Blue Potion (Refill)",
166 "10 Bombs",
167 "Big Key",
168 "Map",
169 "1 Rupee",
170 "5 Rupees",
171 "20 Rupees",
172 "Pendant of Courage",
173 "Pendant of Wisdom",
174 "Pendant of Power",
175 "Bow and Arrows",
176 "Silver Arrows Upgrade",
177 "Bee",
178 "Fairy",
179 "Heart Container (Boss)",
180 "Heart",
181 "1 Arrow",
182 "10 Arrows",
183 "Magic",
184 "Small Magic",
185 "300 Rupees",
186 "20 Rupees (Green)",
187 "100 Rupees",
188 "50 Rupees",
189 "Heart Container (Sanctuary)",
190 "Arrow Refill (5)",
191 "Arrow Refill (10)",
192 "Bomb Refill (1)",
193 "Bomb Refill (4)",
194 "Bomb Refill (8)",
195 "Blue Shield (Refill)",
196 "Magic Upgrade (1/2)",
197 "Magic Upgrade (1/4)",
198 "Programmable Item 1",
199 "Programmable Item 2",
200 "Programmable Item 3",
201 "Silvers",
202 "Rupoor",
203 "Null Item",
204 "Red Clock",
205 "Blue Clock",
206 "Green Clock",
207 "Progressive Sword",
208 "Progressive Shield",
209 "Progressive Armor",
210 "Progressive Lifting Glove",
211 "RNG Item (Single)",
212 "RNG Item (Multi)",
213 "Progressive Bow",
214 "Progressive Bow (Alt)",
215 "Aga Pendant",
216 "Pendant (Green)",
217 "Blue Pendant",
218 "Good Bee",
219 "Tossed Key"};
220 return item_names;
221}
222
223// Music track names
224const std::vector<std::string>& Zelda3Labels::GetMusicTrackNames() {
225 static const std::vector<std::string> music_names = {
226 "Nothing",
227 "Light World",
228 "Beginning",
229 "Rabbit",
230 "Forest",
231 "Intro",
232 "Town",
233 "Warp",
234 "Dark World",
235 "Master Sword",
236 "File Select",
237 "Soldier",
238 "Boss",
239 "Dark World Death Mountain",
240 "Minigame",
241 "Skull Woods",
242 "Indoor",
243 "Cave 1",
244 "Zelda's Rescue",
245 "Crystal",
246 "Shop",
247 "Cave 2",
248 "Game Over",
249 "Boss Victory",
250 "Sanctuary",
251 "Boss Victory (Short)",
252 "Dark World Woods",
253 "Pendant",
254 "Ganon's Message",
255 "Hyrule Castle",
256 "Light World Death Mountain",
257 "Eastern Palace",
258 "Desert Palace",
259 "Agahnim's Theme",
260 "Damp Dungeon",
261 "Ganon Reveals",
262 "Confrontation",
263 "Ganon's Theme",
264 "Triforce",
265 "Credits",
266 "Unused",
267 "Unused",
268 "Unused",
269 "Unused",
270 "Unused",
271 "Unused",
272 "Unused",
273 "Unused"};
274 return music_names;
275}
276
277// Graphics sheet names
278const std::vector<std::string>& Zelda3Labels::GetGraphicsSheetNames() {
279 static const std::vector<std::string> gfx_names = {"Sprite Sheet 0",
280 "Sprite Sheet 1",
281 "Sprite Sheet 2",
282 "Sprite Sheet 3",
283 "Sprite Sheet 4",
284 "Sprite Sheet 5",
285 "Sprite Sheet 6",
286 "Sprite Sheet 7",
287 "Sprite Sheet 8",
288 "Sprite Sheet 9",
289 "Sprite Sheet A",
290 "Sprite Sheet B",
291 "Sprite Sheet C",
292 "Sprite Sheet D",
293 "Sprite Sheet E",
294 "Sprite Sheet F",
295 "Link's Sprites",
296 "Sword Sprites",
297 "Shield Sprites",
298 "Common Sprites",
299 "Boss Sprites",
300 "NPC Sprites",
301 "Enemy Sprites 1",
302 "Enemy Sprites 2",
303 "Item Sprites",
304 "Dungeon Objects",
305 "Overworld Objects",
306 "Interface",
307 "Font",
308 "Credits",
309 "Unused",
310 "Unused"};
311 return gfx_names;
312}
313
314// Room object names - these are large, so we'll delegate to a helper
315namespace {
316std::vector<std::string> ConvertArrayToVector(const char** array, size_t size) {
317 std::vector<std::string> result;
318 result.reserve(size);
319 for (size_t i = 0; i < size; ++i) {
320 result.emplace_back(array[i]);
321 }
322 return result;
323}
324} // namespace
325
326const std::vector<std::string>& Zelda3Labels::GetType1RoomObjectNames() {
327 static const std::vector<std::string> names = []() {
328 std::vector<std::string> result;
329 // Note: Type1RoomObjectNames is constexpr, we need to count its size
330 // For now, we'll add known objects. In full implementation,
331 // we'd import from room_object.h
332 result = {
333 "Ceiling ↔",
334 "Wall (top, north) ↔",
335 "Wall (top, south) ↔",
336 "Wall (bottom, north) ↔",
337 "Wall (bottom, south) ↔",
338 "Wall columns (north) ↔",
339 "Wall columns (south) ↔",
340 "Deep wall (north) ↔",
341 "Deep wall (south) ↔",
342 "Diagonal wall A ◤ (top) ↔",
343 "Diagonal wall A ◣ (top) ↔",
344 "Diagonal wall A ◥ (top) ↔",
345 "Diagonal wall A ◢ (top) ↔",
346 // ... Add all Type1 objects here
347 };
348 return result;
349 }();
350 return names;
351}
352
353const std::vector<std::string>& Zelda3Labels::GetType2RoomObjectNames() {
354 static const std::vector<std::string> names = []() {
355 std::vector<std::string> result;
356 // Add Type2 room objects
357 result = {"Type2 Object 1", "Type2 Object 2" /* ... */};
358 return result;
359 }();
360 return names;
361}
362
363const std::vector<std::string>& Zelda3Labels::GetType3RoomObjectNames() {
364 static const std::vector<std::string> names = []() {
365 std::vector<std::string> result;
366 // Add Type3 room objects
367 result = {"Type3 Object 1", "Type3 Object 2" /* ... */};
368 return result;
369 }();
370 return names;
371}
372
373// Room effect names - reuse existing RoomEffect array
374const std::vector<std::string>& Zelda3Labels::GetRoomEffectNames() {
375 static std::vector<std::string> effect_names;
376 if (effect_names.empty()) {
377 for (const auto& name : RoomEffect) {
378 effect_names.push_back(name);
379 }
380 }
381 return effect_names;
382}
383
384// Room tag names
385const std::vector<std::string>& Zelda3Labels::GetRoomTagNames() {
386 static const std::vector<std::string> tag_names = {
387 "No Tag", "NW", "NE", "SW", "SE", "West", "East",
388 "North", "South", "Entrance", "Treasure", "Boss", "Dark"};
389 return tag_names;
390}
391
392// Tile type names
393const std::vector<std::string>& Zelda3Labels::GetTileTypeNames() {
394 static const std::vector<std::string> tile_names = {
395 "Nothing (standard floor)",
396 "Nothing (unused?)",
397 "Collision",
398 "Collision (unknown types)",
399 "Collision",
400 "Collision (unused?)",
401 "Collision",
402 "Collision",
403 "Deep water",
404 "Shallow water",
405 "Unknown (near water/pit edges)",
406 "Collision (water/pit edges)",
407 "Overlay mask",
408 "Spike floor",
409 "GT ice",
410 "Ice palace ice",
411 "Slope ◤",
412 "Slope ◥",
413 "Slope ◣",
414 "Slope ◢",
415 "Nothing (unused?)",
416 "Nothing (unused?)",
417 "Nothing (unused?)",
418 "Slope ◤",
419 "Slope ◥",
420 "Slope ◣",
421 "Slope ◢",
422 "Layer swap",
423 "Pit",
424 "Manual stairs",
425 "Pot switch",
426 "Pressure switch",
427 "Blocks switch (chest, PoD, walls)",
428 "Layer toggle",
429 "Layer 2 overlay",
430 "North single-layer auto stairs",
431 "North layer swap auto stairs",
432 "South single-layer auto stairs",
433 "South layer swap auto stairs",
434 "North/south layer swap auto stairs",
435 "North/south single-layer auto stairs",
436 "West single-layer auto stairs",
437 "West layer swap auto stairs",
438 "East single-layer auto stairs",
439 "East layer swap auto stairs",
440 "East/west layer swap auto stairs",
441 "East/west single-layer auto stairs",
442 "Nothing (stairs edge)",
443 "Straight inter-room stairs south/up",
444 "Straight inter-room stairs north/down",
445 "Straight inter-room stairs south/down 2",
446 "Straight inter-room stairs north/up 2",
447 "Star tile (inactive on GBA)",
448 "Collision (near stairs)",
449 "Warp tile",
450 "Square corners ⌜⌝⌞⌟",
451 "Thick corner ⌜",
452 "Thick corner ⌝",
453 "Thick corner ⌞",
454 "Thick corner ⌟",
455 "Roof/grass tiles?",
456 "Spike floor"};
457 return tile_names;
458}
459
460// Convert all labels to structured map for project embedding
461std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
463 std::unordered_map<std::string, std::unordered_map<std::string, std::string>>
464 labels;
465
466 // Rooms
467 const auto& rooms = GetRoomNames();
468 for (size_t i = 0; i < rooms.size(); ++i) {
469 labels["room"][std::to_string(i)] = rooms[i];
470 }
471
472 // Entrances
473 const auto& entrances = GetEntranceNames();
474 for (size_t i = 0; i < entrances.size(); ++i) {
475 labels["entrance"][std::to_string(i)] = entrances[i];
476 }
477
478 // Sprites
479 const auto& sprites = GetSpriteNames();
480 for (size_t i = 0; i < sprites.size(); ++i) {
481 labels["sprite"][std::to_string(i)] = sprites[i];
482 }
483
484 // Overlords
485 const auto& overlords = GetOverlordNames();
486 for (size_t i = 0; i < overlords.size(); ++i) {
487 labels["overlord"][std::to_string(i)] = overlords[i];
488 }
489
490 // Overworld maps
491 const auto& maps = GetOverworldMapNames();
492 for (size_t i = 0; i < maps.size(); ++i) {
493 labels["overworld_map"][std::to_string(i)] = maps[i];
494 }
495
496 // Items
497 const auto& items = GetItemNames();
498 for (size_t i = 0; i < items.size(); ++i) {
499 labels["item"][std::to_string(i)] = items[i];
500 }
501
502 // Music tracks
503 const auto& music = GetMusicTrackNames();
504 for (size_t i = 0; i < music.size(); ++i) {
505 labels["music"][std::to_string(i)] = music[i];
506 }
507
508 // Graphics sheets
509 const auto& gfx = GetGraphicsSheetNames();
510 for (size_t i = 0; i < gfx.size(); ++i) {
511 labels["graphics"][std::to_string(i)] = gfx[i];
512 }
513
514 // Room effects
515 const auto& effects = GetRoomEffectNames();
516 for (size_t i = 0; i < effects.size(); ++i) {
517 labels["room_effect"][std::to_string(i)] = effects[i];
518 }
519
520 // Room tags
521 const auto& tags = GetRoomTagNames();
522 for (size_t i = 0; i < tags.size(); ++i) {
523 labels["room_tag"][std::to_string(i)] = tags[i];
524 }
525
526 // Tile types
527 const auto& tiles = GetTileTypeNames();
528 for (size_t i = 0; i < tiles.size(); ++i) {
529 labels["tile_type"][std::to_string(i)] = tiles[i];
530 }
531
532 return labels;
533}
534
535// Get a label by resource type and ID
536std::string Zelda3Labels::GetLabel(const std::string& resource_type, int id,
537 const std::string& default_value) {
538 static auto labels = ToResourceLabels();
539
540 auto type_it = labels.find(resource_type);
541 if (type_it == labels.end()) {
542 return default_value.empty() ? resource_type + "_" + std::to_string(id)
543 : default_value;
544 }
545
546 auto label_it = type_it->second.find(std::to_string(id));
547 if (label_it == type_it->second.end()) {
548 return default_value.empty() ? resource_type + "_" + std::to_string(id)
549 : default_value;
550 }
551
552 return label_it->second;
553}
554
555} // namespace yaze::zelda3
std::vector< std::string > ConvertArrayToVector(const char **array, size_t size)
Zelda 3 specific classes and functions.
Definition editor.h:35
const std::string kOverlordNames[26]
Definition sprite.cc:295
const std::string kSpriteDefaultNames[256]
Definition sprite.cc:13
constexpr std::array< std::string_view, 297 > kRoomNames
Definition room.h:660
const std::string RoomEffect[8]
Definition room.cc:28
constexpr const char * kEntranceNames[]
Definition common.h:91
static const std::vector< std::string > & GetRoomNames()
static const std::vector< std::string > & GetItemNames()
static std::unordered_map< std::string, std::unordered_map< std::string, std::string > > ToResourceLabels()
Convert all labels to a structured map for project embedding.
static const std::vector< std::string > & GetEntranceNames()
static const std::vector< std::string > & GetType2RoomObjectNames()
static const std::vector< std::string > & GetType1RoomObjectNames()
static const std::vector< std::string > & GetGraphicsSheetNames()
static const std::vector< std::string > & GetMusicTrackNames()
static const std::vector< std::string > & GetTileTypeNames()
static const std::vector< std::string > & GetOverlordNames()
static const std::vector< std::string > & GetSpriteNames()
static const std::vector< std::string > & GetOverworldMapNames()
static const std::vector< std::string > & GetType3RoomObjectNames()
static std::string GetLabel(const std::string &resource_type, int id, const std::string &default_value="")
Get a label by resource type and ID.
static const std::vector< std::string > & GetRoomEffectNames()
static const std::vector< std::string > & GetRoomTagNames()