예제 #1
0
        public FloatSelector(
            MVRScript plug, bool insideRestore,
            CallbackAction call,
            string startAtom = null,
            AtomStorableSelector _storableSelected = null)
        {
            try
            {
                currentValue = new JSONStorableFloat("current value", 0f, setValue, -1f, 1f, false);
                plug.RegisterFloat(currentValue);

                currentValueSlider = plug.CreateSlider(currentValue, true);
                currentValueSlider.gameObject.SetActive(false);

                this.insideRestore = insideRestore;
                if (_storableSelected == null)
                {
                    storableSelected = new AtomStorableSelector(plug, SyncStorable, startAtom);
                }
                else
                {
                    storableSelected = _storableSelected;
                    storableSelected.Add(SyncStorable);
                }

                floatChooser = new JSONStorableStringChooser("floatTarget", null, null, "Value", SyncfloatTarget);
                UIDynamicPopup dp = plug.CreateScrollablePopup(floatChooser);
                dp.popupPanelHeight = 820f;
                plug.RegisterStringChooser(floatChooser);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #2
0
        public void AddControls()
        {
            spacer        = synthia.CreateSpacer();
            spacer.height = 24;

            // TODO id just so happens to match here
            // perhaps actually pass in the id here and let animation hold on to it?


            playButton = synthia.CreateButton("Play " + id);
            playButton.button.onClick.AddListener(() =>
            {
                synthia.ForcePlayAnimation(this);
            });
            playButton.buttonColor = new Color(.3f, 0.9f, 0.33f);


            idLabel        = synthia.CreateTextField(new JSONStorableString("id", id));
            idLabel.height = 4;

            loopToggle = synthia.CreateToggle(loopStorable);
            restartOnAnimationChangeToggle = synthia.CreateToggle(restartOnAnimationChangeStorable);
            startFrameSlider   = synthia.CreateSlider(startFrameStorable);
            endFrameSlider     = synthia.CreateSlider(endFrameStorable);
            rootMotionXZToggle = synthia.CreateToggle(rootMotionXZStorable);
            rootMotionYToggle  = synthia.CreateToggle(rootMotionYStorable);

            removeButton = synthia.CreateButton("Remove " + id);
            removeButton.button.onClick.AddListener(() =>
            {
                synthia.animations.Remove(id);
                RemoveControls();
            });
            removeButton.buttonColor = new Color(.8f, 0.3f, 0.2f);
        }
예제 #3
0
        protected void BuildUIControls()
        {
            //Diff Color
            HSVColor diffColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jDiffColor = new JSONStorableColor("DiffuseColor", diffColorHSVC, SetDiffColor);
            RegisterColor(jDiffColor);
            CreateColorPicker(jDiffColor, true);

            //Specular Color
            HSVColor specColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jSpecColor = new JSONStorableColor("SpecularColor", specColorHSVC, SetSpecColor);
            RegisterColor(jSpecColor);
            CreateColorPicker(jSpecColor, true);

            // Specular Intensity
            jSpecIntensityFloat = new JSONStorableFloat("SpecularIntensity", 0.5f, SetSpecIntensity, 0f, 1f, true);
            RegisterFloat(jSpecIntensityFloat);
            specIntensitySlider = CreateSlider(jSpecIntensityFloat);

            // Specular Sharpness
            jSpecSharpnessFloat = new JSONStorableFloat("SpecularSharpness", 6f, SetSpecSharpness, 0f, 10f, true);
            RegisterFloat(jSpecSharpnessFloat);
            specSharpnessSlider = CreateSlider(jSpecSharpnessFloat);

            // Specular Fresnel
            jSpecFresnelFloat = new JSONStorableFloat("SpecularFresnel", 0f, SetSpecFresnel, 0f, 1f, true);
            RegisterFloat(jSpecFresnelFloat);
            specFresnelSlider = CreateSlider(jSpecFresnelFloat);

            // Diffuse Offset
            jDiffOffsetFloat = new JSONStorableFloat("DiffuseOffset", 0f, SetDiffOffset, -1f, 1f, true);
            RegisterFloat(jDiffOffsetFloat);
            diffOffsetSlider = CreateSlider(jDiffOffsetFloat);

            // Spec Offset
            jSpecOffsetFloat = new JSONStorableFloat("SpecularOffset", 0f, SetSpecOffset, -1f, 1f, true);
            RegisterFloat(jSpecOffsetFloat);
            specOffsetSlider = CreateSlider(jSpecOffsetFloat);

            // Gloss Offset
            jGlossOffsetFloat = new JSONStorableFloat("GlossOffset", 0.8f, SetGlossOffset, 0, 1f, true);
            RegisterFloat(jGlossOffsetFloat);
            glossOffsetSlider = CreateSlider(jGlossOffsetFloat);

            // IBL Filter (affects Global Illum Skybox ?!)
            jIBLFilterFloat = new JSONStorableFloat("IBLFilter", 0f, SetIBLFilter, 0, 1f, true);
            RegisterFloat(jIBLFilterFloat);
            iBLFilterSlider = CreateSlider(jIBLFilterFloat);

            //Subdermis Color
            HSVColor subdermisColorHSVC = HSVColorPicker.RGBToHSV(1f, 1f, 1f);

            jSubdermisColor = new JSONStorableColor("SubdermisColor", subdermisColorHSVC, SetSubdermisColor);
            RegisterColor(jSubdermisColor);
            CreateColorPicker(jSubdermisColor, true);
        }
예제 #4
0
        public UIDynamicSlider CreateMorphSlider(string name, float width = 300, float height = 80, Transform parent = null)
        {
            UIDynamicSlider slider = CreateSlider(name, width, height, true);

            slider.transform.Find("Panel").GetComponent <Image>().color = new Color(0, 0, 0);

            slider.slider.GetComponent <Image>().color = new Color(0.7f, 0.7f, 0.7f);

            RectTransform sliderRT = slider.slider.GetComponent <RectTransform>();

            sliderRT.sizeDelta = new Vector2(1, 80);
            //sliderRT.anchoredPosition = new Vector2(0, -0.5f);
            sliderRT.pivot = new Vector2(0, 0.5f);

            Image fillRectImage = slider.slider.fillRect.GetComponent <Image>();

            fillRectImage.color = new Color(0.1f, 0.1f, 0.1f);

            slider.labelText.color = new Color(1, 1, 1);
            slider.GetComponentsInChildren <Text>().ToList().ForEach((Text text) =>
            {
                text.color         = new Color(1, 1, 1);
                text.raycastTarget = false;
                //text.fontSize = 16;
                //RectTransform textRT = text.GetComponent<RectTransform>();
                //textRT.sizeDelta = new Vector2(120, 80);
                //textRT.pivot = new Vector2(-0.2f, 0.5f);
                //textRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 200);
            });

            slider.slider.transform.Find("Handle Slide Area").gameObject.SetActive(false);

            InputField inputField = slider.GetComponentInChildren <InputField>();

            inputField.enabled = false;

            EventTrigger trigger = slider.gameObject.AddComponent <EventTrigger>();

            EventTrigger.Entry mouseEnter = new EventTrigger.Entry();
            mouseEnter.eventID = EventTriggerType.PointerEnter;
            mouseEnter.callback.AddListener((eventData) =>
            {
                fillRectImage.color = new Color(0.3f, 0.4f, 0.6f);
            });
            trigger.triggers.Add(mouseEnter);

            EventTrigger.Entry mouseExit = new EventTrigger.Entry();
            mouseExit.eventID = EventTriggerType.PointerExit;
            mouseExit.callback.AddListener((eventData) =>
            {
                fillRectImage.color = new Color(0.1f, 0.1f, 0.1f);
            });
            trigger.triggers.Add(mouseExit);
            ParentTo(slider.transform, parent);

            //sliderRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 350);
            return(slider);
        }
예제 #5
0
        private void NewSlider(
            JSONStorableFloat storable,
            string valueFormat, // 3 decimal places
            bool rightSide = false
            )
        {
            UIDynamicSlider slider = CreateSlider(storable, rightSide);

            slider.valueFormat = valueFormat;
        }
예제 #6
0
 public void RemoveSlider(JSONStorableFloat jsf, UIDynamicSlider component = null)
 {
     if (jsf.slider != null)
     {
         jsf.slider = null; _storables.Remove(jsf);
     }
     if (component != null)
     {
         Destroy(component.gameObject);
     }
 }
예제 #7
0
파일: VAM-HUD.cs 프로젝트: morph1sm/vam-hud
        protected void SetupPluginUI()
        {
            List <string> choices = new List <string>();

            choices.Add("None");
            choices.Add("FPS");
            choices.Add("Load Dir");
            choices.Add("Total Atoms");

            JSONStorableStringChooser jsonTypeTopLeft = new JSONStorableStringChooser("TopLeft", choices, typeTopLeft, "Top Left", SetTopLeft);
            UIDynamicPopup            dropdownTopLeft = CreatePopup(jsonTypeTopLeft);

            dropdownTopLeft.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeTopRight = new JSONStorableStringChooser("TopRight", choices, typeTopRight, "Top Right", SetTopRight);
            UIDynamicPopup            dropdownTopRight = CreatePopup(jsonTypeTopRight, true);

            dropdownTopRight.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeBottomLeft = new JSONStorableStringChooser("BottomLeft", choices, typeBottomLeft, "Bottom Left", SetBottomLeft);
            UIDynamicPopup            dropdownBottomLeft = CreatePopup(jsonTypeBottomLeft);

            dropdownBottomLeft.labelWidth = 300f;

            JSONStorableStringChooser jsonTypeBottomRight = new JSONStorableStringChooser("BottomRight", choices, typeBottomRight, "Bottom Right", SetBottomRight);
            UIDynamicPopup            dropdownBottomRight = CreatePopup(jsonTypeBottomRight, true);

            dropdownBottomRight.labelWidth = 300f;

            // let user adjust scale and top for HMD viewport differences and personal preference.
            JSONStorableFloat jsonTopOffset = new JSONStorableFloat("Top Offset", topOffset, SetTopOffset, -2f, +2f, true);

            RegisterFloat(jsonTopOffset);
            sliderTopOffset = CreateSlider(jsonTopOffset);

            JSONStorableFloat jsonScale = new JSONStorableFloat("HUD Scale", hudScale, SetScale, 10f, 200f, true);

            RegisterFloat(jsonScale);
            sliderScale = CreateSlider(jsonScale);

            JSONStorableFloat jsonFontSize = new JSONStorableFloat("Text Size", fontSize, SetFontSize, 10f, 100f, true);

            RegisterFloat(jsonFontSize);
            sliderFontSize = CreateSlider(jsonFontSize);


            // JSONStorableColor example
            HSVColor          hsvc          = HSVColorPicker.RGBToHSV(textColor.r, textColor.g, textColor.b);
            JSONStorableColor jsonTextColor = new JSONStorableColor("Text Color", hsvc, SetTextColor);

            RegisterColor(jsonTextColor);
            CreateColorPicker(jsonTextColor, true);
        }
예제 #8
0
        public override void Init()
        {
            try
            {
                ui = new UI(this, 0.001f);
                ui.canvas.transform.SetParent(containingAtom.mainController.transform, false);
                ui.canvas.transform.localPosition = new Vector3(0, -0.15f, 0);

                thrustValue = new JSONStorableFloat("thrust", 0, 0, SLIDER_MAX, true, true);
                RegisterFloat(thrustValue);

                UIDynamicSlider thrustSlider = ui.CreateSlider("Thrust Control", 300, 120);
                thrustSlider.valueFormat = "n0";
                thrustValue.slider       = thrustSlider.slider;

                thrustSlider.slider.onValueChanged.AddListener((float value) =>
                {
                    if (ap != null)
                    {
                        float speed = Remap(thrustValue.val, 0, SLIDER_MAX, 0, maxSpeed.val);
                        ap.SetFloatParamValue("speed", speed);
                    }
                });

                apName = new JSONStorableString("apName", "");
                RegisterString(apName);

                CreateButton("Select Animation Pattern").button.onClick.AddListener(() =>
                {
                    SuperController.singleton.SelectModeAtom((atom) =>
                    {
                        if (atom.GetStorableByID("AnimationPattern") == null)
                        {
                            SuperController.LogError("You must select an animation pattern.");
                            return;
                        }

                        apName.SetVal(atom.name);
                        ap = atom.GetStorableByID("AnimationPattern") as AnimationPattern;
                    });
                });

                maxSpeed = new JSONStorableFloat("maxSpeed", 4, 0, 10, false, true);
                RegisterFloat(maxSpeed);
                CreateSlider(maxSpeed, true);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #9
0
        public ExpressionController(DollmasterPlugin dm) : base(dm)
        {
            morphsEnabled = new JSONStorableBool("morphsEnabled", true, (bool enabled) =>
            {
                if (enabled == false)
                {
                    ZeroTargets();
                }
            });
            dm.RegisterBool(morphsEnabled);
            UIDynamicToggle morphsEnabledToggle = dm.CreateToggle(morphsEnabled);

            morphsEnabledToggle.label           = "Enable Facial Morphs";
            morphsEnabledToggle.backgroundColor = Color.green;

            voiceEnabled = new JSONStorableBool("voiceEnabled", true);
            dm.RegisterBool(voiceEnabled);
            UIDynamicToggle voiceEnabledToggle = dm.CreateToggle(voiceEnabled);

            voiceEnabledToggle.label           = "Enable Voice";
            voiceEnabledToggle.backgroundColor = Color.green;

            morphPercent = new JSONStorableFloat("morph percent", 0.7f, 0, 1, true);
            dm.RegisterFloat(morphPercent);
            UIDynamicSlider morphPercentSlider = dm.CreateSlider(morphPercent);

            JSONStorable         geometry  = atom.GetStorableByID("geometry");
            DAZCharacterSelector character = geometry as DAZCharacterSelector;

            morphControl = character.morphsControlUI;

            mouthOpenMorph   = morphControl.GetMorphByDisplayName("Mouth Open Wide");
            tongueRaiseMorph = morphControl.GetMorphByDisplayName("Tongue Raise-Lower");

            interpolationSpeed = new JSONStorableFloat("expression speed", 8f, 0.1f, 20.0f, true);
            dm.RegisterFloat(interpolationSpeed);
            dm.CreateSlider(interpolationSpeed);

            upperJaw = atom.GetStorableByID("upperJaw") as DAZBone;
            lowerJaw = atom.GetStorableByID("lowerJaw") as DAZBone;

            //  Hack to fix bad tongue morph values.
            //morphControl.GetMorphByDisplayName("Tongue In-Out").startValue = 1.0f;

            dm.CreateSpacer();

            // Prevent mouth from getting too big.
            dm.headAudioSource.SetFloatParamValue("volumeTriggerMultiplier", 0);
        }
예제 #10
0
        public UIDynamicSlider CreateSlider(string name, float width = 300, float height = 80)
        {
            Transform slider = GameObject.Instantiate <Transform>(plugin.manager.configurableSliderPrefab);

            ConfigureTransform(slider, width, height);

            UIDynamicSlider sliderDynamic = slider.GetComponent <UIDynamicSlider>();

            sliderDynamic.quickButtonsEnabled  = false;
            sliderDynamic.rangeAdjustEnabled   = false;
            sliderDynamic.defaultButtonEnabled = false;
            sliderDynamic.label = name;

            return(sliderDynamic);
        }
예제 #11
0
        private void CreateBlendShapeUI()
        {
            ClearBlendShapeUI();

            recordButton        = Plugin.CreateToggle(StorableIsRecording);
            recordButton.height = 75;
            recordButton.label  = GetRecordingLabel();

            recordMessage = Plugin.CreateTextField(StorableRecordingMessage, rightSide: true);
            recordMessage.SetLayoutHeight(75);

            minimumChangeSlider      = Plugin.CreateSlider(StorableMinimumChangePct);
            minimumChangeSliderSpace = Plugin.CreateSpacer(rightSide: true);

            foreach (var group in CBlendShape.Groups())
            {
                var isEnabledStorable = StorableIsGroupEnabled[group];

                var toggle = Plugin.CreateToggle(isEnabledStorable);
                var space  = Plugin.CreateSpacer(rightSide: true);
                space.height = toggle.height;

                groupUiElements.Add(toggle);
                groupUiElements.Add(space);

                if (isEnabledStorable.val)
                {
                    var i             = 0;
                    var shapesInGroup = CBlendShape.IdsInGroup(group).ToList();
                    foreach (var shapeId in shapesInGroup)
                    {
                        shapeMultiplierSliders[shapeId] = Plugin.CreateSlider(StorableBlendShapeStrength[shapeId], rightSide: (i % 2 != 0));
                        i++;
                    }
                    // if there are an odd number of shapes in this group, add a spacer that is the same height
                    // and one of the sliders
                    if (shapesInGroup.Count % 2 != 0 && shapesInGroup.Count > 0)
                    {
                        var spacer = Plugin.CreateSpacer(rightSide: true);
                        spacer.height = shapeMultiplierSliders.FirstOrDefault().Value.height;
                        groupUiElements.Add(spacer);
                    }
                }
            }
        }
예제 #12
0
        void UpdateSliders(List <DAZMorph> foundMorphs, int page = 0)
        {
            int morphStart = page * morphSliders.Count;

            for (int i = 0; i < morphSliders.Count; i++)
            {
                UIDynamicSlider slider = morphSliders[i];
                slider.slider.onValueChanged.RemoveAllListeners();

                slider.gameObject.SetActive(true);
                if (i >= foundMorphs.Count)
                {
                    slider.gameObject.SetActive(false);
                    continue;
                }

                int morphIndex = morphStart + i;

                if (morphIndex >= foundMorphs.Count)
                {
                    slider.gameObject.SetActive(false);
                    continue;
                }

                DAZMorph morph = foundMorphs[morphIndex];


                slider.label = morph.displayName;// + "(" + morph.region + ")";
                if (morph.morphValue < 0f)
                {
                    slider.slider.minValue = morph.morphValue;
                }
                else
                {
                    slider.slider.minValue = 0f;
                }
                slider.slider.maxValue = morph.max;
                slider.slider.value    = morph.morphValue;

                slider.slider.onValueChanged.AddListener((float morphValue) =>
                {
                    morph.SetValue(morphValue);
                });
            }
        }
예제 #13
0
        public override void Init()
        {
            try
            {
                JSONStorableFloat oMeterStorable = new JSONStorableFloat("<3", 0, 0, 1, true, false);
                oMeterStorable.storeType = JSONStorableParam.StoreType.Full;

                UIDynamicSlider oMeterSlider = CreateSlider(oMeterStorable, true);
                oMeterSlider.defaultButtonEnabled = false;
                oMeterSlider.quickButtonsEnabled  = false;
                oMeterSlider.rangeAdjustEnabled   = false;
                RegisterFloat(oMeterStorable);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #14
0
        private JSONStorableFloat NewFloatSlider(
            string paramName,
            float startingValue,
            float minValue,
            float maxValue,
            string valueFormat,
            bool rightSide = false
            )
        {
            JSONStorableFloat storable = new JSONStorableFloat(paramName, startingValue, minValue, maxValue);

            storable.storeType = JSONStorableParam.StoreType.Physical;
            RegisterFloat(storable);
            UIDynamicSlider slider = CreateSlider(storable, rightSide);

            slider.valueFormat = valueFormat;
            return(storable);
        }
예제 #15
0
    public void OnDisable()
    {
        if (_uiTransform == null)
        {
            return;
        }

        try
        {
            _valueJSON.slider = null;
            Destroy(_uiTransform.gameObject);
            _uiTransform = null;
            _ui          = null;
        }
        catch (Exception exc)
        {
            SuperController.LogError($"{nameof(UISlider)}.{nameof(OnDisable)}: " + exc);
        }
    }
예제 #16
0
        public Arousal(DollmasterPlugin dm) : base(dm)
        {
            this.dm = dm;

            arousalEnabled = new JSONStorableBool("arousalEnabled", true);
            dm.RegisterBool(arousalEnabled);
            UIDynamicToggle moduleEnableToggle = dm.CreateToggle(arousalEnabled);

            moduleEnableToggle.label           = "Enable Arousal";
            moduleEnableToggle.backgroundColor = Color.green;

            arousalValue = new JSONStorableFloat("arousal", 0, 0, SLIDER_MAX, false, false);
            dm.RegisterFloat(arousalValue);

            UIDynamicSlider arousalSlider = dm.ui.CreateSlider("❤", 300, 120);

            //arousalSlider.valueFormat = "n0";
            arousalValue.slider           = arousalSlider.slider;
            sliderBGImage                 = arousalSlider.GetComponentInChildren <Image>();
            sliderBGImage.color           = new Color(0.2f, 0.2f, 0.2f, 1.0f);
            arousalSlider.labelText.color = new Color(1, 1, 1);

            arousalRate = new JSONStorableFloat("arousalRate", 1, 0.01f, 10, false, true);
            dm.RegisterFloat(arousalRate);
            dm.CreateSlider(arousalRate);

            arousalDecay = new JSONStorableFloat("arousalDecay", 0.3f, 0.01f, 10, false, true);
            dm.RegisterFloat(arousalDecay);
            dm.CreateSlider(arousalDecay);

            arousalDelay = new JSONStorableFloat("arousalDelay", 0.25f, 0.01f, 5, false, true);
            dm.RegisterFloat(arousalDelay);
            dm.CreateSlider(arousalDelay);

            timeToDecay = new JSONStorableFloat("timeToDecay", 2, 0, 60, false, true);
            dm.RegisterFloat(timeToDecay);
            dm.CreateSlider(timeToDecay);

            dm.CreateSpacer();
        }
예제 #17
0
        public override void Init()
        {
            try
            {
                ui = new UI(this, 0.001f);
                ui.canvas.transform.SetParent(containingAtom.mainController.transform, false);
                ui.canvas.transform.localPosition = new Vector3(0, -0.15f, 0);

                arousalValue = new JSONStorableFloat("arousal", 0, 0, SLIDER_MAX, false, false);
                RegisterFloat(arousalValue);

                UIDynamicSlider arousalSlider = ui.CreateSlider("❤", 300, 120);
                arousalSlider.valueFormat = "n0";
                arousalValue.slider       = arousalSlider.slider;

                arousalRate = new JSONStorableFloat("arousalRate", 1, 0.01f, 10, false, true);
                RegisterFloat(arousalRate);
                CreateSlider(arousalRate);

                arousalDecay = new JSONStorableFloat("arousalDecay", 0.1f, 0.01f, 10, false, true);
                RegisterFloat(arousalDecay);
                CreateSlider(arousalDecay);

                timeToDecay = new JSONStorableFloat("timeToDecay", 4, 0, 60, false, true);
                RegisterFloat(timeToDecay);
                CreateSlider(timeToDecay);

                JSONStorableAction arousalAction = new JSONStorableAction("arouse", () =>
                {
                    arousalValue.val += arousalRate.val;
                    lastArousalTime   = Time.time;
                });
                RegisterAction(arousalAction);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #18
0
    public void OnEnable()
    {
        if (_uiTransform != null || _atom == null)
        {
            return;
        }

        try
        {
            var canvas = _atom.GetComponentInChildren <Canvas>();
            if (canvas == null)
            {
                throw new NullReferenceException("Could not find a canvas to attach to");
            }

            _uiTransform = Instantiate(manager.configurableSliderPrefab.transform);
            if (_uiTransform == null)
            {
                throw new NullReferenceException("Could not instantiate configurableSliderPrefab");
            }
            _uiTransform.SetParent(canvas.transform, false);
            _uiTransform.gameObject.SetActive(true);

            _ui = _uiTransform.GetComponent <UIDynamicSlider>();
            if (_ui == null)
            {
                throw new NullReferenceException("Could not find a UIDynamicSlider component");
            }
            _ui.Configure(_labelJSON.val, _valueJSON.min, _valueJSON.max, _valueJSON.val, _valueJSON.constrained, "F2", true, !_valueJSON.constrained);
            _valueJSON.slider = _ui.slider;

            _uiTransform.Translate(Vector3.down * 0.3f, Space.Self);
            _uiTransform.Translate(Vector3.right * 0.35f, Space.Self);
        }
        catch (Exception exc)
        {
            SuperController.LogError($"{nameof(UISlider)}.{nameof(OnEnable)}: " + exc);
        }
    }
예제 #19
0
        void AddAppearance(JSONClass person, string fileName, float initialWeight = 0)
        {
            appearances.Add(person);

            UIDynamicSlider slider = ui.CreateMorphSlider(fileName, 500, 80, appearancesLayout.transform);

            sliders.Add(slider);

            slider.slider.minValue = 0;
            slider.slider.maxValue = 1;
            slider.slider.value    = initialWeight;

            slider.slider.onValueChanged.AddListener((float value) =>
            {
                computedWeightedMorphs[person] = ComputeWeightedMorphsForPerson(person, value);

                ResetMorphs();
                AverageMorphs();
            });

            computedWeightedMorphs[person] = ComputeWeightedMorphsForPerson(person, initialWeight);
        }
예제 #20
0
 protected void BreastsPhysicsButtonSlider()
 {
     // Adjust Breasts Slider
     dBreastsAdjust = CreateSlider(jBreastsAdjust);
     dBreastsAdjust.rangeAdjustEnabled = false;
     BreastsSliderArray[0]             = dBreastsAdjust;
     // Adjust Breasts Status
     dBreastsAdjustButton                = CreateButton("");
     dBreastsAdjustButton.buttonColor    = Color.Lerp(Color.magenta, Color.white, 0.69f);
     dBreastsAdjustButton.button.enabled = false;
     BreastsButtonArray[0]               = dBreastsAdjustButton;
     // BreastsRotationMultiX
     dFloatBreastsRotationMultiX = CreateSlider(jFloatBreastsRotationMultiX);
     BreastsSliderArray[1]       = dFloatBreastsRotationMultiX;
     // BreastsTargetXButton
     dBreastsTargetXButton                = CreateButton("");
     dBreastsTargetXButton.buttonColor    = Color.Lerp(Color.magenta, Color.white, 0.69f);
     dBreastsTargetXButton.button.enabled = false;
     BreastsButtonArray[1]                = dBreastsTargetXButton;
     // BreastsRotationMultiY
     dFloatBreastsRotationMultiY = CreateSlider(jFloatBreastsRotationMultiY);
     BreastsSliderArray[2]       = dFloatBreastsRotationMultiY;
     // BreastsTargetYButton
     dBreastsTargetYButton                = CreateButton("");
     dBreastsTargetYButton.buttonColor    = Color.Lerp(Color.magenta, Color.white, 0.69f);
     dBreastsTargetYButton.button.enabled = false;
     BreastsButtonArray[2]                = dBreastsTargetYButton;
     // BreastsRotationMultiZ
     dFloatBreastsRotationMultiZ = CreateSlider(jFloatBreastsRotationMultiZ);
     BreastsSliderArray[3]       = dFloatBreastsRotationMultiZ;
     // BreastsTargetZButton
     dBreastsTargetZButton                = CreateButton("");
     dBreastsTargetZButton.buttonColor    = Color.Lerp(Color.magenta, Color.white, 0.69f);
     dBreastsTargetZButton.button.enabled = false;
     BreastsButtonArray[3]                = dBreastsTargetZButton;
 }
예제 #21
0
 protected void GlutesPhysicsButtonSlider()
 {
     // Adjust Glutes Slider
     dGlutesAdjust = CreateSlider(jGlutesAdjust);
     dGlutesAdjust.rangeAdjustEnabled = false;
     GlutesSliderArray[0]             = dGlutesAdjust;
     // Adjust Glutes Status
     dGlutesAdjustButton                = CreateButton("");
     dGlutesAdjustButton.buttonColor    = Color.Lerp(Color.blue, Color.white, 0.69f);
     dGlutesAdjustButton.button.enabled = false;
     GlutesButtonArray[0]               = dGlutesAdjustButton;
     // GlutesRotationMultiX
     dFloatGlutesRotationMultiX = CreateSlider(jFloatGlutesRotationMultiX);
     GlutesSliderArray[1]       = dFloatGlutesRotationMultiX;
     // GlutesTargetXButton
     dGlutesTargetXButton                = CreateButton("");
     dGlutesTargetXButton.buttonColor    = Color.Lerp(Color.blue, Color.white, 0.69f);
     dGlutesTargetXButton.button.enabled = false;
     GlutesButtonArray[1]                = dGlutesTargetXButton;
     // GlutesRotationMultiY
     dFloatGlutesRotationMultiY = CreateSlider(jFloatGlutesRotationMultiY);
     GlutesSliderArray[2]       = dFloatGlutesRotationMultiY;
     // GlutesTargetYButton
     dGlutesTargetYButton                = CreateButton("");
     dGlutesTargetYButton.buttonColor    = Color.Lerp(Color.blue, Color.white, 0.69f);
     dGlutesTargetYButton.button.enabled = false;
     GlutesButtonArray[2]                = dGlutesTargetYButton;
     // GlutesRotationMultiZ
     dFloatGlutesRotationMultiZ = CreateSlider(jFloatGlutesRotationMultiZ);
     GlutesSliderArray[3]       = dFloatGlutesRotationMultiZ;
     // GlutesTargetZButton
     dGlutesTargetZButton                = CreateButton("");
     dGlutesTargetZButton.buttonColor    = Color.Lerp(Color.blue, Color.white, 0.69f);
     dGlutesTargetZButton.button.enabled = false;
     GlutesButtonArray[3]                = dGlutesTargetZButton;
 }
예제 #22
0
 public void RemoveSlider(UIDynamicSlider component)
 {
     _plugin.RemoveSlider(component); _sliders.Remove(component);
 }
예제 #23
0
        public MorphSearch(BaseModule baseModule)
        {
            UI        ui       = baseModule.ui;
            Transform moduleUI = baseModule.moduleUI;
            Atom      atom     = baseModule.atom;

            searchBox = ui.CreateTextInput("Search For Morph", 800, 100, moduleUI);
            searchBox.transform.localPosition = new Vector3(0, -110, 0);

            paginationSlider = ui.CreateSlider("Page", 930, 80, true, moduleUI);
            paginationSlider.transform.localPosition = new Vector3(0, -200, 0);

            paginationValue = new JSONStorableFloat("Page", 0, (float value) =>
            {
            }, 0, 10, true, true);
            paginationSlider.valueFormat = "n0";
            paginationValue.slider       = paginationSlider.slider;

            paginationSlider.gameObject.SetActive(false);

            GridLayoutGroup layout = ui.CreateGridLayout(1200, 800, moduleUI);

            layout.transform.localPosition = new Vector3(0, -1010, 0);
            layout.constraintCount         = 3;
            layout.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
            layout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            layout.cellSize = new Vector2(400, 80);

            for (int i = 0; i < MAX_MORPHS_PER_PAGE - 1; i++)
            {
                UIDynamicSlider slider = ui.CreateMorphSlider("Slider " + i, 400, 80, moduleUI);
                slider.transform.SetParent(layout.transform, false);

                morphSliders.Add(slider);
                slider.gameObject.SetActive(false);
            }


            DAZCharacterSelector personGeometry = atom.GetStorableByID("geometry") as DAZCharacterSelector;

            morphControl = personGeometry.morphsControlUI;

            regions = new HashSet <string>();
            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                regions.Add(morph.region);
            });

            morphNames = morphControl.GetMorphDisplayNames();

            searchBox.onValueChanged.AddListener(UpdateSearch);

            UIDynamicButton clearButton = ui.CreateButton("Clear", 120, 100, moduleUI);

            clearButton.transform.localPosition = new Vector3(810, -110, 0);
            clearButton.button.onClick.AddListener(() =>
            {
                searchBox.text = "";
                ClearSearch();
            });

            VerticalLayoutGroup commonTermsGroup = ui.CreateVerticalLayout(220, 0, moduleUI);

            commonTermsGroup.transform.localPosition = new Vector3(-230, -200, 0);
            commonTermsGroup.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            commonTermsGroup.childAlignment = TextAnchor.UpperLeft;


            for (int i = 0; i < MAX_TERMS; i++)
            {
                UIDynamicButton termButton = ui.CreateButton("Term", 220, 40, moduleUI);
                termButton.transform.SetParent(commonTermsGroup.transform, false);
                termButtons.Add(termButton);
                UI.ColorButton(termButton, Color.white, new Color(0.3f, 0.4f, 0.6f));

                termButton.gameObject.SetActive(false);

                ContentSizeFitter csf = termButton.gameObject.AddComponent <ContentSizeFitter>();
                csf.verticalFit = ContentSizeFitter.FitMode.MinSize;
            }

            //Debug.Log("----------------------------");
            //UIDynamicSlider testSlider = ui.CreateMorphSlider("test");
            //ui.DebugDeeper(testSlider.transform);
        }
예제 #24
0
        public ThrustController(DollmasterPlugin dm) : base(dm)
        {
            thrustEnabled = new JSONStorableBool("thrustEnabled", true);
            dm.RegisterBool(thrustEnabled);
            UIDynamicToggle moduleEnableToggle = dm.CreateToggle(thrustEnabled);

            moduleEnableToggle.label           = "Enable Thrusting";
            moduleEnableToggle.backgroundColor = Color.green;

            thrustAtomChooser = new JSONStorableStringChooser("thrustTarget", GetAnimationPatternNames(), "", "Thrust Control", (string name) =>
            {
                RestoreOriginalSlider();

                ap = null;

                UISetupState(SuperController.singleton.GetAtomByUid(name));
            });
            thrustAtomChooser.storeType = JSONStorableParam.StoreType.Full;
            dm.RegisterStringChooser(thrustAtomChooser);
            UIDynamicPopup popup = dm.CreatePopup(thrustAtomChooser);

            popup.popup.onOpenPopupHandlers += () =>
            {
                thrustAtomChooser.choices = GetAnimationPatternNames();
            };

            slider = dm.ui.CreateSlider("Thrust Speed", 300, 120);
            slider.transform.Translate(0, 0.15f, 0, Space.Self);

            slider.slider.onValueChanged.AddListener((float v) =>
            {
                if (ap == null)
                {
                    return;
                }

                JSONStorableFloat speedStore = ap.GetFloatJSONParam("speed");
                if (speedStore.slider != slider.slider)
                {
                    AttachCustomSlider();
                }
            });

            Image img = slider.GetComponentInChildren <Image>();

            img.color = new Color(0.4f, 0.2f, 0.245f, 1.0f);
            slider.labelText.color = new Color(1, 1, 1);

            slider.gameObject.SetActive(false);

            createButton = dm.ui.CreateButton("Generate Animation Pattern or...", 400, 120);
            createButton.transform.Translate(0, 0.15f, 0, Space.Self);
            createButton.buttonColor = new Color(0.4f, 0.2f, 0.245f, 1.0f);
            createButton.textColor   = new Color(1, 1, 1);

            createButton.button.onClick.AddListener(GenerateThrustAtoms);

            selectButton = dm.ui.CreateButton("Select Animation Pattern To Control", 400, 120);
            selectButton.transform.Translate(0.52f, 0.15f, 0, Space.Self);
            selectButton.buttonColor = new Color(0.4f, 0.2f, 0.245f, 1.0f);
            selectButton.textColor   = new Color(1, 1, 1);

            selectButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.SelectModeAtom((atom) =>
                {
                    if (atom == null)
                    {
                        return;
                    }

                    if (atom.GetStorableByID("AnimationPattern") == null)
                    {
                        SuperController.LogError("Select an Animation Pattern");
                        return;
                    }

                    AnimationPattern ap = atom.GetStorableByID("AnimationPattern") as AnimationPattern;
                    ap.SyncStepNames();
                    ap.autoSyncStepNamesJSON.SetVal(false);

                    thrustAtomChooser.SetVal(atom.uid);
                });
            });

            dm.CreateSpacer();

            GenerateThrustAtoms();
        }
예제 #25
0
        public override void Init()
        {
            try {
                UpdateInitialMorphs();


                #region Choose Atom
                Atom          otherAtom       = null;
                List <string> receiverChoices = SuperController.singleton.GetAtoms()
                                                .Where(atom => atom.GetStorableByID("geometry") != null && atom != containingAtom)
                                                .Select(atom => atom.name).ToList();
                JSONStorableStringChooser receiverChoiceJSON = new JSONStorableStringChooser("copyFrom", receiverChoices, null, "Copy From", delegate(string otherName)
                {
                    otherAtom = GetAtomById(otherName);
                });
                receiverChoiceJSON.storeType = JSONStorableParam.StoreType.Full;
                UIDynamicPopup dp = CreateScrollablePopup(receiverChoiceJSON, false);
                dp.popupPanelHeight = 250f;
                RegisterStringChooser(receiverChoiceJSON);
                #endregion


                #region Morph Slider
                JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
                DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
                GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

                JSONStorableFloat morphMixAmount = new JSONStorableFloat("morphMix", 0.0f, 0f, 1f, true);
                UIDynamicSlider   morphSlider    = CreateSlider(morphMixAmount, true);

                morphSlider.slider.onValueChanged.AddListener(delegate(float mixValue)
                {
                    if (otherAtom == null)
                    {
                        Debug.Log("other atom is null");
                        return;
                    }

                    JSONStorable otherGeometry                   = otherAtom.GetStorableByID("geometry");
                    DAZCharacterSelector otherCharacter          = otherGeometry as DAZCharacterSelector;
                    GenerateDAZMorphsControlUI otherMorphControl = otherCharacter.morphsControlUI;

                    morphControl.GetMorphDisplayNames().ForEach((name) =>
                    {
                        DAZMorph otherMorph = otherMorphControl.GetMorphByDisplayName(name);
                        DAZMorph morph      = morphControl.GetMorphByDisplayName(name);
                        float initialValue  = initialMorphValues[name];
                        float targetValue   = otherMorph.morphValue;
                        morph.morphValue    = initialValue + ((targetValue - initialValue) * mixValue);
                    });
                });
                #endregion


                #region Apply Button
                UIDynamicButton applyButton = CreateButton("Apply As Starting Value", true);
                applyButton.button.onClick.AddListener(delegate()
                {
                    UpdateInitialMorphs();
                });
                #endregion

                CreateSpacer();
                CreateTextField(new JSONStorableString("instructions", "\nPick a Person atom and use the slider to blend morphs."));
                CreateTextField(new JSONStorableString("instructions", "\nUse the Apply As Starting Value button to freeze morphs into place if you want to load a new target appearance."));
            }
            catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #26
0
        public override void Init()
        {
            try
            {
                currentLoop = 0;
                toElapse    = 0;
                axisDict    = new Dictionary <string, int>();
                smoothLoops = new Dictionary <int, float>();
                oldPosition = containingAtom.transform.position;

                pumpOnce = new JSONStorableBool("Pump once", false, (bool on) => {
                    pumpOnce.val = false;
                    toElapse     = durationJSON.val;
                });
                RegisterBool(pumpOnce);

                randomValue = new JSONStorableBool("Random value", false, (bool on) => {
                    randomValue.val = false;
                    randomPump();
                });
                RegisterBool(randomValue);

                increaseOnce = new JSONStorableBool("Increase once", false, (bool on) => {
                    increaseOnce.val   = false;
                    pumpValueJSON.val += upSpeedJSON.val / 2;
                });
                RegisterBool(increaseOnce);

                decreaseOnce = new JSONStorableBool("Decrease once", false, (bool on) => {
                    decreaseOnce.val   = false;
                    pumpValueJSON.val -= downSpeedJSON.val / 2;
                });
                RegisterBool(decreaseOnce);


                speedController = CreateButton("Pump", false);
                speedController.button.onClick.AddListener(delegate(){
                    toElapse = durationJSON.val;
                });

                pumpValueJSON = new JSONStorableFloat("Pump value", 0f, 0f, 1f, false);
                RegisterFloat(pumpValueJSON);
                UIDynamicSlider dsi = CreateSlider(pumpValueJSON, false);
                dsi.defaultButtonEnabled = false;
                dsi.quickButtonsEnabled  = false;
                targetValueJSON          = new JSONStorableFloat("targetValue", 0f, 0f, 1f, false, false);
                currentValueJSON         = new JSONStorableFloat("Current value", 0f, 0f, 1f, false, false);
                UIDynamicSlider ds = CreateSlider(currentValueJSON, false);
                ds.defaultButtonEnabled = false;
                ds.quickButtonsEnabled  = false;

                CreateSpacer().height = 10f;
                disablePump           = new JSONStorableBool("Disable pump up/down speeds", false);
                RegisterBool(disablePump);
                CreateToggle((disablePump), false);

                upSpeedJSON = new JSONStorableFloat("Pump up speed", 0.1f, 0f, 10f, true);
                RegisterFloat(upSpeedJSON);
                CreateSlider(upSpeedJSON, false);

                downSpeedJSON = new JSONStorableFloat("Pump down speed", 0.1f, 0f, 10f, true);
                RegisterFloat(downSpeedJSON);
                CreateSlider(downSpeedJSON, false);

                durationJSON = new JSONStorableFloat("Duration", 50f, 1f, 1000f, true);
                RegisterFloat(durationJSON);
                CreateSlider(durationJSON, false);

                keyIncrease = new JSONStorableStringChooser("Increase key", KeyCodes, "None", "Increase key");
                RegisterStringChooser(keyIncrease);
                dp = CreateScrollablePopup(keyIncrease, false);
                dp.popupPanelHeight = 960f;

                keyDecrease = new JSONStorableStringChooser("Decrease key", KeyCodes, "None", "Decrease key");
                RegisterStringChooser(keyDecrease);
                dp = CreateScrollablePopup(keyDecrease, false);
                dp.popupPanelHeight = 960f;

                keyContinuous = new JSONStorableBool("Increase/decrease continuous", true);
                RegisterBool(keyContinuous);
                CreateToggle((keyContinuous), false);

                keyPump = new JSONStorableStringChooser("Pump key", KeyCodes, "None", "Pump key");
                RegisterStringChooser(keyPump);
                dp = CreateScrollablePopup(keyPump, false);
                dp.popupPanelHeight = 960f;

                keyRandom = new JSONStorableStringChooser("Randomize key", KeyCodes, "None", "Randomize key");
                RegisterStringChooser(keyRandom);
                dp = CreateScrollablePopup(keyRandom, false);
                dp.popupPanelHeight = 960f;

                autoPump = new JSONStorableBool("Autopump when 0", false);
                RegisterBool(autoPump);
                CreateToggle((autoPump), false);

                loopPump = new JSONStorableBool("Loop / 0 when 1", false);
                RegisterBool(loopPump);
                CreateToggle((loopPump), false);

                pumpContinuously = new JSONStorableBool("Pump infinitely", false);
                RegisterBool(pumpContinuously);
                CreateToggle((pumpContinuously), false);

                CreateSpacer().height = 10f;

                List <string> choices = new List <string>();
                choices.Add("None");
                choices.Add("Reverse");
                choices.Add("Sin(x*\u03C0)");
                choices.Add("Cos(x*\u03C0)");
                choices.Add("Tan(x*\u03C0)");
                choices.Add("*2");
                choices.Add("x^2");
                choices.Add("*30*Mathf.Deg2Rad");

                mathChooser1 = new JSONStorableStringChooser("Math operation 1", choices, "None", "Math operation 1");
                mathChooser2 = new JSONStorableStringChooser("Math operation 2", choices, "None", "Math operation 2");
                mathChooser3 = new JSONStorableStringChooser("Math operation 3", choices, "None", "Math operation 3");
                mathChooser4 = new JSONStorableStringChooser("Math operation 4", choices, "None", "Math operation 4");
                mathChooser5 = new JSONStorableStringChooser("Math operation 5", choices, "None", "Math operation 5");
                RegisterStringChooser(mathChooser1);
                RegisterStringChooser(mathChooser2);
                RegisterStringChooser(mathChooser3);
                RegisterStringChooser(mathChooser4);
                RegisterStringChooser(mathChooser5);
                CreatePopup(mathChooser1, false);
                CreatePopup(mathChooser2, false);
                CreatePopup(mathChooser3, false);
                CreatePopup(mathChooser4, false);
                CreatePopup(mathChooser5, false);

                allowOffLimits = new JSONStorableBool("Disable pump/value limits for math", false);
                RegisterBool(allowOffLimits);
                CreateToggle((allowOffLimits), false);

                atomJSON = new JSONStorableStringChooser("atom", SuperController.singleton.GetAtomUIDs(), null, "Atom", SyncAtom);
                RegisterStringChooser(atomJSON);
                SyncAtomChoices();
                dp = CreateScrollablePopup(atomJSON, true);
                dp.popupPanelHeight           = 1100f;
                dp.popup.onOpenPopupHandlers += SyncAtomChoices;

                receiverJSON = new JSONStorableStringChooser("receiver", null, null, "Receiver", SyncReceiver);
                RegisterStringChooser(receiverJSON);
                dp = CreateScrollablePopup(receiverJSON, true);
                dp.popupPanelHeight = 960f;

                receiverTargetJSON = new JSONStorableStringChooser("receiverTarget", null, null, "Target", SyncReceiverTarget);
                RegisterStringChooser(receiverTargetJSON);
                dp = CreateScrollablePopup(receiverTargetJSON, true);
                dp.popupPanelHeight = 820f;

                atomJSON.val     = containingAtom.uid;
                receiverJSON.val = "geometry";

                lowerValueJSON = new JSONStorableFloat("lower value", 0f, 0f, 1f, false);
                RegisterFloat(lowerValueJSON);
                CreateSlider(lowerValueJSON, true);

                upperValueJSON = new JSONStorableFloat("upper value", 1f, 0.1f, 1f, false);
                RegisterFloat(upperValueJSON);
                CreateSlider(upperValueJSON, true);

                CreateSpacer(true).height = 10f;

                smoothLoopFactor = new JSONStorableFloat("Value smoothing factor", 20f, 1f, 100f, true);
                RegisterFloat(smoothLoopFactor);
                CreateSlider(smoothLoopFactor, true);

                smoothLoopFactorMult = new JSONStorableFloat("Smooth factor multiplier", 1f, 1f, 100f, true);
                RegisterFloat(smoothLoopFactorMult);
                CreateSlider(smoothLoopFactorMult, true);

                CreateSpacer(true).height = 10f;

                triggerByTrigger = new JSONStorableBool("Use vive trigger", false);
                RegisterBool(triggerByTrigger);
                CreateToggle((triggerByTrigger), true);

                List <string> viveChoices = new List <string>();
                viveChoices.Add("Trigger");
                viveChoices.Add("Touchpad X axis");
                viveChoices.Add("Touchpad Y axis");

                viveChoicesJSON = new JSONStorableStringChooser("Using", viveChoices, "Trigger", "Using");
                RegisterStringChooser(viveChoicesJSON);
                dp = CreateScrollablePopup(viveChoicesJSON, true);
                dp.popupPanelHeight = 960f;

                triggerDownTrigger = new JSONStorableBool("Use pump for downSpeed", false);
                RegisterBool(triggerDownTrigger);
                CreateToggle((triggerDownTrigger), true);

                pumpByTrigger = new JSONStorableBool("Trigger > 90% = Pump", false);
                RegisterBool(pumpByTrigger);
                CreateToggle((pumpByTrigger), true);

                triggerLockTrigger = new JSONStorableBool("Grip+Trigger = lock value", false);
                RegisterBool(triggerLockTrigger);
                CreateToggle((triggerLockTrigger), true);

                triggerSensitivitySlider           = new JSONStorableFloat("Vive trigger sensitivity", 1f, 0.1f, 10f, true);
                triggerSensitivitySlider.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(triggerSensitivitySlider);
                CreateSlider(triggerSensitivitySlider, true);

                UIDynamicButton detectViveButton = CreateButton("(re)Detect Controllers", true);
                detectViveButton.button.onClick.AddListener(delegate() {
                    detectViveControllers();
                });
                detectViveControllers();

                CreateSpacer(true).height = 10f;

                CameraReceiverJSON = new JSONStorableStringChooser("Reference atom", getControllers(GetContainingAtom()), "head", "Local reference atom");
                RegisterStringChooser(CameraReceiverJSON);
                dp = CreateScrollablePopup(CameraReceiverJSON, true);
                dp.popupPanelHeight = 960f;

                triggerByDistance = new JSONStorableBool("Override pump by distance", false);
                RegisterBool(triggerByDistance);
                CreateToggle((triggerByDistance), true);

                distanceAtomJSON = new JSONStorableStringChooser("distant atom", SuperController.singleton.GetAtomUIDs(), "[CameraRig]", "Distant Atom", SyncAtom2);
                RegisterStringChooser(distanceAtomJSON);
                SyncAtomChoices2();
                dp = CreateScrollablePopup(distanceAtomJSON, true);
                dp.popupPanelHeight           = 1100f;
                dp.popup.onOpenPopupHandlers += SyncAtomChoices2;

                distanceReceiverJSON = new JSONStorableStringChooser("distant receiver", null, "None", "Distant receiver");
                RegisterStringChooser(distanceReceiverJSON);
                dp = CreateScrollablePopup(distanceReceiverJSON, true);
                dp.popupPanelHeight = 960f;

                defMinDistSlider           = new JSONStorableFloat("Minimum distance", 0.2f, 0, 3f, true);
                defMinDistSlider.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(defMinDistSlider);
                CreateSlider(defMinDistSlider, true);

                defDistSlider           = new JSONStorableFloat("Variation distance", 0.2f, 0, 3f, true);
                defDistSlider.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(defDistSlider);
                CreateSlider(defDistSlider, true);

                CreateSpacer(true).height = 10f;

                triggerByAngle = new JSONStorableBool("Override pump by angle of reference", false);
                RegisterBool(triggerByAngle);
                CreateToggle((triggerByAngle), true);

                axisDict.Add("X", 0);
                axisDict.Add("Y", 1);
                axisDict.Add("Z", 2);

                axisChooser = new JSONStorableStringChooser("Axis", axisDict.Keys.ToList(), "X", "Axis");
                RegisterStringChooser(axisChooser);
                CreatePopup(axisChooser, true);

                angleMin = new JSONStorableFloat("lower angle", 0f, 0f, 360f, false);
                RegisterFloat(angleMin);
                CreateSlider(angleMin, true);

                angleMax = new JSONStorableFloat("upper angle", 0f, 0f, 360f, false);
                RegisterFloat(angleMax);
                CreateSlider(angleMax, true);

                CreateSpacer(true).height = 10f;

                triggerBySpeed = new JSONStorableBool("Override pump by speed measure", false);
                RegisterBool(triggerBySpeed);
                CreateToggle((triggerBySpeed), true);

                speedMax = new JSONStorableFloat("Speed sensitivity", 1f, 0f, 5f, false);
                RegisterFloat(speedMax);
                CreateSlider(speedMax, true);

                CreateSpacer(true).height = 900f;
            }

            catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #27
0
        public override void Init()
        {
            try {
                //SuperController.LogMessage("");

                // get controllers
                if (!SuperController.singleton.isOVR)
                {
                    GameObject Rctrl = GameObject.Find("Controller (right)");
                    if (Rctrl != null)
                    {
                        RC = new SteamVRController(Rctrl);
                    }

                    GameObject Lctrl = GameObject.Find("Controller (left)");
                    if (Lctrl != null)
                    {
                        LC = new SteamVRController(Lctrl);
                    }
                }
                else
                {
                    // Triggers will be made in 'Start' so that saved swapTriggers will have been loaded
                    _swapTriggers = new JSONStorableBool("swap triggers", false, (bool aSwap) =>
                    {
                        OVRInput.Axis1D axis;
                        if (!aSwap)
                        {
                            axis = OVRInput.Axis1D.PrimaryIndexTrigger;
                        }
                        else
                        {
                            axis = OVRInput.Axis1D.PrimaryHandTrigger;
                        }
                        LC = new OculusController(OVRInput.Controller.LTouch, axis);
                        RC = new OculusController(OVRInput.Controller.RTouch, axis);
                    });
                    RegisterBool(_swapTriggers);
                    CreateToggle(_swapTriggers);
                }

                //  find hand assets
                hL = GameObject.Find("left_hand(Clone)")?.GetComponent <Animator>();
                if (hL == null)
                {
                    hL = GameObject.Find("left_hand_alpha(Clone)")?.GetComponent <Animator>();
                }
                hR = GameObject.Find("right_hand(Clone)")?.GetComponent <Animator>();
                if (hR == null)
                {
                    hR = GameObject.Find("right_hand_alpha(Clone)")?.GetComponent <Animator>();
                }

                // show in label if one or both hands are found
                if (hL != null)
                {
                    pluginLabelJSON.val = "+Left Hand ";
                }
                if (hR != null)
                {
                    pluginLabelJSON.val += "+Right Hand ";
                }

                pluginLabelJSON.val += " [" + pluginVersion + "]";

                JSONStorableBool hlClose = new JSONStorableBool("close left hand", false, closeHL);
                RegisterBool(hlClose);
                CreateToggle(hlClose);

                JSONStorableFloat Lval = new JSONStorableFloat("left hand", 0f, LhandVal, 0f, 1f, true);
                RegisterFloat(Lval);
                Lslider = CreateSlider(Lval);

                JSONStorableBool hrClose = new JSONStorableBool("close right hand", false, closeHR);
                RegisterBool(hrClose);
                CreateToggle(hrClose);

                JSONStorableFloat Rval = new JSONStorableFloat("right hand", 0f, RhandVal, 0f, 1f, true);
                RegisterFloat(Rval);
                Lslider = CreateSlider(Rval);
            }
            catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #28
0
        public override void Init()
        {
            try
            {
                JSONStorableBool dummy = new JSONStorableBool("dummy", false);
                RegisterBool(dummy);
                dummy.SetVal(true);

                mam = SuperController.singleton.motionAnimationMaster;

                recordButton             = CreateButton("Record");
                recordButton.buttonColor = Color.green;
                recordButton.button.onClick.AddListener(() =>
                {
                    isRecording = !isRecording;

                    // Should now be recording
                    if (isRecording)
                    {
                        mam.ResetAnimation();
                        mam.autoRecordStop   = true;
                        mam.showRecordPaths  = false;
                        mam.showStartMarkers = false;
                        mam.StartRecord();
                        recordButton.buttonColor = Color.red;
                    }
                    else
                    {
                        mam.StopRecord();
                        mam.StopPlayback();
                        recordButton.buttonColor = Color.green;
                    }
                });

                DAZCharacterSelector       dcs     = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector;
                GenerateDAZMorphsControlUI morphUI = dcs.morphsControlUI;
                List <string> allMorphNames        = morphUI.GetMorphDisplayNames();


                List <DAZMorph> acceptableMorphs = allMorphNames
                                                   .Select((string name) =>
                {
                    return(morphUI.GetMorphByDisplayName(name));
                })
                                                   .ToList()
                                                   .Where((morph) =>
                {
                    return(acceptList.Exists((acceptString) =>
                    {
                        return morph.group.Contains(acceptString);
                    }));
                })
                                                   .ToList();

                animatableMorphs = acceptableMorphs;

                acceptableMorphs.ForEach((morph) =>
                {
                    groups.Add(morph.group);
                });

                CreateButton("Rewind").button.onClick.AddListener(() =>
                {
                    mam.SeekToBeginning();
                    GenerateAnimation();
                });

                CreateButton("Play").button.onClick.AddListener(() =>
                {
                    mam.StartPlayback();
                    mam.StopRecord();
                    recordButton.buttonColor = Color.green;
                    GenerateAnimation();
                });

                CreateButton("Stop").button.onClick.AddListener(() =>
                {
                    mam.StopRecord();
                    mam.StopPlayback();
                    recordButton.buttonColor = Color.green;
                    GenerateAnimation();
                });

                CreateButton("Clear All Poses").button.onClick.AddListener(() =>
                {
                    acceptableMorphs.ForEach((morph) =>
                    {
                        morph.Reset();
                    });
                });

                CreateSpacer();

                List <UIDynamicSlider>  morphSliders = new List <UIDynamicSlider>();
                List <JSONStorableBool> onGroups     = new List <JSONStorableBool>();

                groups.ToList().ForEach((groupName) =>
                {
                    JSONStorableBool groupOn = new JSONStorableBool(groupName, false, (bool isOn) =>
                    {
                        // Clear list of morphs.
                        morphSliders.ForEach((slider) =>
                        {
                            RemoveSlider(slider);
                        });
                        morphSliders = new List <UIDynamicSlider>();

                        List <string> onList = onGroups.Where((storableBool) => storableBool.val).ToList().Select((storableBool) => storableBool.name).ToList();

                        acceptableMorphs
                        .Where((morph) =>
                        {
                            return(onList.Exists((name) =>
                            {
                                return morph.group == name;
                            }));
                        })
                        .ToList()
                        .ForEach((morph) =>
                        {
                            bool highCost = IsHighCostMorph(morph);
                            JSONStorableFloat morphValue = new JSONStorableFloat(morph.displayName, morph.morphValue, (float value) =>
                            {
                                morph.SetValue(value);

                                if (isRecording)
                                {
                                    changesOnFrame.Add(new MorphChange()
                                    {
                                        morph = morph,
                                        value = value,
                                    });
                                }
                            }, morph.min, morph.max, false, true);
                            UIDynamicSlider slider = CreateSlider(morphValue, true);
                            slider.labelText.color = highCost ? Color.red : Color.black;
                            morphSliders.Add(slider);
                        });
                    });
                    UIDynamicToggle groupToggle = CreateToggle(groupOn);
                    onGroups.Add(groupOn);
                });
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #29
0
        public MorphSelectUI(ExpressionCreator script)
        {
            this.script = script;

            Color color = GetNextColor();

            groupString = new JSONStorableStringChooser("group", script.morphGroupMap.Keys.ToList(), "", "Morph Group", (string groupPopupName) =>
            {
                string groupName = script.morphGroupMap[groupPopupName];
                GenerateDAZMorphsControlUI morphControl = script.GetMorphControl();
                List <string> acceptedMorphs            = new List <string>();
                script.GetMorphControl().GetMorphDisplayNames().ForEach((name) =>
                {
                    DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                    if (morph.region == groupName)
                    {
                        acceptedMorphs.Add(morph.displayName);
                    }
                });

                if (selectedMorph != null)
                {
                    morphValue.SetVal(selectedMorph.startValue);
                    selectedMorph = null;
                }

                List <string> existing = script.GetExistingMorphNames();

                morphString.choices = acceptedMorphs.ToList().Where((name) =>
                {
                    return(existing.Contains(name) == false);
                }).ToList();
                morphString.SetVal(morphString.choices[0]);

                morphPopup.gameObject.SetActive(true);
            });

            groupPopup        = script.CreatePopup(groupString, true);
            groupString.popup = groupPopup.popup;

            morphString = new JSONStorableStringChooser("morph", new List <string>(), "", "Morph", (string morphName) =>
            {
                GenerateDAZMorphsControlUI morphControl = script.GetMorphControl();
                DAZMorph morph = morphControl.GetMorphByDisplayName(morphName);
                if (morph == null)
                {
                    return;
                }

                if (selectedMorph != null)
                {
                    script.OnMorphRemoved(selectedMorph);

                    morphValue.SetVal(selectedMorph.startValue);
                    selectedMorph = null;
                }

                selectedMorph  = morph;
                morphValue.min = morph.min;
                morphValue.max = morph.max;
                morphValue.SetVal(morph.startValue);
                morphValue.defaultVal = morphValue.defaultVal;

                removeButton.label = "Remove " + selectedMorph.displayName;
                morphSlider.label  = selectedMorph.displayName;

                script.OnMorphSelected(selectedMorph);

                morphSlider.gameObject.SetActive(true);
                groupPopup.gameObject.SetActive(false);
            });
            morphPopup        = script.CreateScrollablePopup(morphString, true);
            morphString.popup = morphPopup.popup;

            morphPopup.gameObject.SetActive(false);

            morphValue = new JSONStorableFloat("morphValue", 0, (float value) =>
            {
                if (selectedMorph == null)
                {
                    return;
                }

                selectedMorph.SetValue(value);

                script.OnMorphValueChanged(selectedMorph, value);
            }, 0, 1, false, true);

            morphSlider       = script.CreateSlider(morphValue, true);
            morphValue.slider = morphSlider.slider;
            morphSlider.gameObject.SetActive(false);
            morphSlider.quickButtonsEnabled = false;

            removeButton = script.CreateButton("Remove Morph", true);
            removeButton.button.onClick.AddListener(() =>
            {
                Remove();
            });

            spacer = script.CreateSpacer(true);
        }
예제 #30
0
        public void Draw()
        {
            Clear();

            int defaultButtonHeight        = 50;
            int defaultSliderHeight        = 120;
            int defaultSectionSpacerHeight = 0;

            if (_plugin.containingAtom.type == "Person")
            {
                // Head Height Guides
                CreateStandardDivider(rightSide: false);
                _headMarkerToggle = _plugin.CreateToggle(showHeadHeightMarkersStorable, rightSide: false);
                _headMarkerToggle.backgroundColor = HEADER_COLOR;
                if (showHeadHeightMarkersStorable.val)
                {
                    _headMarkerColorButton             = _plugin.CreateButton("Set Line Color", rightSide: false);
                    _headMarkerColorButton.buttonColor = _plugin.HSVToColor(headMarkerColor.val);
                    _headMarkerColorButton.button.onClick.AddListener(() => {
                        _choosingHeadColor = !_choosingHeadColor;
                        Draw();
                    });
                    if (_choosingHeadColor)
                    {
                        _headMarkerColorPicker = _plugin.CreateColorPicker(headMarkerColor, rightSide: false);
                    }
                    _headMarkerLineThickness = _plugin.CreateSlider(lineThicknessHeadStorable, rightSide: false);
                    CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                }
                else
                {
                    // if the right side is expanded, add some height padding
                    if (showFeatureMarkersStorable.val)
                    {
                        CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                        CreateStandardSpacer(defaultSliderHeight, rightSide: false);
                        CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                    }
                }
                CreateStandardSpacer(defaultSectionSpacerHeight, rightSide: false);

                // Feature Guides
                CreateStandardDivider(rightSide: true);
                _featureMarkerToggle = _plugin.CreateToggle(showFeatureMarkersStorable, rightSide: true);
                _featureMarkerToggle.backgroundColor = HEADER_COLOR;
                if (showFeatureMarkersStorable.val)
                {
                    _featureMarkerColorButton             = _plugin.CreateButton("Set Line Color", rightSide: true);
                    _featureMarkerColorButton.buttonColor = _plugin.HSVToColor(featureMarkerColor.val);
                    _featureMarkerColorButton.button.onClick.AddListener(() => {
                        _choosingFeatureColor = !_choosingFeatureColor;
                        Draw();
                    });
                    if (_choosingFeatureColor)
                    {
                        _featureMarkerColorPicker = _plugin.CreateColorPicker(featureMarkerColor, rightSide: true);
                    }
                    _featureMarkerLineThickness = _plugin.CreateSlider(lineThicknessFigureStorable, rightSide: true);
                    _featureMarkerToggleLabels  = _plugin.CreateToggle(showFeatureMarkerLabelsStorable, rightSide: true);
                }
                else
                {
                    // if the left side is expanded, add some height padding
                    if (showHeadHeightMarkersStorable.val)
                    {
                        CreateStandardSpacer(defaultButtonHeight, rightSide: true);
                        CreateStandardSpacer(defaultSliderHeight, rightSide: true);
                        CreateStandardSpacer(defaultButtonHeight, rightSide: true);
                    }
                }
                CreateStandardSpacer(defaultSectionSpacerHeight, rightSide: true);

                // Face Guides
                CreateStandardDivider(rightSide: false);
                _faceMarkerToggle = _plugin.CreateToggle(showFaceMarkersStorable, rightSide: false);
                _faceMarkerToggle.backgroundColor = HEADER_COLOR;
                if (showFaceMarkersStorable.val)
                {
                    _faceMarkerColorButton             = _plugin.CreateButton("Set Line Color");
                    _faceMarkerColorButton.buttonColor = _plugin.HSVToColor(faceMarkerColor.val);
                    _faceMarkerColorButton.button.onClick.AddListener(() => {
                        _choosingFaceColor = !_choosingFaceColor;
                        Draw();
                    });
                    if (_choosingFaceColor)
                    {
                        _faceMarkerColorPicker = _plugin.CreateColorPicker(faceMarkerColor, rightSide: false);
                    }
                    _faceMarkerLineThickness = _plugin.CreateSlider(lineThicknessFaceStorable, rightSide: false);
                    CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                }
                else
                {
                    // if right side is expanded
                    if (showCircumferenceMarkersStorable.val)
                    {
                        CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                        CreateStandardSpacer(defaultSliderHeight, rightSide: false);
                        CreateStandardSpacer(defaultButtonHeight, rightSide: false);
                    }
                }
                CreateStandardSpacer(defaultSectionSpacerHeight, rightSide: false);

                // Circumference Guides
                CreateStandardDivider(rightSide: true);
                _circumferenceMarkerToggle = _plugin.CreateToggle(showCircumferenceMarkersStorable, rightSide: true);
                _circumferenceMarkerToggle.backgroundColor = HEADER_COLOR;
                if (showCircumferenceMarkersStorable.val)
                {
                    _circumferenceMarkerColorButton             = _plugin.CreateButton("Set Line Color", rightSide: true);
                    _circumferenceMarkerColorButton.buttonColor = _plugin.HSVToColor(circumferenceMarkerColor.val);
                    _circumferenceMarkerColorButton.button.onClick.AddListener(() => {
                        _choosingCircumferenceColor = !_choosingCircumferenceColor;
                        Draw();
                    });
                    if (_choosingCircumferenceColor)
                    {
                        _circumferenceMarkerColorPicker = _plugin.CreateColorPicker(circumferenceMarkerColor, rightSide: true);
                    }
                    _circumferenceMarkerLineThickness = _plugin.CreateSlider(lineThicknessCircumferenceStorable, rightSide: true);
                    CreateStandardSpacer(defaultButtonHeight, rightSide: true);
                }
                else
                {
                    // if the left side is expanded, add some height padding
                    if (showFaceMarkersStorable.val)
                    {
                        CreateStandardSpacer(defaultButtonHeight, rightSide: true);
                        CreateStandardSpacer(defaultSliderHeight, rightSide: true);
                        CreateStandardSpacer(defaultButtonHeight, rightSide: true);
                    }
                }
                CreateStandardSpacer(defaultSectionSpacerHeight, rightSide: true);
            }

            CreateStandardDivider(rightSide: false);
            _cupAlgorithm    = _plugin.CreateScrollablePopup(cupAlgorithmStorable, rightSide: false);
            _units           = _plugin.CreateScrollablePopup(unitsStorable, rightSide: false);
            _markerSpread    = _plugin.CreateSlider(markerSpreadStorable, rightSide: false);
            _markerFrontBack = _plugin.CreateSlider(markerFrontBackStorable, rightSide: false);
            _markerLeftRight = _plugin.CreateSlider(markerLeftRightStorable, rightSide: false);
            _markerUpDown    = _plugin.CreateSlider(markerUpDownStorable, rightSide: false);

            CreateStandardDivider(rightSide: true);
            _manualMarkerToggle = _plugin.CreateToggle(showManualMarkersStorable, rightSide: true);
            if (showManualMarkersStorable.val)
            {
                if (_plugin.containingAtom.type == "Person")
                {
                    _copyManualMarkers = _plugin.CreateToggle(manualMarkersCopy, rightSide: true);
                }
                _manualMarkerColorButton             = _plugin.CreateButton("Set Line Color", rightSide: true);
                _manualMarkerColorButton.buttonColor = _plugin.HSVToColor(manualMarkerColor.val);
                _manualMarkerColorButton.button.onClick.AddListener(() => {
                    _choosingManualColor = !_choosingManualColor;
                    Draw();
                });
                if (_choosingManualColor)
                {
                    _manualMarkerColorPicker = _plugin.CreateColorPicker(manualMarkerColor, rightSide: true);
                }
                _manualMarkerLineThickness = _plugin.CreateSlider(lineThicknessManualStorable, rightSide: true);
                _manualSliders.Add(_plugin.CreateSlider(manualHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualChinHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualShoulderHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualNippleHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualUnderbustHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualNavelHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualCrotchHeightStorable, rightSide: true));
                _manualSliders.Add(_plugin.CreateSlider(manualKneeBottomHeightStorable, rightSide: true));
            }
        }