yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
editor_manager.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_EDITOR_MANAGER_H
2#define YAZE_APP_EDITOR_EDITOR_MANAGER_H
3
4#define IMGUI_DEFINE_MATH_OPERATORS
5
6#include "app/editor/editor.h"
10
11#include "imgui/imgui.h"
12
13#include <cstddef>
14#include <deque>
15#include <memory>
16#include <string>
17
18#include "absl/status/status.h"
19#include "core/project.h"
37#include "app/emu/emulator.h"
39#include "app/rom.h"
40#include "yaze_config.h"
41
42#ifdef YAZE_WITH_GRPC
45
46// Forward declarations for gRPC-dependent types
47namespace yaze::agent {
48class AgentControlServer;
49}
50#endif
51
52namespace yaze {
53namespace editor {
54
67 public:
68 // Constructor and destructor must be defined in .cc file for std::unique_ptr with forward-declared types
71
72 void Initialize(gfx::IRenderer* renderer, const std::string& filename = "");
73
74 // Processes startup flags to open a specific editor and cards.
75 void OpenEditorAndCardsFromFlags(const std::string& editor_name,
76 const std::string& cards_str);
77 absl::Status Update();
78 void DrawMenuBar();
79
80 auto emulator() -> emu::Emulator& { return emulator_; }
81 auto quit() const { return quit_; }
82 auto version() const { return version_; }
83
86
87 absl::Status SetCurrentRom(Rom* rom);
88 auto GetCurrentRom() const -> Rom* { return session_coordinator_ ? session_coordinator_->GetCurrentRom() : nullptr; }
89 auto GetCurrentEditorSet() const -> EditorSet* { return session_coordinator_ ? session_coordinator_->GetCurrentEditorSet() : nullptr; }
90 auto GetCurrentEditor() const -> Editor* { return current_editor_; }
91 size_t GetCurrentSessionId() const { return session_coordinator_ ? session_coordinator_->GetActiveSessionIndex() : 0; }
93 auto overworld() const -> yaze::zelda3::Overworld* {
94 if (auto* editor_set = GetCurrentEditorSet()) {
95 return &editor_set->overworld_editor_.overworld();
96 }
97 return nullptr;
98 }
99
100 // Session management helpers
101 size_t GetCurrentSessionIndex() const;
102
103 // Get current session's feature flags (falls back to global if no session)
105 size_t current_index = GetCurrentSessionIndex();
106 if (current_index < sessions_.size()) {
107 return &sessions_[current_index].feature_flags;
108 }
109 return &core::FeatureFlags::get(); // Fallback to global
110 }
111
112 void SetFontGlobalScale(float scale) {
114 ImGui::GetIO().FontGlobalScale = scale;
115 auto status = user_settings_.Save();
116 if (!status.ok()) {
117 LOG_WARN("EditorManager", "Failed to save user settings: %s",
118 status.ToString().c_str());
119 }
120 }
121
122 // Workspace management (delegates to WorkspaceManager)
124 void SaveWorkspacePreset(const std::string& name) {
126 }
127 void LoadWorkspacePreset(const std::string& name) {
129 }
130
131 // Jump-to functionality for cross-editor navigation
132 void JumpToDungeonRoom(int room_id);
133 void JumpToOverworldMap(int map_id);
134 void SwitchToEditor(EditorType editor_type);
135
136 // Card-based editor registry
137 static bool IsCardBasedEditor(EditorType type);
138 bool IsSidebarVisible() const {
139 return ui_coordinator_ ? ui_coordinator_->IsCardSidebarVisible() : false;
140 }
141 void SetSidebarVisible(bool visible) {
142 if (ui_coordinator_) {
143 ui_coordinator_->SetCardSidebarVisible(visible);
144 }
145 }
146
147 // Clean up cards when switching editors
149
150 // Session management
151 void CreateNewSession();
153 void CloseCurrentSession();
154 void RemoveSession(size_t index);
155 void SwitchToSession(size_t index);
156 size_t GetActiveSessionCount() const;
157
158 // Workspace layout management
159 // Window management - inline delegation (reduces EditorManager bloat)
164 if (ui_coordinator_)
165 ui_coordinator_->ShowAllWindows();
166 }
168 if (ui_coordinator_)
169 ui_coordinator_->HideAllWindows();
170 }
171
172 // Layout presets (inline delegation)
176
177 // Helper methods
178 std::string GenerateUniqueEditorTitle(EditorType type,
179 size_t session_index) const;
180 bool HasDuplicateSession(const std::string& filepath);
181 void RenameSession(size_t index, const std::string& new_name);
182 void Quit() { quit_ = true; }
183
184 // UI visibility controls (public for MenuOrchestrator)
185 // UI visibility controls - inline for performance (single-line wrappers delegating to UICoordinator)
187 if (ui_coordinator_)
188 ui_coordinator_->ShowGlobalSearch();
189 }
191 if (ui_coordinator_)
192 ui_coordinator_->ShowCommandPalette();
193 }
195 if (ui_coordinator_)
196 ui_coordinator_->SetPerformanceDashboardVisible(true);
197 }
199 if (ui_coordinator_)
200 ui_coordinator_->SetImGuiDemoVisible(true);
201 }
203 if (ui_coordinator_)
204 ui_coordinator_->SetImGuiMetricsVisible(true);
205 }
206 void ShowHexEditor();
207 void ShowEmulator() { if (ui_coordinator_) ui_coordinator_->SetEmulatorVisible(true); }
208 void ShowMemoryEditor() { if (ui_coordinator_) ui_coordinator_->SetMemoryEditorVisible(true); }
209 void ShowResourceLabelManager() { if (ui_coordinator_) ui_coordinator_->SetResourceLabelManagerVisible(true); }
211 if (ui_coordinator_)
212 ui_coordinator_->ShowCardBrowser();
213 }
215 if (ui_coordinator_)
216 ui_coordinator_->SetWelcomeScreenVisible(true);
217 }
218
219#ifdef YAZE_ENABLE_TESTING
220 void ShowTestDashboard() { show_test_dashboard_ = true; }
221#endif
222
223#ifdef YAZE_WITH_GRPC
224 void ShowAIAgent();
225 void ShowChatHistory();
226 void ShowProposalDrawer() { proposal_drawer_.Show(); }
227#endif
228
229 // ROM and Project operations (public for MenuOrchestrator)
230 absl::Status LoadRom();
231 absl::Status SaveRom();
232 absl::Status SaveRomAs(const std::string& filename);
233 absl::Status OpenRomOrProject(const std::string& filename);
234 absl::Status CreateNewProject(
235 const std::string& template_name = "Basic ROM Hack");
236 absl::Status OpenProject();
237 absl::Status SaveProject();
238 absl::Status SaveProjectAs();
239 absl::Status ImportProject(const std::string& project_path);
240 absl::Status RepairCurrentProject();
241
242 private:
243 absl::Status DrawRomSelector() = delete; // Moved to UICoordinator
244 void DrawContextSensitiveCardControl(); // Card control for current editor
245
246 absl::Status LoadAssets();
247
248 // Testing system
250
251 bool quit_ = false;
252
253 // Note: All show_* flags are being moved to UICoordinator
254 // Access via ui_coordinator_->IsXxxVisible() or SetXxxVisible()
255
256 // Workspace dialog flags (managed by EditorManager, not UI)
260
261 // Note: Most UI visibility flags have been moved to UICoordinator
262 // Access via ui_coordinator_->IsXxxVisible() or SetXxxVisible()
263
264 // Agent proposal drawer
267
268#ifdef YAZE_WITH_GRPC
269 AutomationBridge harness_telemetry_bridge_;
270#endif
271
272 // Agent chat history popup
275
276 // Project file editor
278
279 // Note: Editor selection dialog and welcome screen are now managed by UICoordinator
280 // Kept here for backward compatibility during transition
283
284#ifdef YAZE_WITH_GRPC
285 // Agent editor - manages chat, collaboration, and network coordination
286 AgentEditor agent_editor_;
287 std::unique_ptr<yaze::agent::AgentControlServer> agent_control_server_;
288#endif
289
290 std::string version_ = "";
291 absl::Status status_;
293
294 public:
295
296 private:
297 std::deque<RomSession> sessions_;
300 // Tracks which session is currently active so delegators (menus, popups,
301 // shortcuts) stay in sync without relying on per-editor context.
302
304
307 std::unique_ptr<PopupManager> popup_manager_;
312
313 // New delegated components (dependency injection architecture)
314 EditorCardRegistry card_registry_; // Card management with session awareness
316 std::unique_ptr<MenuOrchestrator> menu_orchestrator_;
319 std::unique_ptr<UICoordinator> ui_coordinator_;
321 std::unique_ptr<SessionCoordinator> session_coordinator_;
322 std::unique_ptr<LayoutManager> layout_manager_; // DockBuilder layout management
324
325 float autosave_timer_ = 0.0f;
326
327 // RAII helper for clean session context switching
329 public:
330 SessionScope(EditorManager* manager, size_t session_id);
332
333 private:
338 };
339
340 void ConfigureEditorDependencies(EditorSet* editor_set, Rom* rom,
341 size_t session_id);
342};
343
344} // namespace editor
345} // namespace yaze
346
347#endif // YAZE_APP_EDITOR_EDITOR_MANAGER_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
static Flags & get()
Definition features.h:82
ImGui popup drawer for displaying chat history on the left side.
Comprehensive AI Agent Platform & Bot Creator.
Central registry for all editor cards with session awareness and dependency injection.
The EditorManager controls the main editor window and manages the various editor classes.
std::deque< RomSession > sessions_
static bool IsCardBasedEditor(EditorType type)
std::unique_ptr< SessionCoordinator > session_coordinator_
void SaveWorkspacePreset(const std::string &name)
absl::Status SaveRomAs(const std::string &filename)
project::YazeProject current_project_
void JumpToDungeonRoom(int room_id)
void SwitchToSession(size_t index)
EditorCardRegistry card_registry_
bool HasDuplicateSession(const std::string &filepath)
void SwitchToEditor(EditorType editor_type)
EditorSelectionDialog editor_selection_dialog_
WorkspaceManager * workspace_manager()
std::unique_ptr< LayoutManager > layout_manager_
void LoadWorkspacePreset(const std::string &name)
std::string GenerateUniqueEditorTitle(EditorType type, size_t session_index) const
void RenameSession(size_t index, const std::string &new_name)
void DrawMenuBar()
Draw the main menu bar.
UICoordinator * ui_coordinator()
void Initialize(gfx::IRenderer *renderer, const std::string &filename="")
AgentChatHistoryPopup agent_chat_history_popup_
absl::Status CreateNewProject(const std::string &template_name="Basic ROM Hack")
auto overworld() const -> yaze::zelda3::Overworld *
auto GetCurrentEditorSet() const -> EditorSet *
void SetFontGlobalScale(float scale)
std::unique_ptr< MenuOrchestrator > menu_orchestrator_
ProjectFileEditor project_file_editor_
void SetSidebarVisible(bool visible)
auto GetCurrentEditor() const -> Editor *
absl::Status DrawRomSelector()=delete
void OpenEditorAndCardsFromFlags(const std::string &editor_name, const std::string &cards_str)
void JumpToOverworldMap(int map_id)
absl::Status LoadRom()
Load a ROM file into a new or existing session.
absl::Status Update()
Main update loop for the editor application.
absl::Status ImportProject(const std::string &project_path)
size_t GetCurrentSessionId() const
ShortcutManager shortcut_manager_
auto emulator() -> emu::Emulator &
EditorDependencies::SharedClipboard shared_clipboard_
core::FeatureFlags::Flags * GetCurrentFeatureFlags()
WorkspaceManager workspace_manager_
auto GetCurrentRom() const -> Rom *
void ConfigureEditorDependencies(EditorSet *editor_set, Rom *rom, size_t session_id)
Injects dependencies into all editors within an EditorSet.
absl::Status OpenRomOrProject(const std::string &filename)
void RemoveSession(size_t index)
std::unique_ptr< PopupManager > popup_manager_
std::unique_ptr< UICoordinator > ui_coordinator_
absl::Status SaveRom()
Save the current ROM file.
absl::Status SetCurrentRom(Rom *rom)
Manages editor types, categories, and lifecycle.
Beautiful grid-based editor selection dialog.
Contains a complete set of editors for a single ROM instance.
Interface for editor classes.
Definition editor.h:122
Fluent interface for building ImGui menus with icons.
Editor for .yaze project files with syntax highlighting and validation.
Handles all project file operations.
ImGui drawer for displaying and managing agent proposals.
Handles all ROM file I/O operations.
Handles all UI drawing operations and state management.
Manages user preferences and settings persistence.
Modern welcome screen with project grid and quick actions.
Low-level window operations with minimal dependencies.
Manages workspace layouts, sessions, and presets.
void SaveWorkspacePreset(const std::string &name)
void LoadWorkspacePreset(const std::string &name)
A class for emulating and debugging SNES games.
Definition emulator.h:36
Defines an abstract interface for all rendering operations.
Definition irenderer.h:35
#define LOG_WARN(category, format,...)
Definition log.h:108
Main namespace for the application.
Definition controller.cc:20
Modern project structure with comprehensive settings consolidation.
Definition project.h:78