3#include <unordered_set>
6#include "absl/strings/str_format.h"
13const std::unordered_map<EditorType, std::string>
74 const std::string& category) {
75 if (category ==
"Hex") {
79 if (cat == category) {
106 const std::string& category)
const {
107 std::vector<EditorType> editors;
110 if (cat == category) {
111 editors.push_back(type);
119 std::vector<std::string> categories;
120 std::unordered_set<std::string> seen;
123 if (seen.find(category) == seen.end()) {
124 categories.push_back(category);
125 seen.insert(category);
137 return "Unknown Editor";
144 throw std::invalid_argument(
"Editor pointer cannot be null");
148 printf(
"[EditorRegistry] Registered %s\n",
155 throw std::invalid_argument(
"Editor factory cannot be null");
177 return it->second(rom);
186 printf(
"[EditorRegistry] Unregistered %s\n",
206 return *it->second->active();
216 return *it->second->active();
226 it->second->set_active(active);
236 throw std::invalid_argument(
237 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 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
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 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.