20#include <unordered_map>
21#include <unordered_set>
24#include "../third_party/imgui/imgui.h"
25#include "../TaskSystem/TaskGraphTemplate.h"
26#include "../TaskSystem/LocalBlackboard.h"
27#include "../TaskSystem/EntityBlackboard.h"
28#include "../NodeGraphCore/GlobalTemplateBlackboard.h"
36#include "../Editor/ConditionPreset/ConditionPresetRegistry.h"
37#include "../Editor/ConditionPreset/DynamicDataPinManager.h"
38#include "../Editor/Panels/NodeConditionsPanel.h"
39#include "../Editor/Panels/MathOpPropertyPanel.h"
40#include "../Editor/Panels/GetBBValuePropertyPanel.h"
41#include "../Editor/Panels/SetBBValuePropertyPanel.h"
42#include "../Editor/Panels/VariablePropertyPanel.h"
43#include "../Editor/Panels/ConditionPresetLibraryPanel.h"
44#include "../Editor/Nodes/NodeBranchRenderer.h"
47#include "../Editor/Modals/SwitchCaseEditorModal.h"
50#include "../Editor/Modals/SubGraphFilePickerModal.h"
184 bool SaveAs(
const std::string& path);
436 const std::string&
indent,
454 std::string
FormatTaskParameters(
const std::unordered_map<std::string, ParameterBinding>& parameters,
455 const std::string&
indent);
515 const std::vector<BlackboardEntry>&
allVars,
536 const std::string&
key,
567 const std::vector<BlackboardEntry>&
allVars,
581 const std::vector<BlackboardEntry>&
allVars,
ComponentTypeID GetComponentTypeID_Static()
ICanvasEditor adapter for ImNodes-based editors (VisualScript)
Undo/Redo command stack for ATS Visual Scripting editor (Phase 6).
Stateless validator for exec connections in Visual Script graphs (Phase 20-B).
Global graph verifier for ATS Visual Script graphs (Phase 21-A).
Node style rendering helpers for VisualScriptEditorPanel (Phase 5).
Manages the global pool of ConditionPreset objects.
Encapsule l'effet de sélection des nodes (glow + bordure épaisse)
Immutable, shareable task graph asset.
C++14-compliant type-safe value container for task parameters.
Bounded stack of reversible editor commands.
ImNodes graph editor for ATS Visual Script v4 graphs.
void TraceUpstreamDataNodes(int32_t sourceNodeID, const std::string &indent, std::unordered_set< int > &visitedDataNodes)
Recursively traces all upstream pure data nodes in the graph.
std::vector< std::string > m_validationErrors
std::unique_ptr< DynamicDataPinManager > m_pinManager
Dynamic pin manager shared across all Branch nodes in this panel.
std::string m_propEditOldBBKey
UndoRedoStack m_undoStack
Undo/Redo command stack for reversible graph editing operations.
float m_contextMenuX
Right-click paste position.
void RenderForEachNodeProperties()
bool Save()
Saves the current canvas state to JSON v4 at the loaded path.
void OnNodeDoubleClicked(int nodeID)
Handles double-click on a node (opens SubGraph, etc).
void RunGraphSimulation()
Simulates runtime execution of the current graph and logs traces.
void RenderSwitchNodeProperties(VSEditorNode &eNode, TaskNodeDefinition &def)
Renders the Properties panel content for a selected Switch node (Phase 1).
void PerformRedo()
Re-applies the last undone command and syncs the canvas.
void RenderPresetItemCompact(const ConditionPreset &preset, size_t index)
Render a single preset item in compact horizontal format with index.
bool IsVisible() const
Returns true if the panel window is visible.
bool m_pendingRemovePin
Pending dynamic pin removal (from [-] button clicked in canvas)
char m_saveAsFilename[256]
Buffer for the user-entered filename (without extension)
std::vector< VSEditorLink > m_editorLinks
Editor links (exec + data)
std::unique_ptr< VariablePropertyPanel > m_variablePanel
Properties-panel sub-widget for the selected Variable node (data pure).
float m_verificationLogsPanelHeight
Height of the Verification Logs panel in the left panel (Blueprint Files).
VisualScriptEditorPanel()
VisualScriptEditorPanel Constructor.
int ExecOutAttrUID(int nodeID, int pinIndex) const
Maps node ID + pin index -> ImNodes attribute UID for exec-out pins.
TaskGraphTemplate m_template
The template currently being edited.
void Shutdown()
Shutdown the editor panel and release all resources.
float m_nodePropertiesPanelHeight
Height of the Node Properties panel (Part A) in the right panel.
void RenderAvailableNodesList()
Phase 31 — Nodes list tab in Part A (available nodes for dragging to canvas)
void CommitPendingBlackboardEdits()
Commits any pending key-name edits stored in m_pendingBlackboardEdits.
void RenderNodePropertiesPanelContent()
Phase 31 — Content of Properties tab in Part A.
void EvaluateDataNode(int32_t nodeID, int depth, const std::string &indent)
Helper to recursively evaluate data nodes (MathOp, GetBBValue, etc.) and trace their execution.
int m_lastClickNodeID
Node ID of the last left-click (for double-click detection)
std::unique_ptr< MathOpPropertyPanel > m_mathOpPanel
Properties-panel sub-widget for the selected MathOp node.
int AllocLinkID()
Allocate a unique link ID.
void RenderRightPanelTabs()
Phase 26 — Tab system: Renders the tab bar for the 3-panel right section Displays tabs for Presets,...
void Initialize()
Initialize the editor panel with ImNodes context and UI helpers.
void RemoveNode(int nodeID)
Removes a node from the canvas.
std::string FormatTaskParameters(const std::unordered_map< std::string, ParameterBinding > ¶meters, const std::string &indent)
Format task parameters into a readable string.
std::unique_ptr< SwitchCaseEditorModal > m_switchCaseModal
Phase 26 — Switch Case Editor Modal.
std::unique_ptr< EntityBlackboard > m_entityBlackboard
Per-entity blackboard instance (combines local + global variables) Created in Initialize() and manage...
bool m_simulationDone
True if simulation has been run.
void RemoveLink(int linkID)
Removes an ImNodes link (and its underlying template connection) by link ID.
bool m_skipPositionSyncNextFrame
Set to true by Undo/Redo; causes next frame to skip SyncNodePositionsFromImNodes() so that the positi...
void PerformUndo()
Undoes the last command and syncs the canvas (nodes + links).
int m_condPanelNodeID
ID of the node currently loaded into m_conditionsPanel (-1 = none).
std::vector< std::string > m_verificationLogs
Verification log messages (populated by RunVerification()) Phase 24.3 — for display in the verificati...
void ConnectData(int srcNodeID, const std::string &srcPinName, int dstNodeID, const std::string &dstPinName)
Creates a data connection between two nodes.
static std::vector< std::string > GetExecInputPins(TaskNodeType type)
Returns the exec-in pin names for a node type.
std::string GetNodePropertyString(const TaskNodeDefinition &node)
Gets a comprehensive property string for any node type.
void Render()
Renders the full panel window.
std::string m_propEditOldSubGraphPath
static constexpr float DOUBLE_CLICK_THRESHOLD
Threshold for detecting double-click (300ms)
void RenderContent()
Renders panel content without window wrapper - for fixed layout.
void RenderVariableSelector(std::string &selectedVar, const std::vector< BlackboardEntry > &allVars, VariableType expectedType, const char *label)
Renders a type-filtered variable selector combo box.
std::unique_ptr< NodeConditionsPanel > m_conditionsPanel
Properties-panel sub-widget for the selected Branch node.
std::unique_ptr< NodeBranchRenderer > m_branchRenderer
Specialized renderer for Branch nodes (4-section layout with conditions).
int m_contextLinkID
Link ID captured at the moment a right-click context menu was opened on a link.
void ConnectExec(int srcNodeID, const std::string &srcPinName, int dstNodeID, const std::string &dstPinName)
Creates an exec connection between two nodes.
int m_pendingRemovePinNodeID
void RenderValidationOverlay()
const std::string & GetCurrentPath() const
Returns the currently loaded file path (empty if unsaved).
TaskNodeType m_pendingNodeType
void SyncCanvasFromTemplate()
Builds the editor canvas from the in-memory TaskGraphTemplate.
bool ValidateBlackboardEntry(const BlackboardEntry &entry)
Validates a complete blackboard entry.
void SyncTemplateFromCanvas()
Builds the in-memory TaskGraphTemplate from the editor nodes/links.
void RenderWhileNodeProperties()
Phase 24 — Property panel renderers for While, ForEach, and SubGraph nodes.
void AfterSave()
Restores the ImNodes canvas panning saved by ResetViewportBeforeSave().
std::unique_ptr< SubGraphFilePickerModal > m_subGraphModal
Phase 26 — SubGraph File Picker Modal.
static std::vector< std::string > GetDataOutputPins(TaskNodeType type)
Returns the data-out pin names for a node type.
Vector m_lastViewportPanning
Canvas panning saved by ResetViewportBeforeSave() for restoration in AfterSave().
std::string m_propEditOldMathOp
std::vector< SwitchCaseDefinition > m_propEditSwitchCases
Per-case label edit buffers.
int m_pendingAddPinNodeID
bool m_pendingNodeDrop
True when a node drop is pending processing this frame.
void RenderNodePropertiesPanel()
Part A: Node Properties panel (top-left of right panel)
void RenderContextMenus()
Render node/link context menus opened by right-click detection.
std::unordered_map< int, std::string > m_pendingBlackboardEdits
Deferred key-name edits for blackboard entries: index -> pending new key.
void RenderSaveAsDialog()
void RenderGlobalVariablesPanel()
Phase 24 Global Blackboard — Renders global variables panel.
std::vector< ExecutionToken > m_executionTokenStack
Phase 24.4 — Execution token stack for multi-branch simulation Enables proper handling of Sequence no...
void ValidateAndCleanBlackboardEntries()
Removes blackboard entries with empty keys or VariableType::None.
int AddNode(TaskNodeType type, float x, float y)
Creates a new node on the canvas.
bool IsDirty() const
Returns true when there are unsaved modifications.
std::vector< std::string > m_validationWarnings
Validation messages (rebuilt each frame)
VSVerificationResult m_verificationResult
Latest verification result (produced by RunVerification())
int m_pendingRemovePinDynIdx
0-based index in DynamicExecOutputPins
void RenderLocalVariablesPanel()
Part C: Local Variables reference panel (bottom of right panel)
void RenderPinSelector(std::string &selectedPin, const std::vector< std::string > &availablePins, const char *label)
Renders a pin selector combo box.
void RenderMathOpNodeProperties(VSEditorNode &eNode, TaskNodeDefinition &def)
Renders the Properties panel content for a selected MathOp node.
std::unique_ptr< GetBBValuePropertyPanel > m_getBBPanel
Properties-panel sub-widget for the selected GetBBValue node.
void SyncPresetsFromRegistryToTemplate()
Syncs ALL presets from the registry to the template.
void RunVerification()
Runs VSGraphVerifier on the current graph and stores the result.
bool m_viewportResetDone
True after ResetViewportBeforeSave() has been called and before AfterSave().
void RenderBranchNodeProperties(VSEditorNode &eNode, TaskNodeDefinition &def)
Renders the Properties panel content for a selected Branch (or While) node.
static std::vector< std::string > GetDataInputPins(TaskNodeType type)
Returns the data-in pin names for a node type.
void RenderConstValueInput(TaskValue &value, VariableType varType, const char *label)
Renders a type-aware const value input widget.
void ResetViewportBeforeSave()
Resets the ImNodes canvas panning to (0,0) before saving node positions.
std::unique_ptr< SetBBValuePropertyPanel > m_setBBPanel
Properties-panel sub-widget for the selected SetBBValue node.
std::string m_propEditOldTaskID
static std::string BuildConditionPreview(const Condition &cond)
Builds a human-readable preview string for a condition.
std::string m_propEditOldConditionID
std::unordered_set< int > m_positionedNodes
Nodes for which ImNodes has been given a position.
void RenderVerificationPanel()
Renders the verification results panel (Phase 21-B).
int m_topPanelTabSelection
Top panel tab selection (Part A of right panel) 0 = Properties, 1 = Nodes.
bool SaveAs(const std::string &path)
Saves the current canvas state to a new JSON v4 file.
bool m_showSaveAsDialog
True when the "Save As" modal should be opened next frame.
SelectionEffectRenderer m_selectionRenderer
Renders glow effect for selected nodes (cyan halo + thickened border).
std::unique_ptr< ImNodesCanvasEditor > m_canvasEditor
Canvas editor adapter for minimap support (Phase 37) Abstracts imnodes minimap rendering through ICan...
int DataInAttrUID(int nodeID, int pinIndex) const
Maps node ID + data pin index -> ImNodes attribute UID for data-in pins.
void RebuildLinks()
Rebuilds ImNodes exec/data link arrays from the template.
int m_focusNodeID
Node ID to focus/scroll to on next RenderCanvas() frame (-1 = none)
void SyncNodePositionsFromImNodes()
Pulls the current node positions from ImNodes into m_editorNodes.
int m_contextNodeID
Node ID captured at the moment a right-click context menu was opened on a node.
float m_presetBankPanelHeight
Height of the Preset Bank panel (Part B) in the right panel.
void RenderRightPanelTabContent()
Phase 26 — Tab system: Renders the content of the active tab Dispatches to appropriate render functio...
int m_minimapPosition
Minimap position (0=TopLeft, 1=TopRight, 2=BottomLeft, 3=BottomRight)
float m_propertiesPanelWidth
Width of the properties+blackboard panel on the right.
std::string GetNodeSubGraphPath(const TaskNodeDefinition &def) const
Extracts SubGraph file path from a node definition.
int m_nextNodeID
Next available node ID.
void RunGraphSimulationRecursive(const TaskGraphTemplate *tmpl, std::map< std::string, TaskValue > &blackboard, std::unordered_set< std::string > &visitedGraphs, int recursionDepth, const std::string &traceIndent)
Internal recursive simulation function with cycle detection.
bool m_justPerformedUndoRedo
Set to true immediately after Undo/Redo; blocks node movement tracking for 1 frame to allow ImNodes t...
ImNodesEditorContext * m_imnodesContext
bool SerializeAndWrite(const std::string &path)
Serializes the template to JSON v4 and writes to a file.
BlackboardValidationResult ValidateBlackboardKey(const std::string &key, bool isGlobal, int excludeIndex=-1)
Validates a blackboard key according to schema rules.
std::unordered_map< int, std::pair< float, float > > m_nodeDragStartPositions
Per-node drag-start positions used to record a single MoveNodeCommand per drag gesture instead of one...
int AllocNodeID()
Allocate a unique node ID.
float m_lastClickTime
Frame time of the last left-click (seconds, from ImGui::GetTime())
int DataOutAttrUID(int nodeID, int pinIndex) const
Maps node ID + data pin index -> ImNodes attribute UID for data-out pins.
bool RenderOperandEditor(Operand &operand, const char *labelSuffix)
Render a single operand with dropdown for mode and value editor Returns true if the operand was modif...
std::string m_saveAsDirectory
Currently selected destination directory.
int m_propEditNodeIDOnFocus
Node ID that was selected when RenderProperties() last entered focus.
void RenderConditionEditor(Condition &condition, int conditionIndex, const std::vector< BlackboardEntry > &allVars, const std::vector< std::string > &availablePins)
Renders the full editor UI for one Condition entry on a Branch/While node.
void RenderSubGraphNodeProperties()
void SetVisible(bool v)
Show / hide the panel.
int ExecInAttrUID(int nodeID) const
Maps node ID -> ImNodes attribute UID for an exec-in pin.
int m_rightPanelTabSelection
Phase 26 — Right panel tab selection 0 = Presets, 1 = Local Variables, 2 = Global Variables.
std::string m_currentPath
std::vector< std::string > GetExecOutputPinsForNode(const TaskNodeDefinition &def) const
Returns exec-out pin names for a node definition, including any dynamically-added pins (VSSequence).
bool m_verificationDone
True once RunVerification() has been called at least once for the current graph.
const TaskGraphTemplate & GetTemplate() const
Returns a reference to the internal template being edited.
void RenderNodeDataParameters(TaskNodeDefinition &def)
Renders node parameters for data nodes (GetBBValue, SetBBValue, MathOp).
float m_minimapSize
Minimap size ratio (0.05-0.5 of canvas)
void RenderPresetBankPanel()
Part B: Preset Bank panel (middle of right panel)
bool m_pendingAddPin
Pending dynamic pin addition (from [+] button clicked in canvas)
static std::vector< BlackboardEntry > GetVariablesByType(const std::vector< BlackboardEntry > &allVars, VariableType expectedType)
Returns a filtered subset of blackboard entries matching a type.
std::vector< VSEditorNode > m_editorNodes
Editor nodes (mirrors m_template.Nodes + position/selection state)
bool m_minimapVisible
Minimap visibility flag for VisualScript canvas.
int m_selectedNodeID
Currently selected node (for properties panel)
void SyncEditorNodesFromTemplate()
Rebuilds m_editorNodes from m_template, preserving existing node positions.
~VisualScriptEditorPanel()
VisualScriptEditorPanel Destructor.
void RenderVerificationLogsPanel()
Public render method for verification logs panel.
std::string m_saveAsExtension
Extension to append when saving (derived from m_currentPath; defaults to ".ats")
int m_nextLinkID
Next available ImNodes link ID.
std::string m_propEditSwitchVar
Live buffer for switchVariable field.
ConditionPresetRegistry m_presetRegistry
Global registry of ConditionPreset objects.
std::vector< std::string > m_simulationTraces
Simulation execution traces (populated by RunGraphSimulation()) Phase 24.4 — added to verification lo...
std::unique_ptr< ConditionPresetLibraryPanel > m_libraryPanel
Global condition preset library panel (UI for creating/editing/deleting presets).
void LoadTemplate(const TaskGraphTemplate *tmpl, const std::string &path)
Loads a VS graph template into the editor canvas.
static std::vector< std::string > GetExecOutputPins(TaskNodeType type)
Returns the exec-out pin names for a node type.
std::string m_propEditOldName
Snapshot values captured at focus time for each editable field.
ImVec2 ScreenToCanvasPos(ImVec2 screenPos) const
Converts a screen-space position to canvas (editor) space.
< Provides AssetID and INVALID_ASSET_ID
VariableType
Type tags used by TaskValue to identify stored data.
@ Vector
3-component vector (Vector from vector.h)
TaskNodeType
Identifies the role of a node in the task graph.
@ EntryPoint
Unique entry node for VS graphs (replaces Root)
constexpr int32_t NODE_INDEX_NONE
Sentinel value for "no node" in node index / ID fields.
Single entry in the graph's declared blackboard schema (local or global).
Result of blackboard key validation (Phase 26).
std::string WarningMessage
Set if validation succeeded but has warnings.
std::string ErrorMessage
Set if validation failed.
A globally-stored, reusable condition expression.
Describes a single condition expression for Branch/While nodes.
Represents a single execution point in graph simulation (Phase 24).
int32_t nodeID
Current node to execute.
int depth
Nesting depth (for indentation)
ExecutionToken(int32_t id, int d)
One side of a ConditionPreset comparison expression.
Full description of a single node in the task graph.
Editor-side representation of an exec or data connection.
int dstAttrID
Destination attribute UID.
int linkID
ImNodes link UID.
int srcAttrID
Source attribute UID.
bool isData
false = exec link, true = data link
Editor-side representation of a node in the VS graph canvas.