yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
session_types.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SESSION_TYPES_H_
2#define YAZE_APP_EDITOR_SESSION_TYPES_H_
3
4#include <array>
5#include <cstdint>
6#include <functional>
7#include <map>
8#include <memory>
9#include <optional>
10#include <string>
11#include <string_view>
12#include <unordered_map>
13#include <utility>
14#include <vector>
15
16#include "app/editor/editor.h"
18#include "core/asar_wrapper.h" // For AsarSymbol (backend-agnostic symbol shape)
19#include "core/features.h"
20#include "rom/rom.h"
21#include "zelda3/game_data.h"
22
23namespace yaze::core {
24class AsarWrapper;
25}
26
27namespace yaze::zelda3 {
28class Overworld;
29}
30
31namespace yaze::editor {
32
33class EditorDependencies;
34class EditorRegistry;
35class UserSettings;
36
37// Forward declarations for legacy accessors
38class AssemblyEditor;
39class MemoryEditor;
40class DungeonEditorV2;
41class GraphicsEditor;
42class ScreenEditor;
43class MessageEditor;
44class MusicEditor;
45class OverworldEditor;
46class PaletteEditor;
47class SpriteEditor;
48class SettingsPanel;
49
54class EditorSet {
55 public:
56 explicit EditorSet(Rom* rom = nullptr, zelda3::GameData* game_data = nullptr,
57 UserSettings* user_settings = nullptr,
58 size_t session_id = 0,
59 EditorRegistry* editor_registry = nullptr);
61
62 void set_user_settings(UserSettings* settings);
63 void SetGameData(zelda3::GameData* game_data);
64
65 void ApplyDependencies(const EditorDependencies& dependencies);
66
67 size_t session_id() const { return session_id_; }
68
69 // Generic accessors
70 Editor* GetEditor(EditorType type) const;
71
72 template <typename T>
73 T* GetEditorAs(EditorType type) const {
74 return static_cast<T*>(GetEditor(type));
75 }
76
77 // Convenience helpers that avoid requiring concrete editor headers.
78 // Prefer these from higher-level systems (EditorManager, UI) to keep compile
79 // dependencies minimal.
80 void OpenAssemblyFolder(const std::string& folder_path) const;
81 void ChangeActiveAssemblyFile(std::string_view path) const;
83
84 // Backend-agnostic accessor for assembly symbols (works for both Asar
85 // and z3dk backends). Returns the assembly editor's last-known symbol
86 // table. Empty if no editor / no assemble has happened yet.
87 const std::map<std::string, core::AsarSymbol>& GetAssemblySymbols() const;
88 int LoadedDungeonRoomCount() const;
89 int TotalDungeonRoomCount() const;
90 std::vector<std::pair<uint32_t, uint32_t>> CollectDungeonWriteRanges() const;
92
93 // Deprecated named accessors (legacy compatibility)
94 [[deprecated("Use GetEditorAs<AssemblyEditor>(EditorType::kAssembly)")]]
96 [[deprecated("Use GetEditorAs<DungeonEditorV2>(EditorType::kDungeon)")]]
98 [[deprecated("Use GetEditorAs<GraphicsEditor>(EditorType::kGraphics)")]]
100 [[deprecated("Use GetEditorAs<MusicEditor>(EditorType::kMusic)")]]
102 [[deprecated("Use GetEditorAs<OverworldEditor>(EditorType::kOverworld)")]]
104 [[deprecated("Use GetEditorAs<PaletteEditor>(EditorType::kPalette)")]]
106 [[deprecated("Use GetEditorAs<ScreenEditor>(EditorType::kScreen)")]]
108 [[deprecated("Use GetEditorAs<SpriteEditor>(EditorType::kSprite)")]]
110 [[deprecated("Use GetEditorAs<SettingsPanel>(EditorType::kSettings)")]]
112 [[deprecated("Use GetEditorAs<MessageEditor>(EditorType::kMessage)")]]
114 [[deprecated("Use GetEditorAs<MemoryEditor>(EditorType::kHex)")]]
116
122 return gfx_group_workspace_.get();
123 }
124
125 std::vector<Editor*> active_editors_;
126
127 private:
128 using EditorFactory = std::function<std::unique_ptr<Editor>()>;
129
130 Editor* FindEditor(EditorType type) const;
132 bool ShouldTrackAsActiveEditor(EditorType type) const;
133 void TrackActiveEditor(Editor* editor);
134
135 size_t session_id_ = 0;
136 Rom* rom_ = nullptr;
140
141 std::optional<EditorDependencies> dependencies_;
142 mutable std::unordered_map<EditorType, std::unique_ptr<Editor>> editors_;
143 std::unordered_map<EditorType, EditorFactory> editor_factories_;
144
145 std::unique_ptr<GfxGroupWorkspaceState> gfx_group_workspace_;
146};
147
157 std::string custom_name; // User-defined session name
158 std::string filepath; // ROM filepath for duplicate detection
159 core::FeatureFlags::Flags feature_flags; // Per-session feature flags
160 bool game_data_loaded = false;
161 std::array<bool, kEditorTypeCount> editor_initialized{};
162 std::array<bool, kEditorTypeCount> editor_assets_loaded{};
163
164 RomSession() = default;
165 explicit RomSession(Rom&& r, UserSettings* user_settings = nullptr,
166 size_t session_id = 0,
167 EditorRegistry* editor_registry = nullptr);
168
169 // Get display name (custom name or ROM title)
170 std::string GetDisplayName() const;
171};
172
173} // namespace yaze::editor
174
175#endif // YAZE_APP_EDITOR_SESSION_TYPES_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Modern C++ wrapper for Asar 65816 assembler integration.
Text editor for modifying assembly code.
DungeonEditorV2 - Simplified dungeon editor using component delegation.
Manages editor types, categories, and lifecycle.
Contains a complete set of editors for a single ROM instance.
std::optional< EditorDependencies > dependencies_
MemoryEditor * GetMemoryEditor() const
T * GetEditorAs(EditorType type) const
std::unordered_map< EditorType, std::unique_ptr< Editor > > editors_
DungeonEditorV2 * GetDungeonEditor() const
void OpenAssemblyFolder(const std::string &folder_path) const
MusicEditor * GetMusicEditor() const
ScreenEditor * GetScreenEditor() const
void SetGameData(zelda3::GameData *game_data)
bool ShouldTrackAsActiveEditor(EditorType type) const
core::AsarWrapper * GetAsarWrapper() const
std::unique_ptr< GfxGroupWorkspaceState > gfx_group_workspace_
void TrackActiveEditor(Editor *editor)
void ChangeActiveAssemblyFile(std::string_view path) const
size_t session_id() const
void ApplyDependencies(const EditorDependencies &dependencies)
const std::map< std::string, core::AsarSymbol > & GetAssemblySymbols() const
EditorSet(Rom *rom=nullptr, zelda3::GameData *game_data=nullptr, UserSettings *user_settings=nullptr, size_t session_id=0, EditorRegistry *editor_registry=nullptr)
Editor * EnsureEditorCreated(EditorType type) const
SpriteEditor * GetSpriteEditor() const
UserSettings * user_settings_
Editor * GetEditor(EditorType type) const
GraphicsEditor * GetGraphicsEditor() const
int LoadedDungeonRoomCount() const
Editor * FindEditor(EditorType type) const
PaletteEditor * GetPaletteEditor() const
std::unordered_map< EditorType, EditorFactory > editor_factories_
const GfxGroupWorkspaceState * gfx_group_workspace() const
EditorRegistry * editor_registry_
void set_user_settings(UserSettings *settings)
zelda3::Overworld * GetOverworldData() const
GfxGroupWorkspaceState * gfx_group_workspace()
MessageEditor * GetMessageEditor() const
std::function< std::unique_ptr< Editor >()> EditorFactory
int TotalDungeonRoomCount() const
SettingsPanel * GetSettingsPanel() const
std::vector< Editor * > active_editors_
zelda3::GameData * game_data_
OverworldEditor * GetOverworldEditor() const
AssemblyEditor * GetAssemblyEditor() const
std::vector< std::pair< uint32_t, uint32_t > > CollectDungeonWriteRanges() const
Interface for editor classes.
Definition editor.h:240
Allows the user to edit graphics sheets from the game or view prototype graphics.
A class for editing music data in a Rom.
Main UI class for editing overworld maps in A Link to the Past.
Allows the user to view and edit in game palettes.
The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom me...
Manages the settings UI displayed in the right sidebar.
Allows the user to edit sprites.
Manages user preferences and settings persistence.
Represents the full Overworld data, light and dark world.
Definition overworld.h:261
Editors are the view controllers for the application.
Zelda 3 specific classes and functions.
Unified dependency container for all editor types.
Definition editor.h:164
Per-ROM-session UI state shared by all GfxGroupEditor surfaces.
Represents a single session, containing a ROM and its associated editors.
core::FeatureFlags::Flags feature_flags
std::array< bool, kEditorTypeCount > editor_initialized
zelda3::GameData game_data
std::array< bool, kEditorTypeCount > editor_assets_loaded
std::string GetDisplayName() const