14#include "../../Source/third_party/nlohmann/json.hpp"
121 default:
return "Unknown";
252 :
id(nodeId),
type(nodeType),
name(nodeName) {}
308 bool LinkNodes(
int parentId,
int childId);
329 void CalculateNodePositionsHierarchical();
344 bool CanUndo()
const;
345 bool CanRedo()
const;
346 std::string GetUndoDescription()
const;
347 std::string GetRedoDescription()
const;
355 std::vector<int>
DuplicateNodes(
const std::vector<int>& nodeIds,
float offsetX = 30.0f,
float offsetY = 30.0f);
420 int CreateGraph(
const std::string& name,
const std::string& type);
437 bool SaveGraph(
int graphId,
const std::string& filepath);
438 int LoadGraph(
const std::string& filepath);
459 std::map<int, std::unique_ptr<NodeGraph>>
m_Graphs;
Undo/redo history manager for graph commands.
ComponentTypeID GetComponentTypeID_Static()
Manages undo/redo stacks for graph operations.
NodeGraphManager - Manages multiple node graphs Allows opening multiple behavior trees/FSMs simultane...
int GetActiveGraphId() const
bool IsGraphDirty(int graphId) const
NodeGraph * GetActiveGraph()
bool CloseGraph(int graphId)
std::vector< int > GetAllGraphIds() const
void SetGraphOrder(const std::vector< int > &newOrder)
int LoadGraph(const std::string &filepath)
NodeGraphManager(const NodeGraphManager &)=delete
void SetActiveGraph(int graphId)
NodeGraph * GetGraph(int graphId)
std::string GetGraphName(int graphId) const
int CreateGraph(const std::string &name, const std::string &type)
std::vector< int > m_GraphOrder
static NodeGraphManager & Instance()
bool IsInitialized() const
bool HasUnsavedChanges() const
bool SaveGraph(int graphId, const std::string &filepath)
static NodeGraphManager & Get()
std::map< int, std::unique_ptr< NodeGraph > > m_Graphs
NodeGraphManager & operator=(const NodeGraphManager &)=delete
bool UnlinkNodes(int parentId, int childId)
bool DeleteNode(int nodeId)
int GetRootNodeId() const
const std::string & GetFilepath() const
NodeGraph & operator=(const NodeGraph &other)
void AddEventRoot(uint32_t nodeId)
Add node ID to event roots array Called when creating an OnEvent node.
static NodeGraph FromJson(const nlohmann::json &j)
void CopyNodesToClipboard(const std::vector< int > &nodeIds)
const std::vector< uint32_t > & GetEventRootIds() const
Get all OnEvent root node IDs.
void SetFilepath(const std::string &filepath)
bool LinkNodes(int parentId, int childId)
std::vector< int > PasteNodesFromClipboard(float offsetX=30.0f, float offsetY=30.0f)
EditorMetadata editorMetadata
std::vector< ClipboardNode > m_clipboardData
int GetNextNodeId() const
std::vector< GraphLink > GetAllLinks() const
std::vector< int > DuplicateNodes(const std::vector< int > &nodeIds, float offsetX=30.0f, float offsetY=30.0f)
std::unique_ptr< CommandHistory > m_commandHistory
bool IsValidRoot(uint32_t nodeId) const
Check if a node ID is a valid root (main Root or OnEvent root) Root nodes cannot be deleted or moved ...
std::vector< uint32_t > m_eventRootIds
Separate array of node IDs that are OnEvent root nodes These nodes represent independent execution tr...
bool SetNodeParameter(int nodeId, const std::string ¶mName, const std::string &value)
nlohmann::json ToJson() const
void RemoveEventRoot(uint32_t nodeId)
Remove node ID from event roots array Called when deleting an OnEvent node.
std::vector< GraphNode * > GetAllNodes()
std::vector< GraphNode > m_Nodes
bool ValidateGraph(std::string &errorMsg) const
int FindNodeIndex(int nodeId) const
GraphNode * GetNode(int nodeId)
std::string GetNodeParameter(int nodeId, const std::string ¶mName) const
int CreateNode(NodeType type, float x, float y, const std::string &name="")
< Provides AssetID and INVALID_ASSET_ID
@ BT_OnEvent
Phase 38b: Event-driven root (green, event-triggered)
@ BT_SubGraph
Phase 8: references a subgraph by UUID (BehaviorTree)
@ BT_Root
Phase 38b: Root entry point (green, fixed position)
@ HFSM_SubGraph
Phase 8: references a subgraph by UUID (HFSM)
const char * NodeTypeToString(NodeType type)
NodeType StringToNodeType(const std::string &str)
Serializable node data for copy/paste operations.
std::map< std::string, std::string > parameters
std::vector< int > childIds
std::string decoratorType
std::string conditionType
GraphLink(int from, int to)
std::string conditionType
std::string decoratorType
uint32_t onEventRootIndex
Index of this node in its graph's event roots array (m_eventRootIds) Only valid if this is an OnEvent...
std::map< std::string, std::string > parameters
std::string eventType
Event type that triggers this OnEvent node Only used for BT_OnEvent nodes.
GraphNode(int nodeId, NodeType nodeType, const std::string &nodeName="")
std::vector< int > childIds
std::string eventMessage
Optional event message filter for OnEvent nodes If set, only events with matching message field trigg...