feat: Enhance editor card management and shortcut functionality

- Introduced new shortcut categories for graphics, screen, and sprite editors, improving accessibility and organization.
- Updated DungeonEditorV2 and other editor classes to register cards with the EditorCardManager, allowing for better control and visibility management.
- Refactored shortcut registration for dungeon, graphics, screen, and sprite editors, ensuring consistent user experience across the application.
- Improved initialization processes to handle dynamic card visibility and shortcuts effectively.
This commit is contained in:
scawful
2025-10-09 09:46:29 -04:00
parent 9465195956
commit 219406901d
15 changed files with 315 additions and 86 deletions

View File

@@ -41,7 +41,52 @@ constexpr ImGuiTableFlags kGfxEditTableFlags =
ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable |
ImGuiTableFlags_SizingFixedFit;
void GraphicsEditor::Initialize() {}
void GraphicsEditor::Initialize() {
// Register cards with EditorCardManager during initialization (once)
auto& card_manager = gui::EditorCardManager::Get();
card_manager.RegisterCard({
.card_id = "graphics.sheet_editor",
.display_name = "Sheet Editor",
.icon = ICON_MD_EDIT,
.category = "Graphics",
.shortcut_hint = "Ctrl+Shift+1",
.visibility_flag = &show_sheet_editor_,
.priority = 10
});
card_manager.RegisterCard({
.card_id = "graphics.sheet_browser",
.display_name = "Sheet Browser",
.icon = ICON_MD_VIEW_LIST,
.category = "Graphics",
.shortcut_hint = "Ctrl+Shift+2",
.visibility_flag = &show_sheet_browser_,
.priority = 20
});
card_manager.RegisterCard({
.card_id = "graphics.player_animations",
.display_name = "Player Animations",
.icon = ICON_MD_PERSON,
.category = "Graphics",
.shortcut_hint = "Ctrl+Shift+3",
.visibility_flag = &show_player_animations_,
.priority = 30
});
card_manager.RegisterCard({
.card_id = "graphics.prototype_viewer",
.display_name = "Prototype Viewer",
.icon = ICON_MD_CONSTRUCTION,
.category = "Graphics",
.shortcut_hint = "Ctrl+Shift+4",
.visibility_flag = &show_prototype_viewer_,
.priority = 40
});
printf("[GraphicsEditor] Registered 4 cards with EditorCardManager\n");
}
absl::Status GraphicsEditor::Load() {
gfx::ScopedTimer timer("GraphicsEditor::Load");

View File

@@ -7,6 +7,7 @@
#include "app/editor/editor.h"
#include "app/editor/graphics/palette_editor.h"
#include "app/gfx/bitmap.h"
#include "app/gui/editor_card_manager.h"
#include "app/gfx/snes_tile.h"
#include "app/gui/canvas.h"
#include "app/gui/editor_layout.h"
@@ -116,8 +117,9 @@ class GraphicsEditor : public Editor {
absl::Status DecompressSuperDonkey();
// Member Variables
// Card visibility
bool show_sheet_editor_ = true;
// Card visibility - ALL FALSE by default to prevent crash on ROM load
// Cards only shown when user explicitly opens them via View menu or shortcuts
bool show_sheet_editor_ = false;
bool show_sheet_browser_ = false;
bool show_player_animations_ = false;
bool show_prototype_viewer_ = false;

View File

@@ -29,7 +29,62 @@ namespace editor {
constexpr uint32_t kRedPen = 0xFF0000FF;
void ScreenEditor::Initialize() {}
void ScreenEditor::Initialize() {
// Register cards with EditorCardManager during initialization (once)
auto& card_manager = gui::EditorCardManager::Get();
card_manager.RegisterCard({
.card_id = "screen.dungeon_maps",
.display_name = "Dungeon Maps",
.icon = ICON_MD_MAP,
.category = "Screen",
.shortcut_hint = "Alt+1",
.visibility_flag = &show_dungeon_maps_,
.priority = 10
});
card_manager.RegisterCard({
.card_id = "screen.inventory_menu",
.display_name = "Inventory Menu",
.icon = ICON_MD_INVENTORY,
.category = "Screen",
.shortcut_hint = "Alt+2",
.visibility_flag = &show_inventory_menu_,
.priority = 20
});
card_manager.RegisterCard({
.card_id = "screen.overworld_map",
.display_name = "Overworld Map",
.icon = ICON_MD_PUBLIC,
.category = "Screen",
.shortcut_hint = "Alt+3",
.visibility_flag = &show_overworld_map_,
.priority = 30
});
card_manager.RegisterCard({
.card_id = "screen.title_screen",
.display_name = "Title Screen",
.icon = ICON_MD_TITLE,
.category = "Screen",
.shortcut_hint = "Alt+4",
.visibility_flag = &show_title_screen_,
.priority = 40
});
card_manager.RegisterCard({
.card_id = "screen.naming_screen",
.display_name = "Naming Screen",
.icon = ICON_MD_EDIT,
.category = "Screen",
.shortcut_hint = "Alt+5",
.visibility_flag = &show_naming_screen_,
.priority = 50
});
printf("[ScreenEditor] Registered 5 cards with EditorCardManager\n");
}
absl::Status ScreenEditor::Load() {
gfx::ScopedTimer timer("ScreenEditor::Load");

View File

@@ -7,6 +7,7 @@
#include "app/editor/editor.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_palette.h"
#include "app/gui/editor_card_manager.h"
#include "app/gfx/tilemap.h"
#include "app/gui/canvas.h"
#include "app/rom.h"
@@ -77,8 +78,9 @@ class ScreenEditor : public Editor {
EditingMode current_mode_ = EditingMode::DRAW;
// Card visibility
bool show_dungeon_maps_ = true;
// Card visibility - ALL FALSE by default to prevent crash on ROM load
// Cards only shown when user explicitly opens them via View menu or shortcuts
bool show_dungeon_maps_ = false;
bool show_inventory_menu_ = false;
bool show_overworld_map_ = false;
bool show_title_screen_ = false;