private void RefreshUI(string key) { //Log.Message($"Calling RefreshUI"); activeHairSims.ToList() .Where(kvp => kvp.Key != key && kvp.Value.hasSliders).ToList() .ForEach(kvp => kvp.Value.UnsetSliders()); if (activeHairSims.ContainsKey(key)) { ActiveHairSim selected = activeHairSims[key]; if (!selected.hasSliders) { selected.InitSliders(); } if (selected.wasLetLoose) { UIElementStore.UpdateToggleButtonText(selected.enabled); RefreshNotifications(selected); } } else { UIElementStore.UpdateToggleButtonText(null); UIElementStore.ApplyDummySliders(); } }
public string GetSelectedControlUid() { ActiveHairSim selected = activeHairSims[hairUISelect.val]; if (selected != null) { return(selected.optionName); } return(""); }
private IEnumerator RestoreFromJSONInternal(string selected, JSONArray array) { while (activeHairSims == null || checkCounter < 3) { yield return(null); } string optionName = ""; foreach (JSONClass jc in array) { ActiveHairSim match = null; foreach (KeyValuePair <string, ActiveHairSim> it in activeHairSims) { if (it.Key == jc["id"].Value) { match = it.Value; } if (it.Key == selected) { optionName = it.Value.optionName; } } if (match != null) { match.RestoreFromJSON(jc); } } if (hairUISelect.val == optionName) { RefreshUI(optionName); } else { hairUISelect.val = optionName; } }
public bool?ToggleEnableSelected() { if (!activeHairSims.ContainsKey(hairUISelect.val)) { return(null); } ActiveHairSim selected = activeHairSims[hairUISelect.val]; if (selected.enabled) { selected.enabled = false; selected.RestoreOriginalPhysics(); } else { selected.enabled = true; selected.ReLetLoose(); } RefreshNotifications(selected); return(selected.enabled); }
private void RefreshNotifications(ActiveHairSim selected = null) { if (selected == null) { if (!activeHairSims.ContainsKey(hairUISelect.val)) { notificationsUIText.val = notificationsHeader; return; } selected = activeHairSims[hairUISelect.val]; } if (!selected.enabled) { notificationsUIText.val = notificationsHeader; return; } string changes = selected.TrackPhysics(); notificationsUIText.val = notificationsHeader + $"{(changes.Length > 0 ? changes : "\n\nHair physics settings OK.")}"; }
private void RefreshHairOptions() { foreach (DAZHairGroup hair in hairItems) { string uid = hair.uid; if (hair.active && hair.name == "CustomHairItem" && !activeHairSims.ContainsKey(uid)) { //Log.Message($"Adding option for {uid}"); HairSimControl hairSim = hair.GetComponentInChildren <HairSimControl>(); if (hairSim != null) { ActiveHairSim activeHairSim = new ActiveHairSim($"{hair.creatorName} | {hair.displayName}", hairSim); activeHairSims.Add(uid, activeHairSim); activeHairSim.LetLoose(); } } else if (!hair.active && activeHairSims.ContainsKey(uid)) { //Log.Message($"Removing option for {uid} and restoring original physics"); activeHairSims[uid].RestoreOriginalPhysics(); activeHairSims.Remove(uid); } } }