refactor(editor): integrate EditorCardRegistry for improved card management
- Updated EditorManager and various editor components to utilize EditorCardRegistry for card registration and visibility management, enhancing dependency injection and modularity. - Refactored card registration logic across multiple editors, ensuring a consistent approach to managing editor cards. - Improved UI coordination by delegating visibility checks and card management to the new registry, streamlining the user experience. Benefits: - Simplifies card management, leading to a more organized and efficient user experience. - Enhances maintainability by clearly defining roles for card handling and editor operations, aligning with the overall architecture improvements.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "app/core/window.h"
|
||||
#include "app/editor/system/editor_card_registry.h"
|
||||
#include "util/log.h"
|
||||
|
||||
namespace yaze::core {
|
||||
@@ -361,7 +362,7 @@ void Emulator::Run(Rom* rom) {
|
||||
|
||||
void Emulator::RenderEmulatorInterface() {
|
||||
try {
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
if (!card_registry_) return; // Card registry must be injected
|
||||
|
||||
static gui::EditorCard cpu_card("CPU Debugger", ICON_MD_MEMORY);
|
||||
static gui::EditorCard ppu_card("PPU Viewer", ICON_MD_VIDEOGAME_ASSET);
|
||||
@@ -380,53 +381,53 @@ void Emulator::RenderEmulatorInterface() {
|
||||
breakpoints_card.SetDefaultSize(400, 350);
|
||||
performance_card.SetDefaultSize(350, 300);
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.cpu_debugger") && cpu_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.cpu_debugger") && cpu_card.Begin()) {
|
||||
RenderModernCpuDebugger();
|
||||
cpu_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.ppu_viewer") && ppu_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.ppu_viewer") && ppu_card.Begin()) {
|
||||
RenderNavBar();
|
||||
RenderSnesPpu();
|
||||
ppu_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.memory_viewer") && memory_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.memory_viewer") && memory_card.Begin()) {
|
||||
RenderMemoryViewer();
|
||||
memory_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.breakpoints") && breakpoints_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.breakpoints") && breakpoints_card.Begin()) {
|
||||
RenderBreakpointList();
|
||||
breakpoints_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.performance") && performance_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.performance") && performance_card.Begin()) {
|
||||
RenderPerformanceMonitor();
|
||||
performance_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.ai_agent") && ai_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.ai_agent") && ai_card.Begin()) {
|
||||
RenderAIAgentPanel();
|
||||
ai_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.save_states") && save_states_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.save_states") && save_states_card.Begin()) {
|
||||
RenderSaveStates();
|
||||
save_states_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.keyboard_config") && keyboard_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.keyboard_config") && keyboard_card.Begin()) {
|
||||
RenderKeyboardConfig();
|
||||
keyboard_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.apu_debugger") && apu_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.apu_debugger") && apu_card.Begin()) {
|
||||
RenderApuDebugger();
|
||||
apu_card.End();
|
||||
}
|
||||
|
||||
if (card_manager.IsCardVisible("emulator.audio_mixer") && audio_card.Begin()) {
|
||||
if (card_registry_->IsCardVisible("emulator.audio_mixer") && audio_card.Begin()) {
|
||||
// RenderAudioMixer();
|
||||
audio_card.End();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "app/emu/snes.h"
|
||||
#include "app/emu/audio/audio_backend.h"
|
||||
#include "app/emu/debug/breakpoint_manager.h"
|
||||
#include "app/gui/app/editor_card_manager.h"
|
||||
#include "app/emu/debug/disassembly_viewer.h"
|
||||
#include "app/emu/input/input_manager.h"
|
||||
#include "app/rom.h"
|
||||
@@ -17,6 +16,10 @@ namespace gfx {
|
||||
class IRenderer;
|
||||
} // namespace gfx
|
||||
|
||||
namespace editor {
|
||||
class EditorCardRegistry;
|
||||
} // namespace editor
|
||||
|
||||
/**
|
||||
* @namespace yaze::emu
|
||||
* @brief SNES Emulation and debugging tools.
|
||||
@@ -38,7 +41,8 @@ class Emulator {
|
||||
void Run(Rom* rom);
|
||||
void Cleanup();
|
||||
|
||||
// Card visibility managed by EditorCardManager
|
||||
// Card visibility managed by EditorCardRegistry (dependency injection)
|
||||
void set_card_registry(editor::EditorCardRegistry* registry) { card_registry_ = registry; }
|
||||
|
||||
auto snes() -> Snes& { return snes_; }
|
||||
auto running() const -> bool { return running_; }
|
||||
@@ -175,6 +179,9 @@ class Emulator {
|
||||
|
||||
// Input handling (abstracted for SDL2/SDL3/custom backends)
|
||||
input::InputManager input_manager_;
|
||||
|
||||
// Card registry for card visibility (injected)
|
||||
editor::EditorCardRegistry* card_registry_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace emu
|
||||
|
||||
Reference in New Issue
Block a user