From 79445e1505dd682a34aece8612338b8573eea199 Mon Sep 17 00:00:00 2001 From: Anthony Rabine Date: Sun, 17 Dec 2023 00:05:33 +0100 Subject: [PATCH] fix loading project --- story-editor/src/base_node.cpp | 2 +- story-editor/src/base_node.h | 14 +++++++------- story-editor/src/node_editor_window.cpp | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/story-editor/src/base_node.cpp b/story-editor/src/base_node.cpp index b1a02f5..5d6ce8b 100644 --- a/story-editor/src/base_node.cpp +++ b/story-editor/src/base_node.cpp @@ -3,7 +3,7 @@ #include "IconsMaterialDesignIcons.h" -int BaseNode::s_nextId = 1; +unsigned long BaseNode::s_nextId = 1; BaseNode::BaseNode(const std::string &title, IStoryProject &proj) : m_project(proj) diff --git a/story-editor/src/base_node.h b/story-editor/src/base_node.h index 79c1c8b..7c2ae37 100644 --- a/story-editor/src/base_node.h +++ b/story-editor/src/base_node.h @@ -127,8 +127,8 @@ public: return m_type; } - void SetId(const int id) { m_id = id; } - int GetId() const { return m_id; } + void SetId(unsigned long id) { m_id = id; } + unsigned long GetId() const { return m_id; } unsigned long GetInternalId() const { return m_node->ID.Get(); } void seTitle(const std::string &title) { m_title = title; } @@ -145,7 +145,7 @@ public: return j; } - static int GetNextId() + static unsigned long GetNextId() { return s_nextId++; } @@ -157,7 +157,7 @@ public: ed::PinId GetInputPinAt(int index) { - ed::PinId id = -1; + ed::PinId id = 0; if (index < static_cast(m_node->Inputs.size())) { @@ -169,7 +169,7 @@ public: ed::PinId GetOutputPinAt(int index) { - ed::PinId id = -1; + ed::PinId id = 0; if (index < static_cast(m_node->Outputs.size())) { @@ -192,11 +192,11 @@ private: std::string m_title{"Base node"}; std::string m_type; - int m_id; + unsigned long m_id; NodePosition m_pos; bool m_firstFrame{true}; - static int s_nextId; + static unsigned long s_nextId; diff --git a/story-editor/src/node_editor_window.cpp b/story-editor/src/node_editor_window.cpp index e1a5c7a..ccc30fe 100644 --- a/story-editor/src/node_editor_window.cpp +++ b/story-editor/src/node_editor_window.cpp @@ -74,31 +74,41 @@ void NodeEditorWindow::LoadNode(const nlohmann::json &nodeJson) ed::PinId NodeEditorWindow::GetInputPin(unsigned long modelNodeId, int pinIndex) { - ed::PinId id = -1; + ed::PinId id = 0; for (auto & n : m_nodes) { - if (n.first == modelNodeId) + if (n.second->GetId() == modelNodeId) { id = n.second->GetInputPinAt(pinIndex); } } + if (id.Get() == 0) + { + std::cout << "Invalid Id, input pin not found" << std::endl; + } + return id; } ed::PinId NodeEditorWindow::GetOutputPin(unsigned long modelNodeId, int pinIndex) { - ed::PinId id = -1; + ed::PinId id = 0; for (auto & n : m_nodes) { - if (n.first == modelNodeId) + if (n.second->GetId() == modelNodeId) { id = n.second->GetOutputPinAt(pinIndex); } } + if (id.Get() == 0) + { + std::cout << "Invalid Id, output pin not found" << std::endl; + } + return id; }