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
8
9#include "imgui/imgui.h"
10
11#include <deque>
12#include <vector>
13
14#include "absl/status/status.h"
15#include "app/core/features.h"
16#include "app/core/project.h"
32#ifdef YAZE_WITH_GRPC
35#endif
40#include "app/emu/emulator.h"
42#include "app/rom.h"
43#include "yaze_config.h"
44
45#ifdef YAZE_WITH_GRPC
46// Forward declarations for gRPC-dependent types
47namespace yaze::agent {
48class AgentControlServer;
49}
50#endif
51
52namespace yaze {
53namespace editor {
54
97
110 public:
111 // Constructor and destructor must be defined in .cc file for std::unique_ptr with forward-declared types
114
115 void Initialize(gfx::IRenderer* renderer, const std::string& filename = "");
116
117 // Processes startup flags to open a specific editor and cards.
118 void OpenEditorAndCardsFromFlags(const std::string& editor_name,
119 const std::string& cards_str);
120 absl::Status Update();
121 void DrawMenuBar();
122
123 auto emulator() -> emu::Emulator& { return emulator_; }
124 auto quit() const { return quit_; }
125 auto version() const { return version_; }
126 void DrawMenuBarExtras();
128 void ShowSessionSwitcher();
129 void ShowEditorSelection();
130 void ShowDisplaySettings();
131
132 absl::Status SetCurrentRom(Rom* rom);
133 auto GetCurrentRom() -> Rom* { return current_rom_; }
136
137 // Session management helpers
138 size_t GetCurrentSessionIndex() const;
139
140 // Get current session's feature flags (falls back to global if no session)
142 size_t current_index = GetCurrentSessionIndex();
143 if (current_index < sessions_.size()) {
144 return &sessions_[current_index].feature_flags;
145 }
146 return &core::FeatureFlags::get(); // Fallback to global
147 }
148
149 void SetFontGlobalScale(float scale) {
151 ImGui::GetIO().FontGlobalScale = scale;
153 }
154
155 void BuildModernMenu();
156
157 // User settings helpers
158 void LoadUserSettings();
159 void SaveUserSettings();
160
161 // Workspace management (delegates to WorkspaceManager)
163 void SaveWorkspacePreset(const std::string& name) { workspace_manager_.SaveWorkspacePreset(name); }
164 void LoadWorkspacePreset(const std::string& name) { workspace_manager_.LoadWorkspacePreset(name); }
165
166 // Jump-to functionality for cross-editor navigation
167 void JumpToDungeonRoom(int room_id);
168 void JumpToOverworldMap(int map_id);
169 void SwitchToEditor(EditorType editor_type);
170
171 // Session management
172 void CreateNewSession();
174 void CloseCurrentSession();
175 void RemoveSession(size_t index);
176 void SwitchToSession(size_t index);
177 size_t GetActiveSessionCount() const;
178
179 // Workspace layout management
180 void SaveWorkspaceLayout();
181 void LoadWorkspaceLayout();
183 void ShowAllWindows();
184 void HideAllWindows();
186 void RestoreAllWindows();
188
189 // Layout presets
190 void LoadDeveloperLayout();
191 void LoadDesignerLayout();
192 void LoadModderLayout();
193
194 // Helper methods
195 std::string GenerateUniqueEditorTitle(EditorType type, size_t session_index) const;
196 bool HasDuplicateSession(const std::string& filepath);
197 void RenameSession(size_t index, const std::string& new_name);
198
199 private:
200 void DrawWelcomeScreen();
201 absl::Status DrawRomSelector();
202 void DrawContextSensitiveCardControl(); // Card control for current editor
203 void DrawSessionSwitcher();
204 void DrawSessionManager();
205 void DrawLayoutPresets();
207
208 absl::Status LoadRom();
209 absl::Status LoadAssets();
210 absl::Status SaveRom();
211 absl::Status SaveRomAs(const std::string& filename);
212 absl::Status OpenRomOrProject(const std::string& filename);
213
214 // Project and session management
215 absl::Status CreateNewProject(
216 const std::string& template_name = "Basic ROM Hack");
217 absl::Status OpenProject();
218 absl::Status SaveProject();
219 absl::Status SaveProjectAs();
220 absl::Status ImportProject(const std::string& project_path);
221 absl::Status RepairCurrentProject();
222 void ShowProjectHelp();
223
224 // Testing system
226
227 bool quit_ = false;
228 bool new_project_menu = false;
229
230 bool show_emulator_ = false;
232 bool show_asm_editor_ = false;
234 bool show_imgui_demo_ = false;
243 bool show_homepage_ = true;
249 bool show_card_browser_ = false;
252
253 // Testing interface
256
257 // Agent proposal drawer
260
261#ifdef YAZE_WITH_GRPC
262 AutomationBridge harness_telemetry_bridge_;
263#endif
264
265 // Agent chat history popup
268
269 // Project file editor
271
272 // Editor selection dialog
275
276 // Welcome screen
278
279#ifdef YAZE_WITH_GRPC
280 // Agent editor - manages chat, collaboration, and network coordination
281 AgentEditor agent_editor_;
282 std::unique_ptr<yaze::agent::AgentControlServer> agent_control_server_;
283#endif
284
285 std::string version_ = "";
286 absl::Status status_;
288
289 struct RomSession {
292 std::string custom_name; // User-defined session name
293 std::string filepath; // ROM filepath for duplicate detection
294 core::FeatureFlags::Flags feature_flags; // Per-session feature flags
295
296 RomSession() = default;
297 explicit RomSession(Rom&& r, UserSettings* user_settings = nullptr)
298 : rom(std::move(r)), editors(&rom, user_settings) {
300 // Initialize with default feature flags
302 }
303
304 // Get display name (custom name or ROM title)
305 std::string GetDisplayName() const {
306 if (!custom_name.empty()) {
307 return custom_name;
308 }
309 return rom.title().empty() ? "Untitled Session" : rom.title();
310 }
311 };
312
313 std::deque<RomSession> sessions_;
314 Rom* current_rom_ = nullptr;
318
320
323 std::unique_ptr<PopupManager> popup_manager_;
328
329 float autosave_timer_ = 0.0f;
330};
331
332} // namespace editor
333} // namespace yaze
334
335#endif // YAZE_APP_EDITOR_EDITOR_MANAGER_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
auto filename() const
Definition rom.h:208
auto title() const
Definition rom.h:201
static Flags & get()
Definition features.h:79
ImGui popup drawer for displaying chat history on the left side.
Comprehensive AI Agent Platform & Bot Creator.
Text editor for modifying assembly code.
DungeonEditorV2 - Simplified dungeon editor using component delegation.
The EditorManager controls the main editor window and manages the various editor classes.
std::deque< RomSession > sessions_
void SaveWorkspacePreset(const std::string &name)
absl::Status SaveRomAs(const std::string &filename)
void JumpToDungeonRoom(int room_id)
void SwitchToSession(size_t index)
bool HasDuplicateSession(const std::string &filepath)
void SwitchToEditor(EditorType editor_type)
EditorSelectionDialog editor_selection_dialog_
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 Initialize(gfx::IRenderer *renderer, const std::string &filename="")
AgentChatHistoryPopup agent_chat_history_popup_
absl::Status CreateNewProject(const std::string &template_name="Basic ROM Hack")
void SetFontGlobalScale(float scale)
ProjectFileEditor project_file_editor_
void OpenEditorAndCardsFromFlags(const std::string &editor_name, const std::string &cards_str)
void JumpToOverworldMap(int map_id)
auto GetCurrentEditorSet() -> EditorSet *
absl::Status ImportProject(const std::string &project_path)
core::YazeProject current_project_
auto emulator() -> emu::Emulator &
core::FeatureFlags::Flags * GetCurrentFeatureFlags()
WorkspaceManager workspace_manager_
absl::Status OpenRomOrProject(const std::string &filename)
void RemoveSession(size_t index)
std::unique_ptr< PopupManager > popup_manager_
auto overworld() -> yaze::zelda3::Overworld *
absl::Status SetCurrentRom(Rom *rom)
Beautiful grid-based editor selection dialog.
Contains a complete set of editors for a single ROM instance.
SettingsEditor settings_editor_
DungeonEditorV2 dungeon_editor_
MemoryEditorWithDiffChecker memory_editor_
GraphicsEditor graphics_editor_
EditorSet(Rom *rom=nullptr, UserSettings *user_settings=nullptr)
void set_user_settings(UserSettings *settings)
AssemblyEditor assembly_editor_
OverworldEditor overworld_editor_
MessageEditor message_editor_
std::vector< Editor * > active_editors_
PaletteEditor palette_editor_
Interface for editor classes.
Definition editor.h:82
Allows the user to edit graphics sheets from the game or view prototype graphics.
Fluent interface for building ImGui menus with icons.
A class for editing music data in a Rom.
Manipulates the Overworld and OverworldMap data in a Rom.
zelda3::Overworld & overworld()
Allows the user to view and edit in game palettes.
Editor for .yaze project files with syntax highlighting and validation.
ImGui drawer for displaying and managing agent proposals.
The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom me...
void set_user_settings(UserSettings *settings)
Allows the user to edit sprites.
Manages user preferences and settings persistence.
Modern welcome screen with project grid and quick actions.
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:33
Defines an abstract interface for all rendering operations.
Definition irenderer.h:35
Represents the full Overworld data, light and dark world.
Definition overworld.h:135
Main namespace for the application.
Modern project structure with comprehensive settings consolidation.
Definition project.h:78
core::FeatureFlags::Flags feature_flags
RomSession(Rom &&r, UserSettings *user_settings=nullptr)