refactor(editor): replace SessionCardRegistry with EditorCardRegistry
- Removed the SessionCardRegistry class and its associated methods, streamlining card management within the editor. - Updated EditorManager to utilize EditorCardRegistry for card operations, enhancing session awareness and visibility control. - Refactored related components to ensure compatibility with the new card management structure. Benefits: - Simplifies card management, leading to a more organized and efficient user experience. - Improves maintainability by clearly defining roles for card handling and editor operations.
This commit is contained in:
@@ -41,7 +41,6 @@ set(
|
||||
app/editor/system/project_manager.cc
|
||||
app/editor/system/proposal_drawer.cc
|
||||
app/editor/system/rom_file_manager.cc
|
||||
app/editor/system/session_card_registry.cc
|
||||
app/editor/system/settings_editor.cc
|
||||
app/editor/system/shortcut_manager.cc
|
||||
app/editor/system/session_coordinator.cc
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "zelda3/screen/dungeon_map.h"
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
@@ -116,14 +117,14 @@ void EditorManager::HideCurrentEditorCards() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
// Using EditorCardRegistry directly
|
||||
std::string category = GetEditorCategory(current_editor_->type());
|
||||
card_manager.HideAllCardsInCategory(category);
|
||||
card_registry_.HideAllCardsInCategory(category);
|
||||
}
|
||||
|
||||
void EditorManager::ShowHexEditor() {
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
card_manager.ShowCard("memory.hex_editor");
|
||||
// Using EditorCardRegistry directly
|
||||
card_registry_.ShowCard("memory.hex_editor");
|
||||
}
|
||||
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
@@ -237,64 +238,64 @@ void EditorManager::Initialize(gfx::IRenderer* renderer,
|
||||
});
|
||||
|
||||
// Register emulator cards early (emulator Initialize might not be called)
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
card_manager.RegisterCard({.card_id = "emulator.cpu_debugger",
|
||||
// Using EditorCardRegistry directly
|
||||
card_registry_.RegisterCard({.card_id = "emulator.cpu_debugger",
|
||||
.display_name = "CPU Debugger",
|
||||
.icon = ICON_MD_BUG_REPORT,
|
||||
.category = "Emulator",
|
||||
.priority = 10});
|
||||
card_manager.RegisterCard({.card_id = "emulator.ppu_viewer",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.ppu_viewer",
|
||||
.display_name = "PPU Viewer",
|
||||
.icon = ICON_MD_VIDEOGAME_ASSET,
|
||||
.category = "Emulator",
|
||||
.priority = 20});
|
||||
card_manager.RegisterCard({.card_id = "emulator.memory_viewer",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.memory_viewer",
|
||||
.display_name = "Memory Viewer",
|
||||
.icon = ICON_MD_MEMORY,
|
||||
.category = "Emulator",
|
||||
.priority = 30});
|
||||
card_manager.RegisterCard({.card_id = "emulator.breakpoints",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.breakpoints",
|
||||
.display_name = "Breakpoints",
|
||||
.icon = ICON_MD_STOP,
|
||||
.category = "Emulator",
|
||||
.priority = 40});
|
||||
card_manager.RegisterCard({.card_id = "emulator.performance",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.performance",
|
||||
.display_name = "Performance",
|
||||
.icon = ICON_MD_SPEED,
|
||||
.category = "Emulator",
|
||||
.priority = 50});
|
||||
card_manager.RegisterCard({.card_id = "emulator.ai_agent",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.ai_agent",
|
||||
.display_name = "AI Agent",
|
||||
.icon = ICON_MD_SMART_TOY,
|
||||
.category = "Emulator",
|
||||
.priority = 60});
|
||||
card_manager.RegisterCard({.card_id = "emulator.save_states",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.save_states",
|
||||
.display_name = "Save States",
|
||||
.icon = ICON_MD_SAVE,
|
||||
.category = "Emulator",
|
||||
.priority = 70});
|
||||
card_manager.RegisterCard({.card_id = "emulator.keyboard_config",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.keyboard_config",
|
||||
.display_name = "Keyboard Config",
|
||||
.icon = ICON_MD_KEYBOARD,
|
||||
.category = "Emulator",
|
||||
.priority = 80});
|
||||
card_manager.RegisterCard({.card_id = "emulator.apu_debugger",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.apu_debugger",
|
||||
.display_name = "APU Debugger",
|
||||
.icon = ICON_MD_AUDIOTRACK,
|
||||
.category = "Emulator",
|
||||
.priority = 90});
|
||||
card_manager.RegisterCard({.card_id = "emulator.audio_mixer",
|
||||
card_registry_.RegisterCard({.card_id = "emulator.audio_mixer",
|
||||
.display_name = "Audio Mixer",
|
||||
.icon = ICON_MD_AUDIO_FILE,
|
||||
.category = "Emulator",
|
||||
.priority = 100});
|
||||
|
||||
// Show CPU debugger and PPU viewer by default for emulator
|
||||
card_manager.ShowCard("emulator.cpu_debugger");
|
||||
card_manager.ShowCard("emulator.ppu_viewer");
|
||||
card_registry_.ShowCard("emulator.cpu_debugger");
|
||||
card_registry_.ShowCard("emulator.ppu_viewer");
|
||||
|
||||
// Register memory/hex editor card
|
||||
card_manager.RegisterCard({.card_id = "memory.hex_editor",
|
||||
card_registry_.RegisterCard({.card_id = "memory.hex_editor",
|
||||
.display_name = "Hex Editor",
|
||||
.icon = ICON_MD_MEMORY,
|
||||
.category = "Memory",
|
||||
@@ -646,17 +647,17 @@ void EditorManager::Initialize(gfx::IRenderer* renderer,
|
||||
// Only register essential category-level shortcuts
|
||||
context_.shortcut_manager.RegisterShortcut(
|
||||
"Show All Dungeon Cards", {ImGuiKey_D, ImGuiMod_Ctrl, ImGuiMod_Shift},
|
||||
[]() {
|
||||
gui::EditorCardManager::Get().ShowAllCardsInCategory("Dungeon");
|
||||
[this]() {
|
||||
card_registry_.ShowAllCardsInCategory("Dungeon");
|
||||
});
|
||||
context_.shortcut_manager.RegisterShortcut(
|
||||
"Show All Graphics Cards", {ImGuiKey_G, ImGuiMod_Ctrl, ImGuiMod_Shift},
|
||||
[]() {
|
||||
gui::EditorCardManager::Get().ShowAllCardsInCategory("Graphics");
|
||||
[this]() {
|
||||
card_registry_.ShowAllCardsInCategory("Graphics");
|
||||
});
|
||||
context_.shortcut_manager.RegisterShortcut(
|
||||
"Show All Screen Cards", {ImGuiKey_S, ImGuiMod_Ctrl, ImGuiMod_Shift},
|
||||
[]() { gui::EditorCardManager::Get().ShowAllCardsInCategory("Screen"); });
|
||||
[this]() { card_registry_.ShowAllCardsInCategory("Screen"); });
|
||||
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
// Agent Editor shortcut
|
||||
@@ -810,7 +811,7 @@ absl::Status EditorManager::Update() {
|
||||
// Draw card browser (managed by UICoordinator)
|
||||
if (ui_coordinator_ && ui_coordinator_->IsCardBrowserVisible()) {
|
||||
bool show = true;
|
||||
gui::EditorCardManager::Get().DrawCardBrowser(&show);
|
||||
card_registry_.DrawCardBrowser(&show);
|
||||
if (!show) {
|
||||
ui_coordinator_->SetCardBrowserVisible(false);
|
||||
}
|
||||
@@ -990,7 +991,7 @@ absl::Status EditorManager::Update() {
|
||||
|
||||
// Draw unified sidebar LAST so it appears on top of all other windows
|
||||
if (ui_coordinator_ && ui_coordinator_->IsCardSidebarVisible() && current_editor_set_) {
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
// Using EditorCardRegistry directly
|
||||
|
||||
// Collect all active card-based editors
|
||||
std::vector<std::string> active_categories;
|
||||
@@ -1015,16 +1016,16 @@ absl::Status EditorManager::Update() {
|
||||
std::string sidebar_category;
|
||||
|
||||
// Priority 1: Use active_category from card manager (user's last interaction)
|
||||
if (!card_manager.GetActiveCategory().empty() &&
|
||||
if (!card_registry_.GetActiveCategory().empty() &&
|
||||
std::find(active_categories.begin(), active_categories.end(),
|
||||
card_manager.GetActiveCategory()) !=
|
||||
card_registry_.GetActiveCategory()) !=
|
||||
active_categories.end()) {
|
||||
sidebar_category = card_manager.GetActiveCategory();
|
||||
sidebar_category = card_registry_.GetActiveCategory();
|
||||
}
|
||||
// Priority 2: Use first active category
|
||||
else if (!active_categories.empty()) {
|
||||
sidebar_category = active_categories[0];
|
||||
card_manager.SetActiveCategory(sidebar_category);
|
||||
card_registry_.SetActiveCategory(sidebar_category);
|
||||
}
|
||||
|
||||
// Draw sidebar if we have a category
|
||||
@@ -1043,7 +1044,7 @@ absl::Status EditorManager::Update() {
|
||||
}
|
||||
};
|
||||
|
||||
card_manager.DrawSidebar(sidebar_category, active_categories,
|
||||
card_registry_.DrawSidebar(sidebar_category, active_categories,
|
||||
category_switch_callback, collapse_callback);
|
||||
}
|
||||
}
|
||||
@@ -1167,19 +1168,19 @@ void EditorManager::DrawMenuBar() {
|
||||
if (show_imgui_metrics_)
|
||||
ShowMetricsWindow(&show_imgui_metrics_);
|
||||
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
// Using EditorCardRegistry directly
|
||||
if (current_editor_set_) {
|
||||
// Pass the actual visibility flag pointer so the X button works
|
||||
bool* hex_visibility = card_manager.GetVisibilityFlag("memory.hex_editor");
|
||||
bool* hex_visibility = card_registry_.GetVisibilityFlag("memory.hex_editor");
|
||||
if (hex_visibility && *hex_visibility) {
|
||||
current_editor_set_->memory_editor_.Update(*hex_visibility);
|
||||
}
|
||||
|
||||
bool* assembly_visibility =
|
||||
card_manager.GetVisibilityFlag("assembly.editor");
|
||||
card_registry_.GetVisibilityFlag("assembly.editor");
|
||||
if (assembly_visibility && *assembly_visibility) {
|
||||
current_editor_set_->assembly_editor_.Update(
|
||||
*card_manager.GetVisibilityFlag("assembly.editor"));
|
||||
*card_registry_.GetVisibilityFlag("assembly.editor"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2367,65 +2368,6 @@ std::string EditorManager::GenerateUniqueEditorTitle(
|
||||
|
||||
// Window management methods removed - now inline in header for reduced bloat
|
||||
|
||||
void EditorManager::LoadDeveloperLayout() {
|
||||
if (!current_editor_set_)
|
||||
return;
|
||||
|
||||
// Developer layout: Code editor, assembly editor, test dashboard
|
||||
current_editor_set_->assembly_editor_.set_active(true);
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
show_test_dashboard_ = true;
|
||||
#endif
|
||||
show_imgui_metrics_ = true;
|
||||
|
||||
// Hide non-dev windows
|
||||
current_editor_set_->graphics_editor_.set_active(false);
|
||||
current_editor_set_->music_editor_.set_active(false);
|
||||
current_editor_set_->sprite_editor_.set_active(false);
|
||||
|
||||
toast_manager_.Show("Developer layout loaded", editor::ToastType::kSuccess);
|
||||
}
|
||||
|
||||
void EditorManager::LoadDesignerLayout() {
|
||||
if (!current_editor_set_)
|
||||
return;
|
||||
|
||||
// Designer layout: Graphics, palette, sprite editors
|
||||
current_editor_set_->graphics_editor_.set_active(true);
|
||||
current_editor_set_->palette_editor_.set_active(true);
|
||||
current_editor_set_->sprite_editor_.set_active(true);
|
||||
current_editor_set_->overworld_editor_.set_active(true);
|
||||
|
||||
// Hide non-design windows
|
||||
current_editor_set_->assembly_editor_.set_active(false);
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
show_test_dashboard_ = false;
|
||||
#endif
|
||||
show_imgui_metrics_ = false;
|
||||
|
||||
toast_manager_.Show("Designer layout loaded", editor::ToastType::kSuccess);
|
||||
}
|
||||
|
||||
void EditorManager::LoadModderLayout() {
|
||||
if (!current_editor_set_)
|
||||
return;
|
||||
|
||||
// Modder layout: All editors except technical ones
|
||||
current_editor_set_->overworld_editor_.set_active(true);
|
||||
current_editor_set_->dungeon_editor_.set_active(true);
|
||||
current_editor_set_->graphics_editor_.set_active(true);
|
||||
current_editor_set_->palette_editor_.set_active(true);
|
||||
current_editor_set_->sprite_editor_.set_active(true);
|
||||
current_editor_set_->message_editor_.set_active(true);
|
||||
current_editor_set_->music_editor_.set_active(true);
|
||||
|
||||
// Hide technical windows
|
||||
current_editor_set_->assembly_editor_.set_active(false);
|
||||
show_imgui_metrics_ = false;
|
||||
|
||||
toast_manager_.Show("Modder layout loaded", editor::ToastType::kSuccess);
|
||||
}
|
||||
|
||||
void EditorManager::DrawWelcomeScreen() {
|
||||
// Delegate to UICoordinator for clean separation of concerns
|
||||
if (ui_coordinator_) {
|
||||
@@ -2491,17 +2433,17 @@ void EditorManager::SwitchToEditor(EditorType editor_type) {
|
||||
editor->toggle_active();
|
||||
|
||||
if (IsCardBasedEditor(editor_type)) {
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
// Using EditorCardRegistry directly
|
||||
|
||||
if (*editor->active()) {
|
||||
// Editor activated - set its category
|
||||
card_manager.SetActiveCategory(GetEditorCategory(editor_type));
|
||||
card_registry_.SetActiveCategory(GetEditorCategory(editor_type));
|
||||
} else {
|
||||
// Editor deactivated - switch to another active card-based editor
|
||||
for (auto* other : current_editor_set_->active_editors_) {
|
||||
if (*other->active() && IsCardBasedEditor(other->type()) &&
|
||||
other != editor) {
|
||||
card_manager.SetActiveCategory(GetEditorCategory(other->type()));
|
||||
card_registry_.SetActiveCategory(GetEditorCategory(other->type()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2517,7 +2459,7 @@ void EditorManager::SwitchToEditor(EditorType editor_type) {
|
||||
} else if (editor_type == EditorType::kEmulator) {
|
||||
show_emulator_ = !show_emulator_;
|
||||
if (show_emulator_) {
|
||||
gui::EditorCardManager::Get().SetActiveCategory("Emulator");
|
||||
card_registry_.SetActiveCategory("Emulator");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "app/editor/system/menu_orchestrator.h"
|
||||
#include "app/editor/system/project_manager.h"
|
||||
#include "app/editor/system/rom_file_manager.h"
|
||||
#include "app/editor/system/session_card_registry.h"
|
||||
#include "app/editor/system/editor_card_registry.h"
|
||||
#include "app/editor/system/session_coordinator.h"
|
||||
#include "app/editor/system/window_delegate.h"
|
||||
#include "app/editor/ui/editor_selection_dialog.h"
|
||||
@@ -215,10 +215,10 @@ class EditorManager {
|
||||
void ShowAllWindows() { if (ui_coordinator_) ui_coordinator_->ShowAllWindows(); }
|
||||
void HideAllWindows() { if (ui_coordinator_) ui_coordinator_->HideAllWindows(); }
|
||||
|
||||
// Layout presets
|
||||
void LoadDeveloperLayout();
|
||||
void LoadDesignerLayout();
|
||||
void LoadModderLayout();
|
||||
// Layout presets (inline delegation)
|
||||
void LoadDeveloperLayout() { window_delegate_.LoadDeveloperLayout(); }
|
||||
void LoadDesignerLayout() { window_delegate_.LoadDesignerLayout(); }
|
||||
void LoadModderLayout() { window_delegate_.LoadModderLayout(); }
|
||||
|
||||
// Helper methods
|
||||
std::string GenerateUniqueEditorTitle(EditorType type, size_t session_index) const;
|
||||
@@ -370,12 +370,12 @@ class EditorManager {
|
||||
UserSettings user_settings_;
|
||||
WorkspaceManager workspace_manager_{&toast_manager_};
|
||||
|
||||
// New delegated components
|
||||
// New delegated components (dependency injection architecture)
|
||||
EditorCardRegistry card_registry_; // Card management with session awareness
|
||||
EditorRegistry editor_registry_;
|
||||
std::unique_ptr<MenuOrchestrator> menu_orchestrator_;
|
||||
ProjectManager project_manager_;
|
||||
RomFileManager rom_file_manager_;
|
||||
SessionCardRegistry card_registry_;
|
||||
std::unique_ptr<UICoordinator> ui_coordinator_;
|
||||
WindowDelegate window_delegate_;
|
||||
std::unique_ptr<SessionCoordinator> session_coordinator_;
|
||||
|
||||
@@ -361,6 +361,79 @@ class EditorCardRegistry {
|
||||
* @return true if session_count > 1
|
||||
*/
|
||||
bool ShouldPrefixCards() const { return session_count_ > 1; }
|
||||
|
||||
// ============================================================================
|
||||
// Convenience Methods (for EditorManager direct usage without session_id)
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* @brief Register card for active session (convenience)
|
||||
*/
|
||||
void RegisterCard(const CardInfo& base_info) {
|
||||
RegisterCard(active_session_, base_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Show card in active session (convenience)
|
||||
*/
|
||||
bool ShowCard(const std::string& base_card_id) {
|
||||
return ShowCard(active_session_, base_card_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hide card in active session (convenience)
|
||||
*/
|
||||
bool HideCard(const std::string& base_card_id) {
|
||||
return HideCard(active_session_, base_card_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Hide all cards in category for active session (convenience)
|
||||
*/
|
||||
void HideAllCardsInCategory(const std::string& category) {
|
||||
HideAllCardsInCategory(active_session_, category);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw card browser for active session (convenience)
|
||||
*/
|
||||
void DrawCardBrowser(bool* p_open) {
|
||||
DrawCardBrowser(active_session_, p_open);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get active category (for sidebar)
|
||||
*/
|
||||
std::string GetActiveCategory() const { return active_category_; }
|
||||
|
||||
/**
|
||||
* @brief Set active category (for sidebar)
|
||||
*/
|
||||
void SetActiveCategory(const std::string& category) { active_category_ = category; }
|
||||
|
||||
/**
|
||||
* @brief Show all cards in category for active session (convenience)
|
||||
*/
|
||||
void ShowAllCardsInCategory(const std::string& category) {
|
||||
ShowAllCardsInCategory(active_session_, category);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get visibility flag for active session (convenience)
|
||||
*/
|
||||
bool* GetVisibilityFlag(const std::string& base_card_id) {
|
||||
return GetVisibilityFlag(active_session_, base_card_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draw sidebar for active session (convenience)
|
||||
*/
|
||||
void DrawSidebar(const std::string& category,
|
||||
const std::vector<std::string>& active_categories = {},
|
||||
std::function<void(const std::string&)> on_category_switch = nullptr,
|
||||
std::function<void()> on_collapse = nullptr) {
|
||||
DrawSidebar(active_session_, category, active_categories, on_category_switch, on_collapse);
|
||||
}
|
||||
|
||||
private:
|
||||
// Core card storage (prefixed IDs → CardInfo)
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
#include "session_card_registry.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
void SessionCardRegistry::RegisterSession(size_t session_id) {
|
||||
if (session_cards_.find(session_id) == session_cards_.end()) {
|
||||
session_cards_[session_id] = std::vector<std::string>();
|
||||
session_card_mapping_[session_id] = std::unordered_map<std::string, std::string>();
|
||||
UpdateSessionCount();
|
||||
printf("[SessionCardRegistry] Registered session %zu (total: %zu)\n",
|
||||
session_id, session_count_);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::UnregisterSession(size_t session_id) {
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
UnregisterSessionCards(session_id);
|
||||
session_cards_.erase(it);
|
||||
session_card_mapping_.erase(session_id);
|
||||
UpdateSessionCount();
|
||||
|
||||
// Reset active session if it was the one being removed
|
||||
if (active_session_ == session_id) {
|
||||
active_session_ = 0;
|
||||
if (!session_cards_.empty()) {
|
||||
active_session_ = session_cards_.begin()->first;
|
||||
}
|
||||
}
|
||||
|
||||
printf("[SessionCardRegistry] Unregistered session %zu (total: %zu)\n",
|
||||
session_id, session_count_);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::SetActiveSession(size_t session_id) {
|
||||
if (session_cards_.find(session_id) != session_cards_.end()) {
|
||||
active_session_ = session_id;
|
||||
printf("[SessionCardRegistry] Set active session to %zu\n", session_id);
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::RegisterCard(size_t session_id, const gui::CardInfo& base_info) {
|
||||
RegisterSession(session_id); // Ensure session exists
|
||||
|
||||
std::string prefixed_id = MakeCardId(session_id, base_info.card_id);
|
||||
|
||||
// Create new CardInfo with prefixed ID
|
||||
gui::CardInfo prefixed_info = base_info;
|
||||
prefixed_info.card_id = prefixed_id;
|
||||
|
||||
// Register with the global card manager
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
card_mgr.RegisterCard(prefixed_info);
|
||||
|
||||
// Track in our session mapping
|
||||
session_cards_[session_id].push_back(prefixed_id);
|
||||
session_card_mapping_[session_id][base_info.card_id] = prefixed_id;
|
||||
|
||||
printf("[SessionCardRegistry] Registered card %s -> %s for session %zu\n",
|
||||
base_info.card_id.c_str(), prefixed_id.c_str(), session_id);
|
||||
}
|
||||
|
||||
void SessionCardRegistry::RegisterCard(size_t session_id,
|
||||
const std::string& card_id,
|
||||
const std::string& display_name,
|
||||
const std::string& icon,
|
||||
const std::string& category,
|
||||
const std::string& shortcut_hint,
|
||||
int priority,
|
||||
std::function<void()> on_show,
|
||||
std::function<void()> on_hide,
|
||||
bool visible_by_default) {
|
||||
gui::CardInfo info;
|
||||
info.card_id = card_id;
|
||||
info.display_name = display_name;
|
||||
info.icon = icon;
|
||||
info.category = category;
|
||||
info.shortcut_hint = shortcut_hint;
|
||||
info.priority = priority;
|
||||
info.on_show = on_show;
|
||||
info.on_hide = on_hide;
|
||||
|
||||
RegisterCard(session_id, info);
|
||||
}
|
||||
|
||||
bool SessionCardRegistry::ShowCard(size_t session_id, const std::string& base_card_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
std::string prefixed_id = GetPrefixedCardId(session_id, base_card_id);
|
||||
if (prefixed_id.empty()) {
|
||||
return false;
|
||||
}
|
||||
return card_mgr.ShowCard(prefixed_id);
|
||||
}
|
||||
|
||||
bool SessionCardRegistry::HideCard(size_t session_id, const std::string& base_card_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
std::string prefixed_id = GetPrefixedCardId(session_id, base_card_id);
|
||||
if (prefixed_id.empty()) {
|
||||
return false;
|
||||
}
|
||||
return card_mgr.HideCard(prefixed_id);
|
||||
}
|
||||
|
||||
bool SessionCardRegistry::ToggleCard(size_t session_id, const std::string& base_card_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
std::string prefixed_id = GetPrefixedCardId(session_id, base_card_id);
|
||||
if (prefixed_id.empty()) {
|
||||
return false;
|
||||
}
|
||||
return card_mgr.ToggleCard(prefixed_id);
|
||||
}
|
||||
|
||||
bool SessionCardRegistry::IsCardVisible(size_t session_id, const std::string& base_card_id) const {
|
||||
const auto& card_mgr = gui::EditorCardManager::Get();
|
||||
std::string prefixed_id = GetPrefixedCardId(session_id, base_card_id);
|
||||
if (prefixed_id.empty()) {
|
||||
return false;
|
||||
}
|
||||
return card_mgr.IsCardVisible(prefixed_id);
|
||||
}
|
||||
|
||||
void SessionCardRegistry::ShowAllCardsInSession(size_t session_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
card_mgr.ShowCard(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::HideAllCardsInSession(size_t session_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
card_mgr.HideCard(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::ShowAllCardsInCategory(size_t session_id, const std::string& category) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
const auto* info = card_mgr.GetCardInfo(card_id);
|
||||
if (info && info->category == category) {
|
||||
card_mgr.ShowCard(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionCardRegistry::HideAllCardsInCategory(size_t session_id, const std::string& category) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
const auto* info = card_mgr.GetCardInfo(card_id);
|
||||
if (info && info->category == category) {
|
||||
card_mgr.HideCard(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string SessionCardRegistry::MakeCardId(size_t session_id, const std::string& base_id) const {
|
||||
if (ShouldPrefixCards()) {
|
||||
return absl::StrFormat("s%zu.%s", session_id, base_id);
|
||||
}
|
||||
return base_id;
|
||||
}
|
||||
|
||||
std::vector<std::string> SessionCardRegistry::GetCardsInSession(size_t session_id) const {
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> SessionCardRegistry::GetCardsInCategory(size_t session_id, const std::string& category) const {
|
||||
std::vector<std::string> result;
|
||||
const auto& card_mgr = gui::EditorCardManager::Get();
|
||||
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
const auto* info = card_mgr.GetCardInfo(card_id);
|
||||
if (info && info->category == category) {
|
||||
result.push_back(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> SessionCardRegistry::GetAllCategories(size_t session_id) const {
|
||||
std::vector<std::string> categories;
|
||||
const auto& card_mgr = gui::EditorCardManager::Get();
|
||||
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
const auto* info = card_mgr.GetCardInfo(card_id);
|
||||
if (info) {
|
||||
if (std::find(categories.begin(), categories.end(), info->category) == categories.end()) {
|
||||
categories.push_back(info->category);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
|
||||
void SessionCardRegistry::UpdateSessionCount() {
|
||||
session_count_ = session_cards_.size();
|
||||
}
|
||||
|
||||
std::string SessionCardRegistry::GetPrefixedCardId(size_t session_id, const std::string& base_id) const {
|
||||
auto session_it = session_card_mapping_.find(session_id);
|
||||
if (session_it != session_card_mapping_.end()) {
|
||||
auto card_it = session_it->second.find(base_id);
|
||||
if (card_it != session_it->second.end()) {
|
||||
return card_it->second;
|
||||
}
|
||||
}
|
||||
return ""; // Card not found
|
||||
}
|
||||
|
||||
void SessionCardRegistry::UnregisterSessionCards(size_t session_id) {
|
||||
auto& card_mgr = gui::EditorCardManager::Get();
|
||||
auto it = session_cards_.find(session_id);
|
||||
if (it != session_cards_.end()) {
|
||||
for (const auto& card_id : it->second) {
|
||||
card_mgr.UnregisterCard(card_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
@@ -1,96 +0,0 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_SESSION_CARD_REGISTRY_H_
|
||||
#define YAZE_APP_EDITOR_SYSTEM_SESSION_CARD_REGISTRY_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/gui/app/editor_card_manager.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
/**
|
||||
* @class SessionCardRegistry
|
||||
* @brief Manages session-scoped card registration with automatic prefixing
|
||||
*
|
||||
* This class wraps EditorCardManager to provide session awareness:
|
||||
* - Automatically prefixes card IDs when multiple sessions exist
|
||||
* - Manages per-session card lifecycle (create/destroy/switch)
|
||||
* - Maintains session-specific card visibility state
|
||||
* - Provides clean API for session-aware card operations
|
||||
*
|
||||
* Card ID Format:
|
||||
* - Single session: "dungeon.room_selector"
|
||||
* - Multiple sessions: "s0.dungeon.room_selector", "s1.dungeon.room_selector"
|
||||
*/
|
||||
class SessionCardRegistry {
|
||||
public:
|
||||
SessionCardRegistry() = default;
|
||||
~SessionCardRegistry() = default;
|
||||
|
||||
// Session lifecycle management
|
||||
void RegisterSession(size_t session_id);
|
||||
void UnregisterSession(size_t session_id);
|
||||
void SetActiveSession(size_t session_id);
|
||||
|
||||
// Card registration with session awareness
|
||||
void RegisterCard(size_t session_id, const gui::CardInfo& base_info);
|
||||
void RegisterCard(size_t session_id,
|
||||
const std::string& card_id,
|
||||
const std::string& display_name,
|
||||
const std::string& icon,
|
||||
const std::string& category,
|
||||
const std::string& shortcut_hint = "",
|
||||
int priority = 50,
|
||||
std::function<void()> on_show = nullptr,
|
||||
std::function<void()> on_hide = nullptr,
|
||||
bool visible_by_default = false);
|
||||
|
||||
// Card control with session awareness
|
||||
bool ShowCard(size_t session_id, const std::string& base_card_id);
|
||||
bool HideCard(size_t session_id, const std::string& base_card_id);
|
||||
bool ToggleCard(size_t session_id, const std::string& base_card_id);
|
||||
bool IsCardVisible(size_t session_id, const std::string& base_card_id) const;
|
||||
|
||||
// Batch operations
|
||||
void ShowAllCardsInSession(size_t session_id);
|
||||
void HideAllCardsInSession(size_t session_id);
|
||||
void ShowAllCardsInCategory(size_t session_id, const std::string& category);
|
||||
void HideAllCardsInCategory(size_t session_id, const std::string& category);
|
||||
|
||||
// Utility methods
|
||||
std::string MakeCardId(size_t session_id, const std::string& base_id) const;
|
||||
bool ShouldPrefixCards() const { return session_count_ > 1; }
|
||||
size_t GetSessionCount() const { return session_count_; }
|
||||
size_t GetActiveSession() const { return active_session_; }
|
||||
|
||||
// Query methods
|
||||
std::vector<std::string> GetCardsInSession(size_t session_id) const;
|
||||
std::vector<std::string> GetCardsInCategory(size_t session_id, const std::string& category) const;
|
||||
std::vector<std::string> GetAllCategories(size_t session_id) const;
|
||||
|
||||
// Direct access to underlying card manager (for UI components)
|
||||
gui::EditorCardManager& GetCardManager() { return gui::EditorCardManager::Get(); }
|
||||
const gui::EditorCardManager& GetCardManager() const { return gui::EditorCardManager::Get(); }
|
||||
|
||||
private:
|
||||
size_t session_count_ = 0;
|
||||
size_t active_session_ = 0;
|
||||
|
||||
// Maps session_id -> vector of card IDs registered for that session
|
||||
std::unordered_map<size_t, std::vector<std::string>> session_cards_;
|
||||
|
||||
// Maps session_id -> map of base_card_id -> prefixed_card_id
|
||||
std::unordered_map<size_t, std::unordered_map<std::string, std::string>> session_card_mapping_;
|
||||
|
||||
// Helper methods
|
||||
void UpdateSessionCount();
|
||||
std::string GetPrefixedCardId(size_t session_id, const std::string& base_id) const;
|
||||
void UnregisterSessionCards(size_t session_id);
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_SESSION_CARD_REGISTRY_H_
|
||||
@@ -13,8 +13,8 @@ namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
SessionCoordinator::SessionCoordinator(void* sessions_ptr,
|
||||
SessionCardRegistry* card_registry,
|
||||
ToastManager* toast_manager)
|
||||
EditorCardRegistry* card_registry,
|
||||
ToastManager* toast_manager)
|
||||
: sessions_ptr_(sessions_ptr),
|
||||
card_registry_(card_registry),
|
||||
toast_manager_(toast_manager) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/system/session_card_registry.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/rom.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -15,6 +14,7 @@
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
class EditorManager;
|
||||
class EditorCardRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ToastManager;
|
||||
class SessionCoordinator {
|
||||
public:
|
||||
explicit SessionCoordinator(void* sessions_ptr,
|
||||
SessionCardRegistry* card_registry,
|
||||
EditorCardRegistry* card_registry,
|
||||
ToastManager* toast_manager);
|
||||
~SessionCoordinator() = default;
|
||||
|
||||
@@ -120,7 +120,7 @@ class SessionCoordinator {
|
||||
private:
|
||||
// Core dependencies
|
||||
void* sessions_ptr_; // std::deque<EditorManager::RomSession>*
|
||||
SessionCardRegistry* card_registry_;
|
||||
EditorCardRegistry* card_registry_;
|
||||
ToastManager* toast_manager_;
|
||||
|
||||
// Session state
|
||||
|
||||
@@ -1,492 +0,0 @@
|
||||
#include "ui_coordinator.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/editor_manager.h"
|
||||
#include "app/editor/system/editor_registry.h"
|
||||
#include "app/editor/system/popup_manager.h"
|
||||
#include "app/editor/system/project_manager.h"
|
||||
#include "app/editor/system/rom_file_manager.h"
|
||||
#include "app/editor/system/session_coordinator.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/editor/system/window_delegate.h"
|
||||
#include "app/editor/ui/welcome_screen.h"
|
||||
#include "app/gui/core/icons.h"
|
||||
#include "app/gui/core/style.h"
|
||||
#include "app/gui/core/theme_manager.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
UICoordinator::UICoordinator(
|
||||
EditorManager* editor_manager,
|
||||
RomFileManager& rom_manager,
|
||||
ProjectManager& project_manager,
|
||||
EditorRegistry& editor_registry,
|
||||
SessionCoordinator& session_coordinator,
|
||||
WindowDelegate& window_delegate,
|
||||
ToastManager& toast_manager,
|
||||
PopupManager& popup_manager)
|
||||
: editor_manager_(editor_manager),
|
||||
rom_manager_(rom_manager),
|
||||
project_manager_(project_manager),
|
||||
editor_registry_(editor_registry),
|
||||
session_coordinator_(session_coordinator),
|
||||
window_delegate_(window_delegate),
|
||||
toast_manager_(toast_manager),
|
||||
popup_manager_(popup_manager) {
|
||||
|
||||
// Initialize welcome screen
|
||||
welcome_screen_ = std::make_unique<WelcomeScreen>();
|
||||
}
|
||||
|
||||
void UICoordinator::DrawAllUI() {
|
||||
// Apply Material Design styling
|
||||
ApplyMaterialDesignStyling();
|
||||
|
||||
// Draw all UI components in order
|
||||
DrawMenuBarExtras();
|
||||
DrawContextSensitiveCardControl();
|
||||
DrawSessionSwitcher();
|
||||
DrawSessionManager();
|
||||
DrawSessionRenameDialog();
|
||||
DrawLayoutPresets();
|
||||
DrawWelcomeScreen();
|
||||
DrawProjectHelp();
|
||||
DrawWindowManagementUI();
|
||||
|
||||
// Draw all popups
|
||||
DrawAllPopups();
|
||||
}
|
||||
|
||||
void UICoordinator::DrawMenuBarExtras() {
|
||||
auto* current_rom = rom_manager_.GetCurrentRom();
|
||||
std::string version_text = absl::StrFormat("v%s", editor_manager_->version().c_str());
|
||||
float version_width = ImGui::CalcTextSize(version_text.c_str()).x;
|
||||
float session_rom_area_width = 280.0f;
|
||||
|
||||
ImGui::SameLine(ImGui::GetWindowWidth() - version_width - 10 - session_rom_area_width);
|
||||
|
||||
// Session indicator with Material Design styling
|
||||
if (session_coordinator_.HasMultipleSessions()) {
|
||||
std::string session_button_text = absl::StrFormat("%s%zu", ICON_MD_TAB,
|
||||
session_coordinator_.GetActiveSessionCount());
|
||||
|
||||
// Material Design button styling
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, gui::GetPrimaryVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, gui::GetPrimaryHoverVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, gui::GetPrimaryActiveVec4());
|
||||
|
||||
if (ImGui::SmallButton(session_button_text.c_str())) {
|
||||
session_coordinator_.ToggleSessionSwitcher();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Sessions: %zu active\nClick to switch",
|
||||
session_coordinator_.GetActiveSessionCount());
|
||||
}
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
// ROM information display with Material Design card styling
|
||||
if (current_rom && current_rom->is_loaded()) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, gui::GetTextSecondaryVec4());
|
||||
ImGui::Text("%s %s", ICON_MD_INSERT_DRIVE_FILE, current_rom->title().c_str());
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
// Version info with subtle styling
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, gui::GetTextDisabledVec4());
|
||||
ImGui::Text("%s", version_text.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void UICoordinator::DrawContextSensitiveCardControl() {
|
||||
// Get current editor and determine category
|
||||
auto* current_editor = editor_manager_->GetCurrentEditorSet();
|
||||
if (!current_editor) return;
|
||||
|
||||
// Find active card-based editor
|
||||
Editor* active_editor = nullptr;
|
||||
for (auto* editor : current_editor->active_editors_) {
|
||||
if (*editor->active() && editor_registry_.IsCardBasedEditor(editor->type())) {
|
||||
active_editor = editor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!active_editor) return;
|
||||
|
||||
std::string category = editor_registry_.GetEditorCategory(active_editor->type());
|
||||
|
||||
// Draw compact card control with session awareness
|
||||
auto& card_manager = gui::EditorCardManager::Get();
|
||||
if (session_coordinator_.HasMultipleSessions()) {
|
||||
std::string session_prefix = absl::StrFormat("s%zu", session_coordinator_.GetActiveSessionIndex());
|
||||
card_manager.DrawCompactCardControlWithSession(category, session_prefix);
|
||||
} else {
|
||||
card_manager.DrawCompactCardControl(category);
|
||||
}
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionSwitcher() {
|
||||
if (!show_session_switcher_) return;
|
||||
|
||||
// Material Design dialog styling
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 300), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(16, 16));
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, gui::GetSurfaceVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, gui::GetOutlineVec4());
|
||||
|
||||
if (ImGui::Begin("Session Switcher", &show_session_switcher_,
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse)) {
|
||||
|
||||
// Header with Material Design typography
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, gui::GetOnSurfaceVec4());
|
||||
ImGui::Text("%s Session Switcher", ICON_MD_TAB);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::Separator();
|
||||
|
||||
// Session list with Material Design list styling
|
||||
for (size_t i = 0; i < session_coordinator_.GetActiveSessionCount(); ++i) {
|
||||
std::string session_name = session_coordinator_.GetSessionDisplayName(i);
|
||||
bool is_active = (i == session_coordinator_.GetActiveSessionIndex());
|
||||
|
||||
// Active session highlighting
|
||||
if (is_active) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, gui::GetPrimaryVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, gui::GetPrimaryHoverVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, gui::GetOnPrimaryVec4());
|
||||
}
|
||||
|
||||
std::string button_text = absl::StrFormat("%s %s",
|
||||
is_active ? ICON_MD_RADIO_BUTTON_CHECKED : ICON_MD_RADIO_BUTTON_UNCHECKED,
|
||||
session_name.c_str());
|
||||
|
||||
if (ImGui::Button(button_text.c_str(), ImVec2(-1, 0))) {
|
||||
session_coordinator_.SwitchToSession(i);
|
||||
show_session_switcher_ = false;
|
||||
}
|
||||
|
||||
if (is_active) {
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Action buttons with Material Design styling
|
||||
if (ImGui::Button(absl::StrFormat("%s New Session", ICON_MD_ADD).c_str(), ImVec2(-1, 0))) {
|
||||
session_coordinator_.CreateNewSession();
|
||||
show_session_switcher_ = false;
|
||||
}
|
||||
|
||||
if (ImGui::Button(absl::StrFormat("%s Close", ICON_MD_CLOSE).c_str(), ImVec2(-1, 0))) {
|
||||
show_session_switcher_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionManager() {
|
||||
// TODO: Implement session manager dialog
|
||||
// This would be a more comprehensive session management interface
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionRenameDialog() {
|
||||
// TODO: Implement session rename dialog
|
||||
// This would allow users to rename sessions for better organization
|
||||
}
|
||||
|
||||
void UICoordinator::DrawLayoutPresets() {
|
||||
// TODO: Implement layout presets UI
|
||||
// This would show available layout presets (Developer, Designer, Modder)
|
||||
}
|
||||
|
||||
void UICoordinator::DrawWelcomeScreen() {
|
||||
if (!show_welcome_screen_) return;
|
||||
|
||||
if (welcome_screen_) {
|
||||
welcome_screen_->Show(&show_welcome_screen_);
|
||||
}
|
||||
}
|
||||
|
||||
void UICoordinator::DrawProjectHelp() {
|
||||
// TODO: Implement project help UI
|
||||
// This would show project-specific help and documentation
|
||||
}
|
||||
|
||||
void UICoordinator::DrawWindowManagementUI() {
|
||||
// TODO: Implement window management UI
|
||||
// This would provide controls for window visibility, docking, etc.
|
||||
}
|
||||
|
||||
void UICoordinator::DrawAllPopups() {
|
||||
// Draw all registered popups
|
||||
popup_manager_.DrawPopups();
|
||||
}
|
||||
|
||||
void UICoordinator::ShowPopup(const std::string& popup_name) {
|
||||
popup_manager_.Show(popup_name.c_str());
|
||||
}
|
||||
|
||||
void UICoordinator::HidePopup(const std::string& popup_name) {
|
||||
popup_manager_.Hide(popup_name.c_str());
|
||||
}
|
||||
|
||||
void UICoordinator::ShowEditorSelection() {
|
||||
show_editor_selection_ = true;
|
||||
}
|
||||
|
||||
void UICoordinator::ShowDisplaySettings() {
|
||||
show_display_settings_ = true;
|
||||
ShowPopup("Display Settings");
|
||||
}
|
||||
|
||||
void UICoordinator::ShowSessionSwitcher() {
|
||||
show_session_switcher_ = true;
|
||||
}
|
||||
|
||||
void UICoordinator::HideCurrentEditorCards() {
|
||||
// TODO: Implement card hiding logic
|
||||
// This would hide cards for the current editor
|
||||
}
|
||||
|
||||
void UICoordinator::ShowAllWindows() {
|
||||
window_delegate_.ShowAllWindows();
|
||||
}
|
||||
|
||||
void UICoordinator::HideAllWindows() {
|
||||
window_delegate_.HideAllWindows();
|
||||
}
|
||||
|
||||
void UICoordinator::ApplyMaterialDesignStyling() {
|
||||
// Apply Material Design 3 color scheme
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
// Set Material Design colors
|
||||
style.Colors[ImGuiCol_WindowBg] = gui::GetSurfaceVec4();
|
||||
style.Colors[ImGuiCol_ChildBg] = gui::GetSurfaceVariantVec4();
|
||||
style.Colors[ImGuiCol_PopupBg] = gui::GetSurfaceContainerVec4();
|
||||
style.Colors[ImGuiCol_Border] = gui::GetOutlineVec4();
|
||||
style.Colors[ImGuiCol_BorderShadow] = gui::GetShadowVec4();
|
||||
|
||||
// Text colors
|
||||
style.Colors[ImGuiCol_Text] = gui::GetOnSurfaceVec4();
|
||||
style.Colors[ImGuiCol_TextDisabled] = gui::GetOnSurfaceVariantVec4();
|
||||
|
||||
// Button colors
|
||||
style.Colors[ImGuiCol_Button] = gui::GetSurfaceContainerHighestVec4();
|
||||
style.Colors[ImGuiCol_ButtonHovered] = gui::GetSurfaceContainerHighVec4();
|
||||
style.Colors[ImGuiCol_ButtonActive] = gui::GetPrimaryVec4();
|
||||
|
||||
// Header colors
|
||||
style.Colors[ImGuiCol_Header] = gui::GetSurfaceContainerHighVec4();
|
||||
style.Colors[ImGuiCol_HeaderHovered] = gui::GetSurfaceContainerHighestVec4();
|
||||
style.Colors[ImGuiCol_HeaderActive] = gui::GetPrimaryVec4();
|
||||
|
||||
// Frame colors
|
||||
style.Colors[ImGuiCol_FrameBg] = gui::GetSurfaceContainerHighestVec4();
|
||||
style.Colors[ImGuiCol_FrameBgHovered] = gui::GetSurfaceContainerHighVec4();
|
||||
style.Colors[ImGuiCol_FrameBgActive] = gui::GetPrimaryVec4();
|
||||
|
||||
// Scrollbar colors
|
||||
style.Colors[ImGuiCol_ScrollbarBg] = gui::GetSurfaceContainerVec4();
|
||||
style.Colors[ImGuiCol_ScrollbarGrab] = gui::GetOutlineVec4();
|
||||
style.Colors[ImGuiCol_ScrollbarGrabHovered] = gui::GetOnSurfaceVariantVec4();
|
||||
style.Colors[ImGuiCol_ScrollbarGrabActive] = gui::GetOnSurfaceVec4();
|
||||
|
||||
// Slider colors
|
||||
style.Colors[ImGuiCol_SliderGrab] = gui::GetPrimaryVec4();
|
||||
style.Colors[ImGuiCol_SliderGrabActive] = gui::GetPrimaryActiveVec4();
|
||||
|
||||
// Tab colors
|
||||
style.Colors[ImGuiCol_Tab] = gui::GetSurfaceContainerHighVec4();
|
||||
style.Colors[ImGuiCol_TabHovered] = gui::GetSurfaceContainerHighestVec4();
|
||||
style.Colors[ImGuiCol_TabActive] = gui::GetPrimaryVec4();
|
||||
style.Colors[ImGuiCol_TabUnfocused] = gui::GetSurfaceContainerVec4();
|
||||
style.Colors[ImGuiCol_TabUnfocusedActive] = gui::GetPrimaryActiveVec4();
|
||||
|
||||
// Title bar colors
|
||||
style.Colors[ImGuiCol_TitleBg] = gui::GetSurfaceContainerVec4();
|
||||
style.Colors[ImGuiCol_TitleBgActive] = gui::GetSurfaceContainerHighVec4();
|
||||
style.Colors[ImGuiCol_TitleBgCollapsed] = gui::GetSurfaceContainerVec4();
|
||||
|
||||
// Menu bar colors
|
||||
style.Colors[ImGuiCol_MenuBarBg] = gui::GetSurfaceContainerVec4();
|
||||
|
||||
// Modal dimming
|
||||
style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.6f);
|
||||
}
|
||||
|
||||
void UICoordinator::UpdateThemeElements() {
|
||||
// Update theme-specific elements
|
||||
ApplyMaterialDesignStyling();
|
||||
}
|
||||
|
||||
void UICoordinator::DrawThemePreview() {
|
||||
// TODO: Implement theme preview
|
||||
// This would show a preview of the current theme
|
||||
}
|
||||
|
||||
// Helper methods for drawing operations
|
||||
void UICoordinator::DrawSessionIndicator() {
|
||||
// TODO: Implement session indicator
|
||||
}
|
||||
|
||||
void UICoordinator::DrawVersionInfo() {
|
||||
// TODO: Implement version info display
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionTabs() {
|
||||
// TODO: Implement session tabs
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionBadges() {
|
||||
// TODO: Implement session badges
|
||||
}
|
||||
|
||||
// Material Design component helpers
|
||||
void UICoordinator::DrawMaterialButton(const std::string& text, const std::string& icon,
|
||||
std::function<void()> callback, bool enabled) {
|
||||
if (!enabled) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, gui::GetSurfaceContainerHighestVec4());
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, gui::GetOnSurfaceVariantVec4());
|
||||
}
|
||||
|
||||
std::string button_text = absl::StrFormat("%s %s", icon.c_str(), text.c_str());
|
||||
if (ImGui::Button(button_text.c_str())) {
|
||||
if (enabled && callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
}
|
||||
|
||||
void UICoordinator::DrawMaterialCard(const std::string& title, const std::string& content) {
|
||||
// TODO: Implement Material Design card component
|
||||
}
|
||||
|
||||
void UICoordinator::DrawMaterialDialog(const std::string& title, std::function<void()> content) {
|
||||
// TODO: Implement Material Design dialog component
|
||||
}
|
||||
|
||||
// Layout and positioning helpers
|
||||
void UICoordinator::CenterWindow(const std::string& window_name) {
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
void UICoordinator::PositionWindow(const std::string& window_name, float x, float y) {
|
||||
ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_Appearing);
|
||||
}
|
||||
|
||||
void UICoordinator::SetWindowSize(const std::string& window_name, float width, float height) {
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_FirstUseEver);
|
||||
}
|
||||
|
||||
// Icon and theming helpers
|
||||
std::string UICoordinator::GetIconForEditor(EditorType type) const {
|
||||
switch (type) {
|
||||
case EditorType::kDungeon: return ICON_MD_CASTLE;
|
||||
case EditorType::kOverworld: return ICON_MD_MAP;
|
||||
case EditorType::kGraphics: return ICON_MD_IMAGE;
|
||||
case EditorType::kPalette: return ICON_MD_PALETTE;
|
||||
case EditorType::kSprite: return ICON_MD_TOYS;
|
||||
case EditorType::kScreen: return ICON_MD_TV;
|
||||
case EditorType::kMessage: return ICON_MD_CHAT_BUBBLE;
|
||||
case EditorType::kMusic: return ICON_MD_MUSIC_NOTE;
|
||||
case EditorType::kAssembly: return ICON_MD_CODE;
|
||||
case EditorType::kHex: return ICON_MD_DATA_ARRAY;
|
||||
case EditorType::kEmulator: return ICON_MD_PLAY_ARROW;
|
||||
case EditorType::kSettings: return ICON_MD_SETTINGS;
|
||||
default: return ICON_MD_HELP;
|
||||
}
|
||||
}
|
||||
|
||||
std::string UICoordinator::GetColorForEditor(EditorType type) const {
|
||||
// TODO: Implement editor-specific colors
|
||||
return "primary"; // Placeholder for now
|
||||
}
|
||||
|
||||
void UICoordinator::ApplyEditorTheme(EditorType type) {
|
||||
// TODO: Implement editor-specific theming
|
||||
}
|
||||
|
||||
// Session UI helpers
|
||||
void UICoordinator::DrawSessionList() {
|
||||
// TODO: Implement session list
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionControls() {
|
||||
// TODO: Implement session controls
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionInfo() {
|
||||
// TODO: Implement session info
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionStatus() {
|
||||
// TODO: Implement session status
|
||||
}
|
||||
|
||||
// Popup helpers
|
||||
void UICoordinator::DrawHelpMenuPopups() {
|
||||
// TODO: Implement help menu popups
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSettingsPopups() {
|
||||
// TODO: Implement settings popups
|
||||
}
|
||||
|
||||
void UICoordinator::DrawProjectPopups() {
|
||||
// TODO: Implement project popups
|
||||
}
|
||||
|
||||
void UICoordinator::DrawSessionPopups() {
|
||||
// TODO: Implement session popups
|
||||
}
|
||||
|
||||
// Window management helpers
|
||||
void UICoordinator::DrawWindowControls() {
|
||||
// TODO: Implement window controls
|
||||
}
|
||||
|
||||
void UICoordinator::DrawLayoutControls() {
|
||||
// TODO: Implement layout controls
|
||||
}
|
||||
|
||||
void UICoordinator::DrawDockingControls() {
|
||||
// TODO: Implement docking controls
|
||||
}
|
||||
|
||||
// Performance and debug UI
|
||||
void UICoordinator::DrawPerformanceUI() {
|
||||
// TODO: Implement performance UI
|
||||
}
|
||||
|
||||
void UICoordinator::DrawDebugUI() {
|
||||
// TODO: Implement debug UI
|
||||
}
|
||||
|
||||
void UICoordinator::DrawTestingUI() {
|
||||
// TODO: Implement testing UI
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
@@ -1,181 +0,0 @@
|
||||
#ifndef YAZE_APP_EDITOR_SYSTEM_UI_COORDINATOR_H_
|
||||
#define YAZE_APP_EDITOR_SYSTEM_UI_COORDINATOR_H_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/system/popup_manager.h"
|
||||
#include "app/editor/system/session_coordinator.h"
|
||||
#include "app/editor/ui/welcome_screen.h"
|
||||
#include "app/gui/core/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
// Forward declarations to avoid circular dependencies
|
||||
class EditorManager;
|
||||
class RomFileManager;
|
||||
class ProjectManager;
|
||||
class EditorRegistry;
|
||||
class SessionCoordinator;
|
||||
class ToastManager;
|
||||
class WindowDelegate;
|
||||
|
||||
/**
|
||||
* @class UICoordinator
|
||||
* @brief Handles all UI drawing operations and state management
|
||||
*
|
||||
* Extracted from EditorManager to provide focused UI coordination:
|
||||
* - Drawing operations (menus, dialogs, screens)
|
||||
* - UI state management (visibility, focus, layout)
|
||||
* - Popup and dialog coordination
|
||||
* - Welcome screen and session UI
|
||||
* - Material Design theming and icons
|
||||
*
|
||||
* This class follows the Single Responsibility Principle by focusing solely
|
||||
* on UI presentation and user interaction, delegating business logic to
|
||||
* specialized managers.
|
||||
*/
|
||||
class UICoordinator {
|
||||
public:
|
||||
// Constructor takes references to the managers it coordinates with
|
||||
UICoordinator(EditorManager* editor_manager,
|
||||
RomFileManager& rom_manager,
|
||||
ProjectManager& project_manager,
|
||||
EditorRegistry& editor_registry,
|
||||
SessionCoordinator& session_coordinator,
|
||||
WindowDelegate& window_delegate,
|
||||
ToastManager& toast_manager,
|
||||
PopupManager& popup_manager);
|
||||
~UICoordinator() = default;
|
||||
|
||||
// Non-copyable due to reference members
|
||||
UICoordinator(const UICoordinator&) = delete;
|
||||
UICoordinator& operator=(const UICoordinator&) = delete;
|
||||
|
||||
// Main UI drawing interface
|
||||
void DrawAllUI();
|
||||
void DrawMenuBarExtras();
|
||||
void DrawContextSensitiveCardControl();
|
||||
|
||||
// Session UI components
|
||||
void DrawSessionSwitcher();
|
||||
void DrawSessionManager();
|
||||
void DrawSessionRenameDialog();
|
||||
void DrawLayoutPresets();
|
||||
|
||||
// Welcome screen and project UI
|
||||
void DrawWelcomeScreen();
|
||||
void DrawProjectHelp();
|
||||
|
||||
// Window management UI
|
||||
void DrawWindowManagementUI();
|
||||
|
||||
// Popup and dialog management
|
||||
void DrawAllPopups();
|
||||
void ShowPopup(const std::string& popup_name);
|
||||
void HidePopup(const std::string& popup_name);
|
||||
|
||||
// UI state management
|
||||
void ShowEditorSelection();
|
||||
void ShowDisplaySettings();
|
||||
void ShowSessionSwitcher();
|
||||
void HideCurrentEditorCards();
|
||||
|
||||
// Window visibility management
|
||||
void ShowAllWindows();
|
||||
void HideAllWindows();
|
||||
|
||||
// UI state queries
|
||||
bool IsEditorSelectionVisible() const { return show_editor_selection_; }
|
||||
bool IsDisplaySettingsVisible() const { return show_display_settings_; }
|
||||
bool IsSessionSwitcherVisible() const { return show_session_switcher_; }
|
||||
bool IsWelcomeScreenVisible() const { return show_welcome_screen_; }
|
||||
|
||||
// UI state setters
|
||||
void SetEditorSelectionVisible(bool visible) { show_editor_selection_ = visible; }
|
||||
void SetDisplaySettingsVisible(bool visible) { show_display_settings_ = visible; }
|
||||
void SetSessionSwitcherVisible(bool visible) { show_session_switcher_ = visible; }
|
||||
void SetWelcomeScreenVisible(bool visible) { show_welcome_screen_ = visible; }
|
||||
|
||||
// Theme and styling helpers
|
||||
void ApplyMaterialDesignStyling();
|
||||
void UpdateThemeElements();
|
||||
void DrawThemePreview();
|
||||
|
||||
private:
|
||||
// References to coordinated managers
|
||||
EditorManager* editor_manager_;
|
||||
RomFileManager& rom_manager_;
|
||||
ProjectManager& project_manager_;
|
||||
EditorRegistry& editor_registry_;
|
||||
SessionCoordinator& session_coordinator_;
|
||||
WindowDelegate& window_delegate_;
|
||||
ToastManager& toast_manager_;
|
||||
PopupManager& popup_manager_;
|
||||
|
||||
// UI state flags
|
||||
bool show_editor_selection_ = false;
|
||||
bool show_display_settings_ = false;
|
||||
bool show_session_switcher_ = false;
|
||||
bool show_welcome_screen_ = true;
|
||||
bool show_global_search_ = false;
|
||||
bool show_performance_dashboard_ = false;
|
||||
bool show_imgui_demo_ = false;
|
||||
bool show_imgui_metrics_ = false;
|
||||
bool show_test_dashboard_ = false;
|
||||
|
||||
// Welcome screen component
|
||||
std::unique_ptr<WelcomeScreen> welcome_screen_;
|
||||
|
||||
// Helper methods for drawing operations
|
||||
void DrawSessionIndicator();
|
||||
void DrawVersionInfo();
|
||||
void DrawSessionTabs();
|
||||
void DrawSessionBadges();
|
||||
|
||||
// Material Design component helpers
|
||||
void DrawMaterialButton(const std::string& text, const std::string& icon,
|
||||
std::function<void()> callback, bool enabled = true);
|
||||
void DrawMaterialCard(const std::string& title, const std::string& content);
|
||||
void DrawMaterialDialog(const std::string& title, std::function<void()> content);
|
||||
|
||||
// Layout and positioning helpers
|
||||
void CenterWindow(const std::string& window_name);
|
||||
void PositionWindow(const std::string& window_name, float x, float y);
|
||||
void SetWindowSize(const std::string& window_name, float width, float height);
|
||||
|
||||
// Icon and theming helpers
|
||||
std::string GetIconForEditor(EditorType type) const;
|
||||
std::string GetColorForEditor(EditorType type) const;
|
||||
void ApplyEditorTheme(EditorType type);
|
||||
|
||||
// Session UI helpers
|
||||
void DrawSessionList();
|
||||
void DrawSessionControls();
|
||||
void DrawSessionInfo();
|
||||
void DrawSessionStatus();
|
||||
|
||||
// Popup helpers
|
||||
void DrawHelpMenuPopups();
|
||||
void DrawSettingsPopups();
|
||||
void DrawProjectPopups();
|
||||
void DrawSessionPopups();
|
||||
|
||||
// Window management helpers
|
||||
void DrawWindowControls();
|
||||
void DrawLayoutControls();
|
||||
void DrawDockingControls();
|
||||
|
||||
// Performance and debug UI
|
||||
void DrawPerformanceUI();
|
||||
void DrawDebugUI();
|
||||
void DrawTestingUI();
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_UI_COORDINATOR_H_
|
||||
@@ -58,6 +58,11 @@ class WindowDelegate {
|
||||
void LoadWorkspaceLayout();
|
||||
void ResetWorkspaceLayout();
|
||||
|
||||
// Layout presets
|
||||
void LoadDeveloperLayout();
|
||||
void LoadDesignerLayout();
|
||||
void LoadModderLayout();
|
||||
|
||||
// Window state queries
|
||||
std::vector<std::string> GetVisibleWindows() const;
|
||||
std::vector<std::string> GetHiddenWindows() const;
|
||||
@@ -74,9 +79,6 @@ class WindowDelegate {
|
||||
void UnregisterWindow(const std::string& window_id);
|
||||
|
||||
// Layout presets
|
||||
void LoadDeveloperLayout();
|
||||
void LoadDesignerLayout();
|
||||
void LoadModderLayout();
|
||||
void LoadMinimalLayout();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user