Ejemplo n.º 1
0
 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 CathodeParameter ParameterDefinitionToParameter(ParameterDefinition def)
        {
            CathodeParameter this_param = null;

            switch (def.datatype.ToUpper())
            {
            case "POSITION":
                this_param = new CathodeTransform();
                break;

            case "FLOAT":
                this_param = new CathodeFloat();
                break;

            case "FILEPATH":
            case "STRING":
                this_param = new CathodeString();
                break;

            case "SPLINEDATA":
                this_param = new CathodeSpline();
                break;

            case "BOOL":
                this_param = new CathodeBool();
                break;

            case "DIRECTION":
                this_param = new CathodeVector3();
                break;

            case "INT":
                this_param = new CathodeInteger();
                break;

                /*
                 * case "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;
                 */
            }
            return(this_param);
        }
        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();
        }
        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();
        }