diff --git a/lib/libimhex/include/hex/api/plugin_manager.hpp b/lib/libimhex/include/hex/api/plugin_manager.hpp index cbdcb0696..5eccc5450 100644 --- a/lib/libimhex/include/hex/api/plugin_manager.hpp +++ b/lib/libimhex/include/hex/api/plugin_manager.hpp @@ -38,11 +38,12 @@ namespace hex { InitializePluginFunc initializePluginFunction = nullptr; InitializeLibraryFunc initializeLibraryFunction = nullptr; GetPluginNameFunc getPluginNameFunction = nullptr; - GetLibraryNameFunc getLibraryNameFunction = nullptr; + GetLibraryNameFunc getLibraryNameFunction = nullptr; GetPluginAuthorFunc getPluginAuthorFunction = nullptr; GetPluginDescriptionFunc getPluginDescriptionFunction = nullptr; GetCompatibleVersionFunc getCompatibleVersionFunction = nullptr; SetImGuiContextFunc setImGuiContextFunction = nullptr; + SetImGuiContextFunc setImGuiContextLibraryFunction = nullptr; GetSubCommandsFunc getSubCommandsFunction = nullptr; GetFeaturesFunc getFeaturesFunction = nullptr; }; diff --git a/lib/libimhex/include/hex/plugin.hpp b/lib/libimhex/include/hex/plugin.hpp index da50d1236..600a1c5d3 100644 --- a/lib/libimhex/include/hex/plugin.hpp +++ b/lib/libimhex/include/hex/plugin.hpp @@ -52,27 +52,28 @@ void* PluginSubCommandsFunctionHelper::getSubCommands() { #define IMHEX_LIBRARY_SETUP_IMPL(name) \ namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded library '{}'", name); } } HANDLER; } \ - IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \ - IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getLibraryName() { return name; } \ - IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \ + IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME)(); \ + IMHEX_PLUGIN_VISIBILITY_PREFIX const char *WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME)() { return name; } \ + IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME)(ImGuiContext *ctx) { \ ImGui::SetCurrentContext(ctx); \ GImGui = ctx; \ } \ extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \ hex::PluginManager::addPlugin(name, hex::PluginFunctions { \ nullptr, \ - initializeLibrary, \ + WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME), \ nullptr, \ - getLibraryName, \ + WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME), \ nullptr, \ nullptr, \ nullptr, \ - setImGuiContext, \ + WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME), \ + nullptr, \ nullptr, \ nullptr \ }); \ } \ - IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary() + IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME)() #define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \ namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded plugin '{}'", name); } } HANDLER; } \ @@ -101,6 +102,7 @@ void* PluginSubCommandsFunctionHelper::getSubCommands() { getPluginDescription, \ getCompatibleVersion, \ setImGuiContext, \ + nullptr, \ getSubCommands, \ getFeatures \ }); \ diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index 761de70d4..bb476ca21 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -36,16 +36,19 @@ namespace hex { } #endif - m_functions.initializePluginFunction = getPluginFunction("initializePlugin"); - m_functions.initializeLibraryFunction = getPluginFunction("initializeLibrary"); - m_functions.getPluginNameFunction = getPluginFunction("getPluginName"); - m_functions.getLibraryNameFunction = getPluginFunction("getLibraryName"); - m_functions.getPluginAuthorFunction = getPluginFunction("getPluginAuthor"); - m_functions.getPluginDescriptionFunction = getPluginFunction("getPluginDescription"); - m_functions.getCompatibleVersionFunction = getPluginFunction("getCompatibleVersion"); - m_functions.setImGuiContextFunction = getPluginFunction("setImGuiContext"); - m_functions.getSubCommandsFunction = getPluginFunction("getSubCommands"); - m_functions.getFeaturesFunction = getPluginFunction("getFeatures"); + const auto fileName = path.stem().string(); + + m_functions.initializePluginFunction = getPluginFunction("initializePlugin"); + m_functions.initializeLibraryFunction = getPluginFunction(hex::format("initializeLibrary_{}", fileName)); + m_functions.getPluginNameFunction = getPluginFunction("getPluginName"); + m_functions.getLibraryNameFunction = getPluginFunction(hex::format("getLibraryName_{}", fileName)); + m_functions.getPluginAuthorFunction = getPluginFunction("getPluginAuthor"); + m_functions.getPluginDescriptionFunction = getPluginFunction("getPluginDescription"); + m_functions.getCompatibleVersionFunction = getPluginFunction("getCompatibleVersion"); + m_functions.setImGuiContextFunction = getPluginFunction("setImGuiContext"); + m_functions.setImGuiContextLibraryFunction = getPluginFunction(hex::format("setImGuiContext_{}", fileName)); + m_functions.getSubCommandsFunction = getPluginFunction("getSubCommands"); + m_functions.getFeaturesFunction = getPluginFunction("getFeatures"); } Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) { diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index dc453216d..7df11a024 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -198,6 +198,8 @@ namespace hex { ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); + EventFrameBegin::post(); + // Handle all undocked floating windows ImGuiViewport *viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->WorkPos); @@ -220,8 +222,6 @@ namespace hex { ImGui::End(); ImGui::PopStyleVar(2); - EventFrameBegin::post(); - // Plugin load error popups. These are not translated because they should always be readable, no matter if any localization could be loaded or not { auto drawPluginFolderTable = [] { diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index 8983783bb..f05c014e0 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -258,13 +258,22 @@ namespace hex::plugin::builtin { } for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) { - const auto &[unlocalizedNames, icon, shortcut, view, callback, enabledCallback, selectedCallack, toolbarIndex] = menuItem; + const auto &[ + unlocalizedNames, + icon, + shortcut, + view, + callback, + enabledCallback, + selectedCallack, + toolbarIndex + ] = menuItem; createNestedMenu(unlocalizedNames, icon.glyph.c_str(), *shortcut, callback, enabledCallback, selectedCallack); } }; - if (ImHexApi::System::getLastFrameTime() > 0) { + if (ImGui::GetTime() > 0.2F) { static u32 menuEndPos = 0; if (menuEndPos < s_searchBarPosition) { drawMenu();