示例#1
0
        public RandomizableTime Clone(int cloneFlags = 0)
        {
            var r = new RandomizableTime();

            CopyTo(r, 0);
            return(r);
        }
示例#2
0
        private void CutoffChanged(string s)
        {
            var i = RandomizableTime.CutoffFromString(s);

            if (i == -1)
            {
                return;
            }

            if (value_ != null)
            {
                ((RandomizableTime)value_).Cutoff = i;
            }
        }
示例#3
0
        public override bool FromJSON(J.Node n)
        {
            var o = n.AsObject("RandomDuration");

            if (o == null)
            {
                return(false);
            }

            RandomizableTime t = null;

            o.Opt("time", ref t);
            Time = t;

            Time.Reset(true);

            return(true);
        }
示例#4
0
文件: Step.cs 项目: via5/Synergy
        public bool FromJSON(J.Node n)
        {
            Clear();

            var o = n.AsObject("Step");

            if (o == null)
            {
                return(false);
            }

            o.Opt("enabled", enabled_);
            o.Opt("paused", ref paused_);
            o.Opt("name", ref name_);
            o.Opt("halfMove", halfMove_);
            o.Opt("modifiers", ref modifiers_);

            {
                IDuration d = null;
                o.Opt <DurationFactory, IDuration>("duration", ref d);
                Duration = d;
            }

            {
                RandomizableTime t = null;
                o.Opt("repeat", ref t);
                Repeat = t;
            }

            {
                Delay d = null;
                o.Opt("delay", ref d);
                Delay = d;
            }

            foreach (var m in modifiers_)
            {
                m.ParentStep = this;
            }

            return(true);
        }
示例#5
0
文件: Step.cs 项目: via5/Synergy
        public void Clear()
        {
            if (modifiers_ != null)
            {
                while (modifiers_.Count > 0)
                {
                    DeleteModifier(modifiers_[0]);
                }
            }

            enabled_.Value    = true;
            name_             = null;
            Duration          = new RandomDuration();
            Repeat            = new RandomizableTime(0);
            Delay             = new Delay(new RandomDuration(), false, false);
            halfMove_.Value   = false;
            inFirstHalf_      = true;
            modifiers_        = new List <ModifierContainer>();
            enabledModifiers_ = new List <ModifierContainer>();
        }
示例#6
0
        public RandomizableTimeWidgets(string name, int flags = 0)
            : base(flags)
        {
            interval_ = new FloatSlider(
                name + " change interval", 0, new FloatRange(0, 10),
                IntervalChanged, flags);

            randomHalf_ = new Button("Randomize half", RandomizeHalf, flags);

            initial_ = new FloatSlider(
                name, 0, new FloatRange(0, 0),
                InitialChanged, flags);

            range_ = new FloatSlider(
                name + " random range", 0, new FloatRange(0, 0),
                RangeChanged, flags);

            cutoff_ = new StringList(
                name + " cut-off", "",
                RandomizableTime.GetCutoffNames(), CutoffChanged, flags);
        }
示例#7
0
        public void SetValue(RandomizableTime v, FloatRange preferredRange)
        {
            value_ = v;

            if (value_ != null)
            {
                initial_.Parameter = value_.InitialParameter;
                initial_.Default   = value_.Initial;
                initial_.Range     = preferredRange;

                range_.Parameter = value_.RangeParameter;
                range_.Default   = value_.Range;
                range_.Range     = preferredRange;

                interval_.Parameter = value_.IntervalParameter;
                interval_.Default   = value_.Interval;
            }

            if (v != null)
            {
                cutoff_.Value = RandomizableTime.CutoffToString(v.Cutoff);
            }
        }
示例#8
0
 protected void CopyTo(RandomizableTime r, int cloneFlags)
 {
     base.CopyTo(r, cloneFlags);
     r.cutoff_ = cutoff_;
 }
示例#9
0
 public override void Removed()
 {
     base.Removed();
     Time = null;
 }
示例#10
0
 public RandomDuration(float s, float r = 0)
 {
     Time = new RandomizableTime(s, r, 0);
 }