19+ (void)loadRomAtPath:(NSString *)path {
20 if (!path || path.length == 0) {
23 std::string cpp_path([path UTF8String]);
27+ (void)openProjectAtPath:(NSString *)path {
28 if (!path || path.length == 0) {
32 if (!controller || !controller->editor_manager()) {
36 std::string cpp_path([path UTF8String]);
37 (void)controller->editor_manager()->OpenRomOrProject(cpp_path);
40+ (NSString *)currentRomTitle {
45 auto *
rom = controller->GetCurrentRom();
49 return [NSString stringWithUTF8String:rom->title().c_str()];
52+ (void)setOverlayTopInset:(
double)inset {
56+ (void)setTouchScale:(
double)scale {
60+ (void)showProjectFileEditor {
62 if (!controller || !controller->editor_manager()) {
68+ (void)showProjectManagement {
70 if (!controller || !controller->editor_manager()) {
76+ (void)showPanelBrowser {
78 if (!controller || !controller->editor_manager()) {
84+ (void)showCommandPalette {
86 if (!controller || !controller->editor_manager()) {
96 if (!controller || !controller->editor_manager()) {
101 auto *toast = controller->editor_manager()->toast_manager();
103 toast->Show(std::string(status.message()),
111 if (!controller || !controller->editor_manager()) {
116 (void)editor->Undo();
122 if (!controller || !controller->editor_manager()) {
127 (void)editor->Redo();
132 if (!editorName || editorName.length == 0) {
136 if (!controller || !controller->editor_manager()) {
139 std::string
name([editorName UTF8String]);
142 controller->editor_manager()->SwitchToEditor(
149+ (NSArray<NSString *> *)availableEditorTypes {
151 NSMutableArray<NSString *> *result = [NSMutableArray array];
163 stringWithUTF8String:yaze::editor::kEditorNames[i]]];
172+ (nullable NSString *)currentEditorType {
174 if (!controller || !controller->editor_manager()) {
183 return [NSString stringWithUTF8String:yaze::editor::kEditorNames[index]];
188+ (nullable NSString *)currentRoomStatus {
190 if (!controller || !controller->editor_manager()) {
197 auto *dungeon_editor =
200 return [NSString stringWithFormat:@"Room 0x%03X", room_id];
203+ (NSArray<NSDictionary *> *)getActiveDungeonRooms {
205 if (!controller || !controller->editor_manager()) {
215 NSMutableArray<NSDictionary *> *rooms = [NSMutableArray array];
217 const auto &active_rooms = dungeon_editor->active_rooms();
218 if (active_rooms.Size > 0) {
219 for (
int i = 0; i < active_rooms.Size; ++i) {
220 const int room_id = active_rooms[i];
226 @"room_id" : @(room_id),
227 @"name" : [NSString stringWithUTF8String:label.c_str()],
228 @"is_current" : @(room_id == current_room),
237 @"room_id" : @(room_id),
238 @"name" : [NSString stringWithUTF8String:label.c_str()],
239 @"is_current" : @(room_id == current_room),
245+ (void)focusDungeonRoom:(NSInteger)roomID {
251 if (!controller || !controller->editor_manager()) {
259 editor = controller->editor_manager()->GetCurrentEditor();
266 dungeon_editor->
add_room(
static_cast<int>(roomID));
274 if (!controller || !controller->editor_manager()) {
278 const auto &project = *controller->editor_manager()->GetCurrentProject();
279 if (!project.hack_manifest.loaded()) {
296+ (nullable NSString *)getStoryEventsJSON {
298 if (!controller || !controller->editor_manager()) {
303 if (!project.hack_manifest.loaded() ||
304 !project.hack_manifest.HasProjectRegistry()) {
309 if (!graph.loaded()) {
314 NSMutableArray *events = [NSMutableArray array];
315 for (
const auto &node : graph.nodes()) {
316 NSMutableDictionary *
event = [NSMutableDictionary dictionary];
317 event[@"id"] = [NSString stringWithUTF8String:node.id.c_str()];
318 event[@"name"] = [NSString stringWithUTF8String:node.name.c_str()];
319 event[@"notes"] = [NSString stringWithUTF8String:node.notes.c_str()];
321 NSMutableArray *flags = [NSMutableArray array];
322 for (
const auto &f : node.flags) {
323 [flags addObject:[NSString stringWithUTF8String:f.name.c_str()]];
325 event[@"flags"] = flags;
327 NSMutableArray *locations = [NSMutableArray array];
328 for (
const auto &loc : node.locations) {
329 [locations addObject:[NSString stringWithUTF8String:loc.name.c_str()]];
331 event[@"locations"] = locations;
333 NSMutableArray *text_ids = [NSMutableArray array];
334 for (
const auto &tid : node.text_ids) {
335 [text_ids addObject:[NSString stringWithUTF8String:tid.c_str()]];
337 event[@"text_ids"] = text_ids;
339 NSMutableArray *scripts = [NSMutableArray array];
340 for (
const auto &s : node.scripts) {
341 [scripts addObject:[NSString stringWithUTF8String:s.c_str()]];
343 event[@"scripts"] = scripts;
345 NSMutableArray *deps = [NSMutableArray array];
346 for (
const auto &d : node.dependencies) {
347 [deps addObject:[NSString stringWithUTF8String:d.c_str()]];
349 event[@"dependencies"] = deps;
351 NSMutableArray *unlocks = [NSMutableArray array];
352 for (
const auto &u : node.unlocks) {
353 [unlocks addObject:[NSString stringWithUTF8String:u.c_str()]];
355 event[@"unlocks"] = unlocks;
357 [events addObject:event];
360 NSError *error = nil;
361 NSData *jsonData = [NSJSONSerialization dataWithJSONObject:events
364 if (error || !jsonData) {
367 return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
370+ (NSArray<NSDictionary *> *)getDungeonRooms:(NSString *)dungeonId {
376 if (!controller || !controller->editor_manager()) {
381 if (!project.hack_manifest.loaded() ||
382 !project.hack_manifest.HasProjectRegistry()) {
386 std::string target_id([dungeonId UTF8String]);
387 const auto ®istry = project.hack_manifest.project_registry();
389 for (
const auto &dungeon : registry.dungeons) {
390 if (dungeon.id == target_id) {
391 NSMutableArray *rooms = [NSMutableArray array];
392 for (
const auto &room : dungeon.rooms) {
394 @"room_id" : @(room.id),
395 @"name" : [NSString stringWithUTF8String:room.name.c_str()],
396 @"type" : [NSString stringWithUTF8String:room.type.c_str()],
Controller * GetController()
static Application & Instance()
void LoadRom(const std::string &path)
editor::EditorManager * editor_manager()
const ProjectRegistry & project_registry() const
DungeonEditorV2 - Simplified dungeon editor using component delegation.
void add_room(int room_id)
int current_room_id() const
void ShowProjectManagement()
Injects dependencies into all editors within an EditorSet.
auto GetCurrentEditor() const -> Editor *
PanelManager & panel_manager()
void ShowProjectFileEditor()
project::YazeProject * GetCurrentProject()
void TriggerShowCommandPalette()
void TriggerShowPanelBrowser()
Rom * rom()
Get the current ROM instance.
constexpr std::array< const char *, 14 > kEditorNames
size_t EditorTypeIndex(EditorType type)
std::string GetRoomLabel(int id)
Convenience function to get a room label.
constexpr int kNumberOfRooms
Interop structs for passing data from C++ to Swift.
Oracle of Secrets game progression state parsed from SRAM.
int GetCrystalCount() const
Count completed dungeons using popcount on crystal bitfield.
StoryEventGraph story_events
core::HackManifest hack_manifest
std::string switchToEditor(std::string editor_name)