diff --git a/include/td/display/state/NodeEditorState.h b/include/td/display/state/NodeEditorState.h
new file mode 100644
index 0000000..b52a5e0
--- /dev/null
+++ b/include/td/display/state/NodeEditorState.h
@@ -0,0 +1,127 @@
+#pragma once
+
+#include
+
+#include
+
+namespace ed = ax::NodeEditor;
+
+namespace td {
+
+class NodeEditorState : public DisplayState {
+ public:
+ enum class PinType {
+ Flow,
+ Bool,
+ Int,
+ Float,
+ String,
+ Object,
+ Function,
+ Delegate,
+ };
+
+ enum class PinKind { Output, Input };
+
+ enum class NodeType { Blueprint, Simple, Tree, Comment, Houdini };
+
+ struct Pin;
+
+ struct Node {
+ ed::NodeId ID;
+ std::string Name;
+ std::vector Inputs;
+ std::vector Outputs;
+ ImColor Color;
+ NodeType Type;
+ ImVec2 Size;
+
+ std::string State;
+ std::string SavedState;
+
+ Node(int id, const char* name, ImColor color = ImColor(255, 255, 255)) :
+ ID(id), Name(name), Color(color), Type(NodeType::Blueprint), Size(0, 0) {}
+ };
+
+ struct Pin {
+ ed::PinId ID;
+ ::td::NodeEditorState::Node* Node;
+ std::string Name;
+ PinType Type;
+ PinKind Kind;
+
+ Pin(int id, const char* name, PinType type) : ID(id), Node(nullptr), Name(name), Type(type), Kind(PinKind::Input) {}
+ };
+
+ struct Link {
+ ed::LinkId ID;
+
+ ed::PinId StartPinID;
+ ed::PinId EndPinID;
+
+ ImColor Color;
+
+ Link(ed::LinkId id, ed::PinId startPinId, ed::PinId endPinId) :
+ ID(id), StartPinID(startPinId), EndPinID(endPinId), Color(255, 255, 255) {}
+ };
+
+ struct NodeIdLess {
+ bool operator()(const ed::NodeId& lhs, const ed::NodeId& rhs) const {
+ return lhs.AsPointer() < rhs.AsPointer();
+ }
+ };
+
+ int m_NextId = 1;
+ const int m_PinIconSize = 24;
+ std::vector m_Nodes;
+ std::vector m_Links;
+ ImTextureID m_HeaderBackground = 0;
+ ImTextureID m_SaveIcon = 0;
+ ImTextureID m_RestoreIcon = 0;
+ const float m_TouchTime = 1.0f;
+ std::map m_NodeTouchTime;
+ bool m_ShowOrdinals = false;
+
+
+ public:
+ NodeEditorState(Display& a_Display);
+ ~NodeEditorState();
+
+ virtual void Update(float a_Delta) override;
+
+ private:
+ int GetNextId();
+ ed::LinkId GetNextLinkId();
+ void TouchNode(ed::NodeId id);
+ float GetTouchProgress(ed::NodeId id);
+ void UpdateTouch();
+ Node* FindNode(ed::NodeId id);
+ Link* FindLink(ed::LinkId id);
+ Pin* FindPin(ed::PinId id);
+ bool IsPinLinked(ed::PinId id);
+ bool CanCreateLink(Pin* a, Pin* b);
+ void BuildNode(Node* node);
+ Node* SpawnInputActionNode();
+ Node* SpawnBranchNode();
+ Node* SpawnDoNNode();
+ Node* SpawnOutputActionNode();
+ Node* SpawnPrintStringNode();
+ Node* SpawnMessageNode();
+ Node* SpawnSetTimerNode();
+ Node* SpawnLessNode();
+ Node* SpawnWeirdNode();
+ Node* SpawnTraceByChannelNode();
+ Node* SpawnTreeSequenceNode();
+ Node* SpawnTreeTaskNode();
+ Node* SpawnTreeTask2Node();
+ Node* SpawnComment();
+ Node* SpawnHoudiniTransformNode();
+ Node* SpawnHoudiniGroupNode();
+ void BuildNodes();
+ ImColor GetIconColor(PinType type);
+ void DrawPinIcon(const Pin& pin, bool connected, int alpha);
+ void ShowStyleEditor(bool* show = nullptr);
+ void ShowLeftPane(float paneWidth);
+};
+
+} // namespace td
diff --git a/lib/imgui-node.lua b/lib/imgui-node.lua
index b0bab8a..b3c1b0e 100644
--- a/lib/imgui-node.lua
+++ b/lib/imgui-node.lua
@@ -1,6 +1,6 @@
target("imgui-node-editor")
set_kind("static")
- add_files("imgui-node-editor/*.cpp")
+ add_files("imgui-node-editor/**.cpp")
add_includedirs("imgui-node-editor", {public = true})
- add_packages("imgui")
\ No newline at end of file
+ add_packages("imgui")
diff --git a/src/main.cpp b/src/main.cpp
index 4bd56a2..d16ac4b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,12 +1,12 @@
#include
-#include |
+#include |
#include |
int main(int argc, char** argv) {
// init GL context
td::Display display(1920, 1080, "Tower-Defense 2");
- display.ChangeState();
+ display.ChangeState();
td::Timer timer;
while (!display.IsCloseRequested()) {
diff --git a/src/td/display/state/NodeEditorState.cpp b/src/td/display/state/NodeEditorState.cpp
new file mode 100644
index 0000000..77876bf
--- /dev/null
+++ b/src/td/display/state/NodeEditorState.cpp
@@ -0,0 +1,1700 @@
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "utilities/builders.h"
+#include "utilities/widgets.h"
+#include |
+
+#include
+#include
+
+#include
+#include | | |