2021-12-12 00:41:44 +01:00
|
|
|
#include "content/views/view_provider_settings.hpp"
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
ViewProviderSettings::ViewProviderSettings() : hex::View("hex.builtin.view.provider_settings.name") {
|
|
|
|
EventManager::subscribe<EventProviderCreated>(this, [](hex::prv::Provider *provider){
|
|
|
|
if (provider->hasLoadInterface())
|
|
|
|
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewProviderSettings::~ViewProviderSettings() {
|
|
|
|
EventManager::unsubscribe<EventProviderCreated>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewProviderSettings::drawContent() {
|
|
|
|
if (ImGui::Begin(View::toWindowName("hex.builtin.view.provider_settings.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
|
|
|
auto provider = hex::ImHexApi::Provider::get();
|
|
|
|
|
|
|
|
if (provider != nullptr)
|
|
|
|
provider->drawInterface();
|
|
|
|
}
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ViewProviderSettings::drawAlwaysVisible() {
|
|
|
|
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F));
|
|
|
|
if (ImGui::BeginPopupModal(View::toWindowName("hex.builtin.view.provider_settings.load_popup").c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
|
|
|
|
|
auto provider = hex::ImHexApi::Provider::get();
|
|
|
|
|
|
|
|
if (provider != nullptr) {
|
|
|
|
provider->drawLoadInterface();
|
|
|
|
|
|
|
|
ImGui::NewLine();
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
if (ImGui::Button("hex.common.open"_lang)) {
|
|
|
|
if (provider->open())
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Button("hex.common.cancel"_lang)) {
|
|
|
|
ImHexApi::Provider::remove(provider);
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-10 21:05:37 +01:00
|
|
|
bool ViewProviderSettings::hasViewMenuItemEntry() const {
|
2021-12-12 00:41:44 +01:00
|
|
|
return this->isAvailable();
|
|
|
|
}
|
|
|
|
|
2022-01-10 21:05:37 +01:00
|
|
|
bool ViewProviderSettings::isAvailable() const {
|
2021-12-12 00:41:44 +01:00
|
|
|
auto provider = hex::ImHexApi::Provider::get();
|
|
|
|
|
|
|
|
return provider != nullptr && provider->hasInterface();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|