From 494223fff61024197692a098666b146284eec3b9 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 27 Nov 2023 15:34:05 +0100 Subject: [PATCH] fix: Provider load interface not opening --- lib/libimhex/include/hex/ui/view.hpp | 2 +- main/gui/source/window/window.cpp | 2 ++ plugins/builtin/source/content/events.cpp | 4 +--- .../source/content/views/view_provider_settings.cpp | 8 ++++++-- .../include/content/providers/process_memory_provider.hpp | 7 +++++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/libimhex/include/hex/ui/view.hpp b/lib/libimhex/include/hex/ui/view.hpp index 80aa4826d..0418a3025 100644 --- a/lib/libimhex/include/hex/ui/view.hpp +++ b/lib/libimhex/include/hex/ui/view.hpp @@ -171,7 +171,7 @@ namespace hex { if (this->getWindowOpenState()) ImGui::OpenPopup(View::toWindowName(this->getUnlocalizedName()).c_str()); - if (ImGui::BeginPopupModal(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | this->getWindowFlags())) { + if (ImGui::BeginPopupModal(View::toWindowName(this->getUnlocalizedName()).c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | this->getWindowFlags())) { this->drawContent(); ImGui::EndPopup(); diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index b43892092..adae10f2b 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -469,6 +469,7 @@ namespace hex { ImGui::SetNextWindowSize(ImVec2(width, dockSpaceSize.y + 11_scaled - footerHeight)); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1); + ImGui::PushStyleColor(ImGuiCol_WindowShadow, 0x00000000); if (ImGui::Begin("SideBarWindow", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) { if (ImGui::BeginTable("##Table", 2)) { ImGui::TableSetupColumn("Main", ImGuiTableColumnFlags_WidthStretch, 1.0F); @@ -510,6 +511,7 @@ namespace hex { } ImGui::End(); ImGui::PopStyleVar(); + ImGui::PopStyleColor(); } ImGui::NewLine(); diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 45d9fd31d..7227c0246 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -156,9 +156,7 @@ namespace hex::plugin::builtin { EventManager::post(provider); } - else if (provider->hasLoadInterface()) - EventManager::post(View::toWindowName("hex.builtin.view.provider_settings.load_popup")); - else { + else if (!provider->hasLoadInterface()) { if (!provider->open() || !provider->isAvailable()) { PopupError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); diff --git a/plugins/builtin/source/content/views/view_provider_settings.cpp b/plugins/builtin/source/content/views/view_provider_settings.cpp index 2a0e293da..aced4d072 100644 --- a/plugins/builtin/source/content/views/view_provider_settings.cpp +++ b/plugins/builtin/source/content/views/view_provider_settings.cpp @@ -6,9 +6,9 @@ namespace hex::plugin::builtin { ViewProviderSettings::ViewProviderSettings() : View::Modal("hex.builtin.view.provider_settings.name") { - EventManager::subscribe(this, [](const hex::prv::Provider *provider) { + EventManager::subscribe(this, [this](const hex::prv::Provider *provider) { if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface()) - EventManager::post(View::toWindowName("hex.builtin.view.provider_settings.load_popup")); + this->getWindowOpenState() = true; }); ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] { @@ -40,9 +40,12 @@ namespace hex::plugin::builtin { if (ImGui::Button("hex.builtin.common.open"_lang)) { if (provider->open()) { EventManager::post(provider); + + this->getWindowOpenState() = false; ImGui::CloseCurrentPopup(); } else { + this->getWindowOpenState() = false; ImGui::CloseCurrentPopup(); auto errorMessage = provider->getErrorMessage(); if (errorMessage.empty()) { @@ -59,6 +62,7 @@ namespace hex::plugin::builtin { if (ImGui::Button("hex.builtin.common.cancel"_lang)) { ImGui::CloseCurrentPopup(); + this->getWindowOpenState() = false; TaskManager::doLater([=] { ImHexApi::Provider::remove(provider); }); } } diff --git a/plugins/windows/include/content/providers/process_memory_provider.hpp b/plugins/windows/include/content/providers/process_memory_provider.hpp index dd7c1e059..f9b96af8d 100644 --- a/plugins/windows/include/content/providers/process_memory_provider.hpp +++ b/plugins/windows/include/content/providers/process_memory_provider.hpp @@ -37,10 +37,13 @@ namespace hex::plugin::windows { [[nodiscard]] std::string getName() const override { return hex::format("hex.windows.provider.process_memory.name"_lang, this->m_selectedProcess != nullptr ? this->m_selectedProcess->name : ""); } [[nodiscard]] std::vector getDataDescription() const override { - return { + if (this->m_selectedProcess == nullptr) + return {}; + else + return { { "hex.windows.provider.process_memory.process_name"_lang, this->m_selectedProcess->name }, { "hex.windows.provider.process_memory.process_id"_lang, std::to_string(this->m_selectedProcess->id) } - }; + }; } [[nodiscard]] bool open() override;