示例#1
0
        public BaseModule(DollMaker dm)
        {
            this.dm = dm;
            atom    = dm.containingAtom;
            ui      = dm.ui;

            GameObject moduleLayerObject = new GameObject("module UI", typeof(RectTransform));

            moduleLayerObject.transform.SetParent(ui.canvas.transform, false);
            moduleUI = moduleLayerObject.transform;
            moduleUI.transform.localPosition              = Vector3.zero;
            moduleUI.transform.localScale                 = Vector3.one;
            moduleUI.transform.localEulerAngles           = Vector3.zero;
            moduleUI.transform.localPosition              = new Vector3(0, -300, 0);
            moduleUI.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            dm.modules.Add(this);

            oldContainerName = dm.containingAtom.uid;
            SuperController.singleton.onAtomUIDRenameHandlers += HandleRename;

            float buttonHeight = 60;

            moduleButtonsLayout          = ui.CreateGridLayout(1200, buttonHeight);
            moduleButtonsLayout.cellSize = new Vector2(300, buttonHeight);
            moduleButtonsLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
            moduleButtonsLayout.transform.SetParent(moduleUI, false);
            moduleButtonsLayout.transform.localPosition = new Vector3(0, 0, 0);
        }
示例#2
0
        public WorldUI(DollMaker dm) : base(dm)
        {
            dm.StartCoroutine(CreateAtom("Empty", atomPrefix, (atom) =>
            {
                UIAtom = atom;

                FreeControllerV3 headControl             = dm.containingAtom.GetStorableByID("headControl") as FreeControllerV3;
                Vector3 headPosition                     = headControl.transform.position;
                UIAtom.mainController.transform.position = headPosition;
                UIAtom.mainController.transform.Translate(new Vector3(-1.0f, .6f, 0), Space.Self);
                ui.canvas.transform.SetParent(UIAtom.mainController.transform, false);
            }));
        }
示例#3
0
        public Appearance(DollMaker dm) : base(dm)
        {
            dm.mainControls.RegisterTab("Morphs", moduleUI);

            morphSearch = new MorphSearch(this);

            JSONArray bodyUI = DollMaker.CONFIG_JSON["bodyUI"].AsArray;

            for (int i = 0; i < bodyUI.Count; i++)
            {
                JSONClass uiPart     = bodyUI[i].AsObject;
                string    title      = uiPart["title"].Value;
                string    boneName   = uiPart["bone"].Value;
                string    searchTerm = uiPart["search"].Value;
                float     x          = uiPart["offset"]["x"].AsFloat;
                float     y          = uiPart["offset"]["y"].AsFloat;
                float     z          = uiPart["offset"]["z"].AsFloat;

                DAZBone bone = atom.GetStorableByID(boneName) as DAZBone;

                BoneAttachedUI boneUI = new BoneAttachedUI(title, bone, ui, new Vector3(x, y, z), moduleUI);
                boneUI.button.button.onClick.AddListener(() =>
                {
                    morphSearch.searchBox.text = searchTerm;
                });
                baUI.Add(boneUI);
            }

            UIDynamicButton loadMorphsButton = CreateModuleButton("Load Morphs");

            loadMorphsButton.button.onClick.AddListener(() =>
            {
                string appearancePath = SuperController.singleton.savesDir + "Person" + "\\appearance";
                SuperController.singleton.fileBrowserUI.defaultPath = appearancePath;
                SuperController.singleton.fileBrowserUI.SetTextEntry(b: false);
                SuperController.singleton.fileBrowserUI.Show((string saveName) =>
                {
                    if (!(saveName != string.Empty))
                    {
                        return;
                    }
                    SuperController.singleton.SetLoadDirFromFilePath(saveName);
                    JSONClass save = JSON.Parse(SuperController.singleton.ReadFileIntoString(saveName)).AsObject;
                });
            });
        }
示例#4
0
        public MainControls(DollMaker dm) : base(dm)
        {
            float buttonHeight = 60;

            mainLayout = ui.CreateGridLayout(1200, buttonHeight);
            mainLayout.transform.localPosition = new Vector3(0, -100, 0);
            mainLayout.cellSize        = new Vector2(300, buttonHeight);
            mainLayout.constraintCount = 1;
            mainLayout.constraint      = GridLayoutGroup.Constraint.FixedRowCount;
            mainLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            UIDynamicButton selectButton = ui.CreateButton("Select", 200, buttonHeight, mainLayout.transform);

            selectButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                SuperController.singleton.ClearSelection();
                SuperController.singleton.SelectController(atom.mainController);
            });

            UIDynamicButton loadButton = ui.CreateButton("Load Appearance", 200, buttonHeight, mainLayout.transform);

            loadButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                atom.LoadAppearancePresetDialog();
            });

            UIDynamicButton saveButton = ui.CreateButton("Save Appearance", 200, buttonHeight, mainLayout.transform);

            saveButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                atom.SavePresetDialog(false, true);
            });

            tabLayout = ui.CreateGridLayout(1200, 80);
            tabLayout.transform.localPosition = new Vector3(0, -200, 0);
            tabLayout.cellSize        = new Vector2(300, 80);
            tabLayout.constraintCount = 1;
            tabLayout.constraint      = GridLayoutGroup.Constraint.FixedRowCount;
            tabLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
        }
示例#5
0
        public Appearance(DollMaker dm) : base(dm)
        {
            dm.mainControls.RegisterTab("Morphs", moduleUI, this);

            morphSearch = new MorphSearch(this);

            JSONArray bodyUI = DollMaker.CONFIG_JSON["bodyUI"].AsArray;

            for (int i = 0; i < bodyUI.Count; i++)
            {
                JSONClass uiPart     = bodyUI[i].AsObject;
                string    title      = uiPart["title"].Value;
                string    boneName   = uiPart["bone"].Value;
                string    searchTerm = uiPart["search"].Value;
                float     x          = uiPart["offset"]["x"].AsFloat;
                float     y          = uiPart["offset"]["y"].AsFloat;
                float     z          = uiPart["offset"]["z"].AsFloat;

                DAZBone bone = atom.GetStorableByID(boneName) as DAZBone;

                BoneAttachedUI boneUI = new BoneAttachedUI(title, bone, ui, new Vector3(x, y, z), moduleUI);
                boneUI.button.button.onClick.AddListener(() =>
                {
                    morphSearch.searchBox.text = searchTerm;
                });
                baUI.Add(boneUI);
            }

            UIDynamicButton loadMorphsButton = CreateModuleButton("Load Morph Preset");

            loadMorphsButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUDAuto();
                PresetManager pm             = atom.GetComponentInChildren <PresetManager>(includeInactive: true);
                PresetManagerControlUI pmcui = atom.GetComponentInChildren <PresetManagerControlUI>(includeInactive: true);
                if (pm != null && pmcui != null)
                {
                    pm.itemType   = PresetManager.ItemType.Custom;
                    pm.customPath = "Atom/Person/Morphs/";
                    pmcui.browsePresetsButton.onClick.Invoke();
                }
            });
        }
示例#6
0
        public MainControls(DollMaker dm) : base(dm)
        {
            float buttonHeight = 60;

            sharedControlsLayout = ui.CreateGridLayout(1200, buttonHeight);
            sharedControlsLayout.transform.localPosition = new Vector3(0, -100, 0);
            sharedControlsLayout.cellSize        = new Vector2(300, buttonHeight);
            sharedControlsLayout.constraintCount = 1;
            sharedControlsLayout.constraint      = GridLayoutGroup.Constraint.FixedRowCount;
            sharedControlsLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            UIDynamicButton selectButton = ui.CreateButton("Select", 200, buttonHeight, sharedControlsLayout.transform);

            selectButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                SuperController.singleton.ClearSelection();
                SuperController.singleton.SelectController(atom.mainController);
            });

            UIDynamicButton loadButton = ui.CreateButton("Load Appearance", 200, buttonHeight, sharedControlsLayout.transform);

            loadButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                atom.LoadAppearancePresetDialog();
                dm.RestartModules();
            });

            UIDynamicButton loadPresetButton = ui.CreateButton("Load Preset", 200, buttonHeight, sharedControlsLayout.transform);

            loadPresetButton.button.onClick.AddListener(() =>
            {
                PresetManager pm             = atom.GetComponentInChildren <PresetManager>(includeInactive: true);
                PresetManagerControlUI pmcui = atom.GetComponentInChildren <PresetManagerControlUI>(includeInactive: true);
                if (pm != null && pmcui != null)
                {
                    pm.itemType   = PresetManager.ItemType.Custom;
                    pm.customPath = "Atom/Person/";
                    pmcui.browsePresetsButton.onClick.Invoke();
                    dm.RestartModules();
                }
            });

            UIDynamicButton saveButton = ui.CreateButton("Save Appearance", 200, buttonHeight, sharedControlsLayout.transform);

            saveButton.button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
                atom.SavePresetDialog(false, true);
            });

            moduleSelectLayout = ui.CreateGridLayout(1200, 80);
            moduleSelectLayout.transform.localPosition = new Vector3(0, -200, 0);
            moduleSelectLayout.cellSize        = new Vector2(300, 80);
            moduleSelectLayout.constraintCount = 1;
            moduleSelectLayout.constraint      = GridLayoutGroup.Constraint.FixedRowCount;
            moduleSelectLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
        }
示例#7
0
        public Blend(DollMaker dm) : base(dm)
        {
            dm.mainControls.RegisterTab("Blend", moduleUI, this);

            Button addMorphPresetButton = CreateModuleButton("Add Preset").button;

            addMorphPresetButton.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();
            });
            JSONStorableUrl url = new JSONStorableUrl("presetPath", "", (string path) =>
            {
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                string jsonString    = SuperController.singleton.ReadFileIntoString(path);
                JSONClass appearance = JSON.Parse(jsonString).AsObject;

                AddAppearance(appearance, PathExt.GetFileNameWithoutExtension(path));
            });

            url.RegisterFileBrowseButton(addMorphPresetButton);

            Button addEntirePresetFolder = CreateModuleButton("Add Folder").button;

            addEntirePresetFolder.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();

                PresetManager pm             = atom.GetComponentInChildren <PresetManager>(includeInactive: true);
                PresetManagerControlUI pmcui = atom.GetComponentInChildren <PresetManagerControlUI>(includeInactive: true);
                if (pm != null && pmcui != null)
                {
                    pm.itemType         = PresetManager.ItemType.Custom;
                    pm.customPath       = "Atom/Person/Morphs/";
                    string path         = pm.GetStoreFolderPath();
                    List <string> files = SuperController.singleton.GetFilesAtPath(path).ToList().Where((fileName) =>
                    {
                        return(PathExt.GetExtension(fileName) == ".vap");
                    }).ToList();

                    files.ForEach((file) =>
                    {
                        string jsonString    = SuperController.singleton.ReadFileIntoString(file);
                        JSONClass appearance = JSON.Parse(jsonString).AsObject;
                        AddAppearance(appearance, PathExt.GetFileNameWithoutExtension(file));
                    });
                }
            });

            // Deprecated.
            //Button addAppearanceButton = CreateModuleButton("Add From Look").button;
            //addAppearanceButton.onClick.AddListener(() =>
            //{
            //    SuperController.singleton.editModeToggle.isOn = true;
            //    SuperController.singleton.ShowMainHUD();

            //    SuperController.singleton.GetDirectoryPathDialog((string dir) =>
            //    {
            //        if (dir == null || !(dir != string.Empty))
            //        {
            //            return;
            //        }

            //        //  have load dialog work both inside and outside folder
            //        try
            //        {
            //            PerformLoadOnPath(dir);
            //        }
            //        catch
            //        {
            //            string folderName = "\\" + dir.Substring(dir.LastIndexOf('\\') + 1) + "\\";
            //            dir = dir.Replace(folderName, "\\");
            //            PerformLoadOnPath(dir);
            //        }

            //    }, SuperController.singleton.savesDir + "Person" + "\\appearance");
            //});


            appearancesLayout = ui.CreateGridLayout(1000, 500, moduleUI.transform);
            appearancesLayout.transform.localPosition = new Vector3(0, -600, 0);
            appearancesLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
            appearancesLayout.childAlignment  = TextAnchor.UpperLeft;
            appearancesLayout.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
            appearancesLayout.constraintCount = 3;
            appearancesLayout.cellSize        = new Vector2(Mathf.FloorToInt(1000 / 3), 80);

            SuperController.singleton.currentSaveDir = SuperController.singleton.currentLoadDir;
            JSONClass initialAppearance = SuperController.singleton.GetSaveJSON(atom, false, true).AsObject["atoms"].AsArray[0].AsObject;

            AddAppearance(initialAppearance, "Current", 1);

            CreateModuleButton("Clear List").button.onClick.AddListener(() =>
            {
                ClearAppearances();
                initialAppearance = SuperController.singleton.GetSaveJSON(atom, false, true).AsObject["atoms"].AsArray[0].AsObject;
                AddAppearance(initialAppearance, "Current", 1);
            });

            CreateModuleButton("Randomize").button.onClick.AddListener(() =>
            {
                sliders.ForEach((slider) =>
                {
                    slider.slider.value = UnityEngine.Random.Range(0.0f, 1.0f);
                });
            });

            CreateModuleButton("Average").button.onClick.AddListener(() =>
            {
                sliders.ForEach((slider) =>
                {
                    slider.slider.value = 0.5f;
                });
            });


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

            morphControl = character.morphsControlUI;
        }
