/* Display an entity hierarchy as a string */ public static string HierarchyToString(List <cGUID> hierarchy) { CathodeFlowgraph currentFlowgraphToSearch = CurrentInstance.selectedFlowgraph; CathodeEntity entity = null; string combinedString = ""; for (int i = 0; i < hierarchy.Count; i++) { if (hierarchy[i] == new cGUID("00-00-00-00")) { break; } entity = currentFlowgraphToSearch.GetEntityByID(hierarchy[i]); if (entity != null) { combinedString += NodeDBEx.GetEntityName(entity.nodeID) + " -> "; } if (entity != null && entity.variant == EntityVariant.FUNCTION) { CathodeFlowgraph flowRef = CurrentInstance.commandsPAK.GetFlowgraph(((FunctionEntity)entity).function); if (flowRef != null) { currentFlowgraphToSearch = flowRef; } } } if (combinedString.Length >= 4) { combinedString = combinedString.Substring(0, combinedString.Length - 4); } return(combinedString); }
private static string GenerateNodeNameInternal(CathodeEntity entity, CathodeFlowgraph currentFlowgraph) { string desc = ""; switch (entity.variant) { case EntityVariant.DATATYPE: desc = NodeDBEx.GetParameterName(((DatatypeEntity)entity).parameter) + " (DataType " + ((DatatypeEntity)entity).type.ToString() + ")"; break; case EntityVariant.FUNCTION: desc = NodeDBEx.GetEntityName(entity.nodeID) + " (" + NodeDBEx.GetParameterName(((FunctionEntity)entity).function) + ")"; break; case EntityVariant.OVERRIDE: //desc = NodeDBEx.GetEntityName(entity.nodeID) + " (" + HierarchyToString(((OverrideEntity)entity).hierarchy, currentFlowgraph) + ")"; desc = NodeDBEx.GetEntityName(entity.nodeID) + " (*OVERRIDE*)"; break; case EntityVariant.PROXY: //desc = NodeDBEx.GetEntityName(entity.nodeID) + " (" + HierarchyToString(((ProxyEntity)entity).hierarchy, currentFlowgraph) + ")"; desc = NodeDBEx.GetEntityName(entity.nodeID) + " (*PROXY*)"; break; case EntityVariant.NOT_SETUP: //desc = NodeDBEx.GetEntityName(entity.nodeID); desc = NodeDBEx.GetEntityName(entity.nodeID) + " (*NOT SETUP*)"; break; } return("[" + entity.nodeID.ToString() + "] " + desc); }
/* If selected node is a flowgraph instance, allow jump to it */ private void node_to_flowgraph_jump_Click(object sender, EventArgs e) { CathodeFlowgraph flow; switch (CurrentInstance.selectedEntity.variant) { case EntityVariant.OVERRIDE: { CathodeEntity entity = EditorUtils.ResolveHierarchy(((OverrideEntity)CurrentInstance.selectedEntity).hierarchy, out flow); if (entity != null) { LoadFlowgraph(flow.name); LoadEntity(entity); } break; } case EntityVariant.PROXY: { CathodeEntity entity = EditorUtils.ResolveHierarchy(((ProxyEntity)CurrentInstance.selectedEntity).hierarchy, out flow); if (entity != null) { LoadFlowgraph(flow.name); LoadEntity(entity); } break; } case EntityVariant.FUNCTION: { LoadFlowgraph(selected_node_type_description.Text); break; } } }
/* Remove selected flowgraph */ private void removeSelectedFlowgraph_Click(object sender, EventArgs e) { if (CurrentInstance.selectedFlowgraph == null) { return; } for (int i = 0; i < CurrentInstance.commandsPAK.EntryPoints.Count(); i++) { if (CurrentInstance.selectedFlowgraph.nodeID == CurrentInstance.commandsPAK.EntryPoints[i].nodeID) { MessageBox.Show("Cannot delete a flowgraph which is set as an entry point!", "Cannot delete.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (!ConfirmAction("Are you sure you want to remove this flowgraph?")) { return; } //Remove any entities or links that reference this flowgraph for (int i = 0; i < CurrentInstance.commandsPAK.Flowgraphs.Count; i++) { List <FunctionEntity> prunedFunctionEntities = new List <FunctionEntity>(); for (int x = 0; x < CurrentInstance.commandsPAK.Flowgraphs[i].functions.Count; x++) { if (CurrentInstance.commandsPAK.Flowgraphs[i].functions[x].function == CurrentInstance.selectedFlowgraph.nodeID) { continue; } List <CathodeNodeLink> prunedNodeLinks = new List <CathodeNodeLink>(); for (int l = 0; l < CurrentInstance.commandsPAK.Flowgraphs[i].functions[x].childLinks.Count; l++) { CathodeEntity linkedNode = CurrentInstance.commandsPAK.Flowgraphs[i].GetEntityByID(CurrentInstance.commandsPAK.Flowgraphs[i].functions[x].childLinks[l].childID); if (linkedNode != null && linkedNode.variant == EntityVariant.FUNCTION) { if (((FunctionEntity)linkedNode).function == CurrentInstance.selectedFlowgraph.nodeID) { continue; } } prunedNodeLinks.Add(CurrentInstance.commandsPAK.Flowgraphs[i].functions[x].childLinks[l]); } CurrentInstance.commandsPAK.Flowgraphs[i].functions[x].childLinks = prunedNodeLinks; prunedFunctionEntities.Add(CurrentInstance.commandsPAK.Flowgraphs[i].functions[x]); } CurrentInstance.commandsPAK.Flowgraphs[i].functions = prunedFunctionEntities; } //TODO: remove proxies etc that also reference any of the removed nodes //Remove the flowgraph CurrentInstance.commandsPAK.Flowgraphs.Remove(CurrentInstance.selectedFlowgraph); //Refresh UI ClearUI(false, true, true); RefreshStatsUI(); treeHelper.UpdateFileTree(CurrentInstance.commandsPAK.GetFlowgraphNames().ToList()); }
/* Utility: generate nice entity name to display in UI */ public static string GenerateNodeName(CathodeEntity entity, CathodeFlowgraph currentFlowgraph) { if (CurrentInstance.commandsPAK == null) { return(""); } if (hasFinishedCachingEntityNames && cachedEntityName.ContainsKey(entity.nodeID)) { return(cachedEntityName[entity.nodeID]); } return(GenerateNodeNameInternal(entity, currentFlowgraph)); }
public CathodeEditorGUI_AddParameter(CathodeEntity _node) { node = _node; InitializeComponent(); param_datatype.SelectedIndex = 0; List <string> options = EditorUtils.GenerateParameterList(_node, out loadedParamsFromDB); param_name.BeginUpdate(); for (int i = 0; i < options.Count; i++) { param_name.Items.Add(options[i]); } param_name.EndUpdate(); }
List <CathodeResourceReference> resRef = new List <CathodeResourceReference>(); //FOR TESTING ONLY public CathodeEditorGUI_AddOrEditResource(CathodeEntity entity) { _ent = entity; //FOR TESTING ONLY resRef.AddRange(_ent.resources); cGUID resourceParamID = Utilities.GenerateGUID("resource"); CathodeLoadedParameter resourceParam = CurrentInstance.selectedEntity.parameters.FirstOrDefault(o => o.paramID == resourceParamID); if (resourceParam != null) { resRef.AddRange(((CathodeResource)resourceParam.content).value); } Setup(); }
/* Perform a partial UI reload for a newly added entity */ private void ReloadUIForNewEntity(CathodeEntity newEnt) { if (CurrentInstance.selectedFlowgraph == null || newEnt == null) { return; } if (currentSearch == "") { string newNodeName = EditorUtils.GenerateNodeName(newEnt, CurrentInstance.selectedFlowgraph); flowgraph_content.Items.Add(newNodeName); flowgraph_content_RAW.Add(newNodeName); } else { LoadFlowgraph(CurrentInstance.selectedFlowgraph.name); } LoadEntity(newEnt); }
public CathodeEditorGUI_RemoveParameter(CathodeEntity entity) { InitializeComponent(); if (entity.parameters.Count == 0) { this.Close(); return; } _entity = entity; parameterToDelete.BeginUpdate(); parameterToDelete.Items.Clear(); for (int i = 0; i < _entity.parameters.Count; i++) { parameterToDelete.Items.Add(NodeDBEx.GetParameterName(_entity.parameters[i].paramID)); } parameterToDelete.SelectedIndex = 0; parameterToDelete.EndUpdate(); }
/* Select node from loaded flowgraph */ private void flowgraph_content_SelectedIndexChanged(object sender, EventArgs e) { if (flowgraph_content.SelectedIndex == -1 || CurrentInstance.selectedFlowgraph == null) { return; } try { cGUID entityID = new cGUID(flowgraph_content.SelectedItem.ToString().Substring(1, 11)); CathodeEntity thisEntity = CurrentInstance.selectedFlowgraph.GetEntityByID(entityID); if (thisEntity != null) { LoadEntity(thisEntity); } } catch (Exception ex) { MessageBox.Show("Encountered an issue while looking up entity!\nPlease report this on GitHub!\n" + ex.Message, "Failed lookup!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public CathodeEditorGUI_AddPin(CathodeEntity entity, CathodeFlowgraph flowgraph) { _entity = entity; InitializeComponent(); _entityList = flowgraph.GetEntities(); _entityList = _entityList.OrderBy(o => EditorUtils.GenerateNodeName(o, flowgraph).Substring(13)).ToList <CathodeEntity>(); pin_in_node.BeginUpdate(); for (int i = 0; i < _entityList.Count; i++) { string this_node_string = EditorUtils.GenerateNodeName(_entityList[i], flowgraph); pin_in_node.Items.Add(this_node_string); } pin_in_node.EndUpdate(); pin_out_node.Text = EditorUtils.GenerateNodeName(_entity, flowgraph); pin_out_node.Enabled = false; RefreshPinInParams(); RefreshPinOutParams(); }
/* Go to selected pin out on button press */ private void out_pin_goto_Click(object sender, EventArgs e) { if (node_children.SelectedIndex == -1 || CurrentInstance.selectedFlowgraph == null) { return; } CathodeEntity thisNodeInfo = null; if (currentlyShowingChildLinks) { thisNodeInfo = CurrentInstance.selectedFlowgraph.GetEntityByID(CurrentInstance.selectedEntity.childLinks[node_children.SelectedIndex].childID); } else { List <CathodeEntity> ents = CurrentInstance.selectedFlowgraph.GetEntities(); foreach (CathodeEntity entity in ents) { for (int i = 0; i < entity.childLinks.Count; i++) { if (entity.childLinks[i].connectionID == linkedNodeListIDs[node_children.SelectedIndex]) { thisNodeInfo = entity; break; } } if (thisNodeInfo != null) { break; } } } if (thisNodeInfo != null) { LoadEntity(thisNodeInfo); } }
/* Resolve a node hierarchy */ public static CathodeEntity ResolveHierarchy(List <cGUID> hierarchy, out CathodeFlowgraph containedFlowgraph) { CathodeFlowgraph currentFlowgraphToSearch = CurrentInstance.selectedFlowgraph; CathodeEntity entity = null; for (int i = 0; i < hierarchy.Count; i++) { if (hierarchy[i] == new cGUID("00-00-00-00")) { break; } entity = currentFlowgraphToSearch.GetEntityByID(hierarchy[i]); if (entity != null && entity.variant == EntityVariant.FUNCTION) { CathodeFlowgraph flowRef = CurrentInstance.commandsPAK.GetFlowgraph(((FunctionEntity)entity).function); if (flowRef != null) { currentFlowgraphToSearch = flowRef; } } } containedFlowgraph = currentFlowgraphToSearch; return(entity); }
private void createEntity(object sender, EventArgs e) { cGUID thisID = Utilities.GenerateGUID(DateTime.Now.ToString("G")); if (createDatatypeEntity.Checked) { //Make the DatatypeEntity DatatypeEntity newEntity = new DatatypeEntity(thisID); newEntity.type = (CathodeDataType)entityVariant.SelectedIndex; newEntity.parameter = Utilities.GenerateGUID(textBox1.Text); //Make the parameter to give this DatatypeEntity a value (the only time you WOULDN'T want this is if the val is coming from a linked entity) CathodeParameter thisParam = null; switch (newEntity.type) { case CathodeDataType.POSITION: thisParam = new CathodeTransform(); break; case CathodeDataType.FLOAT: thisParam = new CathodeFloat(); break; case CathodeDataType.FILEPATH: case CathodeDataType.STRING: thisParam = new CathodeString(); break; case CathodeDataType.SPLINE_DATA: thisParam = new CathodeSpline(); break; case CathodeDataType.ENUM: thisParam = new CathodeEnum(); ((CathodeEnum)thisParam).enumID = new cGUID("4C-B9-82-48"); //ALERTNESS_STATE is the first alphabetically break; case CathodeDataType.SHORT_GUID: thisParam = new CathodeResource(); ((CathodeResource)thisParam).resourceID = new cGUID("00-00-00-00"); break; case CathodeDataType.BOOL: thisParam = new CathodeBool(); break; case CathodeDataType.DIRECTION: thisParam = new CathodeVector3(); break; case CathodeDataType.INTEGER: thisParam = new CathodeInteger(); break; } newEntity.parameters.Add(new CathodeLoadedParameter(newEntity.parameter, thisParam)); //Add to flowgraph & save name flow.datatypes.Add(newEntity); if (NodeDB.GetCathodeName(newEntity.parameter) == newEntity.parameter.ToString()) { NodeDBEx.AddNewParameterName(newEntity.parameter, textBox1.Text); } NewEntity = newEntity; } else if (createFunctionEntity.Checked) { //Create FunctionEntity FunctionEntity newEntity = new FunctionEntity(thisID); switch (entityVariant.Text) { //TODO: find a nicer way of auto selecting this (E.G. can we reflect to class names?) case "CAGEAnimation": newEntity = new CAGEAnimation(thisID); break; case "TriggerSequence": newEntity = new TriggerSequence(thisID); break; } newEntity.function = CathodeEntityDatabase.GetEntityAtIndex(entityVariant.SelectedIndex).guid; //TODO: auto populate params here //Add to flowgraph & save name flow.functions.Add(newEntity); NodeDBEx.AddNewNodeName(thisID, textBox1.Text); NewEntity = newEntity; } else if (createFlowgraphEntity.Checked) { //Create FunctionEntity FunctionEntity newEntity = new FunctionEntity(thisID); CathodeFlowgraph selectedFlowgraph = availableFlows.FirstOrDefault(o => o.name == entityVariant.Text); if (selectedFlowgraph == null) { MessageBox.Show("Failed to look up flowgraph!\nPlease report this issue on GitHub.\n\n" + entityVariant.Text, "Could not find flowgraph!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } newEntity.function = selectedFlowgraph.nodeID; //Add to flowgraph & save name flow.functions.Add(newEntity); NodeDBEx.AddNewNodeName(thisID, textBox1.Text); NewEntity = newEntity; } this.Close(); }
/* Load a entity into the UI */ private void LoadEntity(CathodeEntity edit_node) { if (edit_node == null) { return; } ClearUI(false, false, true); CurrentInstance.selectedEntity = edit_node; Cursor.Current = Cursors.WaitCursor; //populate info labels selected_node_id.Text = edit_node.nodeID.ToString(); selected_node_type.Text = edit_node.variant.ToString(); string nodetypedesc = ""; switch (edit_node.variant) { case EntityVariant.FUNCTION: nodetypedesc = NodeDBEx.GetParameterName(((FunctionEntity)edit_node).function); node_to_flowgraph_jump.Visible = (CurrentInstance.commandsPAK.GetFlowgraph(((FunctionEntity)edit_node).function) != null); selected_node_name.Text = NodeDBEx.GetEntityName(edit_node.nodeID); #if DEBUG //TODO: PULL THIS INTO STABLE editCAGEAnimationKeyframes.Visible = nodetypedesc == "CAGEAnimation"; #endif break; case EntityVariant.DATATYPE: nodetypedesc = "DataType " + ((DatatypeEntity)edit_node).type.ToString(); selected_node_name.Text = NodeDBEx.GetParameterName(((DatatypeEntity)edit_node).parameter); break; case EntityVariant.PROXY: case EntityVariant.OVERRIDE: node_to_flowgraph_jump.Visible = true; selected_node_name.Text = NodeDBEx.GetEntityName(edit_node.nodeID); break; default: selected_node_name.Text = NodeDBEx.GetEntityName(edit_node.nodeID); break; } selected_node_type_description.Text = nodetypedesc; //show resource editor button if this node has a resource reference cGUID resourceParamID = Utilities.GenerateGUID("resource"); CathodeLoadedParameter resourceParam = CurrentInstance.selectedEntity.parameters.FirstOrDefault(o => o.paramID == resourceParamID); #if DEBUG //TODO: PULL THIS INTO STABLE editNodeResources.Visible = ((resourceParam != null) || CurrentInstance.selectedEntity.resources.Count != 0); #endif //populate parameter inputs int current_ui_offset = 7; for (int i = 0; i < edit_node.parameters.Count; i++) { if (edit_node.parameters[i].paramID == resourceParamID) { continue; //We use the resource editor button (above) for resource parameters } CathodeParameter this_param = edit_node.parameters[i].content; UserControl parameterGUI = null; switch (this_param.dataType) { case CathodeDataType.POSITION: parameterGUI = new GUI_TransformDataType(); ((GUI_TransformDataType)parameterGUI).PopulateUI((CathodeTransform)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.INTEGER: parameterGUI = new GUI_NumericDataType(); ((GUI_NumericDataType)parameterGUI).PopulateUI_Int((CathodeInteger)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.STRING: parameterGUI = new GUI_StringDataType(); ((GUI_StringDataType)parameterGUI).PopulateUI((CathodeString)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.BOOL: parameterGUI = new GUI_BoolDataType(); ((GUI_BoolDataType)parameterGUI).PopulateUI((CathodeBool)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.FLOAT: parameterGUI = new GUI_NumericDataType(); ((GUI_NumericDataType)parameterGUI).PopulateUI_Float((CathodeFloat)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.DIRECTION: parameterGUI = new GUI_VectorDataType(); ((GUI_VectorDataType)parameterGUI).PopulateUI((CathodeVector3)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.ENUM: parameterGUI = new GUI_EnumDataType(); ((GUI_EnumDataType)parameterGUI).PopulateUI((CathodeEnum)this_param, edit_node.parameters[i].paramID); break; case CathodeDataType.SHORT_GUID: parameterGUI = new GUI_HexDataType(); ((GUI_HexDataType)parameterGUI).PopulateUI((CathodeResource)this_param, edit_node.parameters[i].paramID, CurrentInstance.selectedFlowgraph); break; case CathodeDataType.SPLINE_DATA: parameterGUI = new GUI_SplineDataType(); ((GUI_SplineDataType)parameterGUI).PopulateUI((CathodeSpline)this_param, edit_node.parameters[i].paramID); break; } parameterGUI.Location = new Point(15, current_ui_offset); current_ui_offset += parameterGUI.Height + 6; NodeParams.Controls.Add(parameterGUI); } RefreshNodeLinks(); Cursor.Current = Cursors.Default; }
public CAGEAnimationEditor(CAGEAnimation _node) { animNode = _node; InitializeComponent(); animNode.keyframeHeaders = animNode.keyframeHeaders.OrderBy(o => o.parameterID).ToList(); string previousGroup = ""; int groupCount = 0; int maxWidth = 0; int groupBoxOffset = 3; int groupHeight = 0; int countInGroup = 0; GroupBox currentGroupBox = null; for (int i = 0; i < animNode.keyframeHeaders.Count; i++) { string paramGroupName = NodeDBEx.GetParameterName(animNode.keyframeHeaders[i].parameterID); if (i == 0 || previousGroup != paramGroupName) { if (currentGroupBox != null) { currentGroupBox.Size = new Size(maxWidth, groupHeight); groupBoxOffset += currentGroupBox.Size.Height + 10; } currentGroupBox = new GroupBox(); currentGroupBox.Text = paramGroupName; currentGroupBox.Location = new Point(3, groupBoxOffset); NodeParams.Controls.Add(currentGroupBox); groupCount++; maxWidth = 0; groupHeight = 0; countInGroup = 0; } previousGroup = paramGroupName; TextBox paramName = new TextBox(); paramName.Text = NodeDBEx.GetParameterName(animNode.keyframeHeaders[i].parameterSubID); paramName.ReadOnly = true; paramName.Location = new Point(6, 19 + (countInGroup * 23)); paramName.Size = new Size(119, 20); currentGroupBox.Controls.Add(paramName); CathodeParameterKeyframe paramData = animNode.keyframeData.FirstOrDefault(o => o.ID == animNode.keyframeHeaders[i].keyframeDataID); //TODO: populate full min max keyframes so new ones can be created int keyframeWidth = paramName.Location.X + paramName.Width; if (paramData != null) { for (int x = 0; x < paramData.keyframes.Count; x++) { Button keyframeBtn = new Button(); keyframeBtn.Size = new Size(27, 23); keyframeBtn.Location = new Point(134 + ((keyframeBtn.Size.Width + 6) * x), 18 + (countInGroup * 23)); keyframeBtn.Text = paramData.keyframes[x].secondsSinceStart.ToString(); keyframeBtn.AccessibleDescription = paramData.ID.ToString() + " " + x + " " + paramName.Text; keyframeBtn.Click += KeyframeBtn_Click; currentGroupBox.Controls.Add(keyframeBtn); if (keyframeBtn.Location.X > maxWidth) { maxWidth = keyframeBtn.Location.X; } keyframeWidth = keyframeBtn.Location.X + keyframeBtn.Width; } } CathodeFlowgraph flow; CathodeEntity resolvedEntity = EditorUtils.ResolveHierarchy(animNode.keyframeHeaders[i].connectedEntity, out flow); if (resolvedEntity != null) { TextBox controllingEntity = new TextBox(); controllingEntity.Text = "Controlling: " + NodeDBEx.GetEntityName(resolvedEntity.nodeID); controllingEntity.Location = new Point(keyframeWidth + 5, 18 + (countInGroup * 23)); controllingEntity.Size = new Size(200, 20); controllingEntity.ReadOnly = true; currentGroupBox.Controls.Add(controllingEntity); int thisWidth = controllingEntity.Location.X + controllingEntity.Width + 5; if (thisWidth > maxWidth) { maxWidth = thisWidth; } } groupHeight = paramName.Location.Y + paramName.Height + 5; countInGroup++; } if (currentGroupBox != null) { currentGroupBox.Size = new Size(maxWidth, groupHeight); } }
/* Duplicate selected entity */ private void duplicateSelectedNode_Click(object sender, EventArgs e) { if (CurrentInstance.selectedEntity == null) { return; } if (!ConfirmAction("Are you sure you want to duplicate this entity?")) { return; } //Generate new node ID and name CathodeEntity newEnt = Utilities.CloneObject(CurrentInstance.selectedEntity); newEnt.nodeID = Utilities.GenerateGUID(DateTime.Now.ToString("G")); NodeDBEx.AddNewNodeName(newEnt.nodeID, NodeDBEx.GetEntityName(CurrentInstance.selectedEntity.nodeID) + "_clone"); //Add parent links in to this node that linked in to the other node List <CathodeEntity> ents = CurrentInstance.selectedFlowgraph.GetEntities(); List <CathodeNodeLink> newLinks = new List <CathodeNodeLink>(); int num_of_new_things = 1; foreach (CathodeEntity entity in ents) { newLinks.Clear(); foreach (CathodeNodeLink link in entity.childLinks) { if (link.childID == CurrentInstance.selectedEntity.nodeID) { CathodeNodeLink newLink = new CathodeNodeLink(); newLink.connectionID = Utilities.GenerateGUID(DateTime.Now.ToString("G") + num_of_new_things.ToString()); num_of_new_things++; newLink.childID = newEnt.nodeID; newLink.childParamID = link.childParamID; newLink.parentParamID = link.parentParamID; newLinks.Add(newLink); } } if (newLinks.Count != 0) { entity.childLinks.AddRange(newLinks); } } //Save back to flowgraph switch (newEnt.variant) { case EntityVariant.FUNCTION: CurrentInstance.selectedFlowgraph.functions.Add((FunctionEntity)newEnt); break; case EntityVariant.DATATYPE: CurrentInstance.selectedFlowgraph.datatypes.Add((DatatypeEntity)newEnt); break; case EntityVariant.PROXY: CurrentInstance.selectedFlowgraph.proxies.Add((ProxyEntity)newEnt); break; case EntityVariant.OVERRIDE: CurrentInstance.selectedFlowgraph.overrides.Add((OverrideEntity)newEnt); break; case EntityVariant.NOT_SETUP: CurrentInstance.selectedFlowgraph.unknowns.Add(newEnt); break; } //Load in to UI ReloadUIForNewEntity(newEnt); }
/* Utility: generate a list of suggested parameters for an entity */ public static List <string> GenerateParameterList(CathodeEntity entity, out bool didGenerateFromDB) { didGenerateFromDB = false; List <string> items = new List <string>(); if (CurrentInstance.commandsPAK == null) { return(items); } switch (entity.variant) { case EntityVariant.FUNCTION: cGUID function = ((FunctionEntity)entity).function; List <CathodeEntityDatabase.ParameterDefinition> parameters = CathodeEntityDatabase.GetParametersFromEntity(function); if (parameters != null) { didGenerateFromDB = true; for (int i = 0; i < parameters.Count; i++) { items.Add(parameters[i].name); } } else { string[] options = NodeDB.GetEntityParameterList(NodeDBEx.GetParameterName(function)); items.Add("trigger"); items.Add("reference"); //TODO: populate all params from EntityMethodInterface? if (options == null) { CathodeFlowgraph flow = CurrentInstance.commandsPAK.GetFlowgraph(function); if (flow == null) { break; } for (int i = 0; i < flow.datatypes.Count; i++) { string to_add = NodeDBEx.GetParameterName(flow.datatypes[i].parameter); //TODO: also return datatype here if (!items.Contains(to_add)) { items.Add(to_add); } } } else { for (int i = 0; i < options.Length; i++) { if (!items.Contains(options[i])) { items.Add(options[i]); } } } } break; case EntityVariant.DATATYPE: items.Add(NodeDBEx.GetParameterName(((DatatypeEntity)entity).parameter)); break; //TODO: support other types here } items.Sort(); return(items); }