Example #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();
            }
        }
 public void InitStorables()
 {
     lowerAngleLimit = UIElementStore.NewLowerAngleLimitStorable();
     upperAngleLimit = UIElementStore.NewUpperAngleLimitStorable();
     minMainRigidity = UIElementStore.NewMinMainRigidityStorable();
     maxMainRigidity = UIElementStore.NewMaxMainRigidityStorable();
     minTipRigidity  = UIElementStore.NewMinTipRigidityStorable();
     maxTipRigidity  = UIElementStore.NewMaxTipRigidityStorable();
     minStyleCling   = UIElementStore.NewMinStyleClingStorable();
     maxStyleCling   = UIElementStore.NewMaxStyleClingStorable();
 }
Example #3
0
        private void InitPluginUILeft()
        {
            JSONStorableString titleUIText      = new JSONStorableString("titleText", "");
            UIDynamicTextField titleUITextField = CreateTextField(titleUIText);

            titleUITextField.UItext.fontSize = 30;
            titleUITextField.height          = 100;
            titleUIText.val = $"<b>{nameof(HairLetLoose)}</b>\n<size=26>v{pluginVersion.val}</size>";

            UIElementStore.Init();
            NewSlider(UIElementStore.dummyLowerAngleLimit, valueFormat: "F0");
            NewSlider(UIElementStore.dummyUpperAngleLimit, valueFormat: "F0");
            NewSlider(UIElementStore.dummyMinMainRigidity, valueFormat: "F3");
            NewSlider(UIElementStore.dummyMaxMainRigidity, valueFormat: "F3");
            NewSlider(UIElementStore.dummyMinTipRigidity, valueFormat: "F4");
            NewSlider(UIElementStore.dummyMaxTipRigidity, valueFormat: "F4");
            NewSlider(UIElementStore.dummyMinStyleCling, valueFormat: "F2");
            NewSlider(UIElementStore.dummyMaxStyleCling, valueFormat: "F2");
            UIElementStore.StoreSliders();
        }
Example #4
0
        private void InitPluginUIRight()
        {
            hairSimHandler.CreateHairSelect();
            UIDynamicPopup hairUISelectPopup = CreatePopup(hairSimHandler.hairUISelect, rightSide: true);

            hairUISelectPopup.height = 100;

            UIElementStore.toggleEnableButton        = CreateButton("Disable for selected hairstyle", rightSide: true);
            UIElementStore.toggleEnableButton.height = 50;
            UIElementStore.toggleEnableButton.button.onClick.AddListener(() =>
            {
                if (enabled)
                {
                    bool?result = hairSimHandler.ToggleEnableSelected();
                    UIElementStore.UpdateToggleButtonText(result);
                }
            });
            UIElementStore.UpdateToggleButtonText(null);

            JSONStorableString helpUIText      = new JSONStorableString("helpText", "");
            UIDynamicTextField helpUITextField = CreateTextField(helpUIText, rightSide: true);

            helpUITextField.UItext.fontSize = 26;
            helpUITextField.height          = 325;
            helpUIText.val = $"\n<b><size=30>How it works</size></b>\n\n" +
                             $"Hair is the least rigid at the lower limit angle, and the most rigid at the upper limit angle.\n\n" +
                             $"90° is upright, 0° is horizontal, -90° is upside down.";

            hairSimHandler.valuesUIText = new JSONStorableString("valuesText", "");
            UIDynamicTextField valuesUITextField = CreateTextField(hairSimHandler.valuesUIText, rightSide: true);

            valuesUITextField.UItext.fontSize = 26;
            valuesUITextField.height          = 255;

            hairSimHandler.notificationsUIText = new JSONStorableString("notificationsText", "<");
            UIDynamicTextField notificationsUITextField = CreateTextField(hairSimHandler.notificationsUIText, rightSide: true);

            notificationsUITextField.UItext.fontSize = 26;
            notificationsUITextField.height          = 390;
        }
        public void InitSliders()
        {
            hasSliders = true;
            UIElementStore.ApplySliders(
                lowerAngleLimit,
                upperAngleLimit,
                minMainRigidity,
                maxMainRigidity,
                minTipRigidity,
                maxTipRigidity,
                minStyleCling,
                maxStyleCling
                );

            lowerAngleLimit.slider.onValueChanged.AddListener((float val) =>
            {
                if (val > upperAngleLimit.val)
                {
                    upperAngleLimit.val = val;
                }
            });

            upperAngleLimit.slider.onValueChanged.AddListener((float val) =>
            {
                if (val < lowerAngleLimit.val)
                {
                    lowerAngleLimit.val = val;
                }
            });

            minMainRigidity.slider.onValueChanged.AddListener((float val) =>
            {
                if (val > maxMainRigidity.val)
                {
                    maxMainRigidity.val = val;
                }
            });

            maxMainRigidity.slider.onValueChanged.AddListener((float val) =>
            {
                if (val < minMainRigidity.val)
                {
                    minMainRigidity.val = val;
                }
            });

            minTipRigidity.slider.onValueChanged.AddListener((float val) =>
            {
                if (val > maxTipRigidity.val)
                {
                    maxTipRigidity.val = val;
                }
            });

            maxTipRigidity.slider.onValueChanged.AddListener((float val) =>
            {
                if (val < minTipRigidity.val)
                {
                    minTipRigidity.val = val;
                }
            });

            minStyleCling.slider.onValueChanged.AddListener((float val) =>
            {
                if (val > maxStyleCling.val)
                {
                    maxStyleCling.val = val;
                }
            });

            maxStyleCling.slider.onValueChanged.AddListener((float val) =>
            {
                if (val < minStyleCling.val)
                {
                    minStyleCling.val = val;
                }
            });
        }