diff --git a/src/DynamoCore/Engine/EngineController.cs b/src/DynamoCore/Engine/EngineController.cs index 8b0d030da7c..13d4d13c6f0 100644 --- a/src/DynamoCore/Engine/EngineController.cs +++ b/src/DynamoCore/Engine/EngineController.cs @@ -440,6 +440,9 @@ private bool VerifyGraphSyncData(IEnumerable nodes) { if (!node.IsInputNode) continue; + //We also don't want any nodes that do have input ports or where derived from custom nodes. + if (node.InPorts.Any() || node.IsCustomFunction) continue; + // Only one or the other of the two lists, Added or Modified, will match the node GUID if they do. bool isAdded = false; for (int i = 0; i < graphSyncdata.AddedSubtrees.Count; i++) diff --git a/src/Libraries/CoreNodeModels/DefineData.cs b/src/Libraries/CoreNodeModels/DefineData.cs index a927dd5c09c..b25ce2f0311 100644 --- a/src/Libraries/CoreNodeModels/DefineData.cs +++ b/src/Libraries/CoreNodeModels/DefineData.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Runtime.Serialization; using DSCore; +using Dynamo.Graph; using Dynamo.Graph.Nodes; using Newtonsoft.Json; using ProtoCore.AST.AssociativeAST; @@ -26,6 +27,7 @@ public class DefineData : DSDropDownBase private List serializedItems; private bool isAutoMode; private bool isList; + private string playerValue = ""; /// /// AutoMode property @@ -57,9 +59,25 @@ public bool IsList } } + [JsonIgnore] public override bool IsInputNode { - get { return false; } + get { return true; } + } + + [JsonIgnore] + public string PlayerValue + { + get { return playerValue; } + set + { + var valueToSet = value ?? ""; + if (valueToSet != value) + { + playerValue = valueToSet; + MarkNodeAsModified(); + } + } } /// @@ -115,12 +133,13 @@ public override IEnumerable BuildOutputAst(List>(DSCore.Data.IsSupportedDataNodeType); + var function = new Func>(DSCore.Data.IsSupportedDataNodeType); var funtionInputs = new List { inputAstNodes[0], AstFactory.BuildStringNode((Items[SelectedIndex].Item as Data. DataNodeDynamoType).Type.ToString()), AstFactory.BuildBooleanNode(IsList), - AstFactory.BuildBooleanNode(IsAutoMode) + AstFactory.BuildBooleanNode(IsAutoMode), + AstFactory.BuildStringNode(PlayerValue) }; @@ -153,6 +172,12 @@ public override IEnumerable BuildOutputAst(List private void DataBridgeCallback(object data) { + //Todo If the playerValue is not empty string then we can chanage the UI to reflect the value is coming from the player + //Todo if the function call throws we don't get back to DatabridgeCallback. Not sure if we need to handle this case + + //Now we reset this value to empty string so that the next time a value is set from upstream nodes we can know that it is not coming from the player + playerValue = ""; + if (data == null) return; (bool IsValid, bool UpdateList, DataNodeDynamoType InputType) resultData = (ValueTuple)data; @@ -179,7 +204,6 @@ private void DataBridgeCallback(object data) SelectedIndex = 0; } } - } @@ -205,5 +229,20 @@ private void OnSerializing(StreamingContext context) { serializedItems = Items.ToList(); } + + protected override bool UpdateValueCore(UpdateValueParams updateValueParams) + { + string name = updateValueParams.PropertyName; + string value = updateValueParams.PropertyValue; + + switch (name) + { + case "Value": + PlayerValue = value; + return true; // UpdateValueCore handled. + } + + return base.UpdateValueCore(updateValueParams); + } } } diff --git a/src/Libraries/CoreNodes/Data.cs b/src/Libraries/CoreNodes/Data.cs index 37accd9ee2a..a75d05b92c7 100644 --- a/src/Libraries/CoreNodes/Data.cs +++ b/src/Libraries/CoreNodes/Data.cs @@ -626,13 +626,29 @@ public static List GetDataNodeDynamoTypeList() [IsVisibleInDynamoLibrary(false)] public static Dictionary IsSupportedDataNodeType([ArbitraryDimensionArrayImport] object inputValue, - string typeString, bool isList, bool isAutoMode) + string typeString, bool isList, bool isAutoMode, string playerValue) { + if (inputValue == null) { throw new ArgumentNullException(Properties.Resources.DefineDataNullExceptionMessage); } + // If the playerValue is not empty, then we assume it was set by the player. + // In that case, we need to parse it to get the actual value replace the inputValue. + if (!string.IsNullOrEmpty(playerValue)) + { + try + { + inputValue = ParseJSON(playerValue); + } + catch (Exception ex) + { + dynamoLogger?.Log("A Player value failed to deserialize with this exception: " + ex.Message); + throw new NotSupportedException(Properties.Resources.Exception_Deserialize_Unsupported_Cache); + } + } + object result; // Tuple var type = GetDataNodeDynamoTypeList().First(x => x.Type.ToString().Equals(typeString));