feat(editor): enhance card-based editor functionality and streamline initialization
- Updated EditorManager to support new card-based editors, including Emulator, Hex, and Assembly editors. - Added centralized registration of editor cards with EditorCardManager, improving visibility management. - Implemented methods to retrieve editor types from categories and manage card visibility dynamically. - Enhanced initialization processes for various editors to ensure proper card registration and default visibility settings. Benefits: - Improved user experience by organizing editor cards and providing quick access to new editor functionalities. - Streamlined editor management, making it easier to switch between different editing contexts and enhancing overall workflow efficiency.
This commit is contained in:
@@ -43,48 +43,23 @@ constexpr ImGuiTableFlags kGfxEditTableFlags =
|
||||
ImGuiTableFlags_SizingFixedFit;
|
||||
|
||||
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_editor", .display_name = "Sheet Editor",
|
||||
.icon = ICON_MD_EDIT, .category = "Graphics",
|
||||
.shortcut_hint = "Ctrl+Shift+1", .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", .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", .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", .priority = 40});
|
||||
|
||||
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
|
||||
});
|
||||
// Show sheet editor by default when Graphics Editor is activated
|
||||
card_manager.ShowCard("graphics.sheet_editor");
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::Load() {
|
||||
@@ -124,56 +99,46 @@ absl::Status GraphicsEditor::Load() {
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::Update() {
|
||||
DrawToolset();
|
||||
gui::VerticalSpacing(2.0f);
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
|
||||
static gui::EditorCard sheet_editor_card("Sheet Editor", ICON_MD_EDIT);
|
||||
static gui::EditorCard sheet_browser_card("Sheet Browser", ICON_MD_VIEW_LIST);
|
||||
static gui::EditorCard player_anims_card("Player Animations", ICON_MD_PERSON);
|
||||
static gui::EditorCard prototype_card("Prototype Viewer", ICON_MD_CONSTRUCTION);
|
||||
|
||||
// Create session-aware cards (non-static for multi-session support)
|
||||
gui::EditorCard sheet_editor_card(MakeCardTitle("Sheet Editor").c_str(), ICON_MD_EDIT);
|
||||
gui::EditorCard sheet_browser_card(MakeCardTitle("Sheet Browser").c_str(), ICON_MD_VIEW_LIST);
|
||||
gui::EditorCard player_anims_card(MakeCardTitle("Player Animations").c_str(), ICON_MD_PERSON);
|
||||
gui::EditorCard prototype_card(MakeCardTitle("Prototype Viewer").c_str(), ICON_MD_CONSTRUCTION);
|
||||
sheet_editor_card.SetDefaultSize(900, 700);
|
||||
sheet_browser_card.SetDefaultSize(400, 600);
|
||||
player_anims_card.SetDefaultSize(500, 600);
|
||||
prototype_card.SetDefaultSize(600, 500);
|
||||
|
||||
if (show_sheet_editor_) {
|
||||
if (sheet_editor_card.Begin(&show_sheet_editor_)) {
|
||||
status_ = UpdateGfxEdit();
|
||||
}
|
||||
sheet_editor_card.End(); // ALWAYS call End after Begin
|
||||
// Get visibility flags from card manager and pass to Begin()
|
||||
if (sheet_editor_card.Begin(card_manager.GetVisibilityFlag("graphics.sheet_editor"))) {
|
||||
status_ = UpdateGfxEdit();
|
||||
sheet_editor_card.End();
|
||||
}
|
||||
|
||||
if (show_sheet_browser_) {
|
||||
if (sheet_browser_card.Begin(&show_sheet_browser_)) {
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(gfx::Arena::Get().gfx_sheets());
|
||||
}
|
||||
asset_browser_.Draw(gfx::Arena::Get().gfx_sheets());
|
||||
if (sheet_browser_card.Begin(card_manager.GetVisibilityFlag("graphics.sheet_browser"))) {
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(gfx::Arena::Get().gfx_sheets());
|
||||
}
|
||||
sheet_browser_card.End(); // ALWAYS call End after Begin
|
||||
asset_browser_.Draw(gfx::Arena::Get().gfx_sheets());
|
||||
sheet_browser_card.End();
|
||||
}
|
||||
|
||||
if (show_player_animations_) {
|
||||
if (player_anims_card.Begin(&show_player_animations_)) {
|
||||
status_ = UpdateLinkGfxView();
|
||||
}
|
||||
player_anims_card.End(); // ALWAYS call End after Begin
|
||||
if (player_anims_card.Begin(card_manager.GetVisibilityFlag("graphics.player_animations"))) {
|
||||
status_ = UpdateLinkGfxView();
|
||||
player_anims_card.End();
|
||||
}
|
||||
|
||||
if (show_prototype_viewer_) {
|
||||
if (prototype_card.Begin(&show_prototype_viewer_)) {
|
||||
status_ = UpdateScadView();
|
||||
}
|
||||
prototype_card.End(); // ALWAYS call End after Begin
|
||||
if (prototype_card.Begin(card_manager.GetVisibilityFlag("graphics.prototype_viewer"))) {
|
||||
status_ = UpdateScadView();
|
||||
prototype_card.End();
|
||||
}
|
||||
|
||||
CLEAR_AND_RETURN_STATUS(status_)
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void GraphicsEditor::DrawToolset() {
|
||||
// Sidebar is now drawn by EditorManager for card-based editors
|
||||
// This method kept for compatibility but sidebar handles card toggles
|
||||
}
|
||||
|
||||
|
||||
absl::Status GraphicsEditor::UpdateGfxEdit() {
|
||||
if (ImGui::BeginTable("##GfxEditTable", 3, kGfxEditTableFlags,
|
||||
ImVec2(0, 0))) {
|
||||
@@ -606,8 +571,6 @@ absl::Status GraphicsEditor::UpdateLinkGfxView() {
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::UpdateScadView() {
|
||||
DrawToolset();
|
||||
|
||||
if (open_memory_editor_) {
|
||||
ImGui::Begin("Memory Editor", &open_memory_editor_);
|
||||
RETURN_IF_ERROR(DrawMemoryEditor())
|
||||
|
||||
@@ -107,7 +107,6 @@ class GraphicsEditor : public Editor {
|
||||
absl::Status DrawTilemapImport();
|
||||
|
||||
// Other Functions
|
||||
void DrawToolset();
|
||||
absl::Status DrawPaletteControls();
|
||||
absl::Status DrawClipboardImport();
|
||||
absl::Status DrawExperimentalFeatures();
|
||||
@@ -117,12 +116,7 @@ class GraphicsEditor : public Editor {
|
||||
absl::Status DecompressSuperDonkey();
|
||||
|
||||
// Member Variables
|
||||
// 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;
|
||||
// Card visibility managed by EditorCardManager
|
||||
|
||||
ImVec4 current_color_;
|
||||
uint16_t current_sheet_ = 0;
|
||||
|
||||
@@ -30,58 +30,26 @@ namespace editor {
|
||||
constexpr uint32_t kRedPen = 0xFF0000FF;
|
||||
|
||||
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.dungeon_maps", .display_name = "Dungeon Maps",
|
||||
.icon = ICON_MD_MAP, .category = "Screen",
|
||||
.shortcut_hint = "Alt+1", .priority = 10});
|
||||
card_manager.RegisterCard({.card_id = "screen.inventory_menu", .display_name = "Inventory Menu",
|
||||
.icon = ICON_MD_INVENTORY, .category = "Screen",
|
||||
.shortcut_hint = "Alt+2", .priority = 20});
|
||||
card_manager.RegisterCard({.card_id = "screen.overworld_map", .display_name = "Overworld Map",
|
||||
.icon = ICON_MD_PUBLIC, .category = "Screen",
|
||||
.shortcut_hint = "Alt+3", .priority = 30});
|
||||
card_manager.RegisterCard({.card_id = "screen.title_screen", .display_name = "Title Screen",
|
||||
.icon = ICON_MD_TITLE, .category = "Screen",
|
||||
.shortcut_hint = "Alt+4", .priority = 40});
|
||||
card_manager.RegisterCard({.card_id = "screen.naming_screen", .display_name = "Naming Screen",
|
||||
.icon = ICON_MD_EDIT, .category = "Screen",
|
||||
.shortcut_hint = "Alt+5", .priority = 50});
|
||||
|
||||
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
|
||||
});
|
||||
// Show title screen by default
|
||||
card_manager.ShowCard("screen.title_screen");
|
||||
}
|
||||
|
||||
absl::Status ScreenEditor::Load() {
|
||||
@@ -119,45 +87,40 @@ absl::Status ScreenEditor::Load() {
|
||||
}
|
||||
|
||||
absl::Status ScreenEditor::Update() {
|
||||
DrawToolset();
|
||||
gui::VerticalSpacing(2.0f);
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
|
||||
// Create session-aware cards (non-static for multi-session support)
|
||||
gui::EditorCard dungeon_maps_card(MakeCardTitle("Dungeon Maps").c_str(), ICON_MD_MAP);
|
||||
gui::EditorCard inventory_menu_card(MakeCardTitle("Inventory Menu").c_str(), ICON_MD_INVENTORY);
|
||||
gui::EditorCard overworld_map_card(MakeCardTitle("Overworld Map").c_str(), ICON_MD_PUBLIC);
|
||||
gui::EditorCard title_screen_card(MakeCardTitle("Title Screen").c_str(), ICON_MD_TITLE);
|
||||
gui::EditorCard naming_screen_card(MakeCardTitle("Naming Screen").c_str(), ICON_MD_EDIT_ATTRIBUTES);
|
||||
static gui::EditorCard dungeon_maps_card("Dungeon Maps", ICON_MD_MAP);
|
||||
static gui::EditorCard inventory_menu_card("Inventory Menu", ICON_MD_INVENTORY);
|
||||
static gui::EditorCard overworld_map_card("Overworld Map", ICON_MD_PUBLIC);
|
||||
static gui::EditorCard title_screen_card("Title Screen", ICON_MD_TITLE);
|
||||
static gui::EditorCard naming_screen_card("Naming Screen", ICON_MD_EDIT_ATTRIBUTES);
|
||||
|
||||
if (show_dungeon_maps_) {
|
||||
if (dungeon_maps_card.Begin(&show_dungeon_maps_)) {
|
||||
DrawDungeonMapsEditor();
|
||||
}
|
||||
dungeon_maps_card.End(); // ALWAYS call End after Begin
|
||||
dungeon_maps_card.SetDefaultSize(800, 600);
|
||||
inventory_menu_card.SetDefaultSize(800, 600);
|
||||
overworld_map_card.SetDefaultSize(600, 500);
|
||||
title_screen_card.SetDefaultSize(600, 500);
|
||||
naming_screen_card.SetDefaultSize(500, 400);
|
||||
|
||||
// Get visibility flags from card manager and pass to Begin()
|
||||
if (dungeon_maps_card.Begin(card_manager.GetVisibilityFlag("screen.dungeon_maps"))) {
|
||||
DrawDungeonMapsEditor();
|
||||
dungeon_maps_card.End();
|
||||
}
|
||||
if (show_inventory_menu_) {
|
||||
if (inventory_menu_card.Begin(&show_inventory_menu_)) {
|
||||
DrawInventoryMenuEditor();
|
||||
}
|
||||
inventory_menu_card.End(); // ALWAYS call End after Begin
|
||||
if (inventory_menu_card.Begin(card_manager.GetVisibilityFlag("screen.inventory_menu"))) {
|
||||
DrawInventoryMenuEditor();
|
||||
inventory_menu_card.End();
|
||||
}
|
||||
if (show_overworld_map_) {
|
||||
if (overworld_map_card.Begin(&show_overworld_map_)) {
|
||||
DrawOverworldMapEditor();
|
||||
}
|
||||
overworld_map_card.End(); // ALWAYS call End after Begin
|
||||
if (overworld_map_card.Begin(card_manager.GetVisibilityFlag("screen.overworld_map"))) {
|
||||
DrawOverworldMapEditor();
|
||||
overworld_map_card.End();
|
||||
}
|
||||
if (show_title_screen_) {
|
||||
if (title_screen_card.Begin(&show_title_screen_)) {
|
||||
DrawTitleScreenEditor();
|
||||
}
|
||||
title_screen_card.End(); // ALWAYS call End after Begin
|
||||
if (title_screen_card.Begin(card_manager.GetVisibilityFlag("screen.title_screen"))) {
|
||||
DrawTitleScreenEditor();
|
||||
title_screen_card.End();
|
||||
}
|
||||
if (show_naming_screen_) {
|
||||
if (naming_screen_card.Begin(&show_naming_screen_)) {
|
||||
DrawNamingScreenEditor();
|
||||
}
|
||||
naming_screen_card.End(); // ALWAYS call End after Begin
|
||||
if (naming_screen_card.Begin(card_manager.GetVisibilityFlag("screen.naming_screen"))) {
|
||||
DrawNamingScreenEditor();
|
||||
naming_screen_card.End();
|
||||
}
|
||||
|
||||
return status_;
|
||||
|
||||
@@ -78,14 +78,6 @@ class ScreenEditor : public Editor {
|
||||
|
||||
EditingMode current_mode_ = EditingMode::DRAW;
|
||||
|
||||
// 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;
|
||||
bool show_naming_screen_ = false;
|
||||
|
||||
bool binary_gfx_loaded_ = false;
|
||||
|
||||
uint8_t selected_room = 0;
|
||||
|
||||
Reference in New Issue
Block a user