예제 #1
0
        public UIDynamicPopup CreateUIPopupInCanvas(JSONStorableStringChooser jssc)
        {
            var transform = Object.Instantiate(_owner.manager.configurableScrollablePopupPrefab.transform, _container.transform, false);

            if (transform == null)
            {
                throw new NullReferenceException("Could not instantiate configurableScrollablePopupPrefab");
            }
            transform.gameObject.SetActive(true);

            var ui = transform.GetComponent <UIDynamicPopup>();

            if (ui == null)
            {
                throw new NullReferenceException("Could not find a UIDynamicPopup component");
            }
            ui.popupPanelHeight = 1000;
            jssc.popup          = ui.popup;
            ui.label            = jssc.label;

            return(ui);
        }
예제 #2
0
        public UIDynamicPopup CreatePopup(JSONStorableStringChooser jsc, bool filterable)
        {
            RegisterStorable(jsc);
            Transform prefab;

            #if (VAM_GT_1_20)
            if (filterable)
            {
                prefab = controller.manager.configurableFilterablePopupPrefab;
            }
            else
            #endif
            prefab = controller.Manager.configurableScrollablePopupPrefab;
            var ui = Instantiate(prefab).GetComponent <UIDynamicPopup>();
            ui.gameObject.transform.SetParent(transform, false);
            ui.labelTextColor = Styles.DefaultText;
            ui.popup.backgroundImage.color = Styles.DefaultBg;
            ui.label       = jsc.name;
            ui.popup.label = jsc.val;
            jsc.popup      = ui.popup;
            return(ui);
        }
예제 #3
0
    public override void Init()
    {
        SetUpLabel("Point this controller of the current atom:");

        _localController = SetUpChooser("LocalController", "Local Controller", SetLocalController, SyncLocalControllerChoices);
        AutoSelectSoleController(containingAtom, _localController);

        SetUpLabel("Towards this other controller:", 2);

        _remoteAtom       = SetUpChooser("RemoteAtom", "Remote Atom", SetRemoteAtom, SyncRemoteAtomChoices);
        _remoteController = SetUpChooser("RemoteController", "Remote Controller", SetRemoteController, SyncRemoteControllerChoices);

        SetUpLabel("Optional angle offsets:", 4);

        _angle_offset_x = SetUpFloat("X angle offset", 0f, -180f, 180f);
        _angle_offset_y = SetUpFloat("Y angle offset", 0f, -180f, 180f);
        _angle_offset_z = SetUpFloat("Z angle offset", 0f, -180f, 180f);

        _setOffsetToCurrent = SetUpButton("Record current angle offset", SetOffsetToCurrent);
        _setOffsetsToZero   = SetUpButton("Reset offsets to zero", SetOffsetsToZero);

        _pauseUpdates = SetUpBool("Pause updates", false);
    }
예제 #4
0
    private void InitControls()
    {
        var atoms = SuperController.singleton.GetAtoms().Select(atom => atom.uid).OrderBy(uid => uid).ToList();

        atoms.Insert(0, "None");

        _atomJSON           = new JSONStorableStringChooser("Passenger", atoms, "None", "Passenger");
        _atomJSON.storeType = JSONStorableParam.StoreType.Physical;
        RegisterStringChooser(_atomJSON);

        var linkPopup = CreateScrollablePopup(_atomJSON, false);

        linkPopup.popupPanelHeight = 600f;

        CreateButton("Set Time To This Step", true).button.onClick.AddListener(() =>
        {
            _step.animationParent.GetFloatJSONParam("currentTime").val = _step.timeStep;
        });
        CreateButton("Select Animation Pattern", true).button.onClick.AddListener(() =>
        {
            SuperController.singleton.SelectController(_step.animationParent.containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "control"));
        });
    }
예제 #5
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);
            }
        }
예제 #6
0
        private Dictionary <string, UIDynamicButton> CreateRadioButtonGroup(JSONStorableStringChooser jsc, bool rightSide = false)
        {
            Dictionary <string, UIDynamicButton> buttons = new Dictionary <string, UIDynamicButton>();

            jsc.choices.ForEach((choice) =>
            {
                UIDynamicButton btn      = CreateButton(UI.RadioButtonLabel(Const.MODES[choice], choice == jsc.defaultVal), rightSide);
                btn.buttonText.alignment = TextAnchor.MiddleLeft;
                btn.buttonColor          = UI.darkOffGrayViolet;
                btn.height = 60f;
                buttons.Add(choice, btn);
            });

            buttons.Keys.ToList().ForEach(name =>
            {
                buttons[name].button.onClick.AddListener(() =>
                {
                    jsc.val = name;
                });
            });

            return(buttons);
        }
        private JSONStorableStringChooser InitAnimationSelectorUI(Transform configurableScrollablePopupPrefab)
        {
            var jsc = new JSONStorableStringChooser("Animation", new List <string>(), "", "Animation", (string val) =>
            {
                if (_ignoreAnimationChange)
                {
                    return;
                }
                _animation?.SelectAnimation(val);
            });

            var popup = Instantiate(configurableScrollablePopupPrefab);

            popup.SetParent(transform, false);

            var ui = popup.GetComponent <UIDynamicPopup>();

            ui.label            = "Play";
            ui.popupPanelHeight = GetComponent <UIDynamic>()?.height ?? 500;

            jsc.popup = ui.popup;

            return(jsc);
        }
예제 #8
0
        private void InitAnimationLengthUI(bool rightSide)
        {
            UIDynamicButton applyLengthUI = null;

            _lengthModeJSON = new JSONStorableStringChooser("Change Length Mode", new List <string> {
                ChangeLengthModeCropExtendEnd,
                ChangeLengthModeAddKeyframeEnd,
                ChangeLengthModeCropExtendBegin,
                ChangeLengthModeAddKeyframeBegin,
                ChangeLengthModeCropExtendAtTime,
                ChangeLengthModeStretch,
                ChangeLengthModeLoop
            }, ChangeLengthModeCropExtendEnd, "Change Length Mode", (string val) =>
            {
                _lengthWhenLengthModeChanged = current?.animationLength ?? 0f;
            });
            RegisterStorable(_lengthModeJSON);
            var lengthModeUI = plugin.CreateScrollablePopup(_lengthModeJSON, rightSide);

            lengthModeUI.popupPanelHeight = 550f;
            RegisterComponent(lengthModeUI);

            _lengthJSON = new JSONStorableFloat("Change Length To (s)", AtomAnimationClip.DefaultAnimationLength, 0.5f, 10f, false, true);
            RegisterStorable(_lengthJSON);
            var lengthUI = plugin.CreateSlider(_lengthJSON, rightSide);

            lengthUI.valueFormat = "F3";
            RegisterComponent(lengthUI);

            applyLengthUI = plugin.CreateButton("Apply", rightSide);
            RegisterComponent(applyLengthUI);
            applyLengthUI.button.onClick.AddListener(() =>
            {
                UpdateAnimationLength(_lengthJSON.val);
            });
        }
예제 #9
0
        private void InitControllersUI()
        {
            _addControllerListJSON            = new JSONStorableStringChooser("Controller", new List <string>(), "", "Controller");
            _addControllerUI                  = prefabFactory.CreatePopup(_addControllerListJSON, true, true);
            _addControllerUI.popupPanelHeight = 740f;

            _toggleControllerUI = prefabFactory.CreateButton("Add");
            _toggleControllerUI.button.onClick.AddListener(AddAnimatedController);


            var selectFromSceneUI = prefabFactory.CreateButton("<i>Select from scene</i>");

            selectFromSceneUI.button.onClick.AddListener(() =>
            {
                SuperController.singleton.SelectModeControllers(targetCtrl =>
                {
                    SuperController.singleton.ShowMainHUDAuto();
                    SuperController.singleton.SelectController(plugin.containingAtom.mainController, false, false, false, true);
                    operations.Targets().Add(targetCtrl);
                });
            });

            RefreshControllersList();
        }
    public void Show()
    {
        if (ShowNotSelected(_trackers.selectedJSON.val))
        {
            return;
        }

        CreateText(new JSONStorableString("", "Binds VR trackers (such as the headset or controllers) to an atom's controllers.\n\nHands have no effect when Snug is enabled, and Head has no effect when Passenger is enabled."), true);

        CreateToggle(_trackers.restorePoseAfterPossessJSON, true).label = "Restore pose after possession";

        CreateToggle(_trackers.previewTrackerOffsetJSON, true).label = "Preview offset in 3D";

        _motionControlJSON = _motionControlJSON ?? new JSONStorableStringChooser(
            "",
            _trackers.motionControls.Select(mc => mc.name).ToList(),
            _trackers.motionControls[0].name ?? _none,
            "Motion control",
            (val) => ShowMotionControl(_trackers.motionControls.FirstOrDefault(mc => mc.name == val))
            );
        CreateScrollablePopup(_motionControlJSON);

        ShowMotionControl(_trackers.motionControls[0]);
    }
예제 #11
0
파일: Embody.cs 프로젝트: via5/vam-embody
    private JSONStorableStringChooser InitPresets()
    {
        var jss = new JSONStorableStringChooser("Presets", new List <string>
        {
            "Improved Possession",
            "Improved Possession w/ Leap",
            "Snug",
            "Passenger",
            "Passenger w/ Hands",
            "Passenger w/ Leap",
            "Leap Fingers Only",
            "Legacy Possession",
        }, "(Select To Apply)", "Apply Preset")
        {
            isStorable = false
        };

        jss.setCallbackFunction = val =>
        {
            SelectPreset(val);
            jss.valNoCallback = $"({val} Applied)";
        };
        return(jss);
    }
예제 #12
0
        private void InitStorables()
        {
            _autoPlayJSON = new JSONStorableBool("Auto Play", false);
            RegisterBool(_autoPlayJSON);

            _hideJSON = new JSONStorableBool("Hide", false, (bool val) => Hide(val));
            RegisterBool(_hideJSON);

            _enableKeyboardShortcuts = new JSONStorableBool("Enable Keyboard Shortcuts", false);
            RegisterBool(_enableKeyboardShortcuts);

            _atomsJSON = new JSONStorableStringChooser("Atoms Selector", new List <string>(), "", "Atoms", (string v) => SelectCurrentAtom(v))
            {
                isStorable   = false,
                isRestorable = false
            };

            _animationJSON = new JSONStorableStringChooser(StorableNames.Animation, new List <string>(), "", "Animation", (string v) => ChangeAnimation(v))
            {
                isStorable   = false,
                isRestorable = false
            };
            RegisterStringChooser(_animationJSON);

            _playJSON = new JSONStorableAction(StorableNames.Play, () => Play());
            RegisterAction(_playJSON);

            _playIfNotPlayingJSON = new JSONStorableAction(StorableNames.PlayIfNotPlaying, () => PlayIfNotPlaying());
            RegisterAction(_playIfNotPlayingJSON);

            _stopJSON = new JSONStorableAction(StorableNames.Stop, () => Stop());
            RegisterAction(_stopJSON);

            _stopAndResetJSON = new JSONStorableAction(StorableNames.StopAndReset, () => StopAndReset());
            RegisterAction(_stopAndResetJSON);

            _timeJSON = new JSONStorableFloat(StorableNames.Time, 0f, v => _selectedLink.time.val = v, 0f, 2f, true)
            {
                isStorable   = false,
                isRestorable = false
            };
            RegisterFloat(_timeJSON);

            var nextAnimationJSON = new JSONStorableAction(StorableNames.NextAnimation, () =>
            {
                var i = _animationJSON.choices.IndexOf(_selectedLink?.animation.val);
                if (i < 0 || i > _animationJSON.choices.Count - 2)
                {
                    return;
                }
                _animationJSON.val = _animationJSON.choices[i + 1];
            });

            RegisterAction(nextAnimationJSON);

            var previousAnimationJSON = new JSONStorableAction(StorableNames.PreviousAnimation, () =>
            {
                var i = _animationJSON.choices.IndexOf(_selectedLink?.animation.val);
                if (i < 1 || i > _animationJSON.choices.Count - 1)
                {
                    return;
                }
                _animationJSON.val = _animationJSON.choices[i - 1];
            });

            RegisterAction(previousAnimationJSON);

            StartCoroutine(InitDeferred());
        }
예제 #13
0
        public override void Init()
        {
            try
            {
                receiverChoices             = new List <string>();
                receiverNameToForceReceiver = new Dictionary <string, ForceReceiver>();
                foreach (ForceReceiver fr in containingAtom.forceReceivers)
                {
                    receiverChoices.Add(fr.name);
                    receiverNameToForceReceiver.Add(fr.name, fr);
                }
                receiverChoiceJSON           = new JSONStorableStringChooser("receiver", receiverChoices, null, "Receiver", SyncReceiver);
                receiverChoiceJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterStringChooser(receiverChoiceJSON);
                UIDynamicPopup dp = CreateScrollablePopup(receiverChoiceJSON);
                dp.popupPanelHeight = 1100f;
                dp.popup.alwaysOpen = true;

                forceDirectionXJSON           = new JSONStorableFloat("Force direction X", 0f, -1f, 1f, false, true);
                forceDirectionXJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceDirectionXJSON);
                CreateSlider(forceDirectionXJSON, true);

                forceDirectionYJSON           = new JSONStorableFloat("Force direction Y", 0f, -1f, 1f, false, true);
                forceDirectionYJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceDirectionYJSON);
                CreateSlider(forceDirectionYJSON, true);

                forceDirectionZJSON           = new JSONStorableFloat("Force direction Z", 0f, -1f, 1f, false, true);
                forceDirectionZJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceDirectionZJSON);
                CreateSlider(forceDirectionZJSON, true);

                torqueDirectionXJSON           = new JSONStorableFloat("Torque direction X", 0f, -1f, 1f, false, true);
                torqueDirectionXJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(torqueDirectionXJSON);
                CreateSlider(torqueDirectionXJSON, true);

                torqueDirectionYJSON           = new JSONStorableFloat("Torque direction Y", 0f, -1f, 1f, false, true);
                torqueDirectionYJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(torqueDirectionYJSON);
                CreateSlider(torqueDirectionYJSON, true);

                torqueDirectionZJSON           = new JSONStorableFloat("Torque direction Z", 0f, -1f, 1f, false, true);
                torqueDirectionZJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(torqueDirectionZJSON);
                CreateSlider(torqueDirectionZJSON, true);

                periodJSON           = new JSONStorableFloat("period", 0.5f, 0f, 10f, false);
                periodJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(periodJSON);
                CreateSlider(periodJSON, true);

                periodRatioJSON           = new JSONStorableFloat("periodRatio", 0.5f, 0f, 1f, true);
                periodRatioJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(periodRatioJSON);
                CreateSlider(periodRatioJSON, true);

                forceDurationJSON           = new JSONStorableFloat("forceDuration", 1f, 0f, 1f, true);
                forceDurationJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceDurationJSON);
                CreateSlider(forceDurationJSON, true);

                forceFactorJSON           = new JSONStorableFloat("forceFactor", 0f, 0f, 1000f, false, true);
                forceFactorJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceFactorJSON);
                CreateSlider(forceFactorJSON, true);

                forceQuicknessJSON           = new JSONStorableFloat("forceQuickness", 10f, 0f, 50f, false, true);
                forceQuicknessJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(forceQuicknessJSON);
                CreateSlider(forceQuicknessJSON, true);

                torqueFactorJSON           = new JSONStorableFloat("torqueFactor", 5f, 0f, 100f, false, true);
                torqueFactorJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(torqueFactorJSON);
                CreateSlider(torqueFactorJSON, true);

                torqueQuicknessJSON           = new JSONStorableFloat("torqueQuickness", 10f, 0f, 50f, false, true);
                torqueQuicknessJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(torqueQuicknessJSON);
                CreateSlider(torqueQuicknessJSON, true);

                applyForceOnReturnJSON           = new JSONStorableBool("applyForceOnReturn", true);
                applyForceOnReturnJSON.storeType = JSONStorableParam.StoreType.Full;
                RegisterBool(applyForceOnReturnJSON);
                CreateToggle(applyForceOnReturnJSON, true);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #14
0
        public override void Init()
        {
            try
            {
                enable1Key = new JSONStorableStringChooser("Hold key", KeyCodes, "left ctrl", "Hold key (needed for others hotkeys)");
                RegisterStringChooser(enable1Key);
                dp = CreateScrollablePopup(enable1Key, false);
                dp.popupPanelHeight = 960f;

                enable2Key = new JSONStorableStringChooser("Enable Script (needs Hold key)", KeyCodes, "b", "Enable Script (needs Hold key)");
                RegisterStringChooser(enable2Key);
                dp = CreateScrollablePopup(enable2Key, true);
                dp.popupPanelHeight = 960f;

                grabKey = new JSONStorableStringChooser("Grabbing key", KeyCodes, "g", "Grabbing key");
                RegisterStringChooser(grabKey);
                dp = CreateScrollablePopup(grabKey, false);
                dp.popupPanelHeight = 960f;

                focusKey = new JSONStorableStringChooser("Focus key", KeyCodes, "h", "Focus key");
                RegisterStringChooser(focusKey);
                dp = CreateScrollablePopup(focusKey, false);
                dp.popupPanelHeight = 960f;

                zAxisKey = new JSONStorableStringChooser("ZaxisModeKey", KeyCodes, "left alt", "ZaxisModeKey");
                RegisterStringChooser(zAxisKey);
                dp = CreateScrollablePopup(zAxisKey, false);
                dp.popupPanelHeight = 960f;

                grabScale = new JSONStorableFloat("Grab Sphere Size", 0.03f, 0.001f, 5f, true);
                RegisterFloat(grabScale);
                CreateSlider(grabScale, true);


                sensitivityY = new JSONStorableFloat("Sensitivity of Z axis", 0.01f, 0.05f, 0.5f, true);
                RegisterFloat(sensitivityY);
                CreateSlider(sensitivityY, true);

                pokeForce = new JSONStorableFloat("Poke Force when click", 0f, 0f, 1000f, true);
                RegisterFloat(pokeForce);
                CreateSlider(pokeForce, true);

                stepHotkeyGrabScale = new JSONStorableFloat("StepSizeBelowKeys", 0.1f, 0.01f, 1f, true);
                RegisterFloat(stepHotkeyGrabScale);
                CreateSlider(stepHotkeyGrabScale, false);

                increaseKey = new JSONStorableStringChooser("IncSizeKey(needs Hold key)", KeyCodes, "5", "IncSizeKey(needs Hold key)");
                RegisterStringChooser(increaseKey);
                dp = CreateScrollablePopup(increaseKey, false);
                dp.popupPanelHeight = 960f;

                decreaseKey = new JSONStorableStringChooser("DecSizeKey(needs Hold key)", KeyCodes, "4", "DecSizeKey(needs Hold key)");
                RegisterStringChooser(decreaseKey);
                dp = CreateScrollablePopup(decreaseKey, false);
                dp.popupPanelHeight = 960f;
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #15
0
    public override void Init()
    {
        try
        {
            var sc = SuperController.singleton;
            _wellknown.Add($"{containingAtom.name} (current atom)", () => containingAtom.gameObject);
            _wellknown.Add(nameof(sc.navigationRig), () => sc.navigationRig.gameObject);
            _wellknown.Add(nameof(sc.centerCameraTarget), () => sc.centerCameraTarget.gameObject);
            _wellknown.Add(nameof(sc.worldUI), () => sc.worldUI.gameObject);
            _wellknown.Add(nameof(sc.mainMenuUI), () => sc.mainMenuUI.gameObject);
            if (sc.OVRRig != null)
            {
                _wellknown.Add(nameof(sc.OVRRig), () => sc.OVRRig.gameObject);
            }
            if (sc.ViveRig != null)
            {
                _wellknown.Add(nameof(sc.ViveRig), () => sc.ViveRig.gameObject);
            }
            if (sc.MonitorRig != null)
            {
                _wellknown.Add(nameof(sc.MonitorRig), () => sc.MonitorRig.gameObject);
            }
            if (sc.OVRCenterCamera != null)
            {
                _wellknown.Add(nameof(sc.OVRCenterCamera), () => sc.OVRCenterCamera.gameObject);
            }
            if (sc.ViveCenterCamera != null)
            {
                _wellknown.Add(nameof(sc.ViveCenterCamera), () => sc.ViveCenterCamera.gameObject);
            }
            if (sc.MonitorCenterCamera != null)
            {
                _wellknown.Add(nameof(sc.MonitorCenterCamera), () => sc.MonitorCenterCamera.gameObject);
            }
            foreach (var camera in Camera.allCameras)
            {
                var c = camera;
                _wellknown.Add($"Camera: {c.name}", () => c.gameObject);
            }

            // Left

            _wellKnownJSON = new JSONStorableStringChooser("WellKnown",
                                                           _wellknown.Select(kvp => kvp.Key).OrderBy(k => k).ToList(), "", "Well Known");
            _wellKnownJSON.setCallbackFunction = (string val) => Select(_wellknown[val]());
            var wellKnownUI = CreateFilterablePopup(_wellKnownJSON, SideLeft);
            wellKnownUI.popupPanelHeight = 700f;

            _siblingsJSON = new JSONStorableStringChooser("Selected", new List <string>(), null, "Selected");
            _siblingsJSON.popupOpenCallback   += SyncSiblings;
            _siblingsJSON.setCallbackFunction += SelectSibling;
            var siblingsUI = CreateFilterablePopup(_siblingsJSON, SideLeft);
            siblingsUI.popupPanelHeight = 900f;

            _parentUI = CreateButton("Select Parent", SideLeft);
            _parentUI.button.onClick.AddListener(() => Select(_currentGameObject?.transform.parent?.gameObject));

            _childrenJSON = new JSONStorableStringChooser("Children", new List <string>(), null, "Select Children");
            _childrenJSON.popupOpenCallback   += SyncChildren;
            _childrenJSON.setCallbackFunction += SelectChild;
            var childrenUI = CreateFilterablePopup(_childrenJSON, SideLeft);
            childrenUI.popupPanelHeight = 700f;

            _currentHierarchyJSON = new JSONStorableString("CurrentHierarchy", "");
            CreateTextField(_currentHierarchyJSON).height = 728f;

            // Right

            _currentInfoJSON = new JSONStorableString("CurrentGameObject", "");
            CreateTextField(_currentInfoJSON, SideRight);

            _currentScriptsJSON = new JSONStorableString("CurrentScripts", "");
            CreateTextField(_currentScriptsJSON, SideRight).height = 980f;

            Select(containingAtom.gameObject);
        }
        catch (Exception exc)
        {
            enabled = false;
            SuperController.LogError($"{nameof(GameObjectExplorer)}: Failed to initialize: {exc}");
        }
    }
예제 #16
0
        public override void Init()
        {
            try {
                if (containingAtom.type != "Person")
                {
                    SuperController.LogError($"This plugin is for use with 'Person' atom only, not '{containingAtom.type}'");
                    return;
                }
                pluginLabelJSON.val = "Simple Gaze Mod V1.0";
                person = containingAtom;

                eyes = person.GetStorableByID("Eyes");
                if (eyes != null)
                {
                    lookMode = eyes.GetStringChooserJSONParam("lookMode");
                    if (lookMode == null)
                    {
                        SuperController.LogError("Could not find lookMode param on eyeTargetControl");
                    }
                }
                personEyeTargetControl = person.GetStorableByID("eyeTargetControl") as FreeControllerV3;
                personEyeTarget        = personEyeTargetControl.transform;
                playerTarget           = CameraTarget.centerTarget.transform;
                //Initialise gazeTarget from current lookMode value
                if (lookMode.val == "Player")
                {
                    gazeTarget = playerTarget;
                }
                else
                {
                    gazeTarget = personEyeTarget;
                }


                lookAtPosition = gazeTarget.TransformPoint(gazeOffset);

                chestControl  = person.GetStorableByID("chestControl") as FreeControllerV3;
                pelvisControl = person.GetStorableByID("pelvisControl") as FreeControllerV3;
                head          = person.GetStorableByID("headControl").transform;
                reference     = person.GetStorableByID("abdomen2Control").transform;

                activationDistance = new JSONStorableFloat("Activation Range (ignore eye saccades)", 0.1f, 0f, 10f, true, true);
                RegisterFloat(activationDistance);
                CreateSlider(activationDistance, false);

                gazeDuration = new JSONStorableFloat("Gaze Duration", 0.7f, 0f, 5f, true, true);
                RegisterFloat(gazeDuration);
                CreateSlider(gazeDuration, false);

                focusChangeDurationMin = new JSONStorableFloat("Focus Change Duration Minimum", 1f, dmin => focusChangeDurationMax.SetVal(Mathf.Max(focusChangeDurationMax.val, dmin)), 1f, 10f, true, true);
                RegisterFloat(focusChangeDurationMin);
                CreateSlider(focusChangeDurationMin, true);

                focusChangeDurationMax = new JSONStorableFloat("Focus Change Duration Maximum", 4f, dmax => focusChangeDurationMin.SetVal(Mathf.Min(focusChangeDurationMin.val, dmax)), 1f, 10f, true, true);
                RegisterFloat(focusChangeDurationMax);
                CreateSlider(focusChangeDurationMax, true);

                focusAngleH = new JSONStorableFloat("Focus Angle Horizontal", 3f, 0f, 40f, true, true);
                RegisterFloat(focusAngleH);
                CreateSlider(focusAngleH, false);

                focusAngleV = new JSONStorableFloat("Focus Angle Vertical", 3f, 0f, 40f, true, true);
                RegisterFloat(focusAngleV);
                CreateSlider(focusAngleV, false);

                /*rollChangeDurationMin = new JSONStorableFloat("Roll Change Duration Minimum", 2f, rmin => rollChangeDurationMax.SetVal(Mathf.Max(rollChangeDurationMax.val, rmin)), 1f, 10f, true, true);
                 * RegisterFloat(rollChangeDurationMin);
                 * CreateSlider(rollChangeDurationMin, true);
                 *
                 * rollChangeDurationMax = new JSONStorableFloat("Roll Change Duration Maximum", 6f, rmax => rollChangeDurationMin.SetVal(Mathf.Min(rollChangeDurationMin.val, rmax)), 1f, 10f, true, true);
                 * RegisterFloat(rollChangeDurationMax);
                 * CreateSlider(rollChangeDurationMax, true);
                 *
                 * rollAngleMax = new JSONStorableFloat("Roll Angle Maximum", 1f, 0f, 40f, true, true);
                 * RegisterFloat(rollAngleMax);
                 * CreateSlider(rollAngleMax, false);*/

                offsetV = new JSONStorableFloat("Vertical Offset Angle", -5.0f, -30.0f, 30.0f, true, true);
                RegisterFloat(offsetV);
                CreateSlider(offsetV, false);

                offsetH = new JSONStorableFloat("Horizontal Offset Angle", 0.0f, -30.0f, 30.0f, true, true);
                RegisterFloat(offsetH);
                CreateSlider(offsetH, true);

                List <string> choices = new List <string>();
                choices.Add("Player");
                choices.Add("Target");
                JSONStorableStringChooser chooser = new JSONStorableStringChooser("Gaze Target Choice", choices, lookMode.val, "Gaze Follows", setGazeTarget);
                UIDynamicPopup            udp     = CreatePopup(chooser, true);

                swivelEnabled           = new JSONStorableBool("Enable Body Swivel Action", true);
                swivelEnabled.storeType = JSONStorableParam.StoreType.Full;
                RegisterBool(swivelEnabled);
                CreateToggle(swivelEnabled, false);
            }
            catch (System.Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #17
0
 protected UIDynamicPopup CreateFilterablePopup(JSONStorableStringChooser jss, bool rightSide = false) => _root.CreateFilterablePopup(jss, rightSide);
예제 #18
0
파일: Embody.cs 프로젝트: via5/vam-embody
    public override void Init()
    {
        try
        {
            activeJSON = new JSONStorableBool("Active", false)
            {
                isStorable = false
            };
            var isPerson = containingAtom.type == "Person";

            _scaleChangeReceiver = gameObject.AddComponent <EmbodyScaleChangeReceiver>();

            _modules = new GameObject();
            _modules.transform.SetParent(transform, false);
            _modules.SetActive(false);

            _context = new EmbodyContext(this, this);

            var diagnosticsModule  = CreateModule <DiagnosticsModule>(_context);
            var automationModule   = CreateModule <AutomationModule>(_context);
            var worldScaleModule   = isPerson ? CreateModule <WorldScaleModule>(_context) : null;
            var hideGeometryModule = isPerson ? CreateModule <HideGeometryModule>(_context) : null;
            var offsetCameraModule = isPerson ? CreateModule <OffsetCameraModule>(_context) : null;
            var passengerModule    = CreateModule <PassengerModule>(_context);
            var trackersModule     = isPerson ? CreateModule <TrackersModule>(_context) : null;
            var snugModule         = isPerson ? CreateModule <SnugModule>(_context) : null;
            var eyeTargetModule    = isPerson ? CreateModule <EyeTargetModule>(_context) : null;
            var wizardModule       = isPerson ? CreateModule <WizardModule>(_context) : null;

            _context.diagnostics  = diagnosticsModule;
            _context.automation   = automationModule;
            _context.worldScale   = worldScaleModule;
            _context.hideGeometry = hideGeometryModule;
            _context.offsetCamera = offsetCameraModule;
            _context.passenger    = passengerModule;
            _context.trackers     = trackersModule;
            _context.snug         = snugModule;
            _context.eyeTarget    = eyeTargetModule;
            _context.wizard       = wizardModule;

            if (_scaleChangeReceiver != null)
            {
                _context.scaleChangeReceiver = _scaleChangeReceiver;
                _scaleChangeReceiver.context = _context;
                containingAtom.RegisterDynamicScaleChangeReceiver(_scaleChangeReceiver);
            }

            _modules.SetActive(true);

            presetsJSON = InitPresets();
            RegisterStringChooser(presetsJSON);

            _context.automation.enabledJSON.val = true;

            _screensManager = new ScreensManager();
            var modules = _modules.GetComponents <IEmbodyModule>();
            _screensManager.Add(MainScreen.ScreenName, new MainScreen(_context, modules));
            if (isPerson)
            {
                _screensManager.Add(TrackersSettingsScreen.ScreenName, new TrackersSettingsScreen(_context, trackersModule));
                _screensManager.Add(PassengerSettingsScreen.ScreenName, new PassengerSettingsScreen(_context, passengerModule));
                _screensManager.Add(SnugSettingsScreen.ScreenName, new SnugSettingsScreen(_context, snugModule));
                _screensManager.Add(HideGeometrySettingsScreen.ScreenName, new HideGeometrySettingsScreen(_context, hideGeometryModule));
                _screensManager.Add(OffsetCameraSettingsScreen.ScreenName, new OffsetCameraSettingsScreen(_context, offsetCameraModule));
                _screensManager.Add(WorldScaleSettingsScreen.ScreenName, new WorldScaleSettingsScreen(_context, worldScaleModule));
                _screensManager.Add(EyeTargetSettingsScreen.ScreenName, new EyeTargetSettingsScreen(_context, eyeTargetModule));
                _screensManager.Add(WizardScreen.ScreenName, new WizardScreen(_context, wizardModule));
                _screensManager.Add(ImportExportScreen.ScreenName, new ImportExportScreen(_context));
                _screensManager.Add(MoreScreen.ScreenName, new MoreScreen(_context));
                _screensManager.Add(DiagnosticsScreen.ScreenName, new DiagnosticsScreen(_context, diagnosticsModule));
            }
            else
            {
                _screensManager.Add(PassengerSettingsScreen.ScreenName, new PassengerSettingsScreen(_context, passengerModule));
            }

            activeJSON.setCallbackFunction = val =>
            {
                if (val)
                {
                    Activate();
                }
                else
                {
                    Deactivate(true);
                }
            };
            RegisterBool(activeJSON);

            activeToggle                     = CreateToggle(activeJSON, false);
            activeToggle.label               = "Active";
            activeToggle.backgroundColor     = Color.cyan;
            activeToggle.labelText.fontStyle = FontStyle.Bold;

            var launchWizardJSON = new JSONStorableAction("LaunchWizard", () => StartCoroutine(LaunchWizard()));
            RegisterAction(launchWizardJSON);

            RegisterAction(new JSONStorableAction("ToggleActive", () => activeJSON.val = !activeJSON.val));
            RegisterAction(new JSONStorableAction("Activate_Possession", () => ActivatePreset("Improved Possession")));
            RegisterAction(new JSONStorableAction("Activate_LeapMotion", () => ActivatePreset("Improved Possession w/ Leap")));
            RegisterAction(new JSONStorableAction("Activate_Passenger", () => ActivatePreset("Passenger")));

            LoadFromDefaults();
            SuperController.singleton.StartCoroutine(DeferredInit());
        }
        catch (Exception)
        {
            enabledJSON.val = false;
            if (_modules != null)
            {
                Destroy(_modules);
            }
            throw;
        }
    }
예제 #19
0
        public override void Init()
        {
            try
            {
                radius = new JSONStorableFloat("radius", 2, (float count) =>
                {
                    SetupLights();
                }, 0, 10, false);
                RegisterFloat(radius);
                CreateSlider(radius);

                count = new JSONStorableFloat("count", 4, (float count) =>
                {
                    ClearLights();
                    StartCoroutine(GenerateLights());
                }, 1, 20);
                RegisterFloat(count);
                CreateSlider(count);

                forcePixel = new JSONStorableBool("force pixel lights", true, (bool force) =>
                {
                    SetupLights();
                });
                RegisterBool(forcePixel);
                CreateToggle(forcePixel);

                lightType = new JSONStorableStringChooser("light type", new List <string> {
                    "Point", "Spot"
                }, "Spot", "light type", (string type) =>
                {
                    SetupLights();
                });
                RegisterStringChooser(lightType);
                CreatePopup(lightType);

                lookAt = new JSONStorableBool("look at", true);
                RegisterBool(lookAt);
                CreateToggle(lookAt);

                heightOffset = new JSONStorableFloat("height offset", 0, (float offset) =>
                {
                    SetupLights();
                }, -4, 4, false);
                RegisterFloat(heightOffset);
                CreateSlider(heightOffset);

                sharedIntensity = new JSONStorableFloat("shared intensity", 1.8f, (float intensity) =>
                {
                    SetupLights();
                }, 0, 10, false);
                RegisterFloat(sharedIntensity);
                CreateSlider(sharedIntensity);

                sharedRange = new JSONStorableFloat("shared range", 5, (float intensity) =>
                {
                    SetupLights();
                }, 0, 25, false);
                RegisterFloat(sharedRange);
                CreateSlider(sharedRange);

                sharedSpotAngle = new JSONStorableFloat("shared spot angle", 80, (float intensity) =>
                {
                    SetupLights();
                }, 1, 180, false);
                RegisterFloat(sharedSpotAngle);
                CreateSlider(sharedSpotAngle);

                intensityCurveStart = new JSONStorableFloat("intensity curve start", 1, (float intensity) =>
                {
                    SetupLights();
                }, 0, 4, false);
                RegisterFloat(intensityCurveStart);
                CreateSlider(intensityCurveStart, true);

                intensityCurveMid = new JSONStorableFloat("intensity curve mid", 1, (float intensity) =>
                {
                    SetupLights();
                }, 0, 4, false);
                RegisterFloat(intensityCurveMid);
                CreateSlider(intensityCurveMid, true);

                intensityCurveEnd = new JSONStorableFloat("intensity curve end", 1, (float intensity) =>
                {
                    SetupLights();
                }, 0, 4, false);
                RegisterFloat(intensityCurveEnd);
                CreateSlider(intensityCurveEnd, true);

                intensityMidPoint = new JSONStorableFloat("intensity midPoint", 0.5f, (float intensity) =>
                {
                    SetupLights();
                }, 0, 1, false);
                RegisterFloat(intensityMidPoint);
                CreateSlider(intensityMidPoint, true);

                Color defaultRGB = new Color(1, 0.8941176470588235f, 0.7803921568627451f);
                float h, s, v = 0;
                Color.RGBToHSV(defaultRGB, out h, out s, out v);
                HSVColor startingColor = new HSVColor {
                    H = h, S = s, V = v
                };

                colorStart = new JSONStorableColor("color start", startingColor, (float ch, float cs, float cv) =>
                {
                    SetupLights();
                });
                RegisterColor(colorStart);
                CreateColorPicker(colorStart, true);

                colorEnd = new JSONStorableColor("color end", startingColor, (float ch, float cs, float cv) =>
                {
                    SetupLights();
                });
                RegisterColor(colorEnd);
                CreateColorPicker(colorEnd, true);

                StartCoroutine(GenerateLights());
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #20
0
        private void UICreateAddForm()
        {
            var groupNames = MorphController.GetMorphs().OrderBy(m => m.group.ToLowerInvariant()).Select(m => m.group).Distinct().ToList();

            NewMorphFilterJSON = new JSONStorableStringChooser(NewMorphFilterKey,
                                                               groupNames,
                                                               ALL,
                                                               "Filter Morphs",
                                                               (string filter) =>
            {
                NewMorphNameJSON.val     = String.Empty;
                NewMorphNameJSON.choices = UIMorphNames;
            });
            CreateFilterablePopup(NewMorphFilterJSON);

            // the exact morph to add
            NewMorphNameJSON = new JSONStorableStringChooser(NewMorphNameKey, UIMorphNames, String.Empty, "Morph");
            var p = CreateFilterablePopup(NewMorphNameJSON, rightSide: true);

            p.popupPanelHeight = 1100f;


            // left hand side arm for record
            var armButton = CreateButton("Arm selected morphs for record");

            armButton.button.onClick.AddListener(() => {
                foreach (var tracked in TrackedMorphs)
                {
                    var motionAnimationControl = tracked.Atom.GetComponentInChildren <MotionAnimationControl>();
                    if (motionAnimationControl == null)
                    {
                        continue;
                    }

                    if (!tracked.Enabled)
                    {
                        SuperController.LogMessage($"un-arming {tracked.Atom.name} for record");
                        motionAnimationControl.armedForRecord = false;
                    }
                    else
                    {
                        SuperController.LogMessage($"arming {tracked.Atom.name} for record");
                        motionAnimationControl.armedForRecord = true;
                    }
                }
            });

            // "add" button
            var b = CreateButton("Add morph...", rightSide: true);

            b.button.onClick.AddListener(() =>
            {
                int i         = (int)TrackingCountJSON.val;
                var morphName = NewMorphNameJSON.val ?? String.Empty;

                // only allow one morph with a name to be added at a time
                if (TrackedMorphs.FirstOrDefault(tm => tm.Morph.displayName.Equals(morphName)) != null)
                {
                    SuperController.LogMessage($"'{morphName}' has already been added for morph tracking");
                    return;
                }

                var generatedAtomName = TrackedMorphGeneratedAtomName(i, morphName);
                StartCoroutine(GetOrCreateEmptyAtom(generatedAtomName, (atom) =>
                {
                    if (atom != null)
                    {
                        UICreateMorphRow(i, morphName, true, atom.name, true);
                    }
                }));
            });

            // hidden form element to track how many morphs have been added
            TrackingCountJSON           = new JSONStorableFloat(TrackedMorphCountKey, 0, 0, 1000);
            TrackingCountJSON.storeType = JSONStorableParam.StoreType.Full;
            RegisterFloat(TrackingCountJSON);
        }
예제 #21
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);
            }
        }
예제 #22
0
 private void RefreshSnapshots(JSONStorableStringChooser snapshotsJSON)
 {
     snapshotsJSON.choices = context.diagnostics.snapshots.Select(s => s.name).ToList();
     snapshotsJSON.val     = $"{context.diagnostics.snapshots.Count} snapshots";
 }
예제 #23
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);
        }
예제 #24
0
 private EmbodyDebugSnapshot FindSnapshot(JSONStorableStringChooser snapshotsJSON)
 {
     return(context.diagnostics.snapshots.FirstOrDefault(s => s.name == snapshotsJSON.val));
 }
예제 #25
0
        public void CreateUI(IUIBuilder builder)
        {
            AtomChooser = builder.CreateScrollablePopup("MotionSource:Person", "Select Person", null, null, AtomChooserCallback, true);

            CreateCustomUI(builder);
        }
예제 #26
0
    public void Show()
    {
        UIDynamicButton takeSnapshot = null;
        var             enabledJSON  = new JSONStorableBool("Enabled", _diagnostics.enabledJSON.val, val =>
        {
            context.diagnostics.enabledJSON.val = val;
            // ReSharper disable AccessToModifiedClosure
            if (takeSnapshot == null)
            {
                return;
            }
            takeSnapshot.button.interactable = val;
            // ReSharper restore AccessToModifiedClosure
        });

        CreateToggle(enabledJSON).label = "Record Diagnostics Data";

        var logs     = _diagnostics.logs.ToArray();
        var logsJSON = new JSONStorableString("", logs.Length == 0 ? "Enabling diagnostics will record all VaM errors and your physical position during possession.\n\n<b>ONLY enable this if Acidbubbles asks you to.</b>\n\nAlso keep in mind this will give information about your height and body size, if you are not comfortable sharing this information, please keep diagnostics off." : string.Join("\r\n", logs));

        CreateText(logsJSON, true).height = 1200f;

        var snapshotsJSON = new JSONStorableStringChooser("",
                                                          new List <string>(),
                                                          $"",
                                                          "Snapshots",
                                                          val => ShowSnapshot(logsJSON, val));

        takeSnapshot = CreateButton("Take Snapshot");
        takeSnapshot.button.onClick.AddListener(() =>
        {
            context.diagnostics.TakeSnapshot("ManualSnapshot");
            RefreshSnapshots(snapshotsJSON);
            logsJSON.val = $"{context.diagnostics.snapshots.Count} snapshot{(context.diagnostics.snapshots.Count != 1 ? "s" : "")}";
        });
        takeSnapshot.button.interactable = context.diagnostics.enabledJSON.val;

        var clearDiagnosticsData = CreateButton("Clear Diagnostics Data");

        clearDiagnosticsData.button.onClick.AddListener(() =>
        {
            _diagnostics.ResetToDefault();
            logsJSON.val = "Logs cleared!";
        });

        if (!Input.GetKey(KeyCode.LeftControl))
        {
            return;
        }

        RefreshSnapshots(snapshotsJSON);

        CreateButton("Show Logs").button.onClick.AddListener(() => logsJSON.val = logs.Length == 0 ? "No logs were recorded" : string.Join("\r\n", logs));

        CreateScrollablePopup(snapshotsJSON);

        CreateButton("Create Fake Trackers").button.onClick.AddListener(() =>
        {
            context.diagnostics.CreateFakeTrackers(context.diagnostics.snapshots.FirstOrDefault(s => s.name == snapshotsJSON.val));
        });
        CreateButton("Remove Fake Trackers").button.onClick.AddListener(() =>
        {
            context.diagnostics.RemoveFakeTrackers();
        });
        CreateToggle(_restoreWorldStateJSON);
        CreateButton("Load Snapshot").button.onClick.AddListener(() =>
        {
            var snapshot = FindSnapshot(snapshotsJSON);
            if (snapshot == null)
            {
                logsJSON.val = "Select a snapshot first";
                return;
            }
            context.diagnostics.RestoreSnapshot(snapshot, _restoreWorldStateJSON.val);
        });
        CreateButton("Delete Snapshot").button.onClick.AddListener(() =>
        {
            var snapshot = FindSnapshot(snapshotsJSON);
            if (snapshot == null)
            {
                logsJSON.val = "Select a snapshot first";
                return;
            }
            context.diagnostics.snapshots.Remove(snapshot);
            snapshotsJSON.choices = context.diagnostics.snapshots.Select(s => s.name).ToList();
            snapshotsJSON.val     = $"{context.diagnostics.snapshots.Count} snapshots";
            logsJSON.val          = "";
        });
    }
예제 #27
0
 public UIDynamicPopup CreateFilterablePopup(JSONStorableStringChooser jss, bool rightSide = false)
 {
     return(_popups.AddAndReturn(_plugin.CreateFilterablePopup(jss, rightSide)));
 }
예제 #28
0
        public override void Init()
        {
            try
            {
                THRUST_FORCE_NAME += ":" + containingAtom.name;
                AUDIO_SOURCE_NAME += ":" + containingAtom.name;

                /*
                 * List<string> peopleIds = SuperController.singleton.GetAtoms()
                 * .Where(atom => atom.GetStorableByID("geometry") != null && (atom != containingAtom))
                 * .Select(atom => atom.name).ToList();
                 *
                 * JSONStorableStringChooser receiverChoiceJSON = new JSONStorableStringChooser("target", peopleIds, peopleIds.Count>0?peopleIds[0]:null, "Thrust Target", delegate (string receiverName)
                 * {
                 *  Atom receiver = GetAtomById(receiverName);
                 *  StartCoroutine(CreateThrustForce(receiver));
                 * });
                 * receiverChoiceJSON.storeType = JSONStorableParam.StoreType.Full;
                 * UIDynamicPopup dp = CreateScrollablePopup(receiverChoiceJSON, false);
                 * RegisterStringChooser(receiverChoiceJSON);
                 */

                StartCoroutine(CreateThrustForce());

                CreateButton("Select Thrust Force", true).button.onClick.AddListener(() =>
                {
                    if (thrustAtom != null)
                    {
                        SelectController(thrustAtom.mainController);
                    }
                });


                thrustAmount           = new JSONStorableFloat("thrustAmount", 0f, (float value) => { }, 0f, 1f, true, true);
                thrustAmount.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(thrustAmount);
                CreateSlider(thrustAmount, true);

                grindAmount            = new JSONStorableFloat("grindAmount", 0f, (float value) => { }, 0f, 1f, true, true);
                thrustAmount.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(grindAmount);
                CreateSlider(grindAmount, true);

                skinSlapSFX = new JSONStorableStringChooser("SkinSlapSound", GetAllAudioClipIds(), null, "Skin Slap Sound", (string uid) => {
                    skinSlapClip = URLAudioClipManager.singleton.GetClip(uid);
                });
                skinSlapSFX.storeType = JSONStorableParam.StoreType.Full;
                CreateScrollablePopup(skinSlapSFX).popup.onOpenPopupHandlers += () =>
                {
                    skinSlapSFX.choices = GetAllAudioClipIds();
                };
                RegisterStringChooser(skinSlapSFX);

                grindSFX = new JSONStorableStringChooser("GrindSoundFile", GetAllAudioClipIds(), null, "Grind Sound", (string uid) => {
                    grindClip = URLAudioClipManager.singleton.GetClip(uid);
                });
                grindSFX.storeType = JSONStorableParam.StoreType.Full;
                CreateScrollablePopup(grindSFX).popup.onOpenPopupHandlers += () =>
                {
                    grindSFX.choices = GetAllAudioClipIds();
                };
                RegisterStringChooser(grindSFX);

                StartCoroutine(CreateAudioSource());
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
예제 #29
0
    private void InitControls()
    {
        // Left side

        _activeJSON = new JSONStorableBool(
            "Active",
            false,
            new JSONStorableBool.SetBoolCallback(val => UpdateActivation())
            );
        RegisterBool(_activeJSON);
        CreateToggle(_activeJSON, false);

        var defaultMode = Modes.None;

#if (VAM_DIAGNOSTICS)
        defaultMode = Modes.WindowCamera;
#endif
        _modeJSON = new JSONStorableStringChooser(
            "Mode",
            (new[] { Modes.None, Modes.NavigationRig, Modes.WindowCamera }).ToList(),
            defaultMode,
            "Mode",
            new JSONStorableStringChooser.SetStringCallback(val => UpdateActivation())
            );
        RegisterStringChooser(_modeJSON);
        var activePopup = CreateScrollablePopup(_modeJSON, false);
        activePopup.popupPanelHeight = 600f;

        _transitionTimeJSON = new JSONStorableFloat("Transition Time", 0.6f, 0f, 1f, false);
        RegisterFloat(_transitionTimeJSON);
        CreateSlider(_transitionTimeJSON, false);

        _extendTransitionTime = new JSONStorableFloat("Extend Transition Time", 0.2f, 0f, 1f, false);
        RegisterFloat(_extendTransitionTime);
        CreateSlider(_extendTransitionTime, false);

        // Right side

        _playOnceFromBeginningActionJSON = new JSONStorableAction("Play From Beginning", () => PlayOnceFromBeginning());
        RegisterAction(_playOnceFromBeginningActionJSON);
        CreateButton("Play Once From Beginning", true).button.onClick.AddListener(() => PlayOnceFromBeginning());
        CreateButton("Play", true).button.onClick.AddListener(() => _pattern.Play());
        CreateButton("Pause", true).button.onClick.AddListener(() => _pattern.Pause());
        CreateButton("Previous Step", true).button.onClick.AddListener(() =>
        {
            var previousStep = _pattern.steps.Reverse().SkipWhile(s => !s.active).Skip(1).FirstOrDefault();
            if (previousStep != null)
            {
                _currentTimeJSON.val = previousStep.timeStep == 0 ? float.Epsilon : previousStep.timeStep;
            }
            else if (_pattern.steps.Length > 0f)
            {
                _currentTimeJSON.val = 0.1f;
                _currentTimeJSON.val = 0f;
            }
        });
        CreateButton("Next Step", true).button.onClick.AddListener(() =>
        {
            var nextStep = _pattern.steps.SkipWhile(s => !s.active).Skip(1).FirstOrDefault();
            if (nextStep != null)
            {
                _currentTimeJSON.val = nextStep.timeStep;
            }
            else if (_pattern.steps.Length > 0f && !_pattern.steps.Any(s => s.active))
            {
                _currentTimeJSON.val = 0.1f;
                _currentTimeJSON.val = 0f;
            }
        });
        CreateButton("Teleport to Current Step", true).button.onClick.AddListener(() =>
        {
            var step = _pattern.steps.FirstOrDefault(s => s.active) ?? _pattern.steps.FirstOrDefault();
            if (step == null)
            {
                return;
            }
            UpdateNavigationRigPosition(step);
            UpdateNavigationRigRotation(step);
            Transform navigationRig   = SuperController.singleton.navigationRig;
            navigationRig.eulerAngles = new Vector3(navigationRig.eulerAngles.x, navigationRig.eulerAngles.y, 0f);
            navigationRig.Translate(Vector3.back * 1f + Vector3.up * 0.2f, Space.Self);
        });
        CreateButton("Select Current Step", true).button.onClick.AddListener(() =>
        {
            var step = _pattern.steps.FirstOrDefault(s => s.active) ?? _pattern.steps.FirstOrDefault();
            if (step == null)
            {
                return;
            }
            SuperController.singleton.SelectController(step.containingAtom.freeControllers.FirstOrDefault(fc => fc.name == "control"));
        });
    }
예제 #30
0
        public void InitStorables()
        {
            animationJSON = new JSONStorableStringChooser(StorableNames.Animation, new List <string>(), "", "Animation", val => ChangeAnimation(val))
            {
                isStorable = false
            };
            RegisterStringChooser(animationJSON);

            nextAnimationJSON = new JSONStorableAction(StorableNames.NextAnimation, () =>
            {
                var i = animationJSON.choices.IndexOf(animationJSON.val);
                if (i < 0 || i > animationJSON.choices.Count - 2)
                {
                    return;
                }
                animationJSON.val = animationJSON.choices[i + 1];
            });
            RegisterAction(nextAnimationJSON);

            previousAnimationJSON = new JSONStorableAction(StorableNames.PreviousAnimation, () =>
            {
                var i = animationJSON.choices.IndexOf(animationJSON.val);
                if (i < 1 || i > animationJSON.choices.Count - 1)
                {
                    return;
                }
                animationJSON.val = animationJSON.choices[i - 1];
            });
            RegisterAction(previousAnimationJSON);

            scrubberJSON = new JSONStorableFloat(StorableNames.Scrubber, 0f, v => UpdateTime(v, true), 0f, AtomAnimationClip.DefaultAnimationLength, true)
            {
                isStorable = false
            };
            RegisterFloat(scrubberJSON);

            timeJSON = new JSONStorableFloat(StorableNames.Time, 0f, v => UpdateTime(v, false), 0f, AtomAnimationClip.DefaultAnimationLength, true)
            {
                isStorable = false
            };
            RegisterFloat(timeJSON);

            playJSON = new JSONStorableAction(StorableNames.Play, () =>
            {
                if (animation?.Current == null)
                {
                    SuperController.LogError($"VamTimeline: Cannot play animation, Timeline is still loading");
                    return;
                }
                if (SuperController.singleton.freezeAnimation)
                {
                    _resumePlayOnUnfreeze = true;
                    return;
                }
                animation.Play();
                isPlayingJSON.valNoCallback = true;
                SendToControllers(nameof(IAnimationController.OnTimelineTimeChanged));
            });
            RegisterAction(playJSON);

            playIfNotPlayingJSON = new JSONStorableAction(StorableNames.PlayIfNotPlaying, () =>
            {
                if (animation?.Current == null)
                {
                    SuperController.LogError($"VamTimeline: Cannot play animation, Timeline is still loading");
                    return;
                }
                if (SuperController.singleton.freezeAnimation)
                {
                    _resumePlayOnUnfreeze = true;
                    return;
                }
                if (animation.IsPlaying())
                {
                    return;
                }
                animation.Play();
                isPlayingJSON.valNoCallback = true;
                SendToControllers(nameof(IAnimationController.OnTimelineTimeChanged));
            });
            RegisterAction(playIfNotPlayingJSON);

            isPlayingJSON = new JSONStorableBool(StorableNames.IsPlaying, false, (bool val) =>
            {
                if (val)
                {
                    playIfNotPlayingJSON.actionCallback();
                }
                else
                {
                    stopJSON.actionCallback();
                }
            })
            {
                isStorable = false
            };
            RegisterBool(isPlayingJSON);

            stopJSON = new JSONStorableAction(StorableNames.Stop, () =>
            {
                if (animation.IsPlaying())
                {
                    _resumePlayOnUnfreeze = false;
                    animation.Stop();
                    animation.Time = animation.Time.Snap(snapJSON.val);
                    isPlayingJSON.valNoCallback = false;
                    SendToControllers(nameof(IAnimationController.OnTimelineTimeChanged));
                }
                else
                {
                    animation.Time = 0f;
                }
            });
            RegisterAction(stopJSON);

            stopIfPlayingJSON = new JSONStorableAction(StorableNames.StopIfPlaying, () =>
            {
                if (!animation.IsPlaying())
                {
                    return;
                }
                animation.Stop();
                animation.Time = animation.Time.Snap(snapJSON.val);
                isPlayingJSON.valNoCallback = false;
                SendToControllers(nameof(IAnimationController.OnTimelineTimeChanged));
            });
            RegisterAction(stopIfPlayingJSON);

            nextFrameJSON = new JSONStorableAction(StorableNames.NextFrame, () => NextFrame());
            RegisterAction(nextFrameJSON);

            previousFrameJSON = new JSONStorableAction(StorableNames.PreviousFrame, () => PreviousFrame());
            RegisterAction(previousFrameJSON);

            snapJSON = new JSONStorableFloat(StorableNames.Snap, 0.01f, (float val) =>
            {
                var rounded = val.Snap();
                if (val != rounded)
                {
                    snapJSON.valNoCallback = rounded;
                }
                if (animation != null && animation.Time % rounded != 0)
                {
                    UpdateTime(animation.Time, true);
                }
            }, 0.001f, 1f, true)
            {
                isStorable = true
            };
            RegisterFloat(snapJSON);

            cutJSON   = new JSONStorableAction("Cut", () => Cut());
            copyJSON  = new JSONStorableAction("Copy", () => Copy());
            pasteJSON = new JSONStorableAction("Paste", () => Paste());

            lockedJSON = new JSONStorableBool(StorableNames.Locked, false, (bool val) =>
            {
                _ui.UpdateLocked(val);
                if (_controllerInjectedControlerPanel != null)
                {
                    _controllerInjectedControlerPanel.locked = val;
                }
            });
            RegisterBool(lockedJSON);

            autoKeyframeAllControllersJSON = new JSONStorableBool("Auto Keyframe All Controllers", false)
            {
                isStorable = false
            };

            speedJSON = new JSONStorableFloat(StorableNames.Speed, 1f, v => UpdateAnimationSpeed(v), 0f, 5f, false)
            {
                isStorable = false
            };
            RegisterFloat(speedJSON);
        }