From 2aed6ec13f30ee790cac483fa14de0137ca7a6c2 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 23 Jan 2022 02:28:55 +0100 Subject: [PATCH] ux: Added option to save and load data processors --- .../content/views/view_data_processor.cpp | 21 +++++++++++++++++++ plugins/builtin/source/lang/de_DE.cpp | 2 ++ plugins/builtin/source/lang/en_US.cpp | 2 ++ plugins/builtin/source/lang/it_IT.cpp | 2 ++ plugins/builtin/source/lang/zh_CN.cpp | 2 ++ 5 files changed, 29 insertions(+) diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 75893472e..2ab67ad48 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -1,5 +1,7 @@ #include "content/views/view_data_processor.hpp" +#include + #include #include @@ -44,6 +46,25 @@ namespace hex::plugin::builtin { } this->m_dataOverlays.clear(); }); + + ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 3000, [&, this] { + if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.load_processor"_lang)) { + hex::openFileBrowser("hex.builtin.view.data_processor.menu.file.load_processor"_lang, DialogMode::Open, { { "hex.builtin.view.data_processor.name"_lang, "hexnode"} }, [this](const fs::path &path){ + File file(path, File::Mode::Read); + if (file.isValid()) + this->loadNodes(file.readString()); + }); + } + + if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.save_processor"_lang, nullptr, false, !this->m_nodes.empty())) { + hex::openFileBrowser("hex.builtin.view.data_processor.menu.file.save_processor"_lang, DialogMode::Save, { { "hex.builtin.view.data_processor.name"_lang, "hexnode"} }, [this](const fs::path &path){ + File file(path, File::Mode::Create); + if (file.isValid()) + file.write(this->saveNodes()); + }); + + } + }); } ViewDataProcessor::~ViewDataProcessor() { diff --git a/plugins/builtin/source/lang/de_DE.cpp b/plugins/builtin/source/lang/de_DE.cpp index c99340efe..5418a28cb 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -115,6 +115,8 @@ namespace hex::plugin::builtin { { "hex.builtin.view.data_processor.menu.remove_selection", "Auswahl entfernen" }, { "hex.builtin.view.data_processor.menu.remove_node", "Knoten entfernen" }, { "hex.builtin.view.data_processor.menu.remove_link", "Link entfernen" }, + { "hex.builtin.view.data_processor.menu.file.load_processor", "Datenprozessor laden..." }, + { "hex.builtin.view.data_processor.menu.file.save_processor", "Datenprozessor speichern..." }, { "hex.builtin.view.disassembler.name", "Disassembler" }, { "hex.builtin.view.disassembler.position", "Position" }, diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index 56d35c6bb..3606e7e7c 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -114,6 +114,8 @@ namespace hex::plugin::builtin { { "hex.builtin.view.data_processor.menu.remove_selection", "Remove Selected" }, { "hex.builtin.view.data_processor.menu.remove_node", "Remove Node" }, { "hex.builtin.view.data_processor.menu.remove_link", "Remove Link" }, + { "hex.builtin.view.data_processor.menu.file.load_processor", "Load data processor..." }, + { "hex.builtin.view.data_processor.menu.file.save_processor", "Save data processor..." }, { "hex.builtin.view.disassembler.name", "Disassembler" }, { "hex.builtin.view.disassembler.position", "Position" }, diff --git a/plugins/builtin/source/lang/it_IT.cpp b/plugins/builtin/source/lang/it_IT.cpp index 619dfdafa..690060c95 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -114,6 +114,8 @@ namespace hex::plugin::builtin { { "hex.builtin.view.data_processor.menu.remove_selection", "Rimuovi i selezionati" }, { "hex.builtin.view.data_processor.menu.remove_node", "Rimuovi Nodo" }, { "hex.builtin.view.data_processor.menu.remove_link", "Rimuovi Link" }, + //{ "hex.builtin.view.data_processor.menu.file.load_processor", "Load data processor..." }, + //{ "hex.builtin.view.data_processor.menu.file.save_processor", "Save data processor..." }, { "hex.builtin.view.disassembler.name", "Disassembla" }, { "hex.builtin.view.disassembler.position", "Posiziona" }, diff --git a/plugins/builtin/source/lang/zh_CN.cpp b/plugins/builtin/source/lang/zh_CN.cpp index b81e9af76..63b14f177 100644 --- a/plugins/builtin/source/lang/zh_CN.cpp +++ b/plugins/builtin/source/lang/zh_CN.cpp @@ -114,6 +114,8 @@ namespace hex::plugin::builtin { { "hex.builtin.view.data_processor.menu.remove_selection", "移除已选" }, { "hex.builtin.view.data_processor.menu.remove_node", "移除节点" }, { "hex.builtin.view.data_processor.menu.remove_link", "移除链接" }, + //{ "hex.builtin.view.data_processor.menu.file.load_processor", "Load data processor..." }, + //{ "hex.builtin.view.data_processor.menu.file.save_processor", "Save data processor..." }, { "hex.builtin.view.disassembler.name", "反汇编" }, { "hex.builtin.view.disassembler.position", "位置" },