yaze
0.3.2
Link to the Past ROM Editor
Loading...
Searching...
No Matches
dungeon_project_labels.h
Go to the documentation of this file.
1
#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROJECT_LABELS_H
2
#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROJECT_LABELS_H
3
4
#include <cstddef>
5
#include <string>
6
7
#include "absl/strings/str_format.h"
8
#include "
core/project.h
"
9
#include "
zelda3/resource_labels.h
"
10
11
namespace
yaze::editor::dungeon_project_labels
{
12
13
inline
const
core::DungeonEntry
*
FindDungeonForRoom
(
14
const
project::YazeProject
* project,
int
room_id,
15
size_t
* dungeon_index =
nullptr
) {
16
// Real Oracle .yaze projects can ship a project_registry (Docs/Dev/Planning/
17
// dungeons.json) without an accompanying hack_manifest_v1.json — see
18
// ProjectPathsTest::OpenInjectsOracleDungeonRoomLabelsIntoProjectFile. The
19
// registry is the canonical source of room/dungeon names; the hack manifest
20
// is an independent, optional add-on. Don't gate registry lookups on it.
21
if
(!project || !project->
project_opened
() ||
22
!project->
hack_manifest
.
HasProjectRegistry
()) {
23
return
nullptr
;
24
}
25
26
const
auto
& dungeons = project->
hack_manifest
.
project_registry
().
dungeons
;
27
for
(
size_t
i = 0; i < dungeons.size(); ++i) {
28
const
auto
& dungeon = dungeons[i];
29
for
(
const
auto
& room : dungeon.rooms) {
30
if
(room.id == room_id) {
31
if
(dungeon_index) {
32
*dungeon_index = i;
33
}
34
return
&dungeon;
35
}
36
}
37
}
38
return
nullptr
;
39
}
40
41
inline
const
core::DungeonRoom
*
FindDungeonRoom
(
42
const
project::YazeProject
* project,
int
room_id) {
43
const
core::DungeonEntry
* dungeon =
FindDungeonForRoom
(project, room_id);
44
if
(!dungeon) {
45
return
nullptr
;
46
}
47
for
(
const
auto
& room : dungeon->
rooms
) {
48
if
(room.id == room_id) {
49
return
&room;
50
}
51
}
52
return
nullptr
;
53
}
54
55
inline
std::string
FormatDungeonName
(
const
core::DungeonEntry
& dungeon) {
56
if
(dungeon.
id
.empty()) {
57
return
dungeon.
name
;
58
}
59
if
(dungeon.
name
.empty()) {
60
return
dungeon.
id
;
61
}
62
return
absl::StrFormat(
"%s %s"
, dungeon.
id
, dungeon.
name
);
63
}
64
65
inline
std::string
GetDungeonNameForRoom
(
const
project::YazeProject
* project,
66
int
room_id) {
67
const
core::DungeonEntry
* dungeon =
FindDungeonForRoom
(project, room_id);
68
return
dungeon ?
FormatDungeonName
(*dungeon) : std::string();
69
}
70
71
inline
std::string
GetRoomFloorLabel
(
const
project::YazeProject
* project,
72
int
room_id) {
73
if
(
const
core::DungeonRoom
* room =
FindDungeonRoom
(project, room_id);
74
room && !room->
floor
.empty()) {
75
return
room->floor;
76
}
77
return
std::string();
78
}
79
80
inline
std::string
GetRoomLabel
(
const
project::YazeProject
* project,
81
int
room_id) {
82
if
(
const
core::DungeonRoom
* room =
FindDungeonRoom
(project, room_id);
83
room && !room->
name
.empty()) {
84
return
room->name;
85
}
86
auto
& labels =
zelda3::GetResourceLabels
();
87
return
labels.GetLabel(
zelda3::ResourceType::kRoom
, room_id);
88
}
89
90
}
// namespace yaze::editor::dungeon_project_labels
91
92
#endif
// YAZE_APP_EDITOR_DUNGEON_DUNGEON_PROJECT_LABELS_H
yaze::core::HackManifest::project_registry
const ProjectRegistry & project_registry() const
Definition
hack_manifest.h:453
yaze::core::HackManifest::HasProjectRegistry
bool HasProjectRegistry() const
Definition
hack_manifest.h:457
yaze::editor::dungeon_project_labels
Definition
dungeon_project_labels.h:11
yaze::editor::dungeon_project_labels::GetRoomLabel
std::string GetRoomLabel(const project::YazeProject *project, int room_id)
Definition
dungeon_project_labels.h:80
yaze::editor::dungeon_project_labels::FindDungeonForRoom
const core::DungeonEntry * FindDungeonForRoom(const project::YazeProject *project, int room_id, size_t *dungeon_index=nullptr)
Definition
dungeon_project_labels.h:13
yaze::editor::dungeon_project_labels::GetDungeonNameForRoom
std::string GetDungeonNameForRoom(const project::YazeProject *project, int room_id)
Definition
dungeon_project_labels.h:65
yaze::editor::dungeon_project_labels::FindDungeonRoom
const core::DungeonRoom * FindDungeonRoom(const project::YazeProject *project, int room_id)
Definition
dungeon_project_labels.h:41
yaze::editor::dungeon_project_labels::GetRoomFloorLabel
std::string GetRoomFloorLabel(const project::YazeProject *project, int room_id)
Definition
dungeon_project_labels.h:71
yaze::editor::dungeon_project_labels::FormatDungeonName
std::string FormatDungeonName(const core::DungeonEntry &dungeon)
Definition
dungeon_project_labels.h:55
yaze::zelda3::ResourceType::kRoom
@ kRoom
yaze::zelda3::GetResourceLabels
ResourceLabelProvider & GetResourceLabels()
Get the global ResourceLabelProvider instance.
Definition
resource_labels.cc:146
project.h
resource_labels.h
yaze::core::DungeonEntry
A complete dungeon entry with rooms and connections.
Definition
hack_manifest.h:203
yaze::core::DungeonEntry::id
std::string id
Definition
hack_manifest.h:204
yaze::core::DungeonEntry::name
std::string name
Definition
hack_manifest.h:205
yaze::core::DungeonEntry::rooms
std::vector< DungeonRoom > rooms
Definition
hack_manifest.h:207
yaze::core::DungeonRoom
A room within a dungeon, with spatial and metadata info.
Definition
hack_manifest.h:180
yaze::core::DungeonRoom::floor
std::string floor
Definition
hack_manifest.h:183
yaze::core::DungeonRoom::name
std::string name
Definition
hack_manifest.h:182
yaze::core::ProjectRegistry::dungeons
std::vector< DungeonEntry > dungeons
Definition
hack_manifest.h:230
yaze::project::YazeProject
Modern project structure with comprehensive settings consolidation.
Definition
project.h:172
yaze::project::YazeProject::project_opened
bool project_opened() const
Definition
project.h:348
yaze::project::YazeProject::hack_manifest
core::HackManifest hack_manifest
Definition
project.h:212
src
app
editor
dungeon
dungeon_project_labels.h
Generated by
1.10.0