mirror of https://github.com/WerWolv/ImHex.git
fix: Linking issues and menu bar not appearing sometimes
This commit is contained in:
parent
339541a56f
commit
cecb8b8d31
|
@ -38,11 +38,12 @@ namespace hex {
|
||||||
InitializePluginFunc initializePluginFunction = nullptr;
|
InitializePluginFunc initializePluginFunction = nullptr;
|
||||||
InitializeLibraryFunc initializeLibraryFunction = nullptr;
|
InitializeLibraryFunc initializeLibraryFunction = nullptr;
|
||||||
GetPluginNameFunc getPluginNameFunction = nullptr;
|
GetPluginNameFunc getPluginNameFunction = nullptr;
|
||||||
GetLibraryNameFunc getLibraryNameFunction = nullptr;
|
GetLibraryNameFunc getLibraryNameFunction = nullptr;
|
||||||
GetPluginAuthorFunc getPluginAuthorFunction = nullptr;
|
GetPluginAuthorFunc getPluginAuthorFunction = nullptr;
|
||||||
GetPluginDescriptionFunc getPluginDescriptionFunction = nullptr;
|
GetPluginDescriptionFunc getPluginDescriptionFunction = nullptr;
|
||||||
GetCompatibleVersionFunc getCompatibleVersionFunction = nullptr;
|
GetCompatibleVersionFunc getCompatibleVersionFunction = nullptr;
|
||||||
SetImGuiContextFunc setImGuiContextFunction = nullptr;
|
SetImGuiContextFunc setImGuiContextFunction = nullptr;
|
||||||
|
SetImGuiContextFunc setImGuiContextLibraryFunction = nullptr;
|
||||||
GetSubCommandsFunc getSubCommandsFunction = nullptr;
|
GetSubCommandsFunc getSubCommandsFunction = nullptr;
|
||||||
GetFeaturesFunc getFeaturesFunction = nullptr;
|
GetFeaturesFunc getFeaturesFunction = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,27 +52,28 @@ void* PluginSubCommandsFunctionHelper<T>::getSubCommands() {
|
||||||
|
|
||||||
#define IMHEX_LIBRARY_SETUP_IMPL(name) \
|
#define IMHEX_LIBRARY_SETUP_IMPL(name) \
|
||||||
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded library '{}'", name); } } HANDLER; } \
|
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded library '{}'", name); } } HANDLER; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void initializeLibrary(); \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME)(); \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *getLibraryName() { return name; } \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX const char *WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME)() { return name; } \
|
||||||
IMHEX_PLUGIN_VISIBILITY_PREFIX void setImGuiContext(ImGuiContext *ctx) { \
|
IMHEX_PLUGIN_VISIBILITY_PREFIX void WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME)(ImGuiContext *ctx) { \
|
||||||
ImGui::SetCurrentContext(ctx); \
|
ImGui::SetCurrentContext(ctx); \
|
||||||
GImGui = ctx; \
|
GImGui = ctx; \
|
||||||
} \
|
} \
|
||||||
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
extern "C" [[gnu::visibility("default")]] void WOLV_TOKEN_CONCAT(forceLinkPlugin_, IMHEX_PLUGIN_NAME)() { \
|
||||||
hex::PluginManager::addPlugin(name, hex::PluginFunctions { \
|
hex::PluginManager::addPlugin(name, hex::PluginFunctions { \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
initializeLibrary, \
|
WOLV_TOKEN_CONCAT(initializeLibrary_, IMHEX_PLUGIN_NAME), \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
getLibraryName, \
|
WOLV_TOKEN_CONCAT(getLibraryName_, IMHEX_PLUGIN_NAME), \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
nullptr, \
|
nullptr, \
|
||||||
setImGuiContext, \
|
WOLV_TOKEN_CONCAT(setImGuiContext_, IMHEX_PLUGIN_NAME), \
|
||||||
|
nullptr, \
|
||||||
nullptr, \
|
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) \
|
#define IMHEX_PLUGIN_SETUP_IMPL(name, author, description) \
|
||||||
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded plugin '{}'", name); } } HANDLER; } \
|
namespace { static struct EXIT_HANDLER { ~EXIT_HANDLER() { hex::log::debug("Unloaded plugin '{}'", name); } } HANDLER; } \
|
||||||
|
@ -101,6 +102,7 @@ void* PluginSubCommandsFunctionHelper<T>::getSubCommands() {
|
||||||
getPluginDescription, \
|
getPluginDescription, \
|
||||||
getCompatibleVersion, \
|
getCompatibleVersion, \
|
||||||
setImGuiContext, \
|
setImGuiContext, \
|
||||||
|
nullptr, \
|
||||||
getSubCommands, \
|
getSubCommands, \
|
||||||
getFeatures \
|
getFeatures \
|
||||||
}); \
|
}); \
|
||||||
|
|
|
@ -36,16 +36,19 @@ namespace hex {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_functions.initializePluginFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializePlugin");
|
const auto fileName = path.stem().string();
|
||||||
m_functions.initializeLibraryFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializeLibrary");
|
|
||||||
m_functions.getPluginNameFunction = getPluginFunction<PluginFunctions::GetPluginNameFunc>("getPluginName");
|
m_functions.initializePluginFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>("initializePlugin");
|
||||||
m_functions.getLibraryNameFunction = getPluginFunction<PluginFunctions::GetLibraryNameFunc>("getLibraryName");
|
m_functions.initializeLibraryFunction = getPluginFunction<PluginFunctions::InitializePluginFunc>(hex::format("initializeLibrary_{}", fileName));
|
||||||
m_functions.getPluginAuthorFunction = getPluginFunction<PluginFunctions::GetPluginAuthorFunc>("getPluginAuthor");
|
m_functions.getPluginNameFunction = getPluginFunction<PluginFunctions::GetPluginNameFunc>("getPluginName");
|
||||||
m_functions.getPluginDescriptionFunction = getPluginFunction<PluginFunctions::GetPluginDescriptionFunc>("getPluginDescription");
|
m_functions.getLibraryNameFunction = getPluginFunction<PluginFunctions::GetLibraryNameFunc>(hex::format("getLibraryName_{}", fileName));
|
||||||
m_functions.getCompatibleVersionFunction = getPluginFunction<PluginFunctions::GetCompatibleVersionFunc>("getCompatibleVersion");
|
m_functions.getPluginAuthorFunction = getPluginFunction<PluginFunctions::GetPluginAuthorFunc>("getPluginAuthor");
|
||||||
m_functions.setImGuiContextFunction = getPluginFunction<PluginFunctions::SetImGuiContextFunc>("setImGuiContext");
|
m_functions.getPluginDescriptionFunction = getPluginFunction<PluginFunctions::GetPluginDescriptionFunc>("getPluginDescription");
|
||||||
m_functions.getSubCommandsFunction = getPluginFunction<PluginFunctions::GetSubCommandsFunc>("getSubCommands");
|
m_functions.getCompatibleVersionFunction = getPluginFunction<PluginFunctions::GetCompatibleVersionFunc>("getCompatibleVersion");
|
||||||
m_functions.getFeaturesFunction = getPluginFunction<PluginFunctions::GetSubCommandsFunc>("getFeatures");
|
m_functions.setImGuiContextFunction = getPluginFunction<PluginFunctions::SetImGuiContextFunc>("setImGuiContext");
|
||||||
|
m_functions.setImGuiContextLibraryFunction = getPluginFunction<PluginFunctions::SetImGuiContextFunc>(hex::format("setImGuiContext_{}", fileName));
|
||||||
|
m_functions.getSubCommandsFunction = getPluginFunction<PluginFunctions::GetSubCommandsFunc>("getSubCommands");
|
||||||
|
m_functions.getFeaturesFunction = getPluginFunction<PluginFunctions::GetSubCommandsFunc>("getFeatures");
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) {
|
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) {
|
||||||
|
|
|
@ -198,6 +198,8 @@ namespace hex {
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
EventFrameBegin::post();
|
||||||
|
|
||||||
// Handle all undocked floating windows
|
// Handle all undocked floating windows
|
||||||
ImGuiViewport *viewport = ImGui::GetMainViewport();
|
ImGuiViewport *viewport = ImGui::GetMainViewport();
|
||||||
ImGui::SetNextWindowPos(viewport->WorkPos);
|
ImGui::SetNextWindowPos(viewport->WorkPos);
|
||||||
|
@ -220,8 +222,6 @@ namespace hex {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
ImGui::PopStyleVar(2);
|
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
|
// 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 = [] {
|
auto drawPluginFolderTable = [] {
|
||||||
|
|
|
@ -258,13 +258,22 @@ namespace hex::plugin::builtin {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::impl::getMenuItems()) {
|
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);
|
createNestedMenu(unlocalizedNames, icon.glyph.c_str(), *shortcut, callback, enabledCallback, selectedCallack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ImHexApi::System::getLastFrameTime() > 0) {
|
if (ImGui::GetTime() > 0.2F) {
|
||||||
static u32 menuEndPos = 0;
|
static u32 menuEndPos = 0;
|
||||||
if (menuEndPos < s_searchBarPosition) {
|
if (menuEndPos < s_searchBarPosition) {
|
||||||
drawMenu();
|
drawMenu();
|
||||||
|
|
Loading…
Reference in New Issue