Beispiel #1
0
 public void DisableAllExcept(ModifierContainer except)
 {
     foreach (var m in modifiers_)
     {
         m.Enabled = (m == except);
     }
 }
Beispiel #2
0
        public ModifierContainer AddEmptyModifier()
        {
            var m = new ModifierContainer();

            AddModifier(m);
            return(m);
        }
Beispiel #3
0
 public void AddModifier(ModifierContainer m)
 {
     m.ParentStep = this;
     modifiers_.Add(m);
     m.Added();
     ModifiersChanged?.Invoke();
 }
Beispiel #4
0
        public void DeleteModifier(ModifierContainer mc)
        {
            // remember the modifier, the container nulls it in Removed()
            var m = mc.Modifier;

            mc.Removed();

            if (m != null)
            {
                foreach (var sm in modifiers_)
                {
                    sm.ModifierSync?.OtherModifierRemoved(m);
                }
            }

            modifiers_.Remove(mc);
            ModifiersChanged?.Invoke();
        }
Beispiel #5
0
        public void LoadPreset(string path, int flags)
        {
            J.Node.SaveContext = SaveContext.CreateForPreset(
                Bits.IsSet(flags, Utilities.PresetUsePlaceholder));

            var node = J.Node.Wrap(SuperController.singleton.LoadJSON(path));

            if (Bits.IsSet(flags, Utilities.FullPreset))
            {
                if (Bits.IsSet(flags, Utilities.PresetReplace))
                {
                    FromJSON(node);
                }
                else if (Bits.IsSet(flags, Utilities.PresetAppend))
                {
                    var m = new Manager();
                    m.FromJSON(node);

                    foreach (var s in m.Steps)
                    {
                        AddStep(s);
                    }
                }
            }
            else if (Bits.IsSet(flags, Utilities.StepPreset))
            {
                if (Bits.IsSet(flags, Utilities.PresetReplace))
                {
                    var s = Synergy.Instance.UI.CurrentStep;
                    if (s == null)
                    {
                        Synergy.LogError("no current step");
                        return;
                    }

                    s.FromJSON(node);
                    s.Reset();
                }
                else if (Bits.IsSet(flags, Utilities.PresetAppend))
                {
                    var s = new Step();
                    s.FromJSON(node);
                    AddStep(s);
                    s.Reset();
                }
                else if (Bits.IsSet(flags, Utilities.PresetMerge))
                {
                    var s = Synergy.Instance.UI.CurrentStep;
                    if (s == null)
                    {
                        Synergy.LogError("no current step");
                        return;
                    }

                    var newStep = new Step();
                    newStep.FromJSON(node);

                    foreach (var m in newStep.Modifiers)
                    {
                        s.AddModifier(m);
                    }

                    newStep.RelinquishModifiers();

                    s.Reset();
                }
            }
            else if (Bits.IsSet(flags, Utilities.ModifierPreset))
            {
                if (Bits.IsSet(flags, Utilities.PresetReplace))
                {
                    var m = Synergy.Instance.UI.CurrentModifier;
                    if (m == null)
                    {
                        Synergy.LogError("no current modifier");
                        return;
                    }

                    m.FromJSON(node);
                }
                else if (Bits.IsSet(flags, Utilities.PresetAppend))
                {
                    var s = Synergy.Instance.UI.CurrentStep;
                    if (s == null)
                    {
                        Synergy.LogError("no current step");
                        return;
                    }

                    var m = new ModifierContainer();
                    m.FromJSON(node);

                    s.AddModifier(m);
                }
            }

            J.Node.SaveContext = SaveContext.CreateForScene();
        }
Beispiel #6
0
 public virtual void Removed()
 {
     parent_ = null;
 }
Beispiel #7
0
        public void AddToUI(ModifierContainer sm)
        {
            ListenForModifierEvents(sm?.Modifier);

            currentModifier_ = sm;
            if (currentModifier_ == null)
            {
                return;
            }

            header_.Text       = currentModifier_.Name;
            enabled_.Parameter = sm.EnabledParameter;

            var m = currentModifier_.Modifier;

            type_.Value = m;

            modifierSync_.Value = m?.ModifierSync;

            if (m == null)
            {
                modifierSyncUI_ = null;
                specificUI_     = null;
            }
            else
            {
                if (modifierSyncUI_ == null ||
                    modifierSyncUI_.SyncType != m.ModifierSync.GetFactoryTypeName())
                {
                    modifierSyncUI_ = CreateModifierSyncUI(m.ModifierSync);
                }

                if (specificUI_ == null ||
                    specificUI_.ModifierType != m.GetFactoryTypeName())
                {
                    specificUI_ = CreateSpecificUI(m);
                }
            }

            widgets_.AddToUI(header_);
            widgets_.AddToUI(delete_);
            widgets_.AddToUI(enabled_);
            widgets_.AddToUI(disableOthers_);
            widgets_.AddToUI(enableAll_);
            widgets_.AddToUI(new SmallSpacer(Widget.Right));

            widgets_.AddToUI(type_);

            if (currentModifier_.Modifier != null && currentModifier_.Modifier.UsesSync)
            {
                widgets_.AddToUI(modifierSync_);
            }

            if (modifierSyncUI_ != null)
            {
                modifierSyncUI_.AddToUI(m.ModifierSync);
            }

            widgets_.AddToUI(new SmallSpacer(Widget.Right));

            if (specificUI_ != null)
            {
                specificUI_.AddToTopUI(m);
                widgets_.AddToUI(new SmallSpacer(Widget.Right));
            }

            if (specificUI_ != null)
            {
                widgets_.AddToUI(new SmallSpacer(Widget.Right));
                specificUI_.AddToBottomUI(m);
            }
        }
Beispiel #8
0
 public int IndexOfModifier(ModifierContainer m)
 {
     return(modifiers_.IndexOf(m));
 }