예제 #1
0
 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, "");
 }
예제 #2
0
        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);
        }
예제 #3
0
        //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);
        }
예제 #4
0
    private PreloadedFlowgraphContent PreloadFlowgraphContent(CathodeFlowgraph flowgraph, uint typeID)
    {
        PreloadedFlowgraphContent content = new PreloadedFlowgraphContent();

        content.flowraphID = flowgraph.nodeID;
        List <CathodeNodeEntity> models = GetAllOfType(ref flowgraph, typeID);

        for (int i = 0; i < models.Count; i++)
        {
            CathodeNodeEntity thisNode     = models[i];
            List <int>        modelIndexes = new List <int>();
            List <UInt32>     resourceID   = new List <UInt32>();
            foreach (CathodeParameterReference paramRef in thisNode.nodeParameterReferences)
            {
                CathodeParameter param = commandsPAK.GetParameter(paramRef.offset);
                if (param == null)
                {
                    continue;
                }
                if (param.dataType != CathodeDataType.SHORT_GUID)
                {
                    continue;
                }
                resourceID.Add(((CathodeResource)param).resourceID);
            }
            for (int x = 0; x < resourceID.Count; x++)
            {
                List <CathodeResourceReference> resRef = flowgraph.GetResourceReferencesByID(resourceID[x]);
                for (int y = 0; y < resRef.Count; y++)
                {
                    if (resRef[y].entryType != CathodeResourceReferenceType.RENDERABLE_INSTANCE)
                    {
                        continue;                                                                          //Ignoring collision maps, etc, for now
                    }
                    for (int p = 0; p < resRef[y].entryCountREDS; p++)
                    {
                        modelIndexes.Add(redsBIN[resRef[y].entryIndexREDS] + p);
                    }
                }
            }
            content.nodeModelIDs.Add(modelIndexes);
            content.nodeTransforms.Add(GetTransform(ref thisNode));
            content.half_dimensions = GetHalfDimensions(ref thisNode);
            content.nodeNames.Add(NodeDB.GetNodeTypeName(thisNode.nodeType, ref commandsPAK) + ": " + NodeDB.GetFriendlyName(thisNode.nodeID));
        }
        return(content);
    }
예제 #5
0
 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);
 }
        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();
        }
예제 #7
0
        /* 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();
        }