yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
editor_manager.cc
Go to the documentation of this file.
1#include "editor_manager.h"
2
3#include "absl/status/status.h"
4#include "absl/strings/match.h"
5#include "absl/strings/str_cat.h"
6#include "app/core/features.h"
8#include "app/core/project.h"
17#include "app/emu/emulator.h"
18#include "app/gfx/arena.h"
19#include "app/gui/icons.h"
20#include "app/gui/input.h"
21#include "app/gui/style.h"
22#include "app/rom.h"
23#include "editor/editor.h"
24#include "imgui/imgui.h"
25#include "imgui/misc/cpp/imgui_stdlib.h"
26#include "util/macro.h"
27
28namespace yaze {
29namespace editor {
30
31using namespace ImGui;
32using core::FileDialogWrapper;
33
34namespace {
35
36std::string GetEditorName(EditorType type) {
37 return kEditorNames[static_cast<int>(type)];
38}
39
40} // namespace
41
42constexpr const char *kOverworldEditorName = ICON_MD_LAYERS " Overworld Editor";
43constexpr const char *kGraphicsEditorName = ICON_MD_PHOTO " Graphics Editor";
44constexpr const char *kPaletteEditorName = ICON_MD_PALETTE " Palette Editor";
45constexpr const char *kScreenEditorName = ICON_MD_SCREENSHOT " Screen Editor";
46constexpr const char *kSpriteEditorName = ICON_MD_SMART_TOY " Sprite Editor";
47constexpr const char *kMessageEditorName = ICON_MD_MESSAGE " Message Editor";
48constexpr const char *kSettingsEditorName = ICON_MD_SETTINGS " Settings Editor";
49constexpr const char *kAssemblyEditorName = ICON_MD_CODE " Assembly Editor";
50constexpr const char *kDungeonEditorName = ICON_MD_CASTLE " Dungeon Editor";
51constexpr const char *kMusicEditorName = ICON_MD_MUSIC_NOTE " Music Editor";
52
53void EditorManager::Initialize(const std::string &filename) {
54 // Point to a blank editor set when no ROM is loaded
56
57 if (!filename.empty()) {
59 }
60
61 // Initialize popup manager
62 popup_manager_ = std::make_unique<PopupManager>(this);
63 popup_manager_->Initialize();
64
65 // Set the popup manager in the context
66 context_.popup_manager = popup_manager_.get();
67
68 context_.shortcut_manager.RegisterShortcut(
69 "Open", {ImGuiKey_O, ImGuiMod_Ctrl}, [this]() { status_ = LoadRom(); });
70 context_.shortcut_manager.RegisterShortcut(
71 "Save", {ImGuiKey_S, ImGuiMod_Ctrl}, [this]() { status_ = SaveRom(); });
72 context_.shortcut_manager.RegisterShortcut(
73 "Close", {ImGuiKey_W, ImGuiMod_Ctrl}, [this]() {
74 if (current_rom_) current_rom_->Close();
75 });
76 context_.shortcut_manager.RegisterShortcut(
77 "Quit", {ImGuiKey_Q, ImGuiMod_Ctrl}, [this]() { quit_ = true; });
78
79 context_.shortcut_manager.RegisterShortcut(
80 "Undo", {ImGuiKey_Z, ImGuiMod_Ctrl},
81 [this]() { status_ = current_editor_->Undo(); });
82 context_.shortcut_manager.RegisterShortcut(
83 "Redo", {ImGuiKey_Y, ImGuiMod_Ctrl},
84 [this]() { status_ = current_editor_->Redo(); });
85 context_.shortcut_manager.RegisterShortcut(
86 "Cut", {ImGuiKey_X, ImGuiMod_Ctrl},
87 [this]() { status_ = current_editor_->Cut(); });
88 context_.shortcut_manager.RegisterShortcut(
89 "Copy", {ImGuiKey_C, ImGuiMod_Ctrl},
90 [this]() { status_ = current_editor_->Copy(); });
91 context_.shortcut_manager.RegisterShortcut(
92 "Paste", {ImGuiKey_V, ImGuiMod_Ctrl},
93 [this]() { status_ = current_editor_->Paste(); });
94 context_.shortcut_manager.RegisterShortcut(
95 "Find", {ImGuiKey_F, ImGuiMod_Ctrl},
96 [this]() { status_ = current_editor_->Find(); });
97
98 context_.shortcut_manager.RegisterShortcut(
99 "Load Last ROM", {ImGuiKey_R, ImGuiMod_Ctrl}, [this]() {
100 static RecentFilesManager manager("recent_files.txt");
101 manager.Load();
102 if (!manager.GetRecentFiles().empty()) {
103 auto front = manager.GetRecentFiles().front();
104 status_ = OpenRomOrProject(front);
105 }
106 });
107
108 context_.shortcut_manager.RegisterShortcut(
109 "F1", ImGuiKey_F1, [this]() { popup_manager_->Show("About"); });
110
111 // Initialize menu items
112 std::vector<gui::MenuItem> recent_files;
113 static RecentFilesManager manager("recent_files.txt");
114 manager.Load();
115 if (manager.GetRecentFiles().empty()) {
116 recent_files.emplace_back("No Recent Files", "", nullptr);
117 } else {
118 for (const auto &filePath : manager.GetRecentFiles()) {
119 recent_files.emplace_back(filePath, "", [filePath, this]() {
120 status_ = OpenRomOrProject(filePath);
121 });
122 }
123 }
124
125 std::vector<gui::MenuItem> options_subitems;
126 options_subitems.emplace_back(
127 "Backup ROM", "", [this]() { backup_rom_ |= backup_rom_; },
128 [this]() { return backup_rom_; });
129 options_subitems.emplace_back(
130 "Save New Auto", "", [this]() { save_new_auto_ |= save_new_auto_; },
131 [this]() { return save_new_auto_; });
132
133 std::vector<gui::MenuItem> project_menu_subitems;
134 project_menu_subitems.emplace_back(
135 "New Project", "", [this]() { popup_manager_->Show("New Project"); });
136 project_menu_subitems.emplace_back("Open Project", "",
137 [this]() { status_ = OpenProject(); });
138 project_menu_subitems.emplace_back(
139 "Save Project", "", [this]() { status_ = SaveProject(); },
140 [this]() { return current_project_.project_opened_; });
141
142 gui::kMainMenu = {
143 {"File",
144 {},
145 {},
146 {},
147 {
148 {absl::StrCat(ICON_MD_FILE_OPEN, " Open"),
149 context_.shortcut_manager.GetKeys("Open"),
150 context_.shortcut_manager.GetCallback("Open")},
151 {"Open Recent", "", []() {},
152 []() { return !manager.GetRecentFiles().empty(); }, recent_files},
153 {absl::StrCat(ICON_MD_FILE_DOWNLOAD, " Save"),
154 context_.shortcut_manager.GetKeys("Save"),
155 context_.shortcut_manager.GetCallback("Save")},
156 {absl::StrCat(ICON_MD_SAVE_AS, " Save As.."), "",
157 [this]() { popup_manager_->Show("Save As.."); }},
158 {absl::StrCat(ICON_MD_BALLOT, " Project"), "", []() {},
159 []() { return true; }, project_menu_subitems},
160 {absl::StrCat(ICON_MD_CLOSE, " Close"), "",
161 [this]() {
162 if (current_rom_) current_rom_->Close();
163 }},
164 {gui::kSeparator, "", nullptr, []() { return true; }},
165 {absl::StrCat(ICON_MD_MISCELLANEOUS_SERVICES, " Options"), "",
166 []() {}, []() { return true; }, options_subitems},
167 {absl::StrCat(ICON_MD_EXIT_TO_APP, " Quit"), "Ctrl+Q",
168 [this]() { quit_ = true; }},
169 }},
170 {"Edit",
171 {},
172 {},
173 {},
174 {
175 {absl::StrCat(ICON_MD_CONTENT_CUT, " Cut"),
176 context_.shortcut_manager.GetKeys("Cut"),
177 context_.shortcut_manager.GetCallback("Cut")},
178 {absl::StrCat(ICON_MD_CONTENT_COPY, " Copy"),
179 context_.shortcut_manager.GetKeys("Copy"),
180 context_.shortcut_manager.GetCallback("Copy")},
181 {absl::StrCat(ICON_MD_CONTENT_PASTE, " Paste"),
182 context_.shortcut_manager.GetKeys("Paste"),
183 context_.shortcut_manager.GetCallback("Paste")},
184 {gui::kSeparator, "", nullptr, []() { return true; }},
185 {absl::StrCat(ICON_MD_UNDO, " Undo"),
186 context_.shortcut_manager.GetKeys("Undo"),
187 context_.shortcut_manager.GetCallback("Undo")},
188 {absl::StrCat(ICON_MD_REDO, " Redo"),
189 context_.shortcut_manager.GetKeys("Redo"),
190 context_.shortcut_manager.GetCallback("Redo")},
191 {gui::kSeparator, "", nullptr, []() { return true; }},
192 {absl::StrCat(ICON_MD_SEARCH, " Find"),
193 context_.shortcut_manager.GetKeys("Find"),
194 context_.shortcut_manager.GetCallback("Find")},
195 }},
196 {"View",
197 {},
198 {},
199 {},
200 {
201 {absl::StrCat(ICON_MD_HOME, " Home"), "",
202 [&]() { show_homepage_ = true; }},
203 {kAssemblyEditorName, "", [&]() { show_asm_editor_ = true; },
204 [&]() { return show_asm_editor_; }},
206 [&]() { current_editor_set_->dungeon_editor_.set_active(true); },
207 [&]() { return *current_editor_set_->dungeon_editor_.active(); }},
209 [&]() { current_editor_set_->graphics_editor_.set_active(true); },
210 [&]() { return *current_editor_set_->graphics_editor_.active(); }},
211 {kMusicEditorName, "",
212 [&]() { current_editor_set_->music_editor_.set_active(true); },
213 [&]() { return *current_editor_set_->music_editor_.active(); }},
215 [&]() { current_editor_set_->overworld_editor_.set_active(true); },
216 [&]() { return *current_editor_set_->overworld_editor_.active(); }},
218 [&]() { current_editor_set_->palette_editor_.set_active(true); },
219 [&]() { return *current_editor_set_->palette_editor_.active(); }},
221 [&]() { current_editor_set_->screen_editor_.set_active(true); },
222 [&]() { return *current_editor_set_->screen_editor_.active(); }},
224 [&]() { current_editor_set_->sprite_editor_.set_active(true); },
225 [&]() { return *current_editor_set_->sprite_editor_.active(); }},
227 [&]() { current_editor_set_->message_editor_.set_active(true); },
228 [&]() { return *current_editor_set_->message_editor_.active(); }},
230 [&]() { current_editor_set_->settings_editor_.set_active(true); },
231 [&]() { return *current_editor_set_->settings_editor_.active(); }},
232 {gui::kSeparator, "", nullptr, []() { return true; }},
233 {absl::StrCat(ICON_MD_GAMEPAD, " Emulator"), "",
234 [&]() { show_emulator_ = true; }},
235 {absl::StrCat(ICON_MD_MEMORY, " Memory Editor"), "",
236 [&]() { show_memory_editor_ = true; }},
237 {absl::StrCat(ICON_MD_SIM_CARD, " ROM Metadata"), "",
238 [&]() { popup_manager_->Show("ROM Information"); }},
239 {gui::kSeparator, "", nullptr, []() { return true; }},
240 {absl::StrCat(ICON_MD_HELP, " ImGui Demo"), "",
241 [&]() { show_imgui_demo_ = true; }},
242 {absl::StrCat(ICON_MD_HELP, " ImGui Metrics"), "",
243 [&]() { show_imgui_metrics_ = true; }},
244 }},
245 {"Workspace",
246 {},
247 {},
248 {},
249 {
250 {absl::StrCat(ICON_MD_SPACE_DASHBOARD, " Layout"), "",
251 [&]() { show_workspace_layout = true; }},
252 }},
253 {"Help",
254 {},
255 {},
256 {},
257 {
258 {absl::StrCat(ICON_MD_HELP, " How to open a ROM"), "",
259 [&]() { popup_manager_->Show("Open a ROM"); }},
260 {absl::StrCat(ICON_MD_HELP, " Supported Features"), "",
261 [&]() { popup_manager_->Show("Supported Features"); }},
262 {absl::StrCat(ICON_MD_HELP, " How to manage a project"), "",
263 [&]() { popup_manager_->Show("Manage Project"); }},
264 {absl::StrCat(ICON_MD_HELP, " About"), "F1",
265 [&]() { popup_manager_->Show("About"); }},
266 }}};
267}
268
269absl::Status EditorManager::Update() {
270 popup_manager_->DrawPopups();
271 ExecuteShortcuts(context_.shortcut_manager);
272
273 if (show_homepage_) {
274 ImGui::Begin("Home", &show_homepage_);
275 DrawHomepage();
276 ImGui::End();
277 }
278
279 if (!current_editor_set_) {
280 return absl::OkStatus();
281 }
282 for (auto editor : current_editor_set_->active_editors_) {
283 if (*editor->active()) {
284 if (editor->type() == EditorType::kOverworld) {
285 auto &overworld_editor = static_cast<OverworldEditor &>(*editor);
286 if (overworld_editor.jump_to_tab() != -1) {
287 current_editor_set_->dungeon_editor_.set_active(true);
288 // Set the dungeon editor to the jump to tab
289 current_editor_set_->dungeon_editor_.add_room(
290 overworld_editor.jump_to_tab());
291 overworld_editor.jump_to_tab_ = -1;
292 }
293 }
294
295 if (ImGui::Begin(GetEditorName(editor->type()).c_str(),
296 editor->active())) {
298 status_ = editor->Update();
299 }
300 ImGui::End();
301 }
302 }
303 return absl::OkStatus();
304}
305
307 TextWrapped("Welcome to the Yet Another Zelda3 Editor (yaze)!");
308 TextWrapped("The Legend of Zelda: A Link to the Past.");
309 TextWrapped("Please report any bugs or issues you encounter.");
310 ImGui::SameLine();
311 if (gui::ClickableText("https://github.com/scawful/yaze")) {
312 gui::OpenUrl("https://github.com/scawful/yaze");
313 }
314
315 if (!current_rom_) {
316 TextWrapped("No ROM loaded.");
317 if (gui::ClickableText("Open a ROM")) {
318 status_ = LoadRom();
319 }
320 SameLine();
321 Checkbox("Load custom overworld features",
322 &core::FeatureFlags::get().overworld.kLoadCustomOverworld);
323
324 ImGui::BeginChild("Recent Files", ImVec2(-1, -1), true);
325 static RecentFilesManager manager("recent_files.txt");
326 manager.Load();
327 for (const auto &file : manager.GetRecentFiles()) {
328 if (gui::ClickableText(file.c_str())) {
330 }
331 }
332 ImGui::EndChild();
333 return;
334 }
335
336 TextWrapped("Current ROM: %s", current_rom_->filename().c_str());
337 if (Button(kOverworldEditorName)) {
338 current_editor_set_->overworld_editor_.set_active(true);
339 }
340 ImGui::SameLine();
341 if (Button(kDungeonEditorName)) {
342 current_editor_set_->dungeon_editor_.set_active(true);
343 }
344 ImGui::SameLine();
345 if (Button(kGraphicsEditorName)) {
346 current_editor_set_->graphics_editor_.set_active(true);
347 }
348 ImGui::SameLine();
349 if (Button(kMessageEditorName)) {
350 current_editor_set_->message_editor_.set_active(true);
351 }
352
353 if (Button(kPaletteEditorName)) {
354 current_editor_set_->palette_editor_.set_active(true);
355 }
356 ImGui::SameLine();
357 if (Button(kScreenEditorName)) {
358 current_editor_set_->screen_editor_.set_active(true);
359 }
360 ImGui::SameLine();
361 if (Button(kSpriteEditorName)) {
362 current_editor_set_->sprite_editor_.set_active(true);
363 }
364 ImGui::SameLine();
365 if (Button(kMusicEditorName)) {
366 current_editor_set_->music_editor_.set_active(true);
367 }
368
369 if (Button(kSettingsEditorName)) {
370 current_editor_set_->settings_editor_.set_active(true);
371 }
372}
373
375 SameLine((GetWindowWidth() / 2) - 100);
376 if (current_rom_ && current_rom_->is_loaded()) {
377 SetNextItemWidth(GetWindowWidth() / 6);
378 if (BeginCombo("##ROMSelector", current_rom_->short_name().c_str())) {
379 for (const auto &session : sessions_) {
380 const Rom* rom = &session.rom;
381 if (MenuItem(rom->short_name().c_str())) {
382 RETURN_IF_ERROR(SetCurrentRom(const_cast<Rom*>(rom)));
383 }
384 }
385 EndCombo();
386 }
387 } else {
388 Text("No ROM loaded");
389 }
390 return absl::OkStatus();
391}
392
394 static bool show_display_settings = false;
395 static bool save_as_menu = false;
396
397 if (BeginMenuBar()) {
398 gui::DrawMenu(gui::kMainMenu);
399
401
402 SameLine(GetWindowWidth() - GetStyle().ItemSpacing.x -
403 CalcTextSize(ICON_MD_DISPLAY_SETTINGS).x - 110);
404 PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
405 if (Button(ICON_MD_DISPLAY_SETTINGS)) {
406 show_display_settings = !show_display_settings;
407 }
408 PopStyleColor();
409 Text("yaze v%s", version_.c_str());
410 EndMenuBar();
411 }
412
413 if (show_display_settings) {
414 Begin("Display Settings", &show_display_settings, ImGuiWindowFlags_None);
416 End();
417 }
418
419 if (show_imgui_demo_) ShowDemoWindow();
420 if (show_imgui_metrics_) ShowMetricsWindow(&show_imgui_metrics_);
422 current_editor_set_->memory_editor_.Update(show_memory_editor_);
423 }
425 current_editor_set_->assembly_editor_.Update(show_asm_editor_);
426 }
427
428 if (show_emulator_) {
429 Begin("Emulator", &show_emulator_, ImGuiWindowFlags_MenuBar);
430 emulator_.Run();
431 End();
432 }
433
435 Begin("Palette Editor", &show_palette_editor_);
436 status_ = current_editor_set_->palette_editor_.Update();
437 End();
438 }
439
441 current_rom_->resource_label()->DisplayLabels(&show_resource_label_manager);
442 if (current_project_.project_opened_ &&
443 !current_project_.labels_filename_.empty()) {
444 current_project_.labels_filename_ =
445 current_rom_->resource_label()->filename_;
446 }
447 }
448
449 if (save_as_menu) {
450 static std::string save_as_filename = "";
451 Begin("Save As..", &save_as_menu, ImGuiWindowFlags_AlwaysAutoResize);
452 InputText("Filename", &save_as_filename);
453 if (Button("Save", gui::kDefaultModalSize)) {
454 status_ = SaveRom();
455 save_as_menu = false;
456 }
457 SameLine();
458 if (Button("Cancel", gui::kDefaultModalSize)) {
459 save_as_menu = false;
460 }
461 End();
462 }
463
464 if (new_project_menu) {
465 Begin("New Project", &new_project_menu, ImGuiWindowFlags_AlwaysAutoResize);
466 static std::string save_as_filename = "";
467 InputText("Project Name", &save_as_filename);
468 if (Button("Destination Filepath", gui::kDefaultModalSize)) {
470 }
471 SameLine();
472 Text("%s", current_project_.filepath.c_str());
473 if (Button("ROM File", gui::kDefaultModalSize)) {
475 }
476 SameLine();
477 Text("%s", current_project_.rom_filename_.c_str());
478 if (Button("Labels File", gui::kDefaultModalSize)) {
479 current_project_.labels_filename_ =
481 }
482 SameLine();
483 Text("%s", current_project_.labels_filename_.c_str());
484 if (Button("Code Folder", gui::kDefaultModalSize)) {
486 }
487 SameLine();
488 Text("%s", current_project_.code_folder_.c_str());
489
490 Separator();
491 if (Button("Create", gui::kDefaultModalSize)) {
492 new_project_menu = false;
493 status_ = current_project_.Create(save_as_filename);
494 if (status_.ok()) {
495 status_ = current_project_.Save();
496 }
497 }
498 SameLine();
499 if (Button("Cancel", gui::kDefaultModalSize)) {
500 new_project_menu = false;
501 }
502 End();
503 }
504}
505
507 auto file_name = FileDialogWrapper::ShowOpenFileDialog();
508 Rom temp_rom;
509 RETURN_IF_ERROR(temp_rom.LoadFromFile(file_name));
510
511 sessions_.emplace_back(std::move(temp_rom));
512 RomSession &session = sessions_.back();
513 // Wire editor contexts
514 for (auto *editor : session.editors.active_editors_) {
515 editor->set_context(&context_);
516 }
517 current_rom_ = &session.rom;
518 current_editor_set_ = &session.editors;
519
520 static RecentFilesManager manager("recent_files.txt");
521 manager.Load();
522 manager.AddFile(file_name);
523 manager.Save();
525
526 return absl::OkStatus();
527}
528
531 return absl::FailedPreconditionError("No ROM or editor set loaded");
532 }
533 current_editor_set_->overworld_editor_.Initialize();
534 current_editor_set_->message_editor_.Initialize();
535 ASSIGN_OR_RETURN(*gfx::Arena::Get().mutable_gfx_sheets(),
537 RETURN_IF_ERROR(current_editor_set_->overworld_editor_.Load());
538 RETURN_IF_ERROR(current_editor_set_->dungeon_editor_.Load());
539 RETURN_IF_ERROR(current_editor_set_->screen_editor_.Load());
540 RETURN_IF_ERROR(current_editor_set_->settings_editor_.Load());
541 RETURN_IF_ERROR(current_editor_set_->sprite_editor_.Load());
542 RETURN_IF_ERROR(current_editor_set_->message_editor_.Load());
543 RETURN_IF_ERROR(current_editor_set_->music_editor_.Load());
544 RETURN_IF_ERROR(current_editor_set_->palette_editor_.Load());
545 return absl::OkStatus();
546}
547
550 return absl::FailedPreconditionError("No ROM or editor set loaded");
551 }
552
553 if (core::FeatureFlags::get().kSaveDungeonMaps) {
555 *current_rom_, current_editor_set_->screen_editor_.dungeon_maps_));
556 }
557
558 RETURN_IF_ERROR(current_editor_set_->overworld_editor_.Save());
559
560 if (core::FeatureFlags::get().kSaveGraphicsSheet)
563
564 Rom::SaveSettings settings;
565 settings.backup = backup_rom_;
566 settings.save_new = save_new_auto_;
567 return current_rom_->SaveToFile(settings);
568}
569
570absl::Status EditorManager::OpenRomOrProject(const std::string &filename) {
571 if (absl::StrContains(filename, ".yaze")) {
572 RETURN_IF_ERROR(current_project_.Open(filename));
574 } else {
575 Rom temp_rom;
576 RETURN_IF_ERROR(temp_rom.LoadFromFile(filename));
577 sessions_.emplace_back(std::move(temp_rom));
578 RomSession &session = sessions_.back();
579 for (auto *editor : session.editors.active_editors_) {
580 editor->set_context(&context_);
581 }
582 current_rom_ = &session.rom;
583 current_editor_set_ = &session.editors;
585 }
586 return absl::OkStatus();
587}
588
590 Rom temp_rom;
591 RETURN_IF_ERROR(temp_rom.LoadFromFile(current_project_.rom_filename_));
592
593 if (!temp_rom.resource_label()->LoadLabels(
594 current_project_.labels_filename_)) {
595 return absl::InternalError(
596 "Could not load labels file, update your project file.");
597 }
598
599 sessions_.emplace_back(std::move(temp_rom));
600 RomSession &session = sessions_.back();
601 for (auto *editor : session.editors.active_editors_) {
602 editor->set_context(&context_);
603 }
604 current_rom_ = &session.rom;
605 current_editor_set_ = &session.editors;
606
607 static RecentFilesManager manager("recent_files.txt");
608 manager.Load();
609 manager.AddFile(current_project_.filepath + "/" + current_project_.name +
610 ".yaze");
611 manager.Save();
613 current_editor_set_->assembly_editor_.OpenFolder(
614 current_project_.code_folder_);
615 }
616 current_project_.project_opened_ = true;
618 return absl::OkStatus();
619}
620
622 if (current_project_.project_opened_) {
624 } else {
625 new_project_menu = true;
626 }
627 return absl::OkStatus();
628}
629
631 if (!rom) {
632 return absl::InvalidArgumentError("Invalid ROM pointer");
633 }
634
635 for (auto &session : sessions_) {
636 if (&session.rom == rom) {
637 current_rom_ = &session.rom;
638 current_editor_set_ = &session.editors;
639 return absl::OkStatus();
640 }
641 }
642 // If ROM wasn't found in existing sessions, treat as new session.
643 // Copying an external ROM object is avoided; instead, fail.
644 return absl::NotFoundError("ROM not found in existing sessions");
645}
646
647} // namespace editor
648} // namespace yaze
const std::vector< std::string > & GetRecentFiles() const
Definition project.h:121
void AddFile(const std::string &file_path)
Definition project.h:87
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:58
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:231
ResourceLabelManager * resource_label()
Definition rom.h:194
auto short_name() const
Definition rom.h:184
static Flags & get()
Definition features.h:66
std::deque< RomSession > sessions_
void Initialize(const std::string &filename="")
absl::Status OpenRomOrProject(const std::string &filename)
std::unique_ptr< PopupManager > popup_manager_
absl::Status SetCurrentRom(Rom *rom)
std::vector< Editor * > active_editors_
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path.
Manipulates the Overworld and OverworldMap data in a Rom.
static Arena & Get()
Definition arena.cc:10
#define ICON_MD_CONTENT_CUT
Definition icons.h:464
#define ICON_MD_SETTINGS
Definition icons.h:1697
#define ICON_MD_FILE_OPEN
Definition icons.h:745
#define ICON_MD_EXIT_TO_APP
Definition icons.h:697
#define ICON_MD_MEMORY
Definition icons.h:1193
#define ICON_MD_SEARCH
Definition icons.h:1671
#define ICON_MD_SIM_CARD
Definition icons.h:1762
#define ICON_MD_FILE_DOWNLOAD
Definition icons.h:742
#define ICON_MD_SAVE_AS
Definition icons.h:1644
#define ICON_MD_CODE
Definition icons.h:432
#define ICON_MD_REDO
Definition icons.h:1568
#define ICON_MD_MESSAGE
Definition icons.h:1199
#define ICON_MD_CASTLE
Definition icons.h:378
#define ICON_MD_SCREENSHOT
Definition icons.h:1664
#define ICON_MD_MUSIC_NOTE
Definition icons.h:1262
#define ICON_MD_CONTENT_PASTE
Definition icons.h:465
#define ICON_MD_HOME
Definition icons.h:951
#define ICON_MD_LAYERS
Definition icons.h:1066
#define ICON_MD_DISPLAY_SETTINGS
Definition icons.h:585
#define ICON_MD_BALLOT
Definition icons.h:235
#define ICON_MD_SPACE_DASHBOARD
Definition icons.h:1803
#define ICON_MD_PALETTE
Definition icons.h:1368
#define ICON_MD_CONTENT_COPY
Definition icons.h:463
#define ICON_MD_MISCELLANEOUS_SERVICES
Definition icons.h:1211
#define ICON_MD_PHOTO
Definition icons.h:1449
#define ICON_MD_CLOSE
Definition icons.h:416
#define ICON_MD_GAMEPAD
Definition icons.h:864
#define ICON_MD_HELP
Definition icons.h:931
#define ICON_MD_UNDO
Definition icons.h:2034
#define ICON_MD_SMART_TOY
Definition icons.h:1776
#define PRINT_IF_ERROR(expression)
Definition macro.h:25
#define RETURN_IF_ERROR(expression)
Definition macro.h:51
#define ASSIGN_OR_RETURN(type_variable_name, expression)
Definition macro.h:59
Editors are the view controllers for the application.
constexpr std::array< const char *, 10 > kEditorNames
Definition editor.h:42
constexpr const char * kDungeonEditorName
constexpr const char * kMessageEditorName
constexpr const char * kGraphicsEditorName
constexpr const char * kScreenEditorName
constexpr const char * kSettingsEditorName
constexpr const char * kMusicEditorName
constexpr const char * kOverworldEditorName
constexpr const char * kAssemblyEditorName
constexpr const char * kSpriteEditorName
void ExecuteShortcuts(const ShortcutManager &shortcut_manager)
constexpr const char * kPaletteEditorName
constexpr std::string kSeparator
Definition input.h:91
bool ClickableText(const std::string &text)
Definition input.cc:201
void DrawMenu(Menu &menu)
Definition input.cc:398
void DrawDisplaySettings(ImGuiStyle *ref)
Definition style.cc:396
bool OpenUrl(const std::string &url)
Definition input.cc:427
constexpr ImVec2 kDefaultModalSize
Definition input.h:21
absl::Status SaveDungeonMaps(Rom &rom, std::vector< DungeonMap > &dungeon_maps)
Save the dungeon maps to the ROM.
Main namespace for the application.
Definition controller.cc:12
absl::StatusOr< std::array< gfx::Bitmap, kNumGfxSheets > > LoadAllGraphicsData(Rom &rom, bool defer_render)
This function iterates over all graphics sheets in the Rom and loads them into memory....
Definition rom.cc:135
absl::Status SaveAllGraphicsData(Rom &rom, std::array< gfx::Bitmap, kNumGfxSheets > &gfx_sheets)
Definition rom.cc:194
bool LoadLabels(const std::string &filename)
Definition project.cc:64