1
0
mirror of synced 2025-02-06 14:14:22 +01:00

feat: Turn provider settings into sidebar

This commit is contained in:
WerWolv 2023-11-14 15:55:34 +01:00
parent 33e20df511
commit b78435c881

View File

@ -1,6 +1,7 @@
#include "content/views/view_provider_settings.hpp" #include "content/views/view_provider_settings.hpp"
#include <content/popups/popup_notification.hpp> #include <content/popups/popup_notification.hpp>
#include <hex/api/content_registry.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
@ -9,6 +10,18 @@ namespace hex::plugin::builtin {
if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface()) if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface())
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup")); EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
}); });
ContentRegistry::Interface::addSidebarItem(ICON_VS_SERVER_PROCESS, [] {
auto provider = hex::ImHexApi::Provider::get();
if (provider != nullptr)
provider->drawInterface();
},
[] {
auto provider = hex::ImHexApi::Provider::get();
return provider != nullptr && provider->hasInterface() && provider->isAvailable();
});
} }
ViewProviderSettings::~ViewProviderSettings() { ViewProviderSettings::~ViewProviderSettings() {
@ -16,13 +29,7 @@ namespace hex::plugin::builtin {
} }
void ViewProviderSettings::drawContent() { void ViewProviderSettings::drawContent() {
if (ImGui::Begin(this->getName().c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = hex::ImHexApi::Provider::get();
if (provider != nullptr)
provider->drawInterface();
}
ImGui::End();
} }
void ViewProviderSettings::drawAlwaysVisible() { void ViewProviderSettings::drawAlwaysVisible() {
@ -68,13 +75,11 @@ namespace hex::plugin::builtin {
} }
bool ViewProviderSettings::hasViewMenuItemEntry() const { bool ViewProviderSettings::hasViewMenuItemEntry() const {
return this->isAvailable(); return false;
} }
bool ViewProviderSettings::isAvailable() const { bool ViewProviderSettings::isAvailable() const {
auto provider = hex::ImHexApi::Provider::get(); return false;
return provider != nullptr && provider->hasInterface() && provider->isAvailable();
} }
} }