예제 #1
0
 public void SetMontage(Montage montage)
 {
     currentMontage = montage;
     if (montage == null)
     {
         poseChoice.SetVal(poseChoice.defaultVal);
         return;
     }
     poseChoice.choices = montage.GetPoseNames();
     poseChoice.SetVal(poseChoice.defaultVal);
 }
        public void RefreshForceProducers()
        {
            _targetCycleForceAtomChooser.choices = GetTargetCycleForceAtomChoices();

            if (optimalCycleForce == "")
            {
                _targetCycleForceAtomChooser.SetVal(_targetCycleForceAtomChooser.choices[0]);
            }
            else
            {
                _targetCycleForceAtomChooser.SetVal(optimalCycleForce);
            }
        }
예제 #3
0
        public void GenerateThrustAtoms()
        {
            dm.StartCoroutine(CreateAtom("AnimationPattern", "Thrust AP", (apAtom) =>
            {
                AnimationPattern ap = apAtom.GetStorableByID("AnimationPattern") as AnimationPattern;
                this.ap             = ap;

                ap.autoSyncStepNamesJSON.SetVal(false);

                thrustAtomChooser.SetVal(apAtom.name);

                if (ap.steps.Length >= 2)
                {
                    return;
                }

                ConfigureAPSteps(atom);

                UISetupState(apAtom);

                ap.SyncStepNames();
                ap.containingAtom.hidden   = true;
                ap.hideCurveUnlessSelected = true;
                ap.HideAllSteps();
            }, true));
        }
예제 #4
0
        private JSONStorableStringChooser CreatePeopleChooser(Action <Atom> onChange)
        {
            List <string>             people       = GetPeopleNamesFromScene();
            JSONStorableStringChooser personChoice = new JSONStorableStringChooser("copyFrom", people, null, "Copy From", (string id) =>
            {
                Atom atom = GetAtomById(id);
                onChange(atom);
            })
            {
                storeType = JSONStorableParam.StoreType.Full
            };

            if (people.Count > 0)
            {
                personChoice.SetVal(people[0]);
            }

            UIDynamicPopup scenePersonChooser = CreateScrollablePopup(personChoice, false);

            scenePersonChooser.popupPanelHeight = 250f;
            RegisterStringChooser(personChoice);
            scenePersonChooser.popup.onOpenPopupHandlers += () =>
            {
                personChoice.choices = GetPeopleNamesFromScene();
            };

            return(personChoice);
        }
예제 #5
0
        public void OnInitStorables(VAMLaunch plugin)
        {
            _minPosition = new JSONStorableFloat("patternSourceMinPosition", 10.0f, 0.0f, 99.0f);
            plugin.RegisterFloat(_minPosition);
            _maxPosition = new JSONStorableFloat("patternSourceMaxPosition", 80.0f, 0.0f, 99.0f);
            plugin.RegisterFloat(_maxPosition);

            _targetAnimationAtomChooser = new JSONStorableStringChooser("patternSourceTargetAnimationAtom",
                                                                        GetTargetAnimationAtomChoices(), "", "Target Animation Pattern",
                                                                        (name) =>
            {
                _animationAtomController = null;
                _targetAnimationPattern  = null;

                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                var atom = SuperController.singleton.GetAtomByUid(name);
                if (atom && atom.animationPatterns.Length > 0)
                {
                    _animationAtomController = atom.freeControllers[0];
                    _targetAnimationPattern  = atom.animationPatterns[0];
                    _patternTime             = _targetAnimationPattern.GetFloatJSONParam("currentTime");
                    _patternSpeed            = _targetAnimationPattern.GetFloatJSONParam("speed");
                }
            });
            plugin.RegisterStringChooser(_targetAnimationAtomChooser);

            _samplePlaneChooser = new JSONStorableStringChooser("patternSourceSamplePlane", _samplePlaneChoices, "",
                                                                "Sample Plane", (name) =>
            {
                for (int i = 0; i < _samplePlaneChoices.Count; i++)
                {
                    if (_samplePlaneChoices[i] == name)
                    {
                        _samplePlaneIndex = i;
                        break;
                    }
                }
            });
            plugin.RegisterStringChooser(_samplePlaneChooser);
            if (string.IsNullOrEmpty(_samplePlaneChooser.val))
            {
                _samplePlaneChooser.SetVal("Y");
            }

            _includeMidPoints = new JSONStorableBool("patternSourceIncludeMidPoints", false);
            plugin.RegisterBool(_includeMidPoints);
            _invertPosition = new JSONStorableBool("patternSourceInvertPosition", false);
            plugin.RegisterBool(_invertPosition);
            _useLocalSpace = new JSONStorableBool("patternSourceUseLocalSpace", false);
            plugin.RegisterBool(_useLocalSpace);
        }
예제 #6
0
        public void OnSimulatorUpdate(float prevPos, float newPos, float deltaTime)
        {
            if (_targetAnimationPattern == null)
            {
                if (!string.IsNullOrEmpty(_targetAnimationAtomChooser.val))
                {
                    _targetAnimationAtomChooser.SetVal("");
                }

                return;
            }

            if (_pluginFreeController.selected && SuperController.singleton.editModeToggle.isOn)
            {
                _lineDrawer0.SetLinePoints(_pluginFreeController.transform.position,
                                           _animationAtomController.transform.position);
                _lineDrawer0.Draw();
            }

            var currentTime = _targetAnimationPattern.GetFloatJSONParam("currentTime");

            float totalTime = _targetAnimationPattern.GetTotalTime();

            float normOldTime = currentTime.val / totalTime;

            float normalizedLaunchPos = Mathf.InverseLerp(_minPosition.val, _maxPosition.val, newPos);

            float newTime;

            if (_moveUpwards)
            {
                newTime = Mathf.Lerp(0.0f, totalTime * 0.5f, normalizedLaunchPos);
            }
            else
            {
                newTime = Mathf.Lerp(totalTime, totalTime * 0.5f, normalizedLaunchPos);
            }

            newTime = (newTime + (totalTime * _animationOffset.val)) % totalTime;

            float normNewTime = newTime / totalTime;

            if (Mathf.Abs(normNewTime - normOldTime) > 0.05f)
            {
                currentTime.SetVal(newTime);
            }
            _targetAnimationPattern.SetFloatParamValue("speed", totalTime / (_dirChangeDuration * 2.0f));
        }
예제 #7
0
        private void InitStorables()
        {
            _motionSourceChooser = new JSONStorableStringChooser("motionSource", _motionSourceChoices, "",
                                                                 "Motion Source",
                                                                 (string name) => { _desiredMotionSourceIndex = GetMotionSourceIndex(name); });
            _motionSourceChooser.choices = _motionSourceChoices;
            RegisterStringChooser(_motionSourceChooser);
            if (string.IsNullOrEmpty(_motionSourceChooser.val))
            {
                _motionSourceChooser.SetVal(_motionSourceChoices[0]);
            }

            _pauseLaunchMessages = new JSONStorableBool("pauseLaunchMessages", true);
            RegisterBool(_pauseLaunchMessages);

            _simulatorPosition = new JSONStorableFloat("simulatorPosition", 0.0f, 0.0f, LaunchUtils.LAUNCH_MAX_VAL);
            RegisterFloat(_simulatorPosition);

            foreach (var ms in _motionSources)
            {
                ms.OnInitStorables(this);
            }
        }
예제 #8
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);
        }