示例#8
0
        public Appearance(DollMaker dm) : base(dm)
        {
            JSONArray bodyUI = DollMaker.CONFIG_JSON["bodyUI"].AsArray;

            for (int i = 0; i < bodyUI.Count; i++)
            {
                JSONClass uiPart     = bodyUI[i].AsObject;
                string    title      = uiPart["title"].Value;
                string    boneName   = uiPart["bone"].Value;
                string    searchTerm = uiPart["search"].Value;
                float     x          = uiPart["offset"]["x"].AsFloat;
                float     y          = uiPart["offset"]["y"].AsFloat;
                float     z          = uiPart["offset"]["z"].AsFloat;

                DAZBone bone = person.GetStorableByID(boneName) as DAZBone;

                BoneAttachedUI boneUI = new BoneAttachedUI(title, bone, ui, new Vector3(x, y, z));
                boneUI.button.button.onClick.AddListener(() =>
                {
                    UpdateSearch(searchTerm);
                    searchBox.text = searchTerm;
                });
                baUI.Add(boneUI);
            }

            searchBox = ui.CreateTextInput("Search For Morph", 1200, 120);
            searchBox.transform.localPosition = new Vector3(0, -120, 0);


            //textInput.gameObject.AddComponent<InputPressedHandler>();

            ScrollRect sr = ui.CreateScrollRect(1200, 800);

            sr.transform.localPosition = new Vector3(0, -600, 0);

            VerticalLayoutGroup vlg = ui.CreateVerticalLayout(1200, 1200);

            vlg.transform.SetParent(sr.transform, false);
            vlg.padding = new RectOffset(0, 0, 25, 25);

            RectTransform vlgrt = vlg.GetComponent <RectTransform>();

            vlgrt.pivot            = new Vector2(0.5f, 1);
            vlgrt.anchoredPosition = new Vector2(0, 0);
            sr.content             = vlgrt;

            ContentSizeFitter csf = vlg.gameObject.AddComponent <ContentSizeFitter>();

            csf.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            csf.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

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

            morphControl = personGeometry.morphsControlUI;

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

            List <string> morphNames = personGeometry.GetFloatParamNames();

            morphNames.ForEach((s) =>
            {
                //  For testing scroll rect
                //if (morphNameToSlider.Keys.Count > 20)
                //{
                //    return;
                //}

                UIDynamicSlider morphSlider = ui.CreateSlider(s, 800, 80, false);
                morphSlider.gameObject.SetActive(false);

                //Image image = morphSlider.labelText.transform.parent.gameObject.GetComponentInChildren<Image>();
                morphSlider.transform.SetParent(vlg.transform, false);

                personGeometry.GetFloatJSONParam(s).slider = morphSlider.slider;

                morphNameToSlider[s] = morphSlider;
            });

            searchBox.onValueChanged.AddListener(UpdateSearch);
        }
示例#9
0
        public Blend(DollMaker dm) : base(dm)
        {
            dm.mainControls.RegisterTab("Blend", moduleUI);
            CreateModuleButton("Add Appearances").button.onClick.AddListener(() =>
            {
                SuperController.singleton.editModeToggle.isOn = true;
                SuperController.singleton.ShowMainHUD();

                SuperController.singleton.GetDirectoryPathDialog((string dir) =>
                {
                    if (dir == null || !(dir != string.Empty))
                    {
                        return;
                    }

                    //  have load dialog work both inside and outside folder
                    try
                    {
                        PerformLoadOnPath(dir);
                    }
                    catch
                    {
                        string folderName = "\\" + dir.Substring(dir.LastIndexOf('\\') + 1) + "\\";
                        dir = dir.Replace(folderName, "\\");
                        PerformLoadOnPath(dir);
                    }
                }, SuperController.singleton.savesDir + "Person" + "\\appearance");
            });

            appearancesLayout = ui.CreateGridLayout(1000, 500, moduleUI.transform);
            appearancesLayout.transform.localPosition = new Vector3(0, -600, 0);
            appearancesLayout.GetComponent <RectTransform>().pivot = new Vector2(0, 0);
            appearancesLayout.childAlignment  = TextAnchor.UpperLeft;
            appearancesLayout.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
            appearancesLayout.constraintCount = 3;
            appearancesLayout.cellSize        = new Vector2(Mathf.FloorToInt(1000 / 3), 80);

            SuperController.singleton.currentSaveDir = SuperController.singleton.currentLoadDir;
            JSONClass initialAppearance = SuperController.singleton.GetSaveJSON(atom, false, true).AsObject["atoms"].AsArray[0].AsObject;

            AddAppearance(initialAppearance, "Current", 1);

            CreateModuleButton("Clear List").button.onClick.AddListener(() =>
            {
                sliders.ForEach((slider) =>
                {
                    GameObject.Destroy(slider.gameObject);
                });
                sliders.Clear();
                appearances.Clear();
                computedWeightedMorphs.Clear();

                initialAppearance = SuperController.singleton.GetSaveJSON(atom, false, true).AsObject["atoms"].AsArray[0].AsObject;
                AddAppearance(initialAppearance, "Current", 1);
            });

            CreateModuleButton("Randomize").button.onClick.AddListener(() =>
            {
                sliders.ForEach((slider) =>
                {
                    slider.slider.value = UnityEngine.Random.Range(0.0f, 1.0f);
                });
            });

            CreateModuleButton("Average").button.onClick.AddListener(() =>
            {
                sliders.ForEach((slider) =>
                {
                    slider.slider.value = 0.5f;
                });
            });


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

            morphControl = character.morphsControlUI;
        }