From 1bc0f07a7ed227062d65cfd4c2ec23805dd192b1 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 26 Jan 2025 13:20:29 -0500 Subject: [PATCH] Refactor FlagsMenu to core namespace; remove redundant flags.h file and update references in editor files --- src/app/core/features.h | 47 +++++++++++++++++++ src/app/editor/editor_manager.cc | 3 +- src/app/editor/system/flags.h | 60 ------------------------ src/app/editor/system/settings_editor.cc | 33 +++++++------ 4 files changed, 64 insertions(+), 79 deletions(-) delete mode 100644 src/app/editor/system/flags.h diff --git a/src/app/core/features.h b/src/app/core/features.h index 8f9dcff9..eb412642 100644 --- a/src/app/core/features.h +++ b/src/app/core/features.h @@ -3,6 +3,8 @@ #include +#include "imgui/imgui.h" + namespace yaze { namespace core { @@ -100,6 +102,51 @@ class FeatureFlags { } }; +using ImGui::BeginMenu; +using ImGui::Checkbox; +using ImGui::EndMenu; +using ImGui::MenuItem; +using ImGui::Separator; + +struct FlagsMenu { + void DrawOverworldFlags() { + Checkbox("Enable Overworld Sprites", + &FeatureFlags::get().overworld.kDrawOverworldSprites); + Separator(); + Checkbox("Save Overworld Maps", + &FeatureFlags::get().overworld.kSaveOverworldMaps); + Checkbox("Save Overworld Entrances", + &FeatureFlags::get().overworld.kSaveOverworldEntrances); + Checkbox("Save Overworld Exits", + &FeatureFlags::get().overworld.kSaveOverworldExits); + Checkbox("Save Overworld Items", + &FeatureFlags::get().overworld.kSaveOverworldItems); + Checkbox("Save Overworld Properties", + &FeatureFlags::get().overworld.kSaveOverworldProperties); + Checkbox("Load Custom Overworld", + &FeatureFlags::get().overworld.kLoadCustomOverworld); + } + + void DrawDungeonFlags() { + Checkbox("Draw Dungeon Room Graphics", + &FeatureFlags::get().kDrawDungeonRoomGraphics); + Separator(); + Checkbox("Save Dungeon Maps", &FeatureFlags::get().kSaveDungeonMaps); + } + + void DrawResourceFlags() { + Checkbox("Save All Palettes", &FeatureFlags::get().kSaveAllPalettes); + Checkbox("Save Gfx Groups", &FeatureFlags::get().kSaveGfxGroups); + Checkbox("Save Graphics Sheets", &FeatureFlags::get().kSaveGraphicsSheet); + } + + void DrawSystemFlags() { + Checkbox("Enable Console Logging", &FeatureFlags::get().kLogToConsole); + Checkbox("Log Instructions to Emulator Debugger", + &FeatureFlags::get().kLogInstructions); + } +}; + } // namespace core } // namespace yaze diff --git a/src/app/editor/editor_manager.cc b/src/app/editor/editor_manager.cc index ec821a2d..27b8b290 100644 --- a/src/app/editor/editor_manager.cc +++ b/src/app/editor/editor_manager.cc @@ -13,7 +13,6 @@ #include "app/editor/music/music_editor.h" #include "app/editor/overworld/overworld_editor.h" #include "app/editor/sprite/sprite_editor.h" -#include "app/editor/system/flags.h" #include "app/emu/emulator.h" #include "app/gui/icons.h" #include "app/gui/input.h" @@ -468,7 +467,7 @@ void EditorManager::DrawMenuContent() { MenuItem("Backup ROM", "", &backup_rom_); MenuItem("Save New Auto", "", &save_new_auto_); Separator(); - static FlagsMenu flags_menu; + static core::FlagsMenu flags_menu; if (BeginMenu("System Flags")) { flags_menu.DrawSystemFlags(); EndMenu(); diff --git a/src/app/editor/system/flags.h b/src/app/editor/system/flags.h deleted file mode 100644 index dc320b0a..00000000 --- a/src/app/editor/system/flags.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef YAZE_APP_EDITOR_UTILS_FLAGS_H -#define YAZE_APP_EDITOR_UTILS_FLAGS_H - -#include "app/core/features.h" -#include "core/common.h" -#include "imgui/imgui.h" - -namespace yaze { -namespace editor { - -using core::FeatureFlags; -using ImGui::BeginMenu; -using ImGui::Checkbox; -using ImGui::EndMenu; -using ImGui::MenuItem; -using ImGui::Separator; - -struct FlagsMenu { - void DrawOverworldFlags() { - Checkbox("Enable Overworld Sprites", - &FeatureFlags::get().overworld.kDrawOverworldSprites); - Separator(); - Checkbox("Save Overworld Maps", - &FeatureFlags::get().overworld.kSaveOverworldMaps); - Checkbox("Save Overworld Entrances", - &FeatureFlags::get().overworld.kSaveOverworldEntrances); - Checkbox("Save Overworld Exits", - &FeatureFlags::get().overworld.kSaveOverworldExits); - Checkbox("Save Overworld Items", - &FeatureFlags::get().overworld.kSaveOverworldItems); - Checkbox("Save Overworld Properties", - &FeatureFlags::get().overworld.kSaveOverworldProperties); - Checkbox("Load Custom Overworld", - &FeatureFlags::get().overworld.kLoadCustomOverworld); - } - - void DrawDungeonFlags() { - Checkbox("Draw Dungeon Room Graphics", - &FeatureFlags::get().kDrawDungeonRoomGraphics); - Separator(); - Checkbox("Save Dungeon Maps", &FeatureFlags::get().kSaveDungeonMaps); - } - - void DrawResourceFlags() { - Checkbox("Save All Palettes", &FeatureFlags::get().kSaveAllPalettes); - Checkbox("Save Gfx Groups", &FeatureFlags::get().kSaveGfxGroups); - Checkbox("Save Graphics Sheets", &FeatureFlags::get().kSaveGraphicsSheet); - } - - void DrawSystemFlags() { - Checkbox("Enable Console Logging", &FeatureFlags::get().kLogToConsole); - Checkbox("Log Instructions to Emulator Debugger", - &FeatureFlags::get().kLogInstructions); - } -}; - -} // namespace editor -} // namespace yaze - -#endif // YAZE_APP_EDITOR_UTILS_FLAGS_H_ diff --git a/src/app/editor/system/settings_editor.cc b/src/app/editor/system/settings_editor.cc index 5a2bc4c2..0db8f170 100644 --- a/src/app/editor/system/settings_editor.cc +++ b/src/app/editor/system/settings_editor.cc @@ -1,9 +1,9 @@ #include "app/editor/system/settings_editor.h" -#include "app/gui/style.h" #include "absl/status/status.h" -#include "app/editor/system/flags.h" +#include "app/core/features.h" +#include "app/gui/style.h" #include "imgui/imgui.h" namespace yaze { @@ -49,43 +49,42 @@ absl::Status SettingsEditor::Update() { } void SettingsEditor::DrawGeneralSettings() { - static FlagsMenu flags; + static core::FlagsMenu flags; if (BeginTable("##SettingsTable", 4, ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) { TableSetupColumn("System Flags", ImGuiTableColumnFlags_WidthStretch); TableSetupColumn("Overworld Flags", ImGuiTableColumnFlags_WidthStretch); - TableSetupColumn("Dungeon Flags", ImGuiTableColumnFlags_WidthStretch); + TableSetupColumn("Dungeon Flags", ImGuiTableColumnFlags_WidthStretch); TableSetupColumn("Resource Flags", ImGuiTableColumnFlags_WidthStretch, 0.0f); TableHeadersRow(); TableNextColumn(); - if (BeginChild("##SystemFlags", ImVec2(0, 0), - ImGuiChildFlags_FrameStyle)) { + if (BeginChild("##SystemFlags", ImVec2(0, 0), ImGuiChildFlags_FrameStyle)) { flags.DrawSystemFlags(); EndChild(); } TableNextColumn(); - if (BeginChild("##OverworldFlags", ImVec2(0, 0), - ImGuiChildFlags_FrameStyle)) { - flags.DrawOverworldFlags(); - EndChild(); - } + if (BeginChild("##OverworldFlags", ImVec2(0, 0), + ImGuiChildFlags_FrameStyle)) { + flags.DrawOverworldFlags(); + EndChild(); + } TableNextColumn(); - if (BeginChild("##DungeonFlags", ImVec2(0, 0), - ImGuiChildFlags_FrameStyle)) { - flags.DrawDungeonFlags(); - EndChild(); - } + if (BeginChild("##DungeonFlags", ImVec2(0, 0), + ImGuiChildFlags_FrameStyle)) { + flags.DrawDungeonFlags(); + EndChild(); + } TableNextColumn(); if (BeginChild("##ResourceFlags", ImVec2(0, 0), - ImGuiChildFlags_FrameStyle)) { + ImGuiChildFlags_FrameStyle)) { flags.DrawResourceFlags(); EndChild(); }