public void DisableAllExcept(ModifierContainer except) { foreach (var m in modifiers_) { m.Enabled = (m == except); } }
public ModifierContainer AddEmptyModifier() { var m = new ModifierContainer(); AddModifier(m); return(m); }
public void AddModifier(ModifierContainer m) { m.ParentStep = this; modifiers_.Add(m); m.Added(); ModifiersChanged?.Invoke(); }
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(); }
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(); }
public virtual void Removed() { parent_ = null; }
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); } }
public int IndexOfModifier(ModifierContainer m) { return(modifiers_.IndexOf(m)); }