#include #include #include #include #include namespace hex::plugin::builtin { ViewPatternData::ViewPatternData() : View("hex.builtin.view.pattern_data.name") { EventManager::subscribe(this, [this]() { auto patternStyle = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.pattern_tree_style"); if (patternStyle.is_number()) this->m_patternDrawer.setTreeStyle(static_cast(patternStyle.get())); }); EventManager::subscribe(this, [this](auto, auto) { this->m_patternDrawer.reset(); }); } ViewPatternData::~ViewPatternData() { EventManager::unsubscribe(this); EventManager::unsubscribe(this); } void ViewPatternData::drawContent() { if (ImGui::Begin(View::toWindowName("hex.builtin.view.pattern_data.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) { if (ImHexApi::Provider::isValid()) { auto provider = ImHexApi::Provider::get(); auto &patternLanguage = ProviderExtraData::get(provider).patternLanguage; const auto &patterns = [&] -> const auto& { if (provider->isReadable() && patternLanguage.runtime != nullptr && patternLanguage.executionDone) return ProviderExtraData::get(provider).patternLanguage.runtime->getAllPatterns(); else { static const std::vector> empty; return empty; } }(); if (!patternLanguage.executionDone) this->m_patternDrawer.reset(); this->m_patternDrawer.draw(patterns); } } ImGui::End(); } }