31 Rom* current_rom =
nullptr;
36 std::vector<std::unique_ptr<EditorPanel>>
panels;
37 std::vector<ContentRegistry::Panels::PanelFactory>
factories;
39 std::vector<ContentRegistry::Shortcuts::ShortcutDef>
shortcuts;
40 std::vector<ContentRegistry::Settings::SettingDef>
settings;
54namespace ContentRegistry {
59 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
60 RegistryState::Get().global_context = ctx;
64 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
65 auto& state = RegistryState::Get();
66 if (state.global_context)
return state.global_context->GetCurrentRom();
67 return state.current_rom;
71 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
72 auto& state = RegistryState::Get();
73 if (state.global_context) {
74 state.global_context->SetCurrentRom(
rom);
76 state.current_rom =
rom;
80 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
81 auto& state = RegistryState::Get();
82 if (state.global_context)
return &state.global_context->GetEventBus();
83 return state.event_bus;
87 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
88 auto& state = RegistryState::Get();
91 state.event_bus = bus;
95 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
96 auto& state = RegistryState::Get();
97 if (state.global_context)
return state.global_context->GetCurrentEditor();
98 return state.current_editor;
102 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
103 auto& state = RegistryState::Get();
104 if (state.global_context) {
105 state.global_context->SetCurrentEditor(editor);
107 state.current_editor = editor;
111 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
112 auto& state = RegistryState::Get();
113 if (state.global_context)
return state.global_context->GetGameData();
114 return state.game_data;
118 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
119 auto& state = RegistryState::Get();
120 if (state.global_context) {
121 state.global_context->SetGameData(data);
123 state.game_data = data;
127 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
128 auto& state = RegistryState::Get();
129 if (state.global_context)
return state.global_context->GetCurrentProject();
130 return state.current_project;
134 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
135 auto& state = RegistryState::Get();
136 if (state.global_context) {
137 state.global_context->SetCurrentProject(project);
139 state.current_project = project;
143 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
144 auto& state = RegistryState::Get();
145 if (state.global_context) {
146 state.global_context->Clear();
148 state.current_rom =
nullptr;
149 state.event_bus =
nullptr;
150 state.current_editor =
nullptr;
151 state.game_data =
nullptr;
152 state.current_project =
nullptr;
164 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
165 RegistryState::Get().factories.push_back(std::move(factory));
169 std::vector<PanelFactory> factories;
171 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
172 factories = RegistryState::Get().factories;
175 std::vector<std::unique_ptr<EditorPanel>> result;
176 result.reserve(factories.size());
178 for (
const auto& factory : factories) {
179 if (
auto panel = factory()) {
180 result.push_back(std::move(panel));
189 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
190 RegistryState::Get().panels.push_back(std::move(panel));
194 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
196 std::vector<EditorPanel*> result;
197 result.reserve(RegistryState::Get().panels.size());
199 for (
const auto& panel : RegistryState::Get().panels) {
200 result.push_back(panel.get());
207 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
209 for (
const auto& panel : RegistryState::Get().panels) {
210 if (panel->GetId() == id) {
219 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
220 RegistryState::Get().panels.clear();
232 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
233 RegistryState::Get().editor_factories.push_back(std::move(factory));
237 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
238 std::vector<std::unique_ptr<Editor>> result;
239 result.reserve(RegistryState::Get().editor_factories.size());
241 for (
const auto& factory : RegistryState::Get().editor_factories) {
242 if (
auto editor = factory(deps)) {
243 result.push_back(std::move(editor));
258 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
259 RegistryState::Get().shortcuts.push_back(shortcut);
262void add(
const std::string&
id,
const std::string& key,
const std::string& desc) {
267 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
268 return RegistryState::Get().shortcuts;
280 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
281 RegistryState::Get().settings.push_back(setting);
284void add(
const std::string& section,
const std::string& key,
const std::string& default_val,
const std::string& desc) {
285 Register({key, section, default_val, desc});
289 std::lock_guard<std::mutex> lock(RegistryState::Get().mutex);
290 return RegistryState::Get().settings;
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Base interface for all logical panel components.
Interface for editor classes.
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).
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)
std::vector< SettingDef > GetAll()
void add(const std::string §ion, const std::string &key, const std::string &default_val, const std::string &desc)
std::vector< ShortcutDef > GetAll()
void add(const std::string &id, const std::string &key, const std::string &desc)
void Register(const ShortcutDef &shortcut)
Editors are the view controllers for the application.
Unified dependency container for all editor types.
std::vector< std::unique_ptr< EditorPanel > > panels
std::vector< ContentRegistry::Shortcuts::ShortcutDef > shortcuts
std::vector< ContentRegistry::Panels::PanelFactory > factories
static RegistryState & Get()
std::vector< ContentRegistry::Editors::EditorFactory > editor_factories
std::vector< ContentRegistry::Settings::SettingDef > settings
Modern project structure with comprehensive settings consolidation.