fix loading project

This commit is contained in:
Anthony Rabine 2023-12-17 00:05:33 +01:00
parent 35a54ac94d
commit 79445e1505
3 changed files with 22 additions and 12 deletions

View file

@ -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)

View file

@ -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<int>(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<int>(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;

View file

@ -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;
}