예제 #9
0
        public bool OnUpdate(ref byte outPos, ref byte outSpeed)
        {
            if (_targetAnimationPattern == null)
            {
                if (!string.IsNullOrEmpty(_targetAnimationAtomChooser.val))
                {
                    _targetAnimationAtomChooser.SetVal("");
                }
                return(false);
            }

            if (_pluginFreeController.selected && SuperController.singleton.editModeToggle.isOn)
            {
                _lineDrawer0.SetLinePoints(_pluginFreeController.transform.position,
                                           _animationAtomController.transform.position);
                _lineDrawer0.Draw();
            }

            if (_targetAnimationPattern.steps.Length <= 1)
            {
                return(false);
            }

            float minPos, maxPos;

            GenerateMotionPointsFromPattern(_targetAnimationPattern, ref _motionPoints, out minPos, out maxPos);

            if (_includeMidPoints.val && _pluginFreeController.selected &&
                SuperController.singleton.editModeToggle.isOn)
            {
                for (int i = 0; i < _motionPoints.Count; i++)
                {
                    if (i % 2 == 0)
                    {
                        continue;
                    }

                    var boxMatrix = Matrix4x4.TRS(_motionPoints[i].Position, Quaternion.identity,
                                                  new Vector3(0.1f, 0.1f, 0.1f));

                    Graphics.DrawMesh(_animationAtomController.holdPositionMesh, boxMatrix,
                                      _animationAtomController.linkLineMaterial,
                                      _animationAtomController.gameObject.layer, null, 0, null, false, false);
                }
            }

            int p0, p1;

            if (GetMotionPointIndices(_patternTime.val, _motionPoints, out p0, out p1))
            {
                if (p0 != _lastPointIndex)
                {
                    float yFactor = Mathf.InverseLerp(minPos, maxPos, GetPositionForPlane(_motionPoints[p1].Position));

                    float timeToNextPoint;
                    if (p1 > p0)
                    {
                        timeToNextPoint = _motionPoints[p1].Time - _patternTime.val;
                    }
                    else
                    {
                        timeToNextPoint = _targetAnimationPattern.GetTotalTime() - _patternTime.val +
                                          _motionPoints[p1].Time;
                    }

                    timeToNextPoint /= Mathf.Max(_patternSpeed.val, 0.001f);

                    float launchFactor = _invertPosition.val ? 1.0f - yFactor : yFactor;

                    float launchPos   = Mathf.Lerp(_minPosition.val, _maxPosition.val, launchFactor);
                    float launchSpeed = LaunchUtils.PredictMoveSpeed(_lastLaunchPos, launchPos, timeToNextPoint);

                    outPos   = (byte)launchPos;
                    outSpeed = (byte)launchSpeed;

                    _lastPointIndex = p0;
                    _lastLaunchPos  = launchPos;

                    return(true);
                }
            }

            return(false);
        }
예제 #10
0
        public override void Init()
        {
            try
            {
                createdCycleForce     = false;
                createCycleForceNamed = cycleForceNamePrefix + containingAtom.name;
                CreateButton("Create / Refresh EM Cycle Force").button.onClick.AddListener(
                    () => CreateCycleForceIfNeeded());

                _targetCycleForceAtomChooser = new JSONStorableStringChooser("cycSourceTargetCycleForceAtom",
                                                                             GetTargetCycleForceAtomChoices(), "", "Target Force Producer",
                                                                             (name) =>
                {
                    _cycleForceAtomController = null;
                    _targetCycleForce         = null;

                    if (string.IsNullOrEmpty(name))
                    {
                        return;
                    }

                    var atom = SuperController.singleton.GetAtomByUid(name);
                    if (atom && atom.forceProducers.Length > 0)
                    {
                        if (atom.freeControllers.Length > 0)
                        {
                            _cycleForceAtomController = atom.freeControllers[0];
                        }
                        _targetCycleForce = atom.GetComponentInChildren <CycleForceProducerV2>();
                    }
                });
                RegisterStringChooser(_targetCycleForceAtomChooser);
                if (string.IsNullOrEmpty(_targetCycleForceAtomChooser.val))
                {
                    _targetCycleForceAtomChooser.SetVal(_targetCycleForceAtomChooser.choices[0]);
                }
                _chooseCycleForceAtomPopup = CreateScrollablePopup(_targetCycleForceAtomChooser);
                _chooseCycleForceAtomPopup.popup.onOpenPopupHandlers += () =>
                {
                    _targetCycleForceAtomChooser.choices = GetTargetCycleForceAtomChoices();
                };
                cycleForceCreatesVagTouch = new JSONStorableBool("Always Moan if Cycle Force On", true);
                CreateToggle(cycleForceCreatesVagTouch);
                RegisterBool(cycleForceCreatesVagTouch);
                cycleForceCreatesVagTouch.storeType = JSONStorableParam.StoreType.Full;

                cycleForceRequiresVagTouch = new JSONStorableBool("Cycle Force Requires Vag Touch", false);
                CreateToggle(cycleForceRequiresVagTouch);
                RegisterBool(cycleForceRequiresVagTouch);
                cycleForceRequiresVagTouch.storeType = JSONStorableParam.StoreType.Full;

                explanationString = new JSONStorableString("Arousal: 0%", "");
                UIDynamicTextField dtext = CreateTextField(explanationString);

                cycleForceQuickness = new JSONStorableBool("Force Quickness Linked to Arousal", true);
                CreateToggle(cycleForceQuickness);
                RegisterBool(cycleForceQuickness);
                cycleForceQuickness.storeType = JSONStorableParam.StoreType.Full;

                float forceQuicknessDefault = 0.35f;
                if (IS_AUTOMATE_VERSION.IS_AUTOMATE)
                {
                    forceQuicknessDefault = 1.5f;
                }
                cycleForceQuicknessMin = new JSONStorableFloat("Force Quickness Min", forceQuicknessDefault, 0f, 10f, false);
                RegisterFloat(cycleForceQuicknessMin);
                cycleForceQuicknessMin.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceQuicknessMin);

                cycleForceQuicknessMax = new JSONStorableFloat("Force Quickness Max", 5f, 0f, 10f, false);
                RegisterFloat(cycleForceQuicknessMax);
                cycleForceQuicknessMax.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceQuicknessMax);

                cycleForcePeriod = new JSONStorableBool("Force Period Linked to Arousal", true);
                CreateToggle(cycleForcePeriod, true);
                RegisterBool(cycleForcePeriod);
                cycleForcePeriod.storeType = JSONStorableParam.StoreType.Full;

                float cycleForceDefault = 6.0f;
                if (IS_AUTOMATE_VERSION.IS_AUTOMATE)
                {
                    cycleForceDefault = 1.5f;
                }
                cycleForcePeriodMin = new JSONStorableFloat("Force Period Min", cycleForceDefault, 0.1f, 10f, false);
                RegisterFloat(cycleForcePeriodMin);
                cycleForcePeriodMin.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForcePeriodMin, true);

                cycleForcePeriodMax = new JSONStorableFloat("Force Period Max", 0.5f, 0.1f, 10f, false);
                RegisterFloat(cycleForcePeriodMax);
                cycleForcePeriodMax.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForcePeriodMax, true);

                cycleForceFactor = new JSONStorableBool("Force Factor Linked to Arousal", true);
                CreateToggle(cycleForceFactor, true);
                RegisterBool(cycleForceFactor);
                cycleForceFactor.storeType = JSONStorableParam.StoreType.Full;

                float forceFactorDefault = 30.0f;
                if (IS_AUTOMATE_VERSION.IS_AUTOMATE)
                {
                    forceFactorDefault = 200.0f;
                }
                cycleForceFactorMin = new JSONStorableFloat("Force Factor Min", forceFactorDefault, 0f, 500f, false);
                RegisterFloat(cycleForceFactorMin);
                cycleForceFactorMin.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceFactorMin, true);

                cycleForceFactorMax = new JSONStorableFloat("Force Factor Max", 400f, 0f, 500f, false);
                RegisterFloat(cycleForceFactorMax);
                cycleForceFactorMax.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceFactorMax, true);

                cycleForceRatio = new JSONStorableBool("Force Ratio Linked to Arousal", true);
                CreateToggle(cycleForceRatio, true);
                RegisterBool(cycleForceRatio);
                cycleForceRatio.storeType = JSONStorableParam.StoreType.Full;

                cycleForceRatioMin = new JSONStorableFloat("Force Ratio Min", 0.5f, 0f, 1.0f, false);
                RegisterFloat(cycleForceRatioMin);
                cycleForceRatioMin.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceRatioMin, true);

                cycleForceRatioMax = new JSONStorableFloat("Force Ratio Max", 0.35f, 0f, 1.0f, false);
                RegisterFloat(cycleForceRatioMax);
                cycleForceRatioMax.storeType = JSONStorableParam.StoreType.Full;
                CreateSlider(cycleForceRatioMax, true);
            }
            catch (Exception e) { SuperController.LogError("Exception caught: " + e); }
        }
예제 #11
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(() =>
            {
                dm.StartCoroutine(CreateAtom("AnimationPattern", "Thrust AP", (apAtom) =>
                {
                    AnimationPattern ap = apAtom.GetStorableByID("AnimationPattern") as AnimationPattern;

                    ap.autoSyncStepNamesJSON.SetVal(false);

                    thrustAtomChooser.SetVal(apAtom.name);

                    if (ap.steps.Length >= 2)
                    {
                        return;
                    }

                    FreeControllerV3 hipControl = atom.GetStorableByID("hipControl") as FreeControllerV3;
                    apAtom.mainController.transform.SetPositionAndRotation(hipControl.transform.position, hipControl.transform.rotation);
                    apAtom.SelectAtomParent(atom);

                    //ap.animatedTransform = hipControl.transform;

                    MoveProducer mp = apAtom.GetStorableByID("AnimatedObject") as MoveProducer;
                    mp.SetReceiverByName(atom.name + ":hipControl");

                    AnimationStep stepA = ap.CreateStepAtPosition(0);
                    stepA.containingAtom.ClearParentAtom();
                    stepA.containingAtom.mainController.transform.position = apAtom.mainController.transform.position;
                    stepA.containingAtom.mainController.transform.rotation = apAtom.mainController.transform.rotation;
                    //stepA.containingAtom.SetParentAtom(apAtom.name);

                    AnimationStep stepB = ap.CreateStepAtPosition(1);
                    stepB.containingAtom.ClearParentAtom();
                    FreeControllerV3 abdomen2Control = atom.GetStorableByID("abdomen2Control") as FreeControllerV3;

                    stepB.containingAtom.mainController.transform.position = abdomen2Control.transform.position;
                    stepB.containingAtom.mainController.transform.rotation = apAtom.mainController.transform.rotation;

                    apAtom.mainController.transform.Translate(0, 0, -0.2f, Space.Self);

                    stepA.containingAtom.mainController.currentPositionState = FreeControllerV3.PositionState.ParentLink;
                    stepA.containingAtom.mainController.currentRotationState = FreeControllerV3.RotationState.ParentLink;
                    Rigidbody rba = SuperController.singleton.RigidbodyNameToRigidbody(apAtom.name + ":control");
                    stepA.containingAtom.mainController.SelectLinkToRigidbody(rba, FreeControllerV3.SelectLinkState.PositionAndRotation);

                    stepB.containingAtom.mainController.currentPositionState = FreeControllerV3.PositionState.ParentLink;
                    stepB.containingAtom.mainController.currentRotationState = FreeControllerV3.RotationState.ParentLink;
                    Rigidbody rbb = SuperController.singleton.RigidbodyNameToRigidbody(apAtom.name + ":control");
                    stepB.containingAtom.mainController.SelectLinkToRigidbody(rbb, FreeControllerV3.SelectLinkState.PositionAndRotation);

                    UISetupState(apAtom);

                    ap.SyncStepNames();
                }, true));
            });

            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();
        }
예제 #12
0
        public PoseController(DollmasterPlugin dm) : base(dm)
        {
            poseEnabled = new JSONStorableBool("poseEnabled", true);
            dm.RegisterBool(poseEnabled);
            UIDynamicToggle moduleEnableToggle = dm.CreateToggle(poseEnabled);

            moduleEnableToggle.label           = "Enable Pose Change";
            moduleEnableToggle.backgroundColor = Color.green;

            poseChoice = new JSONStorableStringChooser("poseChoice", new List <string>(), "Default", "Pose", (string poseName) =>
            {
                try
                {
                    if (currentMontage == null)
                    {
                        return;
                    }

                    JSONClass pose = GetPoseFromName(poseName);
                    if (pose == null)
                    {
                        SuperController.LogError("no pose with id " + poseName);
                        return;
                    }

                    AnimateToPose(pose);
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                }
            });

            dm.RegisterStringChooser(poseChoice);



            poseAnimationDuration = new JSONStorableFloat("poseAnimationDuration", 1.2f, 0.01f, 10.0f);
            dm.RegisterFloat(poseAnimationDuration);
            dm.CreateSlider(poseAnimationDuration);

            nextPoseButton = dm.ui.CreateButton("Next Pose", 300, 80);
            nextPoseButton.transform.Translate(0.415f, -0.1f, 0, Space.Self);
            nextPoseButton.buttonColor = new Color(0.4f, 0.3f, 0.05f);
            nextPoseButton.textColor   = new Color(1, 1, 1);
            nextPoseButton.button.onClick.AddListener(() =>
            {
                if (currentMontage == null || poseChoice.choices.Count <= 1)
                {
                    return;
                }

                int index     = poseChoice.choices.IndexOf(poseChoice.val);
                int nextIndex = index + 1;
                if (nextIndex >= poseChoice.choices.Count)
                {
                    nextIndex = 0;
                }

                poseChoice.SetVal(poseChoice.choices[nextIndex]);
            });
            nextPoseButton.gameObject.SetActive(false);

            durationBetweenPoseChange = new JSONStorableFloat("durationBetweenPoseChange", 8.0f, 1.0f, 20.0f, false);
            dm.RegisterFloat(durationBetweenPoseChange);
            dm.CreateSlider(durationBetweenPoseChange);

            holdPose = new JSONStorableBool("holdPose", false);
            dm.RegisterBool(holdPose);
            UIDynamicToggle holdPoseToggle = ui.CreateToggle("Hold Pose", 180, 40);

            holdPose.toggle = holdPoseToggle.toggle;

            holdPoseToggle.transform.Translate(0.415f, 0.0630f, 0, Space.Self);
            holdPoseToggle.backgroundColor = new Color(0.2f, 0.2f, 0.2f);
            holdPoseToggle.labelText.color = new Color(1, 1, 1);

            dm.CreateSpacer();
        }
예제 #13
0
        public void OnInitStorables(VAMLaunch plugin)
        {
            _targetZoneWidth  = new JSONStorableFloat("zoneSourceTargetZoneWidth", 0.1f, 0.005f, 0.2f);
            _targetZoneHeight = new JSONStorableFloat("zoneSourceTargetZoneHeight", 0.1f, 0.005f, 0.2f);
            _targetZoneDepth  = new JSONStorableFloat("zoneSourceTargetZoneDepth", 0.1f, 0.005f, 0.2f);

            plugin.RegisterFloat(_targetZoneWidth);
            plugin.RegisterFloat(_targetZoneHeight);
            plugin.RegisterFloat(_targetZoneDepth);

            _currentTargetPos = new JSONStorableFloat("zoneSourceLaunchPos", 0.0f, 0.0f, LaunchUtils.LAUNCH_MAX_VAL);
            plugin.RegisterFloat(_currentTargetPos);

            _positionSampleRate = new JSONStorableFloat("zoneSourcePositionSampleRate", 40.0f, 10.0f, 90.0f);
            plugin.RegisterFloat(_positionSampleRate);

            _minLaunchSignalTimeThreshold =
                new JSONStorableFloat("zoneSourceMinLaunchSignalTimeThreshold", 0.1f, 0.001f, 0.4f);
            plugin.RegisterFloat(_minLaunchSignalTimeThreshold);

            _maxLaunchSignalTimeThreshold =
                new JSONStorableFloat("zoneSourceMaxLaunchSignalTimeThreshold", 0.25f, 0.001f, 0.4f);
            plugin.RegisterFloat(_maxLaunchSignalTimeThreshold);

            _currentLaunchSignalTimeThreshold =
                new JSONStorableFloat("zoneSourceCurrentLaunchSignalTimeThreshold", 0.099f, 0.001f, 0.4f);
            plugin.RegisterFloat(_currentLaunchSignalTimeThreshold);

            _lowerVelocityBarrier =
                new JSONStorableFloat("zoneSourceLowerVelocityBarrier", 10.0f, 0.0f, LaunchUtils.LAUNCH_MAX_VAL);
            plugin.RegisterFloat(_lowerVelocityBarrier);

            _higherVelocityBarrier = new JSONStorableFloat("zoneSourceHigherVelocityBarrier", 45.0f, 0.0f,
                                                           LaunchUtils.LAUNCH_MAX_VAL);
            plugin.RegisterFloat(_higherVelocityBarrier);

            _launchSpeedMultiplier = new JSONStorableFloat("zoneSourceLaunchSpeedMultiplier", 1.0f, 0.01f, 2.0f);
            plugin.RegisterFloat(_launchSpeedMultiplier);

            _targetAtomChooser = new JSONStorableStringChooser("zoneSourceTargetAtom", GetTargetAtomChoices(), "",
                                                               "Target Atom",
                                                               (name) =>
            {
                _targetAtom = SuperController.singleton.GetAtomByUid(name);
                if (_targetAtom == null)
                {
                    _targetController = null;
                }
                else
                {
                    _targetController =
                        _targetAtom.GetStorableByID(_targetControllerChooser.val) as FreeControllerV3;
                }

                if (_targetController == null)
                {
                    _targetControllerChooser.SetVal("");
                }
            });
            plugin.RegisterStringChooser(_targetAtomChooser);

            _targetControllerChooser = new JSONStorableStringChooser("zoneSourceTargetController",
                                                                     GetTargetControllerChoices(), "", "Target Control",
                                                                     (name) =>
            {
                if (_targetAtom == null)
                {
                    _targetController = null;
                }
                else
                {
                    _targetController = _targetAtom.GetStorableByID(name) as FreeControllerV3;
                }
            });
            plugin.RegisterStringChooser(_targetControllerChooser);
        }
예제 #14
0
        public override void Init()
        {
            try {
                //  The atom in the scene we're going to copy morphs from
                Atom sceneAtom = null;

                //  The JSON we're copying morphs from, if we are copying from a file
                JSONClass filePersonJSON = null;

                //  In a save file, mapped set of all people to their IDs
                Dictionary <string, JSONClass> idToPersonFromFile = null;


                UpdateInitialMorphs();

                #region Select from Scene or File
                UIDynamicButton selectFileButton = null;

                UIDynamicTextField selectedFileTextField = null;

                JSONStorableStringChooser personChoice = null;

                selectionStyle = new JSONStorableStringChooser("selectionStyle", new List <string>()
                {
                    "Scene", "File"
                }, "Scene", "Select Via", (string choice) =>
                {
                    if (choice == "File")
                    {
                        selectFileButton             = CreateButton("Choose from File");
                        selectFileButton.textColor   = Color.black;
                        selectFileButton.buttonColor = new Color(0.5f, 0.96f, 0.5f);
                        selectFileButton.button.onClick.AddListener(() =>
                        {
                            SuperController.singleton.GetScenePathDialog((filePath) =>
                            {
                                if (String.IsNullOrEmpty(filePath))
                                {
                                    return;
                                }

                                if (filePath.ToLower().Contains(".vac"))
                                {
                                    SuperController.LogError("loading VAC files not supported");
                                    return;
                                }

                                List <JSONClass> people = LoadPeopleFromFile(filePath);

                                if (people.Count <= 0)
                                {
                                    return;
                                }

                                idToPersonFromFile = new Dictionary <string, JSONClass>();
                                people.ForEach((person) =>
                                {
                                    string id = person["id"];
                                    idToPersonFromFile[id] = person;
                                });

                                filePersonJSON = idToPersonFromFile.Values.ToArray()[0];

                                List <string> names = people.Select((person) => {
                                    string id = person["id"];
                                    return(id);
                                }).ToList();

                                if (personChoice != null)
                                {
                                    personChoice.choices        = names;
                                    personChoice.displayChoices = names;

                                    if (names.Count > 0)
                                    {
                                        personChoice.SetVal(names[0]);
                                    }
                                }

                                if (selectedFileTextField != null)
                                {
                                    Destroy(selectedFileTextField.gameObject);
                                }
                                selectedFileTextField = CreateTextField(new JSONStorableString("file path", filePath));
                            });
                        });
                    }
                    else
                    {
                        if (selectFileButton != null)
                        {
                            RemoveButton(selectFileButton);
                        }

                        if (selectedFileTextField != null)
                        {
                            Destroy(selectedFileTextField.gameObject);
                        }
                    }
                });

                CreateScrollablePopup(selectionStyle);
                #endregion

                #region Choose Atom
                personChoice = new JSONStorableStringChooser("copyFrom", GetPeopleNamesFromScene(), null, "Copy From", delegate(string otherName)
                {
                    if (SelectingFromScene())
                    {
                        sceneAtom = GetAtomById(otherName);
                    }
                    else
                    {
                        if (idToPersonFromFile == null)
                        {
                            return;
                        }

                        if (idToPersonFromFile.ContainsKey(otherName) == false)
                        {
                            return;
                        }

                        filePersonJSON = idToPersonFromFile[otherName];
                        //Debug.Log(filePersonJSON);
                    }
                });
                personChoice.storeType = JSONStorableParam.StoreType.Full;
                UIDynamicPopup scenePersonChooser = CreateScrollablePopup(personChoice, false);
                scenePersonChooser.popupPanelHeight = 250f;
                RegisterStringChooser(personChoice);

                scenePersonChooser.popup.onOpenPopupHandlers += () =>
                {
                    // refresh from scene if we are looking for people in the current scene
                    if (SelectingFromScene())
                    {
                        personChoice.choices = GetPeopleNamesFromScene();
                    }
                };
                #endregion

                #region Region Group Buttons
                UIDynamicButton selectAll = CreateButton("Select All", true);
                selectAll.button.onClick.AddListener(delegate(){
                    toggles.Values.ToList().ForEach((toggle) =>
                    {
                        toggle.toggle.isOn = true;
                    });
                });
                selectAll.buttonColor = Color.white;

                UIDynamicButton selectNone = CreateButton("Select None", true);
                selectNone.button.onClick.AddListener(delegate() {
                    toggles.Values.ToList().ForEach((toggle) =>
                    {
                        toggle.toggle.isOn = false;
                    });
                });
                selectNone.buttonColor = Color.white;

                UIDynamicButton selectHead = CreateButton("Select Head", true);
                selectHead.button.onClick.AddListener(delegate() {
                    foreach (KeyValuePair <string, UIDynamicToggle> entry in toggles)
                    {
                        entry.Value.toggle.isOn = headRegion.Any((str) => entry.Key.Contains(str));
                    }
                });
                selectHead.buttonColor = Color.white;

                UIDynamicButton selectBody = CreateButton("Select Body", true);
                selectBody.button.onClick.AddListener(delegate() {
                    foreach (KeyValuePair <string, UIDynamicToggle> entry in toggles)
                    {
                        entry.Value.toggle.isOn = bodyRegion.Any((str) => entry.Key.Contains(str));
                    }
                });
                selectBody.buttonColor = Color.white;

                UIDynamicButton selectPose = CreateButton("Select Pose Controls", true);
                selectPose.button.onClick.AddListener(delegate() {
                    foreach (KeyValuePair <string, UIDynamicToggle> entry in toggles)
                    {
                        entry.Value.toggle.isOn = entry.Key.Contains("Pose Controls");
                    }
                });
                selectPose.buttonColor = Color.white;

                UIDynamicButton selectOfficial = CreateButton("Select Official Controls", true);
                selectOfficial.button.onClick.AddListener(delegate() {
                    foreach (KeyValuePair <string, UIDynamicToggle> entry in toggles)
                    {
                        entry.Value.toggle.isOn = officialRegion.Any((str) => entry.Key == str);
                    }
                });
                selectOfficial.buttonColor = Color.white;

                UIDynamicButton selectInvert = CreateButton("Invert Selection", true);
                selectInvert.button.onClick.AddListener(delegate() {
                    foreach (KeyValuePair <string, UIDynamicToggle> entry in toggles)
                    {
                        entry.Value.toggle.isOn = !entry.Value.toggle.isOn;
                    }
                });
                selectInvert.buttonColor = Color.white;

                CreateSpacer(true);

                //JSONStorableString stringFilter = new JSONStorableString("filter", "", (string value)=>
                //{
                //    if (string.IsNullOrEmpty(value))
                //    {
                //        return;
                //    }

                //    foreach (KeyValuePair<string, UIDynamicToggle> entry in toggles)
                //    {
                //        entry.Value.toggle.isOn = entry.Key.Contains(value);
                //    }
                //});

                //stringFilter.inputField.enabled = true;

                //UIDynamicTextField filterField = CreateTextField(stringFilter);
                //filterField.enabled = true;
                //filterField.UItext.enabled = true;


                #endregion

                #region Region Toggle Buttons
                JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
                DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
                GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

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

                foreach (string region in regions)
                {
                    bool isOnByDefault = defaultOff.Any((str) => region.Contains(str)) == false;
                    toggles[region] = CreateToggle(new JSONStorableBool(region, isOnByDefault), true);
                }
                #endregion

                #region Additive Toggle
                JSONStorableBool additiveToggle = new JSONStorableBool("Additive", false);
                CreateToggle(additiveToggle).labelText.text = "Additively Copy Morphs";
                #endregion

                #region Copy Button
                UIDynamicButton copyButton = CreateButton("Copy Morphs", false);
                copyButton.buttonColor = new Color(0, 0, 0.5f);
                copyButton.textColor   = new Color(1, 1, 1);
                copyButton.button.onClick.AddListener(delegate()
                {
                    //  copy morphs directly from an existing atom in the current scene
                    if (SelectingFromScene())
                    {
                        if (sceneAtom == null)
                        {
                            Debug.Log("other atom is null");
                            SuperController.LogMessage("Select an atom first");
                            return;
                        }

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

                        if (additiveToggle.val == false)
                        {
                            ZeroSelectedMorphs(morphControl);
                        }

                        morphControl.GetMorphDisplayNames().ForEach((name) =>
                        {
                            DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                            if (toggles.ContainsKey(morph.region) == false)
                            {
                                return;
                            }

                            if (toggles[morph.region].toggle.isOn)
                            {
                                morph.morphValue = otherMorphControl.GetMorphByDisplayName(name).morphValue;
                            }
                        });

                        //  also copy morphs that weren't included with this atom, such as imported morphs
                        otherMorphControl.GetMorphDisplayNames().ForEach((name) =>
                        {
                            DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                            if (toggles.ContainsKey(morph.region) == false)
                            {
                                return;
                            }

                            if (toggles[morph.region].toggle.isOn)
                            {
                                morph.morphValue = otherMorphControl.GetMorphByDisplayName(name).morphValue;
                            }
                        });
                    }

                    //  copy morphs from a JSON person atom
                    else
                    if (filePersonJSON != null)
                    {
                        JSONClass storableGeometry = null;

                        //  find geometry storable...
                        JSONArray storables = filePersonJSON["storables"].AsArray;
                        for (int i = 0; i < storables.Count; i++)
                        {
                            JSONClass storable = storables[i].AsObject;
                            string id          = storable["id"];
                            if (id == "geometry")
                            {
                                storableGeometry = storable;
                                break;
                            }
                        }

                        if (storableGeometry == null)
                        {
                            return;
                        }

                        if (additiveToggle.val == false)
                        {
                            ZeroSelectedMorphs(morphControl);
                        }

                        //  build a morph value dictionary...
                        Dictionary <string, float> otherMorphNameToValue = new Dictionary <string, float>();
                        if (storableGeometry != null)
                        {
                            JSONArray morphs = storableGeometry["morphs"].AsArray;
                            for (int i = 0; i < morphs.Count; i++)
                            {
                                JSONClass morphStorable     = morphs[i].AsObject;
                                string name                 = morphStorable["name"];
                                float value                 = morphStorable["value"].AsFloat;
                                otherMorphNameToValue[name] = value;
                            }
                        }

                        morphControl.GetMorphDisplayNames().ForEach((name) =>
                        {
                            DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                            if (morph == null)
                            {
                                Debug.Log("morph " + name + " does not exist in this context");
                                return;
                            }

                            if (toggles.ContainsKey(morph.region) == false)
                            {
                                return;
                            }

                            if (otherMorphNameToValue.ContainsKey(name) == false)
                            {
                                return;
                            }

                            if (toggles[morph.region].toggle.isOn)
                            {
                                morph.morphValue = otherMorphNameToValue[name];
                            }
                        });

                        otherMorphNameToValue.Keys.ToList().ForEach((name) =>
                        {
                            DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                            if (morph == null)
                            {
                                Debug.Log("morph " + name + " does not exist in this context");
                                return;
                            }
                            if (toggles.ContainsKey(morph.region) == false)
                            {
                                return;
                            }

                            if (toggles[morph.region].toggle.isOn)
                            {
                                morph.morphValue = otherMorphNameToValue[name];
                            }
                        });
                    }
                });

                CreateSpacer();
                #endregion

                #region Reset Button
                UIDynamicButton resetButton = CreateButton("Reset", false);
                resetButton.buttonColor = new Color(0.96f, 0.45f, 0.45f);
                resetButton.button.onClick.AddListener(delegate()
                {
                    ResetMorphs();
                });
                CreateSpacer();
                #endregion

                #region Zero Selected Button
                UIDynamicButton zeroButton = CreateButton("Zero Selected", false);
                zeroButton.buttonColor = new Color(0, 0, 0.5f);
                zeroButton.textColor   = new Color(1, 1, 1);
                zeroButton.button.onClick.AddListener(delegate()
                {
                    ZeroSelectedMorphs(morphControl);
                });
                #endregion

                #region Clear Animatable Button
                UIDynamicButton animatableButton = CreateButton("Clear Animatable", false);
                animatableButton.buttonColor = new Color(0, 0, 0.5f);
                animatableButton.textColor   = new Color(1, 1, 1);
                animatableButton.button.onClick.AddListener(delegate()
                {
                    morphControl.GetMorphDisplayNames().ForEach((name) =>
                    {
                        DAZMorph morph   = morphControl.GetMorphByDisplayName(name);
                        morph.animatable = false;
                    });
                });

                CreateSpacer();
                #endregion
            }
            catch (Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #15
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();
        }
예제 #16
0
        private void InitOptionsUI(VAMLaunch plugin)
        {
            _chooseAtomButton = plugin.CreateButton("Select Zone Target");
            _chooseAtomButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.SelectModeAtom((atom) =>
                {
                    if (atom == null)
                    {
                        return;
                    }

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

            _chooseAtomPopup = plugin.CreateScrollablePopup(_targetAtomChooser);
            _chooseAtomPopup.popup.onOpenPopupHandlers += () =>
            {
                _targetAtomChooser.choices = GetTargetAtomChoices();
            };

            _chooseControlPopup = plugin.CreateScrollablePopup(_targetControllerChooser);
            _chooseControlPopup.popup.onOpenPopupHandlers += () =>
            {
                _targetControllerChooser.choices = GetTargetControllerChoices();
            };

            var slider = plugin.CreateSlider(_targetZoneWidth, true);

            slider.label = "Target Zone Width";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneWidth.SetVal(v);
            });

            slider       = plugin.CreateSlider(_targetZoneHeight, true);
            slider.label = "Target Zone Height";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneHeight.SetVal(v);
            });

            slider       = plugin.CreateSlider(_targetZoneDepth, true);
            slider.label = "Target Zone Depth";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneDepth.SetVal(v);
            });

            slider       = plugin.CreateSlider(_positionSampleRate, true);
            slider.label = "Position Sample Rate";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _positionSampleRate.SetVal(v);
            });

            slider       = plugin.CreateSlider(_minLaunchSignalTimeThreshold, true);
            slider.label = "Min Adjust Time Threshold";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _minLaunchSignalTimeThreshold.SetVal(v);
            });

            slider       = plugin.CreateSlider(_maxLaunchSignalTimeThreshold, true);
            slider.label = "Max Adjust Time Threshold";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _maxLaunchSignalTimeThreshold.SetVal(v);
            });

            slider       = plugin.CreateSlider(_lowerVelocityBarrier, true);
            slider.label = "Min Adjust Time Vel Barrier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _lowerVelocityBarrier.SetVal(v);
            });

            slider       = plugin.CreateSlider(_higherVelocityBarrier, true);
            slider.label = "Max Adjust Time Vel Barrier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _higherVelocityBarrier.SetVal(v);
            });

            slider       = plugin.CreateSlider(_launchSpeedMultiplier, true);
            slider.label = "Launch Speed Multiplier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _launchSpeedMultiplier.SetVal(v);
            });

            _spacer0 = plugin.CreateSpacer();

            slider       = plugin.CreateSlider(_currentLaunchSignalTimeThreshold, false);
            slider.label = "Adjust Time";

            slider       = plugin.CreateSlider(_currentTargetPos, false);
            slider.label = "Current Target Position";
        }
예제 #17
0
파일: VAMLaunch.cs 프로젝트: qdot/VAMLaunch
        private void InitMenu()
        {
            CreateButton("Select VAM Launch Target").button.onClick.AddListener(() =>
            {
                SuperController.singleton.SelectModeAtom((atom) =>
                {
                    if (atom == null)
                    {
                        return;
                    }

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

            UIDynamicPopup popup = CreateScrollablePopup(_targetAtomChooser);

            popup.popup.onOpenPopupHandlers += () =>
            {
                _targetAtomChooser.choices = GetAtomChoices();
            };

            popup = CreateScrollablePopup(_targetControllerChooser);
            popup.popup.onOpenPopupHandlers += () =>
            {
                _targetControllerChooser.choices = GetControllerChoices();
            };

            var slider = CreateSlider(_targetZoneWidth, true);

            slider.label = "Target Zone Width";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneWidth.SetVal(v);
            });

            slider       = CreateSlider(_targetZoneHeight, true);
            slider.label = "Target Zone Height";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneHeight.SetVal(v);
            });

            slider       = CreateSlider(_targetZoneDepth, true);
            slider.label = "Target Zone Depth";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _targetZoneDepth.SetVal(v);
            });

            slider       = CreateSlider(_minLaunchSignalTimeThreshold, true);
            slider.label = "Min Adjust Time Threshold";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _minLaunchSignalTimeThreshold.SetVal(v);
            });

            slider       = CreateSlider(_maxLaunchSignalTimeThreshold, true);
            slider.label = "Max Adjust Time Threshold";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _maxLaunchSignalTimeThreshold.SetVal(v);
            });

            slider       = CreateSlider(_lowerVelocityBarrier, true);
            slider.label = "Min Adjust Time Vel Barrier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _lowerVelocityBarrier.SetVal(v);
            });

            slider       = CreateSlider(_higherVelocityBarrier, true);
            slider.label = "Max Adjust Time Vel Barrier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _higherVelocityBarrier.SetVal(v);
            });

            slider       = CreateSlider(_launchSpeedMultiplier, true);
            slider.label = "Launch Speed Multiplier";
            slider.slider.onValueChanged.AddListener((v) =>
            {
                _launchSpeedMultiplier.SetVal(v);
            });

            CreateSpacer();

            slider       = CreateSlider(_currentLaunchSignalTimeThreshold, false);
            slider.label = "Adjust Time";

            slider       = CreateSlider(_currentLaunchPos, false);
            slider.label = "Current Launch Position";

//            slider = CreateSlider(_debugVelocity, false);
//            slider.label = "Velocity";

            CreateSpacer();

            var toggle = CreateToggle(_pauseLaunchMessages);

            toggle.label = "Pause Launch";

            slider       = CreateSlider(_simulatorPosition, false);
            slider.label = "Simulator";
        }
예제 #18
0
파일: VAMLaunch.cs 프로젝트: qdot/VAMLaunch
        private void InitValues()
        {
            _targetZoneWidth  = new JSONStorableFloat("targetZoneWidth", 0.1f, 0.005f, 0.2f);
            _targetZoneHeight = new JSONStorableFloat("targetZoneHeight", 0.1f, 0.005f, 0.2f);
            _targetZoneDepth  = new JSONStorableFloat("targetZoneDepth", 0.1f, 0.005f, 0.2f);

            RegisterFloat(_targetZoneWidth);
            RegisterFloat(_targetZoneHeight);
            RegisterFloat(_targetZoneDepth);

            _currentLaunchPos = new JSONStorableFloat("launchPos", 0.0f, 0.0f, LAUNCH_MAX_VAL);
            RegisterFloat(_currentLaunchPos);

            _minLaunchSignalTimeThreshold = new JSONStorableFloat("minLaunchSignalTimeThreshold", 0.1f, 0.001f, 0.4f);
            RegisterFloat(_minLaunchSignalTimeThreshold);

            _maxLaunchSignalTimeThreshold = new JSONStorableFloat("maxLaunchSignalTimeThreshold", 0.4f, 0.001f, 0.4f);
            RegisterFloat(_maxLaunchSignalTimeThreshold);

            _currentLaunchSignalTimeThreshold = new JSONStorableFloat("currentLaunchSignalTimeThreshold", 0.099f, 0.001f, 0.4f);
            RegisterFloat(_currentLaunchSignalTimeThreshold);

            _lowerVelocityBarrier = new JSONStorableFloat("lowerVelocityBarrier", 10.0f, 0.0f, LAUNCH_MAX_VAL);
            RegisterFloat(_lowerVelocityBarrier);

            _higherVelocityBarrier = new JSONStorableFloat("higherVelocityBarrier", 40.0f, 0.0f, LAUNCH_MAX_VAL);
            RegisterFloat(_higherVelocityBarrier);

            _launchSpeedMultiplier = new JSONStorableFloat("launchSpeedMultiplier", 1.0f, 0.01f, 2.0f);
            RegisterFloat(_launchSpeedMultiplier);

            _pauseLaunchMessages = new JSONStorableBool("pauseLaunchMessages", true);
            RegisterBool(_pauseLaunchMessages);

            _simulatorPosition = new JSONStorableFloat("simulatorPosition", 0.0f, 0.0f, LAUNCH_MAX_VAL);
            RegisterFloat(_simulatorPosition);

            _debugVelocity = new JSONStorableFloat("launchVelocity", 0.0f, -LAUNCH_MAX_VAL, LAUNCH_MAX_VAL);
            RegisterFloat(_debugVelocity);

            _targetAtomChooser = new JSONStorableStringChooser("targetAtom", GetAtomChoices(), "", "Target Atom",
                                                               (name) =>
            {
                _targetAtom = SuperController.singleton.GetAtomByUid(name);
                if (_targetAtom == null)
                {
                    _targetController = null;
                }
                else
                {
                    _targetController = _targetAtom.GetStorableByID(_targetControllerChooser.val) as FreeControllerV3;
                }

                if (_targetController == null)
                {
                    _targetControllerChooser.SetVal("");
                }
            });
            RegisterStringChooser(_targetAtomChooser);

            _targetControllerChooser = new JSONStorableStringChooser("targetController", GetControllerChoices(), "", "Target Control",
                                                                     (name) =>
            {
                if (_targetAtom == null)
                {
                    _targetController = null;
                }
                else
                {
                    _targetController = _targetAtom.GetStorableByID(name) as FreeControllerV3;
                }
            });
            RegisterStringChooser(_targetControllerChooser);
        }
예제 #19
0
        public MontageController(DollmasterPlugin dm, PoseController poseController) : base(dm)
        {
            this.poseController = poseController;

            UIDynamicButton saveButton = dm.CreateButton("Create Montage", true);

            saveButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.currentSaveDir = SuperController.singleton.currentLoadDir;

                string name     = "Montage " + montages.Count;
                Montage montage = new Montage(name, GetMontageAtoms());
                montages.Add(montage);

                montageChoice.SetVal(name);
                montageChoice.choices = GetMontageNamesList();

                currentMontage = montage;

                nextMontageButton.gameObject.SetActive(true);
                poseController.nextPoseButton.gameObject.SetActive(true);
            });

            montageChoice = new JSONStorableStringChooser("montage", GetMontageNamesList(), "", "Select Montage", (string montageName) =>
            {
                Montage found = FindMontageByName(montageName);
                if (found == null)
                {
                    //SuperController.LogError("montage not found " + montageName);
                    SetPoseUIActive(false);
                    return;
                }

                float prevThrustValue = dm.thrustController.slider.slider.value;

                found.Apply();
                currentMontage = found;
                Debug.Log("Applying Montage " + montageName);
                poseController.SetMontage(found);

                dm.thrustController.slider.slider.value = prevThrustValue;

                nextMontageButton.gameObject.SetActive(true);
                poseController.nextPoseButton.gameObject.SetActive(true);

                SetPoseUIActive(true);
            });
            dm.RegisterStringChooser(montageChoice);
            //montageChoice.storeType = JSONStorableParam.StoreType.Appearance;

            nextMontageButton = dm.ui.CreateButton("Next Montage", 300, 80);
            nextMontageButton.transform.Translate(0, -0.1f, 0, Space.Self);
            nextMontageButton.buttonColor = new Color(0.4f, 0.3f, 0.05f);
            nextMontageButton.textColor   = new Color(1, 1, 1);
            nextMontageButton.button.onClick.AddListener(() =>
            {
                if (montages.Count == 0)
                {
                    return;
                }

                int index     = montageChoice.choices.IndexOf(montageChoice.val);
                int nextIndex = index + 1;
                if (nextIndex >= montageChoice.choices.Count)
                {
                    nextIndex = 0;
                }

                string choice = montageChoice.choices[nextIndex];
                montageChoice.SetVal(choice);

                poseController.StopCurrentAnimation();
            });
            nextMontageButton.gameObject.SetActive(false);

            dm.CreateSpacer(true).height = 25;
            dm.CreatePopup(montageChoice, true);
            montageChoice.popup.onOpenPopupHandlers += () => {
                montageChoice.choices = GetMontageNamesList();
            };

            dm.CreateButton("Update Selected Montage", true).button.onClick.AddListener(() =>
            {
                if (currentMontage != null)
                {
                    currentMontage.montageJSON = GetMontageAtoms();
                }
            });

            //dm.CreateButton("Clear Montages", true).button.onClick.AddListener(() =>
            //{
            //    montages.Clear();
            //    currentMontage = null;
            //    poseController.SetMontage(null);

            //    nextMontageButton.gameObject.SetActive(false);
            //    poseController.nextPoseButton.gameObject.SetActive(false);
            //});

            dm.CreateButton("Delete Selected Montage", true).button.onClick.AddListener(() =>
            {
                if (currentMontage == null)
                {
                    return;
                }

                montages.Remove(currentMontage);
                currentMontage = null;
                poseController.SetMontage(null);
                montageChoice.SetVal("");

                if (montages.Count == 0)
                {
                    nextMontageButton.gameObject.SetActive(false);
                    poseController.nextPoseButton.gameObject.SetActive(false);
                }
                else
                {
                    montageChoice.SetVal(montages[0].name);
                }
            });


            dm.CreateSpacer(true).height = 50;

            poseChoicePopup       = dm.CreatePopup(poseController.poseChoice, true);
            poseChoicePopup.label = "Select Pose";
            poseChoicePopup.popup.onOpenPopupHandlers += () =>
            {
                if (currentMontage == null)
                {
                    poseController.poseChoice.choices = new List <string>();
                    return;
                }
                poseController.poseChoice.choices = currentMontage.GetPoseNames();
            };

            dm.CreateSpacer(true).height = 25;

            addPoseButton = dm.CreateButton("Add Pose", true);
            addPoseButton.button.onClick.AddListener(() =>
            {
                if (currentMontage == null)
                {
                    return;
                }

                currentMontage.AddPose(PoseController.GetLocalPose(atom));
            });

            deletePoseButton = dm.CreateButton("Delete Selected Pose", true);
            deletePoseButton.button.onClick.AddListener(() =>
            {
                if (currentMontage == null)
                {
                    return;
                }

                JSONClass pose = poseController.GetPoseFromName(poseController.poseChoice.val);
                if (pose == null)
                {
                    return;
                }

                currentMontage.poses.Remove(pose);
            });

            //clearPosesButton = dm.CreateButton("Clear Poses", true);
            //clearPosesButton.button.onClick.AddListener(() =>
            //{
            //    if (currentMontage == null)
            //    {
            //        return;
            //    }

            //    currentMontage.poses.Clear();
            //    poseController.poseChoice.choices = new List<string>();
            //});


            SetPoseUIActive(false);
        }
예제 #20
0
        public override void Init()
        {
            try
            {
                PATH_WHEN_LOADED = SuperController.singleton.currentLoadDir;

                SuperController sc = SuperController.singleton;

                CreateButton("New").button.onClick.AddListener(() =>
                {
                    audioChoice.SetVal("");
                    RemoveAllSteps();
                    RemoveAllSelectors();
                    CreateStep(0);
                    CreateStep(1);
                    playback.SetVal(0);
                    totalDuration.SetVal(totalDuration.defaultVal);
                });

                CreateButton("Save").button.onClick.AddListener(() =>
                {
                    if (steps.Count <= 0)
                    {
                        return;
                    }

                    List <ExpressionKeyframe> keyframes = steps.Select((step) => step.ToKeyFrame()).ToList();

                    string audioUID = "";
                    if (currentClip != null)
                    {
                        audioUID = currentClip.uid;
                    }

                    ExpressionAnimation animation = new ExpressionAnimation()
                    {
                        audio     = audioUID,
                        duration  = totalDuration.val,
                        keyframes = keyframes
                    };

                    JSONNode json = animation.GetJSON();
                    //Debug.Log(json.ToString());

                    //sc.activeUI = SuperController.ActiveUI.None;
                    sc.fileBrowserUI.defaultPath = PATH_WHEN_LOADED;
                    sc.fileBrowserUI.SetTextEntry(true);

                    sc.fileBrowserUI.Show((path) =>
                    {
                        //  cancel or invalid
                        if (string.IsNullOrEmpty(path))
                        {
                            return;
                        }

                        //  ensure extension
                        if (!path.EndsWith(".json"))
                        {
                            path += ".json";
                        }

                        sc.SaveStringIntoFile(path, json.ToString(""));
                        SuperController.LogMessage("Wrote expression file: " + path);
                    });

                    //  set default filename
                    if (sc.fileBrowserUI.fileEntryField != null)
                    {
                        sc.fileBrowserUI.fileEntryField.text = currentClip.uid + ".json";
                        sc.fileBrowserUI.ActivateFileNameField();
                    }
                });
                CreateSpacer().height = 12;

                CreateButton("Load", true).button.onClick.AddListener(() =>
                {
                    sc.fileBrowserUI.defaultPath = PATH_WHEN_LOADED;
                    sc.fileBrowserUI.SetTextEntry(false);
                    sc.fileBrowserUI.Show((path) =>
                    {
                        if (string.IsNullOrEmpty(path))
                        {
                            return;
                        }

                        string jsonString = sc.ReadFileIntoString(path);

                        /*
                         * Example:
                         *
                         * {
                         * "audio" : "holding it 1.mp3",
                         * "keyframes" : [
                         *    {
                         *       "time" : "0",
                         *       "Brow Down" : "0"
                         *    },
                         *    {
                         *       "time" : "1",
                         *       "Brow Down" : "1"
                         *    }
                         * ]
                         * }
                         *
                         */

                        JSONClass jsc = JSON.Parse(jsonString).AsObject;


                        string clipId = jsc["audio"].Value;

                        //  validate this audio clip exists
                        NamedAudioClip nac = URLAudioClipManager.singleton.GetClip(clipId);
                        if (nac == null)
                        {
                            //SuperController.LogError("Clip " + clipId + " is not loaded to scene. Add it first.");
                            //return;
                        }

                        audioChoice.SetVal(jsc["audio"].Value);
                        totalDuration.SetVal(jsc["duration"].AsFloat);

                        RemoveAllSteps();
                        RemoveAllSelectors();

                        JSONArray keyframes = jsc["keyframes"].AsArray;

                        HashSet <DAZMorph> morphSet             = new HashSet <DAZMorph>();
                        GenerateDAZMorphsControlUI morphControl = GetMorphControl();

                        for (int i = 0; i < keyframes.Count; i++)
                        {
                            JSONClass keyframe = keyframes[i].AsObject;
                            float time         = keyframe["time"].AsFloat;

                            ExpressionStep step = CreateStep(time);

                            keyframe.Keys.ToList().ForEach((key =>
                            {
                                if (key == "time")
                                {
                                    return;
                                }

                                string morphName = key;

                                DAZMorph morph = morphControl.GetMorphByDisplayName(morphName);
                                if (morph == null)
                                {
                                    SuperController.LogError("Expression has a morph not imported: " + morphName);
                                    return;
                                }

                                if (morphSet.Contains(morph) == false)
                                {
                                    morphSet.Add(morph);
                                    MorphSelectUI selector = CreateMorphSelector();
                                    selector.morphString.SetVal(morphName);
                                    selector.SetCollapse(morphsCollapsed);
                                }

                                float value = keyframe[morphName].AsFloat;
                                step.morphKeyframe[morph] = value;
                            }));
                        }

                        playback.SetVal(0);
                    });
                });
                CreateSpacer(true).height = 12;

                totalDuration = new JSONStorableFloat("duration", 2.0f, (float newDuration) =>
                {
                }, 0.0f, 10.0f, false);

                UIDynamicSlider slider = CreateSlider(totalDuration);
                slider.label = "Duration (based on audio clip if selected)";

                audioChoice = new JSONStorableStringChooser("clip", GetAudioClipIds(), "", "Audio Clip", (string clipId) => {
                    NamedAudioClip nac = URLAudioClipManager.singleton.GetClip(clipId);
                    if (nac == null)
                    {
                        currentClip = null;
                        return;
                    }

                    currentClip = nac;
                    PlayAudioClipAtT(nac, 0);

                    totalDuration.SetVal(nac.sourceClip.length);
                });
                //RegisterStringChooser(audioChoice);

                UIDynamicPopup popup = CreateScrollablePopup(audioChoice);
                popup.popup.onOpenPopupHandlers += () =>
                {
                    audioChoice.choices = GetAudioClipIds();
                };

                playback = new JSONStorableFloat("time", 0, (float t) =>
                {
                    if (isTesting == false)
                    {
                        if (currentClip != null)
                        {
                            SampleAudioClipAtT(currentClip, t);
                        }
                        SetMorphAtT(t);
                    }

                    createKeyButton.label = "Key At " + t;

                    CancelDeleteConfirmation();
                }, 0, 1, true, true);

                UIDynamicSlider playbackSlider = CreateSlider(playback);
                playbackSlider.quickButtonsEnabled  = false;
                playbackSlider.rangeAdjustEnabled   = false;
                playbackSlider.defaultButtonEnabled = false;

                CreateButton("Test").button.onClick.AddListener(() =>
                {
                    if (isTesting == true)
                    {
                        isTesting = false;
                        return;
                    }

                    isTesting     = true;
                    testStartTime = Time.time;
                    if (currentClip != null)
                    {
                        PlayAudioClipAtT(currentClip, 0);
                    }

                    CancelDeleteConfirmation();
                });

                createKeyButton = CreateButton("Key At 0");
                createKeyButton.button.onClick.AddListener(() => {
                    CreateStep(playback.val);
                });

                CreateSpacer();


                UIDynamicButton addMorphButton = CreateButton("Add Morph", true);
                addMorphButton.button.onClick.AddListener(() =>
                {
                    CreateMorphSelector();
                });

                UIDynamicButton minimizeViewButton = CreateButton("Minimize Morph Controls", true);
                minimizeViewButton.button.onClick.AddListener(() =>
                {
                    morphsCollapsed = !morphsCollapsed;
                    morphSelectors.ForEach((selector) =>
                    {
                        selector.SetCollapse(morphsCollapsed);
                    });

                    CancelDeleteConfirmation();

                    minimizeViewButton.label = morphsCollapsed ? "Maximize Morph Controls" : "Minimize Morph Controls";
                });

                deleteButton = CreateButton("Delete Selected", false);
                deleteButton.button.onClick.AddListener(() =>
                {
                    if (selectedStep == null)
                    {
                        return;
                    }

                    if (deleteConfirmation == false)
                    {
                        BeginDeleteConfirmation();
                        return;
                    }
                    else
                    {
                        RemoveStep(selectedStep);
                        CancelDeleteConfirmation();
                    }
                });

                CreateStep(0);
                CreateStep(1);
                playback.SetVal(0);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }