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()) {
87+ (void)showCommandPalette {
89 if (!controller || !controller->editor_manager()) {
102 if (!controller || !controller->editor_manager()) {
107 auto *toast = controller->editor_manager()->toast_manager();
109 toast->Show(std::string(status.message()),
117 if (!controller || !controller->editor_manager()) {
122 (void)editor->Undo();
128 if (!controller || !controller->editor_manager()) {
133 (void)editor->Redo();
138 if (!editorName || editorName.length == 0) {
142 if (!controller || !controller->editor_manager()) {
145 std::string
name([editorName UTF8String]);
148 controller->editor_manager()->SwitchToEditor(
155+ (NSArray<NSString *> *)availableEditorTypes {
157 NSMutableArray<NSString *> *result = [NSMutableArray array];
169 stringWithUTF8String:yaze::editor::kEditorNames[i]]];
178+ (nullable NSString *)currentEditorType {
180 if (!controller || !controller->editor_manager()) {
189 return [NSString stringWithUTF8String:yaze::editor::kEditorNames[index]];
194+ (nullable NSString *)currentRoomStatus {
196 if (!controller || !controller->editor_manager()) {
203 auto *dungeon_editor =
206 return [NSString stringWithFormat:@"Room 0x%03X", room_id];
209+ (NSArray<NSDictionary *> *)getActiveDungeonRooms {
211 if (!controller || !controller->editor_manager()) {
221 NSMutableArray<NSDictionary *> *rooms = [NSMutableArray array];
223 const auto &active_rooms = dungeon_editor->active_rooms();
224 if (active_rooms.Size > 0) {
225 for (
int i = 0; i < active_rooms.Size; ++i) {
226 const int room_id = active_rooms[i];
232 @"room_id" : @(room_id),
233 @"name" : [NSString stringWithUTF8String:label.c_str()],
234 @"is_current" : @(room_id == current_room),
243 @"room_id" : @(room_id),
244 @"name" : [NSString stringWithUTF8String:label.c_str()],
245 @"is_current" : @(room_id == current_room),
251+ (void)focusDungeonRoom:(NSInteger)roomID {
257 if (!controller || !controller->editor_manager()) {
265 editor = controller->editor_manager()->GetCurrentEditor();
272 dungeon_editor->
add_room(
static_cast<int>(roomID));
280 if (!controller || !controller->editor_manager()) {
284 const auto &project = *controller->editor_manager()->GetCurrentProject();
285 if (!project.hack_manifest.loaded()) {
302+ (nullable NSString *)getStoryEventsJSON {
304 if (!controller || !controller->editor_manager()) {
309 if (!project.hack_manifest.loaded() ||
310 !project.hack_manifest.HasProjectRegistry()) {
315 if (!graph.loaded()) {
320 NSMutableArray *events = [NSMutableArray array];
321 for (
const auto &node : graph.nodes()) {
322 NSMutableDictionary *
event = [NSMutableDictionary dictionary];
323 event[@"id"] = [NSString stringWithUTF8String:node.id.c_str()];
324 event[@"name"] = [NSString stringWithUTF8String:node.name.c_str()];
325 event[@"notes"] = [NSString stringWithUTF8String:node.notes.c_str()];
327 NSMutableArray *flags = [NSMutableArray array];
328 for (
const auto &f : node.flags) {
329 [flags addObject:[NSString stringWithUTF8String:f.name.c_str()]];
331 event[@"flags"] = flags;
333 NSMutableArray *locations = [NSMutableArray array];
334 for (
const auto &loc : node.locations) {
335 [locations addObject:[NSString stringWithUTF8String:loc.name.c_str()]];
337 event[@"locations"] = locations;
339 NSMutableArray *text_ids = [NSMutableArray array];
340 for (
const auto &tid : node.text_ids) {
341 [text_ids addObject:[NSString stringWithUTF8String:tid.c_str()]];
343 event[@"text_ids"] = text_ids;
345 NSMutableArray *scripts = [NSMutableArray array];
346 for (
const auto &s : node.scripts) {
347 [scripts addObject:[NSString stringWithUTF8String:s.c_str()]];
349 event[@"scripts"] = scripts;
351 NSMutableArray *deps = [NSMutableArray array];
352 for (
const auto &d : node.dependencies) {
353 [deps addObject:[NSString stringWithUTF8String:d.c_str()]];
355 event[@"dependencies"] = deps;
357 NSMutableArray *unlocks = [NSMutableArray array];
358 for (
const auto &u : node.unlocks) {
359 [unlocks addObject:[NSString stringWithUTF8String:u.c_str()]];
361 event[@"unlocks"] = unlocks;
363 [events addObject:event];
366 NSError *error = nil;
367 NSData *jsonData = [NSJSONSerialization dataWithJSONObject:events
370 if (error || !jsonData) {
373 return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
376+ (NSArray<NSDictionary *> *)getDungeonRooms:(NSString *)dungeonId {
382 if (!controller || !controller->editor_manager()) {
387 if (!project.hack_manifest.loaded() ||
388 !project.hack_manifest.HasProjectRegistry()) {
392 std::string target_id([dungeonId UTF8String]);
393 const auto ®istry = project.hack_manifest.project_registry();
395 for (
const auto &dungeon : registry.dungeons) {
396 if (dungeon.id == target_id) {
397 NSMutableArray *rooms = [NSMutableArray array];
398 for (
const auto &room : dungeon.rooms) {
400 @"room_id" : @(room.id),
401 @"name" : [NSString stringWithUTF8String:room.name.c_str()],
402 @"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
UICoordinator * ui_coordinator()
void ShowProjectManagement()
Injects dependencies into all editors within an EditorSet.
auto GetCurrentEditor() const -> Editor *override
void ShowProjectFileEditor()
project::YazeProject * GetCurrentProject()
void ShowCommandPalette(const char *initial_query=nullptr)
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)