mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
nodes: Added primitive saving and loading mechanism
Not fully integrated yet. Also doesn't yet save any node settings, just nodes and links
This commit is contained in:
@@ -160,7 +160,13 @@ namespace hex {
|
||||
|
||||
template<hex::derived_from<dp::Node> T, typename ... Args>
|
||||
static void add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, Args&& ... args) {
|
||||
add(Entry{ unlocalizedCategory.data(), unlocalizedName.data(), [args...]{ return new T(std::forward<Args>(args)...); } });
|
||||
add(Entry{ unlocalizedCategory.data(), unlocalizedName.data(),
|
||||
[args..., name = std::string(unlocalizedName)]{
|
||||
auto node = new T(std::forward<Args>(args)...);
|
||||
node->setUnlocalizedName(name);
|
||||
return node;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void addSeparator();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace hex::dp {
|
||||
In, Out
|
||||
};
|
||||
|
||||
Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorNodeIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
|
||||
Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorAttrIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace hex::dp {
|
||||
}
|
||||
|
||||
[[nodiscard]] u32 getID() const { return this->m_id; }
|
||||
void setID(u32 id) { this->m_id = id; }
|
||||
|
||||
[[nodiscard]] IOType getIOType() const { return this->m_ioType; }
|
||||
[[nodiscard]] Type getType() const { return this->m_type; }
|
||||
[[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; }
|
||||
|
||||
@@ -4,9 +4,11 @@ namespace hex::dp {
|
||||
|
||||
class Link {
|
||||
public:
|
||||
Link(u32 from, u32 to) : m_id(SharedData::dataProcessorNodeIdCounter++), m_from(from), m_to(to) { }
|
||||
Link(u32 from, u32 to) : m_id(SharedData::dataProcessorLinkIdCounter++), m_from(from), m_to(to) { }
|
||||
|
||||
[[nodiscard]] u32 getID() const { return this->m_id; }
|
||||
void setID(u32 id) { this->m_id = id; }
|
||||
|
||||
[[nodiscard]] u32 getFromID() const { return this->m_from; }
|
||||
[[nodiscard]] u32 getToID() const { return this->m_to; }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace hex::dp {
|
||||
|
||||
class Node {
|
||||
public:
|
||||
Node(std::string_view unlocalizedName, std::vector<Attribute> attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_unlocalizedName(unlocalizedName), m_attributes(std::move(attributes)) {
|
||||
Node(std::string_view unlocalizedTitle, std::vector<Attribute> attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_unlocalizedTitle(unlocalizedTitle), m_attributes(std::move(attributes)) {
|
||||
for (auto &attr : this->m_attributes)
|
||||
attr.setParentNode(this);
|
||||
}
|
||||
@@ -17,7 +17,12 @@ namespace hex::dp {
|
||||
virtual ~Node() = default;
|
||||
|
||||
[[nodiscard]] u32 getID() const { return this->m_id; }
|
||||
void setID(u32 id) { this->m_id = id; }
|
||||
|
||||
[[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; }
|
||||
void setUnlocalizedName(std::string_view unlocalizedName) { this->m_unlocalizedName = unlocalizedName; }
|
||||
|
||||
[[nodiscard]] std::string_view getUnlocalizedTitle() const { return this->m_unlocalizedTitle; }
|
||||
[[nodiscard]] std::vector<Attribute>& getAttributes() { return this->m_attributes; }
|
||||
|
||||
void setCurrentOverlay(prv::Overlay *overlay) {
|
||||
@@ -40,7 +45,7 @@ namespace hex::dp {
|
||||
|
||||
private:
|
||||
u32 m_id;
|
||||
std::string m_unlocalizedName;
|
||||
std::string m_unlocalizedTitle, m_unlocalizedName;
|
||||
std::vector<Attribute> m_attributes;
|
||||
std::set<u32> m_processedInputs;
|
||||
prv::Overlay *m_overlay = nullptr;
|
||||
|
||||
@@ -71,6 +71,8 @@ namespace hex {
|
||||
|
||||
static std::vector<ContentRegistry::DataProcessorNode::Entry> dataProcessorNodes;
|
||||
static u32 dataProcessorNodeIdCounter;
|
||||
static u32 dataProcessorLinkIdCounter;
|
||||
static u32 dataProcessorAttrIdCounter;
|
||||
|
||||
static std::list<std::string> recentFilePaths;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace hex {
|
||||
|
||||
std::vector<ContentRegistry::DataProcessorNode::Entry> SharedData::dataProcessorNodes;
|
||||
u32 SharedData::dataProcessorNodeIdCounter = 1;
|
||||
u32 SharedData::dataProcessorLinkIdCounter = 1;
|
||||
u32 SharedData::dataProcessorAttrIdCounter = 1;
|
||||
|
||||
std::list<std::string> SharedData::recentFilePaths;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user