2020-12-27 15:39:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-13 14:08:23 +02:00
|
|
|
#include <string>
|
|
|
|
|
2020-12-27 15:39:06 +01:00
|
|
|
#include <imgui.h>
|
2021-08-21 00:52:11 +02:00
|
|
|
#include <imgui_internal.h>
|
2020-12-27 15:39:06 +01:00
|
|
|
|
|
|
|
#include <hex.hpp>
|
2023-07-13 14:08:23 +02:00
|
|
|
#include <hex/api/plugin_manager.hpp>
|
|
|
|
|
|
|
|
#include <wolv/utils/string.hpp>
|
2023-10-04 12:00:32 +02:00
|
|
|
#include <wolv/utils/preproc.hpp>
|
|
|
|
|
|
|
|
#if defined (IMHEX_STATIC_LINK_PLUGINS)
|
|
|
|
#define IMHEX_PLUGIN_VISIBILITY_PREFIX static
|
|
|
|
#else
|
|
|
|
#define IMHEX_PLUGIN_VISIBILITY_PREFIX extern "C" [[gnu::visibility("default")]]
|
|
|
|
#endif
|
2020-12-27 15:39:06 +01:00
|
|
|
|
2023-04-18 10:06:47 +02:00
|
|
|
/**
|
|
|
|
* This macro is used to define all the required entry points for a plugin.
|
|
|
|
* Name, Author and Description will be displayed in the in the plugin list on the Welcome screen.
|
|
|
|
*/
|
2022-02-02 17:19:50 +01:00
|
|
|
#define IMHEX_PLUGIN_SETUP(name, author, description) IMHEX_PLUGIN_SETUP_IMPL(name, author, description)
|
2021-02-07 13:40:47 +01:00
|
|
|
|
2023-10-04 12:00:32 +02:00
|
|
|
#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginName() { return name; } \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginAuthor() { return author; } \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getPluginDescription() { return description; } \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getCompatibleVersion() { return IMHEX_VERSION; } \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
|
|
|
ImGui::SetCurrentContext(ctx); \
|
|
|
|
GImGui = ctx; \
|
|
|
|
} \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin(); \
|
|
|
|
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
|
|
|
hex::PluginManager::addPlugin(hex::PluginFunctions { \
|
|
|
|
initializePlugin, \
|
|
|
|
getPluginName, \
|
|
|
|
getPluginAuthor, \
|
|
|
|
getPluginDescription, \
|
|
|
|
getCompatibleVersion, \
|
|
|
|
setImGuiContext, \
|
|
|
|
nullptr, \
|
|
|
|
nullptr \
|
|
|
|
}); \
|
|
|
|
} \
|
|
|
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializePlugin()
|
2023-07-13 14:08:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This macro is used to define subcommands defined by the plugin
|
|
|
|
* A subcommand consists of a key, a description, and a callback
|
|
|
|
* The key is what the first argument to ImHex should be, prefixed by `--`
|
|
|
|
* For example, if the key if `help`, ImHex should be started with `--help` as its first argument to trigger the subcommand
|
|
|
|
* when the subcommand is triggerred, it's callback will be executed. The callback is executed BEFORE most of ImHex initialization
|
|
|
|
* so to do anything meaningful, you should subscribe to an event (like EventImHexStartupFinished) and run your code there.
|
|
|
|
*/
|
|
|
|
#define IMHEX_PLUGIN_SUBCOMMANDS() IMHEX_PLUGIN_SUBCOMMANDS_IMPL()
|
|
|
|
|
|
|
|
#define IMHEX_PLUGIN_SUBCOMMANDS_IMPL() \
|
|
|
|
extern std::vector<hex::SubCommand> g_subCommands; \
|
2023-07-21 14:12:08 +02:00
|
|
|
extern "C" [[gnu::visibility("default")]] void* getSubCommands() { \
|
|
|
|
return &g_subCommands; \
|
2023-07-13 14:08:23 +02:00
|
|
|
} \
|
|
|
|
std::vector<hex::SubCommand> g_subCommands
|