1
0
mirror of synced 2024-11-12 10:10:53 +01:00

ux: Added option to save and load data processors

This commit is contained in:
WerWolv 2022-01-23 02:28:55 +01:00
parent 714d421334
commit 2aed6ec13f
5 changed files with 29 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "content/views/view_data_processor.hpp"
#include <hex/helpers/file.hpp>
#include <hex/providers/provider.hpp>
#include <hex/helpers/project_file_handler.hpp>
@ -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() {

View File

@ -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" },

View File

@ -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" },

View File

@ -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" },

View File

@ -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", "位置" },