3#include <unordered_set>
6#include "absl/strings/str_format.h"
13const std::unordered_map<EditorType, std::string>
91 return "Unknown Editor";
103 const std::string& category) {
104 if (category ==
"Hex") {
108 if (cat == category) {
135 const std::string& category)
const {
136 std::vector<EditorType> editors;
139 if (cat == category) {
140 editors.push_back(type);
148 std::vector<std::string> categories;
149 std::unordered_set<std::string> seen;
152 if (seen.find(category) == seen.end()) {
153 categories.push_back(category);
154 seen.insert(category);
166 return "Unknown Editor";
173 throw std::invalid_argument(
"Editor pointer cannot be null");
177 printf(
"[EditorRegistry] Registered %s\n",
184 throw std::invalid_argument(
"Editor factory cannot be null");
206 return it->second(rom);
215 printf(
"[EditorRegistry] Unregistered %s\n",
235 return *it->second->active();
245 return *it->second->active();
255 it->second->set_active(active);
265 throw std::invalid_argument(
266 absl::StrFormat(
"Invalid editor type: %d",
static_cast<int>(type)));
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
void RegisterEditor(EditorType type, Editor *editor)
static const std::unordered_map< EditorType, std::string > kEditorNames
static bool UpdateAllowedWithoutLoadedRom(EditorType type)
static EditorType GetEditorTypeFromCategory(const std::string &category)
static const std::unordered_map< EditorType, std::string > kEditorCategories
void ValidateEditorType(EditorType type) const
static std::vector< std::string > GetAllEditorCategories()
Get all editor categories in display order for sidebar.
std::vector< EditorType > GetEditorsInCategory(const std::string &category) const
static bool IsPanelBasedEditor(EditorType type)
std::unique_ptr< Editor > CreateEditor(EditorType type, Rom *rom) const
static bool IsExperimentalEditor(EditorType type)
std::function< std::unique_ptr< Editor >(Rom *)> EditorFactory
void SetEditorActive(EditorType type, bool active)
std::string GetEditorDisplayName(EditorType type) const
bool HasFactory(EditorType type) const
void UnregisterEditor(EditorType type)
bool IsEditorActive(EditorType type) const
std::unordered_map< EditorType, EditorFactory > editor_factories_
bool IsValidEditorType(EditorType type) const
void RegisterFactory(EditorType type, EditorFactory factory)
bool IsEditorVisible(EditorType type) const
void UnregisterFactory(EditorType type)
std::vector< std::string > GetAvailableCategories() const
static std::string GetEditorName(EditorType type)
static const std::unordered_map< EditorType, bool > kPanelBasedEditors
Editor * GetEditor(EditorType type) const
static std::string GetEditorCategory(EditorType type)
std::unordered_map< EditorType, Editor * > registered_editors_
Interface for editor classes.