Example #1
0
        public override void Evaluate(int SpreadMax)
        {
            //calc input spreadcount
            int inputSpreadCount = GetSpreadMax();

            //create or delete button groups
            int diff = inputSpreadCount - FControllerGroups.Count;

            if (diff > 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    FControllerGroups.Add(new SliderGroup());
                }
            }
            else if (diff < 0)
            {
                for (int i = 0; i < -diff; i++)
                {
                    FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i);
                }
            }

            //update parameters
            int slice;

            if (FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FSizeXIn.PinIsChanged ||
                FSizeYIn.PinIsChanged ||
                FIsXSliderIn.PinIsChanged ||
                FSizeSliderIn.PinIsChanged ||
                FTransformIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FSliderColorIn.PinIsChanged ||
                FSliderSpeedIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderGroup group = (SliderGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;
                    double    sizeSlider, sliderSpeed, isX;
                    RGBAColor col, over, active, slider;

                    FTransformIn.GetMatrix(slice, out trans);
                    FCountXIn.GetValue(slice, out count.x);
                    FCountYIn.GetValue(slice, out count.y);
                    FSizeXIn.GetValue(slice, out size.x);
                    FSizeYIn.GetValue(slice, out size.y);
                    FSizeSliderIn.GetValue(slice, out sizeSlider);
                    FColorIn.GetColor(slice, out col);
                    FOverColorIn.GetColor(slice, out over);
                    FActiveColorIn.GetColor(slice, out active);
                    FSliderColorIn.GetColor(slice, out slider);
                    FSliderSpeedIn.GetValue(slice, out sliderSpeed);
                    FIsXSliderIn.GetValue(slice, out isX);

                    group.UpdateTransform(trans, count, size, sizeSlider, col, over, active, slider, sliderSpeed, isX >= 0.5);
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

            for (slice = 0; slice < inputSpreadCount; slice++)
            {
                SliderGroup group = (SliderGroup)FControllerGroups[slice];

                outcount += group.FControllers.Length;
                FSpreadCountsOut.SetValue(slice, group.FControllers.Length);
            }

            //update mouse and colors
            bool valueSet = false;

            if (FMouseXIn.PinIsChanged ||
                FMouseYIn.PinIsChanged ||
                FLeftButtonIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FSliderColorIn.PinIsChanged ||
                FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FLastMouseLeft)
            {
                Vector2D mouse;
                double   mouseLeft;

                FMouseXIn.GetValue(0, out mouse.x);
                FMouseYIn.GetValue(0, out mouse.y);
                FLeftButtonIn.GetValue(0, out mouseLeft);

                bool mouseDown    = mouseLeft >= 0.5;
                bool mousDownEdge = mouseDown && !FLastMouseLeft;

                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderGroup group = (SliderGroup)FControllerGroups[slice];
                    valueSet |= group.UpdateMouse(mouse, mousDownEdge, mouseDown);
                }

                FLastMouseLeft = mouseDown;
            }

            //set value
            slice = 0;
            if (FValueIn.PinIsChanged ||
                FSetValueIn.PinIsChanged)
            {
                for (int i = 0; i < inputSpreadCount; i++)
                {
                    SliderGroup group  = (SliderGroup)FControllerGroups[i];
                    int         pcount = group.FControllers.Length;

                    for (int j = 0; j < pcount; j++)
                    {
                        double val;

                        FSetValueIn.GetValue(slice, out val);

                        if (val >= 0.5)
                        {
                            //update value
                            FValueIn.GetValue(slice, out val);
                            group.UpdateValue((Slider)group.FControllers[j], val);

                            valueSet = true;
                        }
                        else if (FFirstframe)
                        {
                            //load from config pin on first frame
                            FInternalValueConfig.GetValue(slice, out val);
                            group.UpdateValue((Slider)group.FControllers[j], val);
                        }

                        slice++;
                    }
                }
            }


            //write output to pins
            FValueOut.SliceCount = outcount;
            if (outcount != FInternalValueConfig.SliceCount)
            {
                FInternalValueConfig.SliceCount = outcount;
            }
            FTransformOut.SliceCount = outcount * 2;
            FColorOut.SliceCount     = outcount * 2;
            FHitOut.SliceCount       = outcount;
            FActiveOut.SliceCount    = outcount;
            FMouseOverOut.SliceCount = outcount;

            slice = 0;
            for (int i = 0; i < inputSpreadCount; i++)
            {
                SliderGroup group  = (SliderGroup)FControllerGroups[i];
                int         pcount = group.FControllers.Length;

                for (int j = 0; j < pcount; j++)
                {
                    Slider s = (Slider)group.FControllers[j];

                    FTransformOut.SetMatrix(slice * 2, s.Transform);
                    FTransformOut.SetMatrix(slice * 2 + 1, s.SliderTransform);
                    FColorOut.SetColor(slice * 2, s.CurrentCol);
                    FColorOut.SetColor(slice * 2 + 1, s.ColorSlider);
                    FValueOut.SetValue(slice, s.Value);
                    FMouseOverOut.SetValue(slice, s.MouseOver ? 1 : 0);
                    FHitOut.SetValue(slice, s.Hit ? 1 : 0);
                    FActiveOut.SetValue(slice, s.Active ? 1 : 0);

                    //update config pin
                    if (valueSet)
                    {
                        double val;
                        FInternalValueConfig.GetValue(slice, out val);

                        if (Math.Abs(s.Value - val) > 0.00000001)
                        {
                            FInternalValueConfig.SetValue(slice, s.Value);
                        }
                    }

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }
Example #2
0
        public override void Evaluate(int SpreadMax)
        {
            //calc input spreadcount
            int inputSpreadCount = SpreadMax;

            //create or delete button groups
            int diff = inputSpreadCount - FControllerGroups.Count;

            if (diff > 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    FControllerGroups.Add(new RadioButtonGroup());
                }
            }
            else if (diff < 0)
            {
                for (int i = 0; i < -diff; i++)
                {
                    FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i);
                }
            }

            //update parameters
            int slice;

            if (FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FSizeXIn.PinIsChanged ||
                FSizeYIn.PinIsChanged ||
                FTransformIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;
                    RGBAColor col, over, active;

                    FTransformIn.GetMatrix(slice, out trans);
                    FCountXIn.GetValue(slice, out count.x);
                    FCountYIn.GetValue(slice, out count.y);
                    FSizeXIn.GetValue(slice, out size.x);
                    FSizeYIn.GetValue(slice, out size.y);
                    FColorIn.GetColor(slice, out col);
                    FOverColorIn.GetColor(slice, out over);
                    FActiveColorIn.GetColor(slice, out active);

                    group.UpdateTransform(trans, count, size, col, over, active);
                }
            }


            //update mouse and colors
            bool valueSet = false;

            if (FMouseXIn.PinIsChanged ||
                FMouseYIn.PinIsChanged ||
                FLeftButtonIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FLastMouseLeft ||
                FSetValueIn.PinIsChanged)
            {
                Vector2D mouse;
                double   mouseLeft;

                FMouseXIn.GetValue(0, out mouse.x);
                FMouseYIn.GetValue(0, out mouse.y);
                FLeftButtonIn.GetValue(0, out mouseLeft);

                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];
                    valueSet = group.UpdateMouse(mouse, (mouseLeft >= 0.5) && !FLastMouseLeft, mouseLeft >= 0.5);
                }

                valueSet       = FLastMouseLeft && mouseLeft < 0.5;
                FLastMouseLeft = mouseLeft >= 0.5;
            }

            if (FValueIn.PinIsChanged ||
                FSetValueIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];

                    double val;

                    FSetValueIn.GetValue(slice, out val);

                    if (val >= 0.5)
                    {
                        //update value
                        FValueIn.GetValue(slice, out val);
                        group.UpdateValue((int)Math.Round(val));
                        valueSet = true;
                    }
                    else if (FFirstframe)
                    {
                        //load from config pin on first frame
                        FInternalValueConfig.GetValue(slice, out val);
                        group.UpdateValue((int)Math.Round(val));
                    }
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

            for (slice = 0; slice < inputSpreadCount; slice++)
            {
                RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];

                outcount += group.FControllers.Length;
                FSpreadCountsOut.SetValue(slice, group.FControllers.Length);
            }



            //write output to pins
            FValueOut.SliceCount = inputSpreadCount;
            if (outcount != FInternalValueConfig.SliceCount)
            {
                FInternalValueConfig.SliceCount = outcount;
            }
            FTransformOut.SliceCount = outcount;
            FColorOut.SliceCount     = outcount;
            FHitOut.SliceCount       = outcount;
            FActiveOut.SliceCount    = outcount;
            FMouseOverOut.SliceCount = outcount;

            slice = 0;
            for (int i = 0; i < inputSpreadCount; i++)
            {
                RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[i];
                int pcount             = group.FControllers.Length;

                FValueOut.SetValue(i, group.SelectedSlice);
                if (valueSet)
                {
                    FInternalValueConfig.SetValue(i, group.SelectedSlice);
                }

                for (int j = 0; j < pcount; j++)
                {
                    RadioButton b = (RadioButton)group.FControllers[j];

                    FTransformOut.SetMatrix(slice, b.Transform);
                    FColorOut.SetColor(slice, b.CurrentCol);
                    FMouseOverOut.SetValue(slice, b.MouseOver ? 1 : 0);
                    FHitOut.SetValue(slice, b.Hit ? 1 : 0);
                    FActiveOut.SetValue(slice, b.Active ? 1 : 0);

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }