public void PopulateUI(CathodeBool cBool, cGUID paramID) { boolVal = cBool; BOOL_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; checkBox1.Checked = cBool.value; //checkBox1.DataBindings.Add("Checked", cBool.value, ""); }
public void PopulateUI(CathodeString cString, cGUID paramID) { stringVal = cString; STRING_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; textBox1.Text = cString.value; //textBox1.DataBindings.Add("Text", cString.value, ""); }
public void PopulateUI_Int(CathodeInteger cInt, cGUID paramID) { isIntInput = true; intVal = cInt; NUMERIC_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; textBox1.Text = cInt.value.ToString(); }
public static void RemoveNewNodeName(cGUID id) { ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID == id); if (desc == null) { return; } customNodeNames.Remove(desc); }
public void PopulateUI(CathodeEnum cEnum, cGUID paramID) { enumVal = cEnum; ENUM_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; comboBox1.Text = NodeDB.GetEnum(cEnum.enumID).Name; //comboBox1.Enabled = false; //numericUpDown8.Value = cEnum.enumIndex; textBox1.Text = cEnum.enumIndex.ToString(); //numericUpDown8.DataBindings.Add("Value", cEnum.enumIndex, ""); }
public void PopulateUI(CathodeVector3 cVec, cGUID paramID) { vectorVal = cVec; VECTOR_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; POS_X_1.Value = (decimal)cVec.value.x; POS_Y_1.Value = (decimal)cVec.value.y; POS_Z_1.Value = (decimal)cVec.value.z; //POS_X_1.DataBindings.Add("Value", (decimal)cVec.value.X, ""); //POS_Y_1.DataBindings.Add("Value", (decimal)cVec.value.Y, ""); //POS_Z_1.DataBindings.Add("Value", (decimal)cVec.value.Z, ""); }
public static string GetEntityName(cGUID id) { string id_string = id.ToString(); ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID_cachedstring == id_string); if (desc == null) { return(NodeDB.GetEditorName(id)); } return(desc.Description); }
//Get parameter/entity name //We fall through to NodeDB here which means we can replace all NodeDB calls to Cathode/Editor name in the GUI app public static string GetParameterName(cGUID id) { string id_string = id.ToString(); ShortGUIDDescriptor desc = customParamNames.FirstOrDefault(o => o.ID_cachedstring == id_string); if (desc == null) { return(NodeDB.GetCathodeName(id, CurrentInstance.commandsPAK)); } return(desc.Description); }
public static void PurgeEntityNameFromCache(cGUID entId) { if (!hasFinishedCachingEntityNames) { queuedForRemoval.Add(entId); } else { cachedEntityName.Remove(entId); } }
private CathodeFlowgraph GetFlowgraphContainingNode(cGUID nodeID) { for (int i = 0; i < CurrentInstance.commandsPAK.Flowgraphs.Count; i++) { List <CathodeEntity> entities = CurrentInstance.commandsPAK.Flowgraphs[i].GetEntities(); for (int x = 0; x < entities.Count; x++) { if (entities[x].nodeID == nodeID) { return(CurrentInstance.commandsPAK.Flowgraphs[i]); } } } return(null); }
//Add new param/node names public static void AddNewParameterName(cGUID id, string name) { ShortGUIDDescriptor desc = customParamNames.FirstOrDefault(o => o.ID == id); if (desc != null) { desc.Description = name; } else { customParamNames.Add(new ShortGUIDDescriptor { ID = id, ID_cachedstring = id.ToString(), Description = name }); } }
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(); }
//-- public static void AddNewNodeName(cGUID id, string name) { ShortGUIDDescriptor desc = customNodeNames.FirstOrDefault(o => o.ID == id); if (desc != null) { desc.Description = name; } else { customNodeNames.Add(new ShortGUIDDescriptor { ID = id, ID_cachedstring = id.ToString(), Description = name }); } EditorUtils.PurgeEntityNameFromCache(id); }
public void PopulateUI(CathodeTransform cTrans, cGUID paramID) { transformVal = cTrans; POSITION_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; POS_X.Value = (decimal)cTrans.position.x; POS_Y.Value = (decimal)cTrans.position.y; POS_Z.Value = (decimal)cTrans.position.z; ROT_X.Value = (decimal)cTrans.rotation.x; ROT_Y.Value = (decimal)cTrans.rotation.y; ROT_Z.Value = (decimal)cTrans.rotation.z; //POS_X.DataBindings.Add("Value", (decimal)cTrans.position.X, ""); //POS_Y.DataBindings.Add("Value", (decimal)cTrans.position.Y, ""); //POS_Z.DataBindings.Add("Value", (decimal)cTrans.position.Z, ""); //ROT_X.DataBindings.Add("Value", (decimal)cTrans.rotation.X, ""); //ROT_Y.DataBindings.Add("Value", (decimal)cTrans.rotation.Y, ""); //ROT_Z.DataBindings.Add("Value", (decimal)cTrans.rotation.Z, ""); }
private void KeyframeBtn_Click(object sender, EventArgs e) { string info = ((Button)sender).AccessibleDescription; string[] infoS = info.Split(' '); cGUID id = new cGUID(infoS[0]); currentEditData = animNode.keyframeData.FirstOrDefault(o => o.ID == id).keyframes[Convert.ToInt32(infoS[1])]; textBox2.Text = currentEditData.paramValue.ToString(); groupBox1.Visible = true; string name = ""; for (int i = 2; i < infoS.Length; i++) { name += infoS[i]; } groupBox1.Text = name + ": " + currentEditData.secondsSinceStart + " seconds"; }
/* 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 static string[] GetEntityParameterList(string entity_name) { //We should never need to correct NodeDB here, as you can't add custom parameters to hardcoded nodes (for obvious reasons) //But... doing it anyway string[] content = NodeDB.GetEntityParameterList(entity_name); for (int i = 0; i < content.Length; i++) { if (content[i].Length == 11) { if (content[i][2] == '-' && content[i][5] == '-' && content[i][8] == '-') { try { cGUID id = new cGUID(content[i]); content[i] = GetParameterName(id); } catch { } } } } return(content); }
public void PopulateUI(CathodeResource cResource, cGUID paramID, CathodeFlowgraph selected_flowgraph) { GUID_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; resRef = cResource; if (cResource.resourceID.val != null) { textBox2.Text = BitConverter.ToString(new byte[] { cResource.resourceID.val[0] }); textBox3.Text = BitConverter.ToString(new byte[] { cResource.resourceID.val[1] }); textBox5.Text = BitConverter.ToString(new byte[] { cResource.resourceID.val[2] }); textBox4.Text = BitConverter.ToString(new byte[] { cResource.resourceID.val[3] }); } /* * List<RenderableElement> redsList = new List<RenderableElement>(); * CathodeResourceReference resRef = selected_flowgraph.resources.FirstOrDefault(o => o.resourceRefID == cResource.resourceID); * if (resRef == null || resRef.entryType != CathodeResourceReferenceType.RENDERABLE_INSTANCE) return; * for (int p = 0; p < resRef.entryCountREDS; p++) redsList.Add(redsBIN.GetRenderableElement(resRef.entryIndexREDS + p)); * if (resRef.entryCountREDS != redsList.Count || redsList.Count == 0) return; //TODO: handle this nicer * CathodeEditorGUI_EditResource res_editor = new CathodeEditorGUI_EditResource(modelPAK.GetCS2s(), redsList); * res_editor.Show(); * res_editor.EditComplete += new FinishedEditingIndexes(res_editor_submitted); */ }
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(); }
public CathodeEditorGUI_RenameNode(cGUID node) { InitializeComponent(); entity_name.Text = NodeDBEx.GetEntityName(node); NodeID = node; }
public void PopulateUI_Float(CathodeFloat cFloat, cGUID paramID) { floatVal = cFloat; NUMERIC_VARIABLE_DUMMY.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; textBox1.Text = cFloat.value.ToString(); }
public static string GetEntityClassName(cGUID node_guid) { return(entities.FirstOrDefault(o => o.guid == node_guid).className); }
public static ParameterDefinition GetParameterFromEntity(cGUID node_guid, string parameter_name) { string node_name = GetEntityClassName(node_guid); return(entities.FirstOrDefault(o => o.className == node_name).parameters.FirstOrDefault(o => o.name == parameter_name)); }
public static List <ParameterDefinition> GetParametersFromEntity(cGUID node_guid) { string node_name = GetEntityClassName(node_guid); return(entities.FirstOrDefault(o => o.className == node_name).parameters); }
/* 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 void PopulateUI(CathodeSpline cSpline, cGUID paramID) { UNIMPLEMENTED_VARIABLE_TYPE.Text = NodeDBEx.GetParameterName(paramID) + " (" + paramID.ToString() + ")"; //todo: dynamically populate UI }
/* 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); }
private void button1_Click(object sender, EventArgs e) { if (param_name.Text == "") { return; } cGUID thisParamID = Utilities.GenerateGUID(param_name.Text); foreach (CathodeLoadedParameter param in node.parameters) { if (param.paramID == thisParamID) { MessageBox.Show("This parameter already exists on the entity!"); return; } } CathodeParameter thisParam = null; switch ((CathodeDataType)param_datatype.SelectedIndex) { 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; } node.parameters.Add(new CathodeLoadedParameter(thisParamID, thisParam)); //If this parameter doesn't come up in the CATHODE string table, add it to our own if (NodeDB.GetCathodeName(thisParamID) == thisParamID.ToString()) { NodeDBEx.AddNewParameterName(thisParamID, param_name.Text); } this.Close(); }