mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
build/plugin: Make plugins no longer depend on their file name
This commit is contained in:
@@ -22,33 +22,39 @@ namespace hex {
|
||||
[[nodiscard]] std::string getPluginName() const;
|
||||
[[nodiscard]] std::string getPluginAuthor() const;
|
||||
[[nodiscard]] std::string getPluginDescription() const;
|
||||
[[nodiscard]] std::string getCompatibleVersion() const;
|
||||
void setImGuiContext(ImGuiContext *ctx) const;
|
||||
|
||||
[[nodiscard]] const fs::path& getPath() const;
|
||||
|
||||
[[nodiscard]] bool isLoaded() const;
|
||||
private:
|
||||
using InitializePluginFunc = void(*)();
|
||||
using GetPluginNameFunc = const char*(*)();
|
||||
using GetPluginAuthorFunc = const char*(*)();
|
||||
using GetPluginDescriptionFunc = const char*(*)();
|
||||
using GetCompatibleVersionFunc = const char*(*)();
|
||||
using SetImGuiContextFunc = void(*)(ImGuiContext*);
|
||||
|
||||
void *m_handle = nullptr;
|
||||
fs::path m_path;
|
||||
|
||||
mutable bool m_initialized = false;
|
||||
|
||||
InitializePluginFunc m_initializePluginFunction = nullptr;
|
||||
GetPluginNameFunc m_getPluginNameFunction = nullptr;
|
||||
GetPluginAuthorFunc m_getPluginAuthorFunction = nullptr;
|
||||
GetPluginDescriptionFunc m_getPluginDescriptionFunction = nullptr;
|
||||
GetCompatibleVersionFunc m_getCompatibleVersionFunction = nullptr;
|
||||
SetImGuiContextFunc m_setImGuiContextFunction = nullptr;
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] auto getPluginFunction(const std::string &pluginName, const std::string &symbol) {
|
||||
return reinterpret_cast<T>(this->getPluginFunction(pluginName, symbol));
|
||||
[[nodiscard]] auto getPluginFunction(const std::string &symbol) {
|
||||
return reinterpret_cast<T>(this->getPluginFunction(symbol));
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] void* getPluginFunction(const std::string &pluginName, const std::string &symbol);
|
||||
[[nodiscard]] void* getPluginFunction(const std::string &symbol);
|
||||
};
|
||||
|
||||
class PluginManager {
|
||||
|
||||
Reference in New Issue
Block a user