refactor(editor): streamline ImGui card management across various editors
- Refactored multiple editor classes to ensure that ImGui::End() is always called after ImGui::Begin(), enhancing state management and preventing potential rendering issues. - Updated the DungeonEditor, GraphicsEditor, ScreenEditor, MessageEditor, MusicEditor, and SpriteEditor to follow this pattern, improving code consistency and reliability. Benefits: - Improves the stability of the editor UI by ensuring proper handling of ImGui state. - Enhances code readability and maintainability by standardizing the usage of ImGui functions across different editor components.
This commit is contained in:
@@ -112,28 +112,29 @@ absl::Status GraphicsEditor::Update() {
|
||||
prototype_card.SetDefaultSize(600, 500);
|
||||
|
||||
// Get visibility flags from card manager and pass to Begin()
|
||||
// Always call End() after Begin() - End() handles ImGui state safely
|
||||
if (sheet_editor_card.Begin(card_manager.GetVisibilityFlag("graphics.sheet_editor"))) {
|
||||
status_ = UpdateGfxEdit();
|
||||
sheet_editor_card.End();
|
||||
}
|
||||
sheet_editor_card.End();
|
||||
|
||||
if (sheet_browser_card.Begin(card_manager.GetVisibilityFlag("graphics.sheet_browser"))) {
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(gfx::Arena::Get().gfx_sheets());
|
||||
}
|
||||
asset_browser_.Draw(gfx::Arena::Get().gfx_sheets());
|
||||
sheet_browser_card.End();
|
||||
}
|
||||
sheet_browser_card.End();
|
||||
|
||||
if (player_anims_card.Begin(card_manager.GetVisibilityFlag("graphics.player_animations"))) {
|
||||
status_ = UpdateLinkGfxView();
|
||||
player_anims_card.End();
|
||||
}
|
||||
player_anims_card.End();
|
||||
|
||||
if (prototype_card.Begin(card_manager.GetVisibilityFlag("graphics.prototype_viewer"))) {
|
||||
status_ = UpdateScadView();
|
||||
prototype_card.End();
|
||||
}
|
||||
prototype_card.End();
|
||||
|
||||
CLEAR_AND_RETURN_STATUS(status_)
|
||||
return absl::OkStatus();
|
||||
|
||||
@@ -109,30 +109,29 @@ absl::Status ScreenEditor::Update() {
|
||||
naming_screen_card.SetDefaultSize(500, 400);
|
||||
|
||||
// Get visibility flags from card manager and pass to Begin()
|
||||
// Always call End() after Begin() - End() handles ImGui state safely
|
||||
if (dungeon_maps_card.Begin(card_manager.GetVisibilityFlag("screen.dungeon_maps"))) {
|
||||
DrawDungeonMapsEditor();
|
||||
}
|
||||
dungeon_maps_card.End();
|
||||
|
||||
|
||||
if (inventory_menu_card.Begin(card_manager.GetVisibilityFlag("screen.inventory_menu"))) {
|
||||
DrawInventoryMenuEditor();
|
||||
|
||||
}
|
||||
inventory_menu_card.End();
|
||||
|
||||
|
||||
if (overworld_map_card.Begin(card_manager.GetVisibilityFlag("screen.overworld_map"))) {
|
||||
DrawOverworldMapEditor();
|
||||
}
|
||||
overworld_map_card.End();
|
||||
|
||||
|
||||
if (title_screen_card.Begin(card_manager.GetVisibilityFlag("screen.title_screen"))) {
|
||||
DrawTitleScreenEditor();
|
||||
|
||||
}
|
||||
title_screen_card.End();
|
||||
|
||||
|
||||
if (naming_screen_card.Begin(card_manager.GetVisibilityFlag("screen.naming_screen"))) {
|
||||
DrawNamingScreenEditor();
|
||||
DrawNamingScreenEditor();
|
||||
}
|
||||
naming_screen_card.End();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user