mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
nodes: Added support for nested, shareable, custom data processor nodes
This commit is contained in:
@@ -63,12 +63,16 @@ namespace hex::plugin::builtin {
|
||||
std::list<ImHexApi::Bookmarks::Entry> bookmarks;
|
||||
|
||||
struct DataProcessor {
|
||||
std::list<dp::Node*> endNodes;
|
||||
std::list<std::unique_ptr<dp::Node>> nodes;
|
||||
std::list<dp::Link> links;
|
||||
struct Workspace {
|
||||
std::list<std::unique_ptr<dp::Node>> nodes;
|
||||
std::list<dp::Node*> endNodes;
|
||||
std::list<dp::Link> links;
|
||||
std::vector<hex::prv::Overlay *> dataOverlays;
|
||||
std::optional<dp::Node::NodeError> currNodeError;
|
||||
};
|
||||
|
||||
std::vector<hex::prv::Overlay *> dataOverlays;
|
||||
std::optional<dp::Node::NodeError> currNodeError;
|
||||
Workspace mainWorkspace;
|
||||
std::vector<Workspace*> workspaceStack;
|
||||
} dataProcessor;
|
||||
|
||||
struct HexEditor {
|
||||
@@ -101,7 +105,7 @@ namespace hex::plugin::builtin {
|
||||
return get(ImHexApi::Provider::get());
|
||||
}
|
||||
|
||||
static Data& get(hex::prv::Provider *provider) {
|
||||
static Data& get(const hex::prv::Provider *provider) {
|
||||
return s_data[provider];
|
||||
}
|
||||
|
||||
@@ -115,7 +119,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
private:
|
||||
ProviderExtraData() = default;
|
||||
static inline std::map<hex::prv::Provider*, Data> s_data = {};
|
||||
static inline std::map<const hex::prv::Provider*, Data> s_data = {};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <hex/data_processor/node.hpp>
|
||||
#include <hex/data_processor/link.hpp>
|
||||
|
||||
#include "content/helpers/provider_extra_data.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
@@ -14,24 +16,38 @@ namespace hex::plugin::builtin {
|
||||
|
||||
class ViewDataProcessor : public View {
|
||||
public:
|
||||
using Workspace = ProviderExtraData::Data::DataProcessor::Workspace;
|
||||
|
||||
ViewDataProcessor();
|
||||
~ViewDataProcessor() override;
|
||||
|
||||
void drawContent() override;
|
||||
|
||||
static nlohmann::json saveNode(const dp::Node *node);
|
||||
static nlohmann::json saveNodes(const Workspace &workspace);
|
||||
|
||||
static std::unique_ptr<dp::Node> loadNode(const nlohmann::json &data);
|
||||
static void loadNodes(Workspace &workspace, const nlohmann::json &data);
|
||||
|
||||
private:
|
||||
bool m_justSwitchedProvider = false;
|
||||
static void eraseLink(Workspace &workspace, int id);
|
||||
static void eraseNodes(Workspace &workspace, const std::vector<int> &ids);
|
||||
static void processNodes(Workspace &workspace);
|
||||
|
||||
void reloadCustomNodes();
|
||||
private:
|
||||
bool m_updateNodePositions = false;
|
||||
int m_rightClickedId = -1;
|
||||
ImVec2 m_rightClickedCoords;
|
||||
|
||||
bool m_continuousEvaluation = false;
|
||||
|
||||
void eraseLink(int id);
|
||||
void eraseNodes(const std::vector<int> &ids);
|
||||
void processNodes();
|
||||
struct CustomNode {
|
||||
std::string name;
|
||||
nlohmann::json data;
|
||||
};
|
||||
|
||||
std::string saveNodes(prv::Provider *provider);
|
||||
void loadNodes(prv::Provider *provider, const std::string &data);
|
||||
std::vector<CustomNode> m_customNodes;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user