Exemple #1
0
        public TodoHdeEnumVariable(INode2 node, TodoEngine engine, string varname)
        {
            this.node = node;
            //this.var = var;

            this.valuepin = this.node.FindPin("Input Enum");

            enumname = this.valuepin.SubType.Split(",".ToCharArray())[1].Trim();

            int ecnt = EnumManager.GetEnumEntryCount(enumname);

            for (int i = 0; i < ecnt; i++)
            {
                string eval = EnumManager.GetEnumEntryString(enumname, i);
                string vn   = varname + "-" + eval;

                TodoVariable var = engine.GetVariableByName(vn);
                if (var == null)
                {
                    var          = new TodoVariable(vn);
                    var.Category = "Global";
                    engine.RegisterVariable(var, false);
                }

                var.ValueChanged += var_ValueChanged;
                vars.Add(var);
            }
            //this.valuepin.
            //this.valuepin.Type

            //var.ValueChanged += var_ValueChanged;
            //var.VariableUpdated += var_VariableUpdated;
        }
Exemple #2
0
        public TodoHdeVariable(INode2 node, TodoEngine engine, string varname)
        {
            this.node = node;

            this.valuepin = this.node.FindPin("Y Input Value");
            if (this.valuepin.SliceCount == 1)
            {
                TodoVariable var = engine.GetVariableByName(varname);
                if (var == null)
                {
                    var          = new TodoVariable(varname);
                    var.Category = "Global";
                    engine.RegisterVariable(var, false);
                }

                var.ValueChanged    += var_ValueChanged;
                var.VariableUpdated += var_VariableUpdated;

                this.vars.Add(var);
            }
            else if (this.valuepin.SliceCount > 1)
            {
                for (int i = 0; i < this.valuepin.SliceCount; i++)
                {
                    string vn = varname + "-" + i.ToString();

                    TodoVariable var = engine.GetVariableByName(vn);
                    if (var == null)
                    {
                        var          = new TodoVariable(vn);
                        var.Category = "Global";
                        engine.RegisterVariable(var, false);
                    }

                    var.ValueChanged    += var_ValueChanged;
                    var.VariableUpdated += var_VariableUpdated;

                    this.vars.Add(var);
                }
            }

            this.minpin = this.node.FindPin("Minimum");
            this.maxpin = this.node.FindPin("Maximum");

            this.minpin.Changed += minpin_Changed;
            this.maxpin.Changed += maxpin_Changed;
        }
Exemple #3
0
        private static void LoadVariable(TodoEngine engine, XmlNode node)
        {
            TodoVariable var = new TodoVariable();

            var.Inputs = new List <AbstractTodoInput>();

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.Name == "Name")
                {
                    var.Name = child.InnerText;
                }
                if (child.Name == "Category")
                {
                    var.Category = child.InnerText;
                }
                if (child.Name == "AllowFeedBack")
                {
                    var.AllowFeedBack = BoolExtension.ParseEnglish(child.InnerText);
                }
                if (child.Name == "Default")
                {
                    var.Default = Convert.ToDouble(child.InnerText, CultureInfo.InvariantCulture);
                }
                if (child.Name == "MinValue")
                {
                    var.Mapper.MinValue = Convert.ToDouble(child.InnerText, CultureInfo.InvariantCulture);
                }
                if (child.Name == "MaxValue")
                {
                    var.Mapper.MaxValue = Convert.ToDouble(child.InnerText, CultureInfo.InvariantCulture);
                }
                if (child.Name == "TweenMode")
                {
                    var.Mapper.TweenMode = (eTweenMode)Enum.Parse(typeof(eTweenMode), child.InnerText);
                }
                if (child.Name == "EaseMode")
                {
                    var.Mapper.EaseMode = (eTweenEaseMode)Enum.Parse(typeof(eTweenEaseMode), child.InnerText);
                }
                if (child.Name == "TakeOverMode")
                {
                    var.TakeOverMode = (eTodoGlobalTakeOverMode)Enum.Parse(typeof(eTodoGlobalTakeOverMode), child.InnerText);
                }
                if (child.Name == "TodoInputs")
                {
                    foreach (XmlNode input in child.ChildNodes)
                    {
                        LoadInputs(engine, input, var);
                    }
                }
            }

            if (var.Category == null)
            {
                var.Category = "Global";
            }
            else
            {
                if (var.Category.Length == 0)
                {
                    var.Category = "Global";
                }
            }
            engine.RegisterVariable(var, false);
            var.SetDefault();

            //foreach (AbstractTodoInput ti in var.Inputs)
            //{
            //    engine.RegisterInput(ti);
            //}
        }