Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/DynamoCore/Engine/EngineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ private bool VerifyGraphSyncData(IEnumerable<NodeModel> 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++)
Expand Down
47 changes: 43 additions & 4 deletions src/Libraries/CoreNodeModels/DefineData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +27,7 @@ public class DefineData : DSDropDownBase
private List<DynamoDropDownItem> serializedItems;
private bool isAutoMode;
private bool isList;
private string playerValue = "";

/// <summary>
/// AutoMode property
Expand Down Expand Up @@ -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();
}
}
}

/// <summary>
Expand Down Expand Up @@ -115,12 +133,13 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode
// the object to be (type) evaluated
// the expected datatype
// if the input is an ArrayList or not
var function = new Func<object, string, bool, bool, Dictionary<string, object>>(DSCore.Data.IsSupportedDataNodeType);
var function = new Func<object, string, bool, bool, string, Dictionary<string, object>>(DSCore.Data.IsSupportedDataNodeType);
var funtionInputs = new List<AssociativeNode> {
inputAstNodes[0],
AstFactory.BuildStringNode((Items[SelectedIndex].Item as Data. DataNodeDynamoType).Type.ToString()),
AstFactory.BuildBooleanNode(IsList),
AstFactory.BuildBooleanNode(IsAutoMode)
AstFactory.BuildBooleanNode(IsAutoMode),
AstFactory.BuildStringNode(PlayerValue)
};


Expand Down Expand Up @@ -153,6 +172,12 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode
/// <param name="data"></param>
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<bool, bool, DataNodeDynamoType>)data;
Expand All @@ -179,7 +204,6 @@ private void DataBridgeCallback(object data)
SelectedIndex = 0;
}
}

}


Expand All @@ -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);
}
}
}
18 changes: 17 additions & 1 deletion src/Libraries/CoreNodes/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,29 @@ public static List<DataNodeDynamoType> GetDataNodeDynamoTypeList()

[IsVisibleInDynamoLibrary(false)]
public static Dictionary<string, object> 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<IsValid: bool, UpdateList: bool, InputType: DataNodeDynamoType>

var type = GetDataNodeDynamoTypeList().First(x => x.Type.ToString().Equals(typeString));
Expand Down