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:
scawful
2025-10-13 15:14:01 -04:00
parent 27aba01864
commit c95e5ac7ef
8 changed files with 168 additions and 165 deletions

View File

@@ -57,15 +57,16 @@ absl::Status SpriteEditor::Update() {
custom_card.SetDefaultSize(800, 600);
// Get visibility flags from card manager and pass to Begin()
// Always call End() after Begin() - End() handles ImGui state safely
if (vanilla_card.Begin(card_manager.GetVisibilityFlag("sprite.vanilla_editor"))) {
DrawVanillaSpriteEditor();
vanilla_card.End();
}
vanilla_card.End();
if (custom_card.Begin(card_manager.GetVisibilityFlag("sprite.custom_editor"))) {
DrawCustomSprites();
custom_card.End();
}
custom_card.End();
return status_.ok() ? absl::OkStatus() : status_;
}