1
0
mirror of synced 2024-11-28 01:20:51 +01:00

fix: Provider load interface not opening

This commit is contained in:
WerWolv 2023-11-27 15:34:05 +01:00
parent af77b8dfc4
commit 494223fff6
5 changed files with 15 additions and 8 deletions

View File

@ -171,7 +171,7 @@ namespace hex {
if (this->getWindowOpenState()) if (this->getWindowOpenState())
ImGui::OpenPopup(View::toWindowName(this->getUnlocalizedName()).c_str()); 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(); this->drawContent();
ImGui::EndPopup(); ImGui::EndPopup();

View File

@ -469,6 +469,7 @@ namespace hex {
ImGui::SetNextWindowSize(ImVec2(width, dockSpaceSize.y + 11_scaled - footerHeight)); ImGui::SetNextWindowSize(ImVec2(width, dockSpaceSize.y + 11_scaled - footerHeight));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1); 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::Begin("SideBarWindow", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
if (ImGui::BeginTable("##Table", 2)) { if (ImGui::BeginTable("##Table", 2)) {
ImGui::TableSetupColumn("Main", ImGuiTableColumnFlags_WidthStretch, 1.0F); ImGui::TableSetupColumn("Main", ImGuiTableColumnFlags_WidthStretch, 1.0F);
@ -510,6 +511,7 @@ namespace hex {
} }
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::PopStyleColor();
} }
ImGui::NewLine(); ImGui::NewLine();

View File

@ -156,9 +156,7 @@ namespace hex::plugin::builtin {
EventManager::post<EventProviderOpened>(provider); EventManager::post<EventProviderOpened>(provider);
} }
else if (provider->hasLoadInterface()) else if (!provider->hasLoadInterface()) {
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
else {
if (!provider->open() || !provider->isAvailable()) { if (!provider->open() || !provider->isAvailable()) {
PopupError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage())); PopupError::open(hex::format("hex.builtin.provider.error.open"_lang, provider->getErrorMessage()));
TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); }); TaskManager::doLater([provider] { ImHexApi::Provider::remove(provider); });

View File

@ -6,9 +6,9 @@
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
ViewProviderSettings::ViewProviderSettings() : View::Modal("hex.builtin.view.provider_settings.name") { ViewProviderSettings::ViewProviderSettings() : View::Modal("hex.builtin.view.provider_settings.name") {
EventManager::subscribe<EventProviderCreated>(this, [](const hex::prv::Provider *provider) { EventManager::subscribe<EventProviderCreated>(this, [this](const hex::prv::Provider *provider) {
if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface()) if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface())
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup")); this->getWindowOpenState() = true;
}); });
ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] { ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] {
@ -40,9 +40,12 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.common.open"_lang)) { if (ImGui::Button("hex.builtin.common.open"_lang)) {
if (provider->open()) { if (provider->open()) {
EventManager::post<EventProviderOpened>(provider); EventManager::post<EventProviderOpened>(provider);
this->getWindowOpenState() = false;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
else { else {
this->getWindowOpenState() = false;
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
auto errorMessage = provider->getErrorMessage(); auto errorMessage = provider->getErrorMessage();
if (errorMessage.empty()) { if (errorMessage.empty()) {
@ -59,6 +62,7 @@ namespace hex::plugin::builtin {
if (ImGui::Button("hex.builtin.common.cancel"_lang)) { if (ImGui::Button("hex.builtin.common.cancel"_lang)) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
this->getWindowOpenState() = false;
TaskManager::doLater([=] { ImHexApi::Provider::remove(provider); }); TaskManager::doLater([=] { ImHexApi::Provider::remove(provider); });
} }
} }

View File

@ -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::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<Description> getDataDescription() const override { [[nodiscard]] std::vector<Description> 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_name"_lang, this->m_selectedProcess->name },
{ "hex.windows.provider.process_memory.process_id"_lang, std::to_string(this->m_selectedProcess->id) } { "hex.windows.provider.process_memory.process_id"_lang, std::to_string(this->m_selectedProcess->id) }
}; };
} }
[[nodiscard]] bool open() override; [[nodiscard]] bool open() override;