yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
content_registry.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_CORE_CONTENT_REGISTRY_H_
2#define YAZE_APP_EDITOR_CORE_CONTENT_REGISTRY_H_
3
4#include <functional>
5#include <memory>
6#include <string>
7#include <vector>
8
9namespace yaze {
10class Rom;
11class EventBus;
12
13namespace project {
14struct YazeProject;
15} // namespace project
16
17namespace zelda3 {
18class GameData;
19} // namespace zelda3
20
21namespace editor {
22class EditorPanel;
23class Editor;
24class GlobalEditorContext;
25struct EditorDependencies;
26
45namespace ContentRegistry {
46
53namespace Context {
54
63
68 Rom* rom();
69
74 void SetRom(Rom* rom);
75
81
87
93
100 void SetCurrentEditor(Editor* editor);
101
107
115
121
129
135 void Clear();
136} // namespace Context
137
147namespace Panels {
148 using PanelFactory = std::function<std::unique_ptr<EditorPanel>()>;
149
154 void RegisterFactory(PanelFactory factory);
155
160 template<typename T>
161 void add() {
162 RegisterFactory([]() { return std::make_unique<T>(); });
163 }
164
169 std::vector<std::unique_ptr<EditorPanel>> CreateAll();
170
175 void Register(std::unique_ptr<EditorPanel> panel);
176
181 std::vector<EditorPanel*> GetAll();
182
188 EditorPanel* Get(const std::string& id);
189
195 void Clear();
196} // namespace Panels
197
201namespace Editors {
202 using EditorFactory = std::function<std::unique_ptr<Editor>(const EditorDependencies&)>;
203
204 void RegisterFactory(EditorFactory factory);
205
206 template<typename T>
207 void add() {
208 RegisterFactory([](const EditorDependencies& deps) {
209 auto editor = std::make_unique<T>();
210 editor->SetDependencies(deps);
211 return editor;
212 });
213 }
214
215 std::vector<std::unique_ptr<Editor>> CreateAll(const EditorDependencies& deps);
216} // namespace Editors
217
222namespace Shortcuts {
223 struct ShortcutDef {
224 std::string id;
225 std::string default_key;
226 std::string description;
227 };
228
229 void Register(const ShortcutDef& shortcut);
230 void add(const std::string& id, const std::string& key, const std::string& desc);
231 std::vector<ShortcutDef> GetAll();
232} // namespace Shortcuts
233
238namespace Settings {
239 struct SettingDef {
240 std::string key;
241 std::string section;
242 std::string default_value; // serialized
243 std::string description;
244 };
245
246 void Register(const SettingDef& setting);
247 void add(const std::string& section, const std::string& key, const std::string& default_val, const std::string& desc);
248 std::vector<SettingDef> GetAll();
249} // namespace Settings
250
251} // namespace ContentRegistry
252
253} // namespace editor
254} // namespace yaze
255
256#endif // YAZE_APP_EDITOR_CORE_CONTENT_REGISTRY_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
Base interface for all logical panel components.
Interface for editor classes.
Definition editor.h:236
Instance-based runtime context replacing ContentRegistry::Context.
void SetGlobalContext(GlobalEditorContext *ctx)
Rom * rom()
Get the current ROM instance.
void SetEventBus(::yaze::EventBus *bus)
Set the current EventBus instance.
::yaze::EventBus * event_bus()
Get the current EventBus instance.
void SetRom(Rom *rom)
Set the current ROM instance.
void SetGameData(::yaze::zelda3::GameData *data)
Set the current game data instance.
Editor * current_editor()
Get the currently active editor.
void SetCurrentEditor(Editor *editor)
Set the currently active editor.
::yaze::zelda3::GameData * game_data()
Get the current game data instance.
::yaze::project::YazeProject * current_project()
Get the current project instance.
void Clear()
Clear all context state.
void SetCurrentProject(::yaze::project::YazeProject *project)
Set the current project instance.
void RegisterFactory(EditorFactory factory)
std::function< std::unique_ptr< Editor >(const EditorDependencies &)> EditorFactory
std::vector< std::unique_ptr< Editor > > CreateAll(const EditorDependencies &deps)
std::vector< std::unique_ptr< EditorPanel > > CreateAll()
Create new instances of all registered panels.
std::vector< EditorPanel * > GetAll()
Get all registered panels.
void Clear()
Clear all registered panels.
void Register(std::unique_ptr< EditorPanel > panel)
Register a panel instance (Legacy/Global).
void add()
Register a panel type for auto-creation.
std::function< std::unique_ptr< EditorPanel >()> PanelFactory
void RegisterFactory(PanelFactory factory)
Register a panel factory.
EditorPanel * Get(const std::string &id)
Get a specific panel by its ID.
void Register(const SettingDef &setting)
void add(const std::string &section, const std::string &key, const std::string &default_val, const std::string &desc)
void add(const std::string &id, const std::string &key, const std::string &desc)
void Register(const ShortcutDef &shortcut)
Unified dependency container for all editor types.
Definition editor.h:163
Modern project structure with comprehensive settings consolidation.
Definition project.h:120