void PerformLoadOnPath(string dir) { List <string> files = SuperController.singleton.GetFilesAtPath(dir, "*.json").ToList(); files.ForEach((file) => { JSONClass person = ReadScene(file); if (person == null) { return; } AddAppearance(person, PathExt.GetFileNameWithoutExtension(file)); }); }
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; }