From 03875a646514bd093dafc80de71c9b78e5ec14ff Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 20 Jul 2024 10:23:13 -0400 Subject: [PATCH] add FlagsMenu for FileMenu and SettingsEditor --- src/app/editor/dungeon_editor.h | 10 ++--- src/app/editor/master_editor.cc | 48 ++------------------- src/app/editor/settings_editor.cc | 11 ++--- src/app/editor/settings_editor.h | 2 + src/app/editor/utils/flags.h | 70 +++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 55 deletions(-) create mode 100644 src/app/editor/utils/flags.h diff --git a/src/app/editor/dungeon_editor.h b/src/app/editor/dungeon_editor.h index 5584eb4f..6930bb53 100644 --- a/src/app/editor/dungeon_editor.h +++ b/src/app/editor/dungeon_editor.h @@ -49,11 +49,11 @@ class DungeonEditor : public Editor, DungeonEditor() { type_ = EditorType::kDungeon; } absl::Status Update() override; - absl::Status Undo() { return absl::UnimplementedError("Undo"); } - absl::Status Redo() { return absl::UnimplementedError("Redo"); } - absl::Status Cut() { return absl::UnimplementedError("Cut"); } - absl::Status Copy() { return absl::UnimplementedError("Copy"); } - absl::Status Paste() { return absl::UnimplementedError("Paste"); } + absl::Status Undo() override { return absl::UnimplementedError("Undo"); } + absl::Status Redo() override { return absl::UnimplementedError("Redo"); } + absl::Status Cut() override { return absl::UnimplementedError("Cut"); } + absl::Status Copy() override { return absl::UnimplementedError("Copy"); } + absl::Status Paste() override { return absl::UnimplementedError("Paste"); } absl::Status Find() override { return absl::UnimplementedError("Find"); } void add_room(int i) { active_rooms_.push_back(i); } diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 91c8ee1b..44dee397 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -22,6 +22,7 @@ #include "app/editor/music/music_editor.h" #include "app/editor/overworld_editor.h" #include "app/editor/sprite/sprite_editor.h" +#include "app/editor/utils/flags.h" #include "app/editor/utils/recent_files.h" #include "app/emu/emulator.h" #include "app/gfx/snes_palette.h" @@ -539,51 +540,8 @@ void MasterEditor::DrawFileMenu() { MenuItem("Backup ROM", "", &backup_rom_); MenuItem("Save New Auto", "", &save_new_auto_); Separator(); - if (BeginMenu("Experiment Flags")) { - if (BeginMenu("Overworld Flags")) { - Checkbox("Enable Overworld Sprites", - &mutable_flags()->overworld.kDrawOverworldSprites); - Separator(); - Checkbox("Save Overworld Maps", - &mutable_flags()->overworld.kSaveOverworldMaps); - Checkbox("Save Overworld Entrances", - &mutable_flags()->overworld.kSaveOverworldEntrances); - Checkbox("Save Overworld Exits", - &mutable_flags()->overworld.kSaveOverworldExits); - Checkbox("Save Overworld Items", - &mutable_flags()->overworld.kSaveOverworldItems); - Checkbox("Save Overworld Properties", - &mutable_flags()->overworld.kSaveOverworldProperties); - ImGui::EndMenu(); - } - - if (BeginMenu("Dungeon Flags")) { - Checkbox("Draw Dungeon Room Graphics", - &mutable_flags()->kDrawDungeonRoomGraphics); - Separator(); - Checkbox("Save Dungeon Maps", &mutable_flags()->kSaveDungeonMaps); - ImGui::EndMenu(); - } - - if (BeginMenu("Emulator Flags")) { - Checkbox("Load Audio Device", &mutable_flags()->kLoadAudioDevice); - ImGui::EndMenu(); - } - - Checkbox("Use built-in file dialog", - &mutable_flags()->kNewFileDialogWrapper); - Checkbox("Enable Console Logging", &mutable_flags()->kLogToConsole); - Checkbox("Enable Texture Streaming", - &mutable_flags()->kLoadTexturesAsStreaming); - Checkbox("Use Bitmap Manager", &mutable_flags()->kUseBitmapManager); - Checkbox("Log Instructions to Debugger", - &mutable_flags()->kLogInstructions); - Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes); - Checkbox("Save Gfx Groups", &mutable_flags()->kSaveGfxGroups); - Checkbox("Use New ImGui Input", &mutable_flags()->kUseNewImGuiInput); - ImGui::EndMenu(); - } - + static FlagsMenu flags_menu; + flags_menu.Draw(); ImGui::EndMenu(); } diff --git a/src/app/editor/settings_editor.cc b/src/app/editor/settings_editor.cc index af1e01a2..34774a29 100644 --- a/src/app/editor/settings_editor.cc +++ b/src/app/editor/settings_editor.cc @@ -1,4 +1,6 @@ #include +#include +#include #include "absl/status/status.h" @@ -6,20 +8,20 @@ namespace yaze { namespace app { namespace editor { +using ImGui::BeginTabBar; using ImGui::BeginTabItem; using ImGui::EndTabBar; using ImGui::EndTabItem; -using ImGui::TabBar; using ImGui::Text; absl::Status SettingsEditor::Update() { - if (TabBar("Settings", ImGuiTabBarFlags_None)) { + if (BeginTabBar("Settings", ImGuiTabBarFlags_None)) { if (BeginTabItem("General")) { - Text("General settings"); + static FlagsMenu flags; + flags.Draw(); EndTabItem(); } if (BeginTabItem("Keyboard Shortcuts")) { - EndTabItem(); } EndTabBar(); @@ -32,7 +34,6 @@ absl::Status SettingsEditor::DrawKeyboardShortcuts() { return absl::OkStatus(); } - } // namespace editor } // namespace app } // namespace yaze diff --git a/src/app/editor/settings_editor.h b/src/app/editor/settings_editor.h index cc5c8f18..e63f8e97 100644 --- a/src/app/editor/settings_editor.h +++ b/src/app/editor/settings_editor.h @@ -10,6 +10,8 @@ namespace editor { class SettingsEditor : public Editor { public: + SettingsEditor() : Editor() { type_ = EditorType::kSettings; } + absl::Status Update() override; absl::Status Undo() override { return absl::UnimplementedError("Undo"); } diff --git a/src/app/editor/utils/flags.h b/src/app/editor/utils/flags.h new file mode 100644 index 00000000..985d27ec --- /dev/null +++ b/src/app/editor/utils/flags.h @@ -0,0 +1,70 @@ +#ifndef YAZE_APP_EDITOR_UTILS_FLAGS_H +#define YAZE_APP_EDITOR_UTILS_FLAGS_H + +#include +#include + +namespace yaze { +namespace app { +namespace editor { + +using ImGui::BeginMenu; +using ImGui::Checkbox; +using ImGui::EndMenu; +using ImGui::MenuItem; +using ImGui::Separator; + +struct FlagsMenu : public core::ExperimentFlags { + void Draw() { + if (BeginMenu("Experiment Flags")) { + if (BeginMenu("Overworld Flags")) { + Checkbox("Enable Overworld Sprites", + &mutable_flags()->overworld.kDrawOverworldSprites); + Separator(); + Checkbox("Save Overworld Maps", + &mutable_flags()->overworld.kSaveOverworldMaps); + Checkbox("Save Overworld Entrances", + &mutable_flags()->overworld.kSaveOverworldEntrances); + Checkbox("Save Overworld Exits", + &mutable_flags()->overworld.kSaveOverworldExits); + Checkbox("Save Overworld Items", + &mutable_flags()->overworld.kSaveOverworldItems); + Checkbox("Save Overworld Properties", + &mutable_flags()->overworld.kSaveOverworldProperties); + ImGui::EndMenu(); + } + + if (BeginMenu("Dungeon Flags")) { + Checkbox("Draw Dungeon Room Graphics", + &mutable_flags()->kDrawDungeonRoomGraphics); + Separator(); + Checkbox("Save Dungeon Maps", &mutable_flags()->kSaveDungeonMaps); + ImGui::EndMenu(); + } + + if (BeginMenu("Emulator Flags")) { + Checkbox("Load Audio Device", &mutable_flags()->kLoadAudioDevice); + ImGui::EndMenu(); + } + + Checkbox("Use built-in file dialog", + &mutable_flags()->kNewFileDialogWrapper); + Checkbox("Enable Console Logging", &mutable_flags()->kLogToConsole); + Checkbox("Enable Texture Streaming", + &mutable_flags()->kLoadTexturesAsStreaming); + Checkbox("Use Bitmap Manager", &mutable_flags()->kUseBitmapManager); + Checkbox("Log Instructions to Debugger", + &mutable_flags()->kLogInstructions); + Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes); + Checkbox("Save Gfx Groups", &mutable_flags()->kSaveGfxGroups); + Checkbox("Use New ImGui Input", &mutable_flags()->kUseNewImGuiInput); + ImGui::EndMenu(); + } + } +}; + +} // namespace editor +} // namespace app +} // namespace yaze + +#endif // YAZE_APP_EDITOR_UTILS_FLAGS_H_ \ No newline at end of file