Exemple #1
0
        void CreateIntControl(GroupBox aGroupBox, ParameterObject aParameterObject, int aControlNumber)
        {
            Label l = new Label();

            l.Name      = aParameterObject.variableName + "textbox" + aControlNumber;
            l.Location  = new Point(15, 30 * aControlNumber);
            l.Text      = aParameterObject.variableName;
            l.ForeColor = Color.White;


            NumericUpDown n = new NumericUpDown();

            n.Name     = aParameterObject.variableName + "numericInput" + aControlNumber;
            n.Location = new Point(140, 30 * aControlNumber);
            n.Minimum  = -10000;
            n.Maximum  = 10000;
            n.Value    = Int32.Parse(aParameterObject.variableValue);


            aGroupBox.Controls.Add(l);
            aGroupBox.Controls.Add(n);

            globalIntNumerInputs.Add(n);
        }
Exemple #2
0
        void CheckForParameters()
        {
            for (int i = 0; i < lines.Count; i++)
            {
                if (lines[i].Contains("/*"))
                {
                    int charLocation = lines[i].IndexOf("*/", StringComparison.Ordinal);

                    string textToCheck = lines[i].Substring(0, charLocation);

                    if (textToCheck.ToLower().Contains("global"))
                    {
                        if (textToCheck.ToLower().Contains("-int -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "int";

                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;

                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\s(-)?\d*\;");
                            Match valueMatch = varValue.Match(lines[i]);

                            string value = valueMatch.Groups[0].Value.Substring(1, valueMatch.Groups[0].Value.Length - 2);
                            pObj.variableValue = value;

                            globalParameterList.Add(pObj);
                            globalIntParameterList.Add(pObj);
                        }
                        else if (textToCheck.ToLower().Contains("-float -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "float";

                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;

                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\s(-)?\d*(\.\d*)");
                            Match valueMatch = varValue.Match(lines[i]);

                            if (valueMatch.Groups[0].Value == null || valueMatch.Groups[0].Value == "")
                            {
                                MessageBox.Show("Error on line " + (pObj.line + 1) + ": floats not valid, even if the float is a whole number it needs .0 at the end.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                string value = valueMatch.Groups[0].Value.Substring(0, valueMatch.Groups[0].Value.Length - 2);
                                pObj.variableValue = value;


                                globalParameterList.Add(pObj);
                                globalFloatParameterList.Add(pObj);
                            }
                        }
                        else if (textToCheck.ToLower().Contains("-color -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "color";



                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;



                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\((\d*\.\d*),(\s)?(\d*\.\d*)\,(\s)?\d*(\.\d*)?\);");
                            Match valueMatch = varValue.Match(lines[i]);
                            if (valueMatch.Success)
                            {
                                string value = valueMatch.Groups[0].Value;
                                pObj.variableValue = value;
                                globalParameterList.Add(pObj);
                                globalColorParameterList.Add(pObj);
                            }
                            else
                            {
                                MessageBox.Show("Error on line " + (pObj.line + 1) + ": float3 color flags can not contains negative values.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                    else if (textToCheck.ToLower().Contains("solo"))
                    {
                        if (textToCheck.ToLower().Contains("-int -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "int";

                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;

                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\s(-)?\d*\;");
                            Match valueMatch = varValue.Match(lines[i]);

                            string value = valueMatch.Groups[0].Value.Substring(1, valueMatch.Groups[0].Value.Length - 2);
                            pObj.variableValue = value;

                            soloParameterList.Add(pObj);
                            soloIntParameterList.Add(pObj);
                        }
                        else if (textToCheck.ToLower().Contains("-float -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "float";

                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;

                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\s(-)?\d*(\.\d*)");
                            Match valueMatch = varValue.Match(lines[i]);

                            if (valueMatch.Groups[0].Value == null || valueMatch.Groups[0].Value == "")
                            {
                                MessageBox.Show("Error on line " + (pObj.line + 1) + ": floats not valid, even if the float is a whole number it needs .0 at the end.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                string value = valueMatch.Groups[0].Value.Substring(0, valueMatch.Groups[0].Value.Length - 2);
                                pObj.variableValue = value;


                                soloParameterList.Add(pObj);
                                soloFloatParameterList.Add(pObj);
                            }
                        }
                        else if (textToCheck.ToLower().Contains("-color -"))
                        {
                            ParameterObject pObj = new ParameterObject();
                            pObj.line         = i;
                            pObj.variableType = "color";



                            Regex catName  = new Regex(@"\-\w*\*");
                            Match catMatch = catName.Match(lines[i]);

                            string cat = catMatch.Groups[0].Value.Substring(1, catMatch.Groups[0].Value.Length - 2);
                            pObj.categoryName = cat;



                            //To get variable name
                            Regex varName   = new Regex(@"\w*?\s(?<!=)=(?!=)");
                            Match nameMatch = varName.Match(lines[i]);

                            string name = nameMatch.Groups[0].Value.Substring(0, nameMatch.Groups[0].Value.Length - 2);
                            pObj.variableName = name;

                            Regex varValue   = new Regex(@"\((\d*\.\d*),(\s)?(\d*\.\d*)\,(\s)?\d*(\.\d*)?\);");
                            Match valueMatch = varValue.Match(lines[i]);
                            if (valueMatch.Success)
                            {
                                string value = valueMatch.Groups[0].Value;
                                pObj.variableValue = value;
                                soloParameterList.Add(pObj);
                                soloColorParameterList.Add(pObj);
                            }
                            else
                            {
                                MessageBox.Show("Error on line " + (pObj.line + 1) + ": float3 color flags can not contains negative values.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                }
            }
        }