public MontageController(DollmasterPlugin dm, PoseController poseController) : base(dm) { montagePath = new JSONStorableUrl("montagePath", DollmasterPlugin.VAMASUTRA_PATH); dm.RegisterUrl(montagePath); UIDynamicButton selectMontageFolderButton = dm.CreateButton("Select Montage Folder", true); selectMontageFolderButton.button.onClick.AddListener(() => { SuperController.singleton.directoryBrowserUI.defaultPath = SuperController.singleton.savesDir; SuperController.singleton.directoryBrowserUI.showDirs = true; SuperController.singleton.directoryBrowserUI.showFiles = false; SuperController.singleton.directoryBrowserUI.selectDirectory = true; SuperController.singleton.directoryBrowserUI.SetTextEntry(true); SuperController.singleton.directoryBrowserUI.Show((path) => { montagePath.SetVal(path); LoadMontagesFromPath(path); }); }); UIDynamicButton montageButton = ui.CreateButton("Random Montage", 200, 50); montageButton.button.onClick.AddListener(RandomMontage); montageButton.transform.Translate(0, 0.3f, 0, Space.Self); UI.ColorButton(montageButton, accessTextColor, accessButtonColor); poseButton = ui.CreateButton("Random Pose", 200, 50); poseButton.button.onClick.AddListener(RandomPose); poseButton.transform.Translate(0.3f, 0.3f, 0, Space.Self); UI.ColorButton(poseButton, accessTextColor, accessButtonColor); }
void LoadPreset(string presetType, string path) { PresetManager pm = containingAtom.GetComponentInChildren <PresetManager>(includeInactive: true); pm.itemType = PresetManager.ItemType.Atom; JSONStorable js = containingAtom.GetStorableByID(presetType); JSONStorableUrl presetPathJSON = js.GetUrlJSONParam("presetBrowsePath"); presetPathJSON.val = SuperController.singleton.NormalizePath(path); js.CallAction("LoadPreset"); }
public override void Init() { try { lastTriedPath = SuperController.singleton.currentLoadDir; loadLog = new JSONStorableString("log", ""); CreateTextField(loadLog, true).height = 1200; JSONStorableString pathStorable = new JSONStorableUrl("audioPath", "", (string path) => { if (string.IsNullOrEmpty(path)) { return; } /* * Debug.Log("savedPath: " + path); * Debug.Log("dataPath: " + Application.dataPath); * Debug.Log("savedir: " + SuperController.singleton.currentLoadDir); * Debug.Log("loaddir: " + SuperController.singleton.currentSaveDir); * Debug.Log("combined: " + Application.dataPath + "/../" + path); */ lastTriedPath = LoadClips(path); }); CreateButton("Load Audio From Folder").button.onClick.AddListener(() => { SuperController.singleton.GetDirectoryPathDialog((string path) => { if (String.IsNullOrEmpty(path)) { return; } pathStorable.val = path; }, lastTriedPath); }); CreateButton("Remove All Audio").button.onClick.AddListener(() => { URLAudioClipManager.singleton.RemoveAllClips(); }); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
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; }
public UrlStorableParameter(JSONStorableUrl p = null) : base(p) { }
public override void Init() { try { if (containingAtom.type == "SessionPluginManager" || containingAtom.type == "CoreControl") { SuperController.LogError("Embody: Cannot run as a session or scene plugin"); CreateTextField(new JSONStorableString("Error", "Embody cannot run as a session or scene plugin. Please add it to a Person atom, or an Empty.")); enabled = false; return; } activeJSON = new JSONStorableBool("Active", false) { isStorable = false }; activateOnLoadJSON = new JSONStorableBool("ActivateOnLoad", false) { isStorable = true }; RegisterBool(activateOnLoadJSON); returnToSpawnPoint = new JSONStorableStringChooser("ReturnToSpawnPoint", new List <string>(), "", "Return To Spawn Point") { popupOpenCallback = SyncSpawnPointAtoms }; SyncSpawnPointAtoms(); RegisterStringChooser(returnToSpawnPoint); 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 = CreateModule <WorldScaleModule>(_context); 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(); _screensManager.Add(MainScreen.ScreenName, new MainScreen(_context, _modulesList)); 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(ProfilesScreen.ScreenName, new ProfilesScreen(_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)); _screensManager.Add(WorldScaleSettingsScreen.ScreenName, new WorldScaleSettingsScreen(_context, worldScaleModule)); _screensManager.Add(MoreScreen.ScreenName, new MoreScreen(_context)); } activeJSON.setCallbackFunction = val => { if (val) { Activate(false); } else { Deactivate(); } }; RegisterBool(activeJSON); activeToggle = CreateToggle(activeJSON, false); activeToggle.label = "Active"; activeToggle.backgroundColor = Color.cyan; activeToggle.labelText.fontStyle = FontStyle.Bold; activeToggle.toggle.onValueChanged.AddListener(v => { if (!v) { return; } _activatedManually = true; }); _loadProfileWithPathUrlJSON = new JSONStorableUrl("ProfilePathUrl", string.Empty, url => { _loadProfileWithPathUrlJSON.valNoCallback = null; new Storage(_context).LoadProfile(url); }, SaveFormat.SaveExt, SaveFormat.SaveFolder, true) { allowFullComputerBrowse = false, allowBrowseAboveSuggestedPath = true, hideExtension = false, showDirs = true, isRestorable = false, isStorable = false, beginBrowseWithObjectCallback = jsurl => { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); jsurl.shortCuts = FileManagerSecure.GetShortCutsForDirectory(SaveFormat.SaveFolder, false, false, true, true); } }; RegisterUrl(_loadProfileWithPathUrlJSON); _loadProfileWithPathJSON = new JSONStorableActionPresetFilePath("LoadProfileWithPath", url => { _loadProfileWithPathUrlJSON.SetFilePath(url); }, _loadProfileWithPathUrlJSON); RegisterPresetFilePathAction(_loadProfileWithPathJSON); var launchWizardJSON = new JSONStorableAction("LaunchWizard", () => StartCoroutine(LaunchWizard())); RegisterAction(launchWizardJSON); RegisterAction(new JSONStorableAction("ToggleActive", () => activeJSON.val = !activeJSON.val)); RegisterAction(new JSONStorableAction("ReinitializeIfActive", () => StartCoroutine(ReinitializeIfActiveCo()))); 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(); if (containingAtom.on) { TryInitializeModuleReferences(); } SuperController.singleton.StartCoroutine(DeferredInit()); } catch (Exception) { enabledJSON.val = false; if (_modules != null) { Destroy(_modules); } throw; } }