Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        public string GetSelectedControlUid()
        {
            ActiveHairSim selected = activeHairSims[hairUISelect.val];

            if (selected != null)
            {
                return(selected.optionName);
            }

            return("");
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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.")}";
        }
Exemplo n.º 6
0
 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);
         }
     }
 }