private JSONStorableBool GetToggle() { Synergy.LogVerbose("gaze: searching for enabled parameter"); foreach (var id in atom_.GetStorableIDs()) { if (id.Contains("MacGruber.Gaze")) { var st = atom_.GetStorableByID(id); if (st == null) { Synergy.LogError("gaze: can't find storable " + id); continue; } var en = st.GetBoolJSONParam("enabled"); if (en == null) { Synergy.LogError("gaze: no enabled param"); continue; } return(en); } } return(null); }
public void SetStorable(string id) { if (atom_ == null || string.IsNullOrEmpty(id)) { return; } var s = atom_.GetStorableByID(id); if (s == null) { Synergy.LogError( $"storable id '{id}' not found in atom '{atom_.uid}'"); return; } storable_ = s; if (Parameter != null) { if (!SetParameterImpl(parameter_.Name)) { Parameter = null; } } }
public void RemoveMorph(SelectedMorph sm) { if (modifier_ == null) { return; } modifier_.RemoveMorph(sm.Morph); for (int i = 0; i < selectedMorphs_.Count; ++i) { if (selectedMorphs_[i].SelectedMorph == sm) { selectedMorphsCollapsible_.Remove( selectedMorphs_[i].Collapsible); selectedMorphs_.RemoveAt(i); if (selectedMorphsCollapsible_.Expanded) { ui_.NeedsReset("selected morph removed"); } return; } } Synergy.LogError( "can't remove morph " + sm.Morph.displayName + ", " + "not in list"); }
private void CheckGaze() { bool e; if (gazeSetting_ == SettingEnable) { e = true; } else if (gazeSetting_ == SettingDisable) { e = false; } else { return; } if (!gaze_.SetEnabled(Atom, e)) { Synergy.LogError( "gaze: can't set value, changing setting to Ignore"); gazeSetting_ = SettingIgnore; } }
private void CheckBlink() { if (Atom == null) { return; } bool e; if (blinkSetting_ == SettingEnable) { e = true; } else if (blinkSetting_ == SettingDisable) { e = false; } else { return; } if (blink_ == null) { var ec = Atom.GetStorableByID("EyelidControl"); if (ec == null) { Synergy.LogError( "blink: EyelidControl not found, " + "changing setting to Ignore"); blinkSetting_ = SettingIgnore; return; } blink_ = ec.GetBoolJSONParam("blinkEnabled"); if (blink_ == null) { Synergy.LogError( "blink: blinkEnabled not found in EyelidControl, " + "changing setting to Ignore"); blinkSetting_ = SettingIgnore; return; } } try { blink_.val = e; } catch (Exception ex) { Synergy.LogError( "blink: can't set value on blinkEnabled, " + ex.ToString() + ", changing setting to Ignore"); blinkSetting_ = SettingIgnore; } }
private void ResolveModifier() { if (ParentModifier?.ParentStep == null) { return; } if (modifierIndex_ == -1 && modifier_ != null) { modifierIndex_ = ParentModifier.ParentStep.IndexOfModifier(modifier_); } else if (modifierIndex_ >= 0 && modifier_ == null) { var mods = ParentModifier.ParentStep.Modifiers; if (modifierIndex_ >= 0 && modifierIndex_ < mods.Count) { modifier_ = mods[modifierIndex_].Modifier; } } if (modifier_ == ParentModifier) { Synergy.LogError("OtherModifierSyncedModifier: same modifiers"); modifier_ = null; modifierIndex_ = -1; } }
public bool FromJSON(J.Node n) { var o = n.AsObject("EyesTargetContainer"); if (o == null) { return(false); } o.Opt("enabled", ref enabled_); // migration: constant target removed, was redundant with rigidbody if (o.HasChildObject("target")) { var t = o.Get("target").AsObject(); string type = ""; t.Opt("factoryTypeName", ref type); if (type == "constant") { Synergy.LogInfo("found constant eye target, converting to rigidbody"); target_ = new RigidbodyEyesTarget(); return(target_.FromJSON(t)); } } o.Opt <EyesTargetFactory, IEyesTarget>("target", ref target_); return(true); }
protected override void AtomChanged() { base.AtomChanged(); var fixedList = new List <SelectedMorph>(); foreach (var sm in morphs_) { var newMorph = Utilities.FindMorphInNewAtom(Atom, sm.Morph); if (newMorph == null) { Synergy.LogWarning( "morph " + sm.Morph.displayName + " doesn't exist in " + Atom.uid); sm.Removed(); continue; } sm.Reset(); sm.Atom = Atom; sm.Morph = newMorph; fixedList.Add(sm); } morphs_.Clear(); morphs_.AddRange(fixedList); Progression.MorphsChanged(); }
public bool SetEnabled(Atom atom, bool b) { if (toggle_ == null) { if (atom_ == null) { return(true); } toggle_ = GetToggle(); } if (toggle_ == null) { return(false); } try { toggle_.val = b; return(true); } catch (Exception) { Synergy.LogError( "gaze: failed to change value, " + "assuming script is gone"); toggle_ = null; } return(false); }
private void ResetUI() { Synergy.LogVerbose("resetting ui"); ReselectStepAndModifier(); widgets_.RemoveFromUI(); step_.RemoveFromUI(); modifier_.RemoveFromUI(); monitor_.RemoveFromUI(); if (inMonitor_) { AddMonitorToUI(); } else if (inManageAnimatables_) { AddManageAnimatablesToUI(); } else { AddMainToUI(); } needsReset_ = false; Synergy.LogVerbose("done resetting ui"); }
private void UpdateStorables() { if (!storablesStale_) { return; } List <string> list = null; var a = holder_?.Atom; if (a != null) { bool pluginsOnly = false; string type = type_; if (type.EndsWith(PluginSuffix)) { type = type.Substring(0, type.Length - PluginSuffix.Length); pluginsOnly = true; } list = new List <string>(); if (type == "") { foreach (var id in a.GetStorableIDs()) { if (!pluginsOnly || Utilities.StorableIsPlugin(id)) { list.Add(id); } } } else { var p = new StorableParameterFactory().Create(type); if (p == null) { Synergy.LogError($"unknown type {type}"); } else { list = new List <string>(p.GetStorableNames(a, pluginsOnly)); } } } if (list == null) { list = new List <string>(); } Utilities.NatSort(list); storables_.Choices = list; storablesStale_ = false; }
public void SetParameter(string name) { if (!SetParameterImpl(name)) { Parameter = null; Synergy.LogError( $"parameter '{name}' not found in storable " + $"'{storable_.name}'"); } }
private void OnToggled(Morph m, bool b) { try { mc_.Toggle(m, b); } catch (Exception e) { Synergy.LogError(e.ToString()); } }
private void UpdateAtom() { gaze_.Atom = Atom; blink_ = null; if (Atom == null) { head_ = null; eyes_ = null; lookMode_ = null; chest_ = null; return; } head_ = Utilities.FindRigidbody(Atom, "headControl"); eyes_ = Utilities.FindRigidbody(Atom, "eyeTargetControl"); chest_ = Utilities.FindRigidbody(Atom, "chestControl"); lookMode_ = null; var eyesStorable = Atom.GetStorableByID("Eyes"); if (eyesStorable != null) { lookMode_ = eyesStorable.GetStringChooserJSONParam("lookMode"); if (lookMode_ == null) { Synergy.LogError("atom " + Atom.uid + " has no lookMode"); } } if (chest_ == null) { Synergy.LogError("atom " + Atom.uid + " has no chest"); } if (head_ != null && eyes_ != null) { return; } if (head_ == null) { Synergy.LogError("atom " + Atom.uid + " has no head"); } if (eyes_ == null) { Synergy.LogError("atom " + Atom.uid + " has no eyes"); } head_ = null; eyes_ = null; }
public override void PostLoad(JSONStorable s) { param_ = s.GetParam(paramName_) as T; if (param_ == null) { Synergy.LogError( $"PostLoad: param name {paramName_} not in " + $"storable {s.storeId}"); } paramName_ = null; }
private void UpdateAtom() { if (atom_ == null && atomName_ != "") { atom_ = SuperController.singleton.GetAtomByUid(atomName_); if (atom_ == null && !logged_) { Synergy.LogError($"cannot find atom {atomName_}"); logged_ = true; } } }
private void DoAddMorph(DAZMorph morph, string parentPath) { if (morphs_.ContainsKey(morph.displayName)) { Synergy.LogVerbose( "duplicate morph '" + morph.displayName + "' " + "in '" + parentPath + "'"); } else { morphs_.Add(morph.displayName, new Morph(morph)); } }
public virtual T Create(string s) { foreach (var e in GetAllObjects()) { if (e.GetFactoryTypeName() == s) { return(e); } } Synergy.LogError("factory object type '" + s + "' not found"); return(null); }
public override bool FromJSON(J.Node n) { if (!base.FromJSON(n)) { return(false); } var o = n.AsObject("AudioModifier"); if (o == null) { return(false); } if (o.HasChildArray("clips")) { var clipsArray = o.Get("clips").AsArray(); if (clipsArray != null) { var cm = URLAudioClipManager.singleton; clipsArray.ForEach((clipNode) => { var clipUID = clipNode?.AsString("Clip node"); if (string.IsNullOrEmpty(clipUID)) { return; } var clip = cm.GetClip(clipUID); if (clip == null) { Synergy.LogError("clip '" + clipUID + "' not found"); } else { clips_.Add(clip); } }); Reshuffle(); } } o.Opt("playType", ref playType_); return(true); }
public override bool FromJSON(J.Node n) { if (!base.FromJSON(n)) { return(false); } var o = n.AsObject("RigidbodyEyesTarget"); if (o == null) { return(false); } if (o.HasKey("atom")) { var atomUID = o.Get("atom").AsString(); if (atomUID != null) { if (atomUID == Utilities.PresetAtomPlaceholder) { atom_ = Synergy.Instance.DefaultAtom; } else { atom_ = SuperController.singleton.GetAtomByUid(atomUID); } if (atom_ == null) { Synergy.LogError("atom '" + atomUID + "' not found"); } } } // migration from constant eye target o.OptRigidbody("relative", atom_, ref receiver_); if (receiver_ == null) { o.OptRigidbody("receiver", atom_, ref receiver_); } if (o.HasKey("offset")) { J.Wrappers.FromJSON(o.Get("offset"), ref offset_); } return(true); }
public void SetMorphs(List <DAZMorph> morphs) { var fixedMorphs = new List <SelectedMorph>(); foreach (var m in morphs) { bool found = false; foreach (var sm in morphs_) { if (sm.Morph == m) { fixedMorphs.Add(sm); found = true; break; } } if (!found) { var nsm = SelectedMorph.Create(Atom, m); nsm.Movement = new Movement(0, 1); fixedMorphs.Add(nsm); } } int i = 0; while (i < morphs_.Count) { if (fixedMorphs.Contains(morphs_[i])) { ++i; } else { morphs_[i].Removed(); morphs_.RemoveAt(i); } } morphs_.Clear(); morphs_.AddRange(fixedMorphs); Synergy.LogError("new morphs: " + morphs.Count.ToString()); Progression.MorphsChanged(); }
private void TriggerTypeChanged(string s) { int i = 0; if (!int.TryParse(s, out i)) { Synergy.LogError($"can't parse trigger type '{s}'"); return; } if (param_ != null) { param_.TriggerType = i; } }
private void UpdateParameters() { if (!parametersStale_) { return; } List <string> list = null; var s = holder_?.Storable; if (s != null) { string type = type_; if (type.EndsWith(PluginSuffix)) { type = type.Substring(0, type.Length - PluginSuffix.Length); } if (type == "") { list = s.GetAllParamAndActionNames(); } else { var p = new StorableParameterFactory().Create(type); if (p == null) { Synergy.LogError($"unknown type {type_}"); } else { list = new List <string>(p.GetParameterNames(s)); } } } if (list == null) { list = new List <string>(); } Utilities.NatSort(list); parameters_.Choices = list; parametersStale_ = false; }
private void UpdateRigidbody() { if (rb_ == null && rbName_ != "" && atom_ != null) { rb_ = Utilities.FindRigidbody(atom_, rbName_); if (rb_ == null && !logged_) { Synergy.LogError( $"cannot find rigidbody {rbName_} in atom " + $"{atom_.uid}"); logged_ = true; } } }
public override void PostLoad(JSONStorable s) { if (!string.IsNullOrEmpty(paramName_)) { param_ = s.GetAction(paramName_); if (param_ == null) { Synergy.LogError( $"PostLoad: action name {paramName_} not in " + $"storable {s.storeId}"); } paramName_ = null; } }
public override bool FromJSON(J.Node n) { if (!base.FromJSON(n)) { return(false); } var o = n.AsObject("RandomEyesTarget"); if (o == null) { return(false); } if (o.HasKey("atom")) { var atomUID = o.Get("atom").AsString(); if (atomUID != null) { if (atomUID == Utilities.PresetAtomPlaceholder) { atom_ = Synergy.Instance.DefaultAtom; } else { atom_ = SuperController.singleton.GetAtomByUid(atomUID); } if (atom_ == null) { Synergy.LogError("atom '" + atomUID + "' not found"); } } } o.OptRigidbody("relative", atom_, ref rel_); o.Opt("distance", ref distance_); o.Opt("xCenter", ref centerX_); o.Opt("yCenter", ref centerY_); o.Opt("xRange", ref xRange_); o.Opt("yRange", ref yRange_); o.Opt("avoidXRange_", ref avoidXRange_); o.Opt("avoidYRange_", ref avoidYRange_); return(true); }
private void UpdateController(Atom atom) { if (controller_ == null && controllerName_ != "") { controller_ = Utilities.FindFreeController( atom, controllerName_); if (controller_ == null && !logged_) { Synergy.LogError( $"cannot find controller {controllerName_} in atom " + $"{atom.uid}"); logged_ = true; } } }
public override void AddToUI(IModifierSync s) { sync_ = s as OtherModifierSyncedModifier; if (sync_?.ParentModifier?.ParentStep == null) { return; } var names = new List <string>(); bool found = false; foreach (var m in sync_.ParentModifier.ParentStep.Modifiers) { if (m.Modifier == sync_.ParentModifier) { continue; } names.Add(m.Name); if (sync_.OtherModifier != null && sync_.OtherModifier == m.Modifier) { found = true; } } modifiers_.Choices = names; if (found) { modifiers_.Value = sync_.OtherModifier.Name; } else { if (sync_.OtherModifier != null) { Synergy.LogError( "modifier '" + sync_.OtherModifier.Name + "' " + "not found"); } modifiers_.Value = ""; } modifiers_.AddToUI(); }
public void SetParameter(JSONStorableParam sp) { if (Parameter != null && Parameter.TryParameter(sp)) { return; } var p = StorableParameterFactory.Create(sp); if (p == null) { Synergy.LogError("unknown parameter type " + sp.ToString()); return; } Parameter = p; }
protected override void DoAddToUI() { if (dirty_) { Synergy.LogVerbose("list is dirty"); UpdateList(); dirty_ = false; } RemoveFromUI(); root_.AddToUI(); if (focusSearch_) { search_.Focus(); focusSearch_ = false; } }