mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
Added data inspector to content registry
This commit is contained in:
@@ -108,10 +108,36 @@ namespace hex {
|
||||
|
||||
/* Tools Registry. Allows adding new entries to the tools window */
|
||||
struct Tools {
|
||||
Tools() = delete;
|
||||
|
||||
static void add(const std::function<void()> &function);
|
||||
|
||||
static std::vector<std::function<void()>>& getEntries();
|
||||
};
|
||||
|
||||
/* Data Inspector Registry. Allows adding of new types to the data inspector */
|
||||
struct DataInspector {
|
||||
DataInspector() = delete;
|
||||
|
||||
enum class NumberDisplayStyle {
|
||||
Decimal,
|
||||
Hexadecimal,
|
||||
Octal
|
||||
};
|
||||
|
||||
using DisplayFunction = std::function<void()>;
|
||||
using GeneratorFunction = std::function<DisplayFunction(const std::vector<u8>&, std::endian, NumberDisplayStyle)>;
|
||||
|
||||
struct Entry {
|
||||
std::string name;
|
||||
size_t requiredSize;
|
||||
GeneratorFunction generatorFunction;
|
||||
};
|
||||
|
||||
static void add(std::string_view name, size_t requiredSize, GeneratorFunction function);
|
||||
|
||||
static std::vector<Entry>& getEntries();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -51,7 +51,8 @@ namespace hex {
|
||||
static std::vector<ContentRegistry::CommandPaletteCommands::Entry> commandPaletteCommands;
|
||||
static std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function> patternLanguageFunctions;
|
||||
static std::vector<View*> views;
|
||||
static std::vector<std::function<void()>> tools;
|
||||
static std::vector<std::function<void()>> toolsEntries;
|
||||
static std::vector<ContentRegistry::DataInspector::Entry> dataInspectorEntries;
|
||||
|
||||
static int mainArgc;
|
||||
static char **mainArgv;
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
#include <helpers/shared_data.hpp>
|
||||
#include <helpers/content_registry.hpp>
|
||||
|
||||
#define IMHEX_PLUGIN_SETUP namespace hex::plugin { void setup(); } \
|
||||
namespace hex::plugin::internal { \
|
||||
void initializePlugin() { \
|
||||
hex::plugin::setup(); \
|
||||
} \
|
||||
} \
|
||||
void hex::plugin::setup()
|
||||
#define IMHEX_PLUGIN_SETUP namespace hex::plugin::internal { \
|
||||
void initializePlugin(); \
|
||||
} \
|
||||
void hex::plugin::internal::initializePlugin()
|
||||
|
||||
@@ -107,7 +107,17 @@ namespace hex {
|
||||
}
|
||||
|
||||
std::vector<std::function<void()>>& ContentRegistry::Tools::getEntries() {
|
||||
return SharedData::tools;
|
||||
return SharedData::toolsEntries;
|
||||
}
|
||||
|
||||
|
||||
/* Data Inspector */
|
||||
|
||||
void ContentRegistry::DataInspector::add(std::string_view name, size_t requiredSize, ContentRegistry::DataInspector::GeneratorFunction function) {
|
||||
getEntries().push_back(Entry{ name.data(), requiredSize, function });
|
||||
}
|
||||
|
||||
std::vector<ContentRegistry::DataInspector::Entry>& ContentRegistry::DataInspector::getEntries() {
|
||||
return SharedData::dataInspectorEntries;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ namespace hex {
|
||||
std::vector<ContentRegistry::CommandPaletteCommands::Entry> SharedData::commandPaletteCommands;
|
||||
std::map<std::string, ContentRegistry::PatternLanguageFunctions::Function> SharedData::patternLanguageFunctions;
|
||||
std::vector<View*> SharedData::views;
|
||||
std::vector<std::function<void()>> SharedData::tools;
|
||||
std::vector<std::function<void()>> SharedData::toolsEntries;
|
||||
std::vector<ContentRegistry::DataInspector::Entry> SharedData::dataInspectorEntries;
|
||||
|
||||
int SharedData::mainArgc;
|
||||
char **SharedData::mainArgv;
|
||||
|
||||
Reference in New Issue
Block a user