refactor(editor): centralize sidebar management for card-based editors
- Updated EditorManager to handle sidebar drawing for card-based editors, improving consistency across editor types. - Removed individual toolbar implementations from GraphicsEditor, ScreenEditor, and SpriteEditor, as sidebar functionality is now centralized. - Enhanced EditorCardManager to manage card visibility and selection more effectively, including improved UI feedback for empty card categories. Benefits: - Streamlined editor interface and improved user experience by consolidating sidebar management, making it easier to navigate and manage editor cards.
This commit is contained in:
@@ -91,6 +91,7 @@ std::string GetEditorName(EditorType type) {
|
||||
} // namespace
|
||||
|
||||
// Static registry of editors that use the card-based layout system
|
||||
// These editors register their cards with EditorCardManager
|
||||
bool EditorManager::IsCardBasedEditor(EditorType type) {
|
||||
switch (type) {
|
||||
case EditorType::kDungeon:
|
||||
@@ -99,8 +100,7 @@ bool EditorManager::IsCardBasedEditor(EditorType type) {
|
||||
case EditorType::kScreen:
|
||||
case EditorType::kSprite:
|
||||
case EditorType::kMessage:
|
||||
case EditorType::kMusic:
|
||||
case EditorType::kEmulator:
|
||||
case EditorType::kOverworld:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -912,8 +912,8 @@ absl::Status EditorManager::Update() {
|
||||
}
|
||||
}
|
||||
|
||||
// Draw sidebar for current category editor
|
||||
if (current_editor_) {
|
||||
// Draw sidebar for current card-based editor (only if sidebar is visible)
|
||||
if (show_card_sidebar_ && current_editor_ && IsCardBasedEditor(current_editor_->type())) {
|
||||
std::string category = GetEditorCategory(current_editor_->type());
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
card_manager.DrawSidebar(category);
|
||||
|
||||
@@ -169,23 +169,8 @@ absl::Status GraphicsEditor::Update() {
|
||||
}
|
||||
|
||||
void GraphicsEditor::DrawToolset() {
|
||||
static gui::Toolset toolbar;
|
||||
toolbar.Begin();
|
||||
|
||||
if (toolbar.AddAction(ICON_MD_EDIT, "Sheet Editor")) {
|
||||
show_sheet_editor_ = !show_sheet_editor_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_VIEW_LIST, "Sheet Browser")) {
|
||||
show_sheet_browser_ = !show_sheet_browser_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_PERSON, "Player Animations")) {
|
||||
show_player_animations_ = !show_player_animations_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_CONSTRUCTION, "Prototype Viewer")) {
|
||||
show_prototype_viewer_ = !show_prototype_viewer_;
|
||||
}
|
||||
|
||||
toolbar.End();
|
||||
// Sidebar is now drawn by EditorManager for card-based editors
|
||||
// This method kept for compatibility but sidebar handles card toggles
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -164,26 +164,8 @@ absl::Status ScreenEditor::Update() {
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawToolset() {
|
||||
static gui::Toolset toolbar;
|
||||
toolbar.Begin();
|
||||
|
||||
if (toolbar.AddAction(ICON_MD_MAP, "Dungeon Maps")) {
|
||||
show_dungeon_maps_ = !show_dungeon_maps_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_INVENTORY, "Inventory Menu")) {
|
||||
show_inventory_menu_ = !show_inventory_menu_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_PUBLIC, "Overworld Map")) {
|
||||
show_overworld_map_ = !show_overworld_map_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_TITLE, "Title Screen")) {
|
||||
show_title_screen_ = !show_title_screen_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_EDIT_ATTRIBUTES, "Naming Screen")) {
|
||||
show_naming_screen_ = !show_naming_screen_;
|
||||
}
|
||||
|
||||
toolbar.End();
|
||||
// Sidebar is now drawn by EditorManager for card-based editors
|
||||
// This method kept for compatibility but sidebar handles card toggles
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawInventoryMenuEditor() {
|
||||
|
||||
@@ -85,17 +85,8 @@ absl::Status SpriteEditor::Update() {
|
||||
}
|
||||
|
||||
void SpriteEditor::DrawToolset() {
|
||||
static gui::Toolset toolbar;
|
||||
toolbar.Begin();
|
||||
|
||||
if (toolbar.AddAction(ICON_MD_PEST_CONTROL_RODENT, "Vanilla Sprites")) {
|
||||
show_vanilla_editor_ = !show_vanilla_editor_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_ADD_MODERATOR, "Custom Sprites")) {
|
||||
show_custom_editor_ = !show_custom_editor_;
|
||||
}
|
||||
|
||||
toolbar.End();
|
||||
// Sidebar is now drawn by EditorManager for card-based editors
|
||||
// This method kept for compatibility but sidebar handles card toggles
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user