From 0a9dca5be7cbf5a47425f152907a48e2a51dc387 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 21 Feb 2024 23:21:24 +0100 Subject: [PATCH] impr: Save data information view settings to projects --- .../source/content/views/view_information.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index 82cf6012a..87a17642b 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -21,6 +22,34 @@ namespace hex::plugin::builtin { data.informationSections.push_back(informationSectionConstructor()); } }); + + ProjectFile::registerPerProviderHandler({ + .basePath = "data_information.json", + .required = false, + .load = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { + std::string save = tar.readString(basePath); + nlohmann::json input = nlohmann::json::parse(save); + + for (const auto §ion : m_analysisData.get(provider).informationSections) { + if (!input.contains(section->getUnlocalizedName().get())) + continue; + + section->load(input[section->getUnlocalizedName().get()]); + } + + return true; + }, + .store = [this](prv::Provider *provider, const std::fs::path &basePath, const Tar &tar) { + nlohmann::json output; + for (const auto §ion : m_analysisData.get(provider).informationSections) { + output[section->getUnlocalizedName().get()] = section->store(); + } + + tar.writeString(basePath, output.dump(4)); + + return true; + } + }); } void ViewInformation::analyze() {