public void SaveModifier() { FileManagerSecure.CreateDirectory(Utilities.PresetSavePath); int flags = Utilities.ModifierPreset; if (usePlaceholder_.Value) { flags |= Utilities.PresetUsePlaceholder; } SuperController.singleton.GetMediaPathDialog( (string path) => { if (string.IsNullOrEmpty(path)) { return; } if (!path.Contains(".")) { path += "." + Utilities.ModifierPresetExtension; } Synergy.Instance.Manager.SavePreset(path, flags); }, Utilities.ModifierPresetExtension, Utilities.PresetSavePath); var browser = SuperController.singleton.mediaFileBrowserUI; browser.SetTextEntry(true); browser.ActivateFileNameField(); }
private void MakeDefault() { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var jc = context.plugin.GetJSON(); context.plugin.SaveJSON(jc, SaveFormat.DefaultsPath); }
public string FileFingerPrint(string fileName) { fileName = FileManagerSecure.NormalizePath(fileName); #if LFE_DEBUG var sw = new Stopwatch(); sw.Start(); #endif var inBytes = FileManagerSecure.ReadAllBytes(fileName); #if LFE_DEBUG sw.Stop(); SuperController.LogMessage($"fingerprint: read {fileName} took: {sw.ElapsedMilliseconds}ms"); sw.Reset(); sw.Start(); #endif var outBytes = _md5.ComputeHash(inBytes); var sb = new StringBuilder(); for (var i = 0; i < outBytes.Length; i++) { sb.Append(outBytes[i].ToString("X2")); } var print = sb.ToString(); #if LFE_DEBUG sw.Stop(); SuperController.LogMessage($"fingerprint: hash {fileName} took: {sw.ElapsedMilliseconds}ms"); #endif return(print); }
private void Export() { try { #if (VAM_GT_1_20) FileManagerSecure.CreateDirectory(_saveFolder); #endif var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save animation"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = _saveExt; fileBrowserUI.defaultPath = _saveFolder; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show(ExportFileSelected); fileBrowserUI.ActivateFileNameField(); } catch (Exception exc) { SuperController.LogError($"Timeline: Failed to save file dialog: {exc}"); } }
public bool Apply() { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var jc = new JSONClass(); context.embody.StoreJSON(jc, true, false); context.plugin.SaveJSON(jc, SaveFormat.DefaultsPath); return(true); }
public void MakeDefault() { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var jc = new JSONClass(); _context.embody.StoreJSON(jc, true, false); jc.Remove(_context.diagnostics.storeId); _context.plugin.SaveJSON(jc, SaveFormat.DefaultsPath); }
public void Show() { CreateText(new JSONStorableString("", "Export all settings so you can easily re-use them in other scenes or on other atoms.\n\nMake Default will save your settings so that whenever you load this plugin on a new atom, the parameters will be automatically applied.\n\nTo clear your height and body proportions from this instance, e.g. before making a scene public, use Clear Personal Data."), true); CreateTitle("Import / Export", true); var loadPresetUI = CreateButton("Import Profile...", true); loadPresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var shortcuts = FileManagerSecure.GetShortCutsForDirectory(SaveFormat.SaveFolder); SuperController.singleton.GetMediaPathDialog(_storage.LoadProfile, SaveFormat.SaveExt, SaveFormat.SaveFolder, false, true, false, null, false, shortcuts); }); var savePresetUI = CreateButton("Export Profile...", true); savePresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save Embody Profile"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = SaveFormat.SaveExt; fileBrowserUI.defaultPath = SaveFormat.SaveFolder; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show(_storage.SaveProfile); fileBrowserUI.ActivateFileNameField(); }); CreateSpacer(true).height = 40f; CreateTitle("Default Profile", true); var makeDefaults = CreateButton("Save As Default Profile", true); makeDefaults.button.onClick.AddListener(_storage.MakeDefault); var applyDefaults = CreateButton("Load Default Profile", true); applyDefaults.button.onClick.AddListener(() => context.embody.LoadFromDefaults()); var clearDefaults = CreateButton("Delete Default Profile", true); clearDefaults.button.onClick.AddListener(() => FileManagerSecure.DeleteFile(SaveFormat.DefaultsPath)); CreateSpacer(true).height = 40f; CreateTitle("Clear Data", true); CreateButton("Clear Personal Data From Plugin", true).button.onClick.AddListener(_storage.ClearPersonalData); CreateButton("Reset To Built-In Defaults", true).button.onClick.AddListener(() => Utilities.ResetToDefaults(context)); }
private void OnPluginsListChanged() { if (_pauseListChangedEvent) { return; } transform.parent.parent.BroadcastMessage(nameof(IActionsInvoker.OnActionsProviderAvailable), this, SendMessageOptions.DontRequireReceiver); FileManagerSecure.CreateDirectory(@"Saves\PluginData"); SaveJSON(GetJSON(), _configPath); }
private void Import() { try { FileManagerSecure.CreateDirectory(_saveFolder); var shortcuts = FileManagerSecure.GetShortCutsForDirectory(_saveFolder); SuperController.singleton.GetMediaPathDialog(ImportFileSelected, _saveExt, _saveFolder, false, true, false, null, false, shortcuts); } catch (Exception exc) { SuperController.LogError($"VamTimeline: Failed to open file dialog: {exc}"); } }
private void InitPresetUI() { var loadPresetUI = CreateButton("Load Preset", false); loadPresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(_saveFolder); var shortcuts = FileManagerSecure.GetShortCutsForDirectory(_saveFolder); SuperController.singleton.GetMediaPathDialog((string path) => { if (string.IsNullOrEmpty(path)) { return; } JSONClass jc = (JSONClass)LoadJSON(path); RestoreFromJSON(jc); SyncSelectedAnchorJSON(""); SyncHandsOffset(); }, _saveExt, _saveFolder, false, true, false, null, false, shortcuts); }); var savePresetUI = CreateButton("Save Preset", false); savePresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(_saveFolder); var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save colliders preset"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = _saveExt; fileBrowserUI.defaultPath = _saveFolder; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show((string path) => { fileBrowserUI.fileFormat = null; if (string.IsNullOrEmpty(path)) { return; } if (!path.ToLower().EndsWith($".{_saveExt}")) { path += $".{_saveExt}"; } var jc = GetJSON(); jc.Remove("id"); SaveJSON(jc, path); }); fileBrowserUI.ActivateFileNameField(); }); }
private bool Import(bool clear, string path) { if (string.IsNullOrEmpty(path)) { return(false); } if (clear) { _keyMapManager.Clear(); _analogMapManager.Clear(); } if (!FileManagerSecure.FileExists(path)) { return(false); } var jc = (JSONClass)SuperController.singleton.LoadJSON(path); if (jc == null) { return(false); } var version = jc["version"].AsInt; _settings.RestoreFromJSON(jc["settings"].AsObject); _keyMapManager.RestoreFromJSON(jc["keybindings"]); _analogMapManager.RestoreFromJSON(jc["analogMaps"]); if (version < 2) { if (_analogMapManager.maps.Any(m => m.commandName == "Camera.Pan_X" && m.slot == 0 && m.leftChord.Equals(new KeyChord(KeyCode.A, false, false, false)))) { _analogMapManager.maps.Add( new AnalogMap(new KeyChord(KeyCode.A, false, false, true), new KeyChord(KeyCode.D, false, false, true), "Camera.Pan_X.Fast", 0)); } if (_analogMapManager.maps.Any(m => m.commandName == "Camera.Pan_Y" && m.slot == 0 && m.leftChord.Equals(new KeyChord(KeyCode.Z, false, false, false)))) { _analogMapManager.maps.Add( new AnalogMap(new KeyChord(KeyCode.Z, false, false, true), new KeyChord(KeyCode.X, false, false, true), "Camera.Pan_Y.Fast", 0)); } if (_analogMapManager.maps.Any(m => m.commandName == "Camera.Pan_Z" && m.slot == 0 && m.leftChord.Equals(new KeyChord(KeyCode.W, false, false, false)))) { _analogMapManager.maps.Add( new AnalogMap(new KeyChord(KeyCode.W, false, false, true), new KeyChord(KeyCode.S, false, false, true), "Camera.Pan_Z.Fast", 0)); } } return(true); }
public void OpenImportDialog(bool clear) { var shortcuts = FileManagerSecure.GetShortCutsForDirectory(_saveFolder); SuperController.singleton.GetMediaPathDialog(path => { Import(clear, path); }, _saveExt, _saveFolder, true, true, false, null, false, shortcuts); }
public void Show() { CreateText(new JSONStorableString("", "Export all settings so you can easily re-use them in other scenes or on other atoms."), true); var loadPresetUI = CreateButton("Import", true); loadPresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var shortcuts = FileManagerSecure.GetShortCutsForDirectory(SaveFormat.SaveFolder); SuperController.singleton.GetMediaPathDialog(LoadCallback, SaveFormat.SaveExt, SaveFormat.SaveFolder, false, true, false, null, false, shortcuts); }); var savePresetUI = CreateButton("Export", true); savePresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(SaveFormat.SaveFolder); var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save Embody preset"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = SaveFormat.SaveExt; fileBrowserUI.defaultPath = SaveFormat.SaveFolder; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show(SaveCallback); fileBrowserUI.ActivateFileNameField(); }); var makeDefaults = CreateButton("Make Default (Saves)", true); makeDefaults.button.onClick.AddListener(MakeDefault); var clearDefaults = CreateButton("Clear Default (Saves)", true); clearDefaults.button.onClick.AddListener(() => FileManagerSecure.DeleteFile(SaveFormat.DefaultsPath)); var clearPersonalData = CreateButton("Clear Personal Data (Plugin)", true); clearPersonalData.button.onClick.AddListener(() => ClearPersonalData()); }
public static void SaveConfig(string path, IConfigProvider provider) { if (!CheckPath(ref path)) { return; } var directory = FileManagerSecure.GetDirectoryName(path); if (!FileManagerSecure.DirectoryExists(directory)) { FileManagerSecure.CreateDirectory(directory); } var config = new JSONClass(); provider.StoreConfig(config); Controller.SaveJSON(config, path, () => SuperController.LogMessage($"Saved config! \"{path}\""), null, null); }
private static void OpenDialog(string defaultPath, string filter, bool textEntry, uFileBrowser.FileBrowserCallback callback) { if (!FileManagerSecure.DirectoryExists(defaultPath)) { FileManagerSecure.CreateDirectory(defaultPath); } Controller.mediaFileBrowserUI.fileRemovePrefix = null; Controller.mediaFileBrowserUI.hideExtension = false; Controller.mediaFileBrowserUI.keepOpen = false; Controller.mediaFileBrowserUI.showDirs = true; Controller.mediaFileBrowserUI.shortCuts = null; Controller.mediaFileBrowserUI.browseVarFilesAsDirectories = true; Controller.mediaFileBrowserUI.fileFormat = filter; Controller.mediaFileBrowserUI.defaultPath = defaultPath; Controller.mediaFileBrowserUI.SetTextEntry(textEntry); Controller.mediaFileBrowserUI.Show(callback); }
private IEnumerator DeferredInit() { yield return(new WaitForEndOfFrame()); if (!_restored) { containingAtom.RestoreFromLast(this); } if (!_restored) { if (FileManagerSecure.FileExists(SaveFormat.DefaultsPath)) { var profile = LoadJSON(SaveFormat.DefaultsPath); RestoreFromJSON(profile.AsObject, false, false, null, false); } } SuperController.singleton.BroadcastMessage("OnActionsProviderAvailable", this, SendMessageOptions.DontRequireReceiver); }
public void LoadFromDefaults() { try { if (!FileManagerSecure.FileExists(SaveFormat.DefaultsPath)) { return; } var profile = LoadJSON(SaveFormat.DefaultsPath)?.AsObject; if (profile == null) { return; } RestoreFromJSONInternal(profile, true, false, false); } catch (Exception exc) { SuperController.LogError($"Embody: Error loading defaults file: {exc}"); } }
public static void LoadConfig(string path, IConfigProvider provider) { if (!CheckPath(ref path)) { return; } var directory = FileManagerSecure.GetDirectoryName(path); if (!FileManagerSecure.DirectoryExists(directory)) { return; } var config = Controller.LoadJSON(path); provider.RestoreConfig(config); SuperController.LogMessage($"Loaded config! \"{path}\""); }
public override void Init() { if (containingAtom.type != "SessionPluginManager") { SuperController.LogError($"{nameof(KeybindingsExtensions_AddPlugin)} plugin can only be installed as a session plugin."); CreateTextField(new JSONStorableString("Error", $"{nameof(KeybindingsExtensions_AddPlugin)} plugin can only be installed as a session plugin.")); enabledJSON.val = false; return; } var addButton = CreateButton("+ Add Plugin"); addButton.buttonColor = Color.green; addButton.button.onClick.AddListener(() => AddPlugin()); var clearButton = CreateButton("Clear", true); clearButton.textColor = Color.white; clearButton.buttonColor = Color.red; clearButton.button.onClick.AddListener(() => { try { _pauseListChangedEvent = true; foreach (var plugin in _plugins) { plugin.onRemove.Invoke(); } } finally { _plugins.Clear(); _pauseListChangedEvent = false; OnPluginsListChanged(); } }); if (FileManagerSecure.FileExists(_configPath)) { RestoreFromJSON(LoadJSON(_configPath).AsObject); } }
public void LoadModifier(int flags) { FileManagerSecure.CreateDirectory(Utilities.PresetSavePath); var shortcuts = FileManagerSecure.GetShortCutsForDirectory( Utilities.PresetSavePath); SuperController.singleton.GetMediaPathDialog( (string path) => { if (string.IsNullOrEmpty(path)) { return; } Synergy.Instance.Manager.LoadPreset( path, Utilities.ModifierPreset | flags); Synergy.Instance.UI.NeedsReset("modifier preset loaded"); }, Utilities.ModifierPresetExtension, Utilities.PresetSavePath, false, true, false, null, false, shortcuts); }
public PluginReference(MVRScript plugin) { _plugin = plugin; _selectButton = plugin.CreateButton("Browse..."); _labelJSON.setCallbackFunction = val => _selectButton.label = string.IsNullOrEmpty(_labelJSON.val) ? "Browse..." : _labelJSON.val; _pluginJSON.beginBrowseWithObjectCallback = jsu => { jsu.shortCuts = FileManagerSecure.GetShortCutsForDirectory("Custom/Scripts", true, true, true, true); }; _pluginJSON.setCallbackFunction = val => { if (string.IsNullOrEmpty(val)) { return; } SyncLabel(val); onChange.Invoke(); }; _pluginJSON.fileBrowseButton = _selectButton.button; _removeButton = plugin.CreateButton("Remove", true); _removeButton.button.onClick.AddListener(() => onRemove.Invoke()); _removeButton.textColor = Color.white; _removeButton.buttonColor = Color.red; }
public void OpenExportDialog() { FileManagerSecure.CreateDirectory(_saveFolder); var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save keybindings"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = _saveExt; fileBrowserUI.defaultPath = _saveFolder; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; var shortCuts = new List <ShortCut> { new ShortCut { path = @"Saves\keybindings", displayName = "Custom keybindings" }, }; const string devKeybindingsPath = @"Custom\Scripts\Dev\vam-keybindings\keybindings"; if (FileManagerSecure.DirectoryExists(devKeybindingsPath)) { shortCuts.Add(new ShortCut { path = devKeybindingsPath, displayName = "Dev keybindings" }); } fileBrowserUI.shortCuts = shortCuts; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show(path => { fileBrowserUI.fileFormat = "json"; Export(path); }); fileBrowserUI.ActivateFileNameField(); }
public override void Init() { try { if (containingAtom.type != "Person") { Log.Error($"Plugin is for use with 'Person' atom, not '{containingAtom.type}'"); return; } FileManagerSecure.CreateDirectory(mocapDir); lastBrowseDir = mocapDir; coreControl = SuperController.singleton.GetAtomByUid("CoreControl"); SetAnimationStorableIds(); InitPluginUILeft(); InitPluginUIRight(); } catch (Exception e) { Log.Error($"{e}"); } }
private void BuildUI() { var showPreviews = new JSONStorableBool("showPreviews", ColliderPreviewConfig.DefaultPreviewsEnabled, value => { _config.PreviewsEnabled = value; foreach (var editable in _editables.All) { editable.UpdatePreviewFromConfig(); } }); RegisterBool(showPreviews); var showPreviewsToggle = CreateToggle(showPreviews); showPreviewsToggle.label = "Show Previews"; var xRayPreviews = new JSONStorableBool("xRayPreviews", ColliderPreviewConfig.DefaultXRayPreviews, value => { _config.XRayPreviews = value; foreach (var editable in _editables.All) { editable.UpdatePreviewFromConfig(); } }); RegisterBool(xRayPreviews); var xRayPreviewsToggle = CreateToggle(xRayPreviews); xRayPreviewsToggle.label = "Use XRay Previews"; JSONStorableFloat previewOpacity = new JSONStorableFloat("previewOpacity", ColliderPreviewConfig.DefaultPreviewsOpacity, value => { if (!showPreviews.val) { showPreviews.val = true; } var alpha = value.ExponentialScale(ColliderPreviewConfig.ExponentialScaleMiddle, 1f); _config.PreviewsOpacity = alpha; foreach (var editable in _editables.All) { editable.UpdatePreviewFromConfig(); } }, 0f, 1f); RegisterFloat(previewOpacity); CreateSlider(previewOpacity).label = "Preview Opacity"; JSONStorableFloat selectedPreviewOpacity = new JSONStorableFloat("selectedPreviewOpacity", ColliderPreviewConfig.DefaultSelectedPreviewOpacity, value => { if (!showPreviews.val) { showPreviews.val = true; } var alpha = value.ExponentialScale(ColliderPreviewConfig.ExponentialScaleMiddle, 1f); _config.SelectedPreviewsOpacity = alpha; if (_selected != null) { _selected.UpdatePreviewFromConfig(); } }, 0f, 1f); RegisterFloat(selectedPreviewOpacity); CreateSlider(selectedPreviewOpacity).label = "Selected Preview Opacity"; var loadPresetUI = CreateButton("Load Preset"); loadPresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(_collidersSavePath); var shortcuts = FileManagerSecure.GetShortCutsForDirectory(_collidersSavePath); SuperController.singleton.GetMediaPathDialog(HandleLoadPreset, _saveExt, _collidersSavePath, false, true, false, null, false, shortcuts); }); var savePresetUI = CreateButton("Save Preset"); savePresetUI.button.onClick.AddListener(() => { FileManagerSecure.CreateDirectory(_collidersSavePath); var fileBrowserUI = SuperController.singleton.fileBrowserUI; fileBrowserUI.SetTitle("Save colliders preset"); fileBrowserUI.fileRemovePrefix = null; fileBrowserUI.hideExtension = false; fileBrowserUI.keepOpen = false; fileBrowserUI.fileFormat = _saveExt; fileBrowserUI.defaultPath = _collidersSavePath; fileBrowserUI.showDirs = true; fileBrowserUI.shortCuts = null; fileBrowserUI.browseVarFilesAsDirectories = false; fileBrowserUI.SetTextEntry(true); fileBrowserUI.Show(HandleSavePreset); fileBrowserUI.fileEntryField.text = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds + "." + _saveExt; fileBrowserUI.ActivateFileNameField(); }); var resetAllUI = CreateButton("Reset All"); resetAllUI.button.onClick.AddListener(() => { foreach (var editable in _editables.All) { editable.ResetToInitial(); } }); var groups = new List <string> { _noSelectionLabel }; groups.AddRange(_editables.Groups.Select(e => e.Name).Distinct()); groups.Add(_allLabel); _groupsJson = new JSONStorableStringChooser("Group", groups, groups[0], "Group"); _groupsJson.setCallbackFunction = _ => UpdateFilter(); var groupsList = CreateScrollablePopup(_groupsJson, false); groupsList.popupPanelHeight = 400f; _popups.Add(groupsList); var types = new List <string> { _noSelectionLabel }; types.AddRange(_editables.All.Select(e => e.Type).Distinct()); types.Add(_allLabel); _typesJson = new JSONStorableStringChooser("Type", types, types[0], "Type"); _typesJson.setCallbackFunction = _ => UpdateFilter(); var typesList = CreateScrollablePopup(_typesJson, false); typesList.popupPanelHeight = 400f; _popups.Add(typesList); _modifiedOnlyJson = new JSONStorableBool("Modified Only", false); _modifiedOnlyJson.setCallbackFunction = _ => UpdateFilter(); CreateToggle(_modifiedOnlyJson, false); _textFilterJson = new JSONStorableString("Search", _searchDefault); _textFilterJson.setCallbackFunction = _ => UpdateFilter(); CreateTextInput(_textFilterJson, false); _editablesJson = new JSONStorableStringChooser( "Edit", new List <string>(), new List <string>(), "", "Edit"); var editablesList = CreateScrollablePopup(_editablesJson, true); editablesList.popupPanelHeight = 1000f; _popups.Add(editablesList); _editablesJson.setCallbackFunction = id => { IModel val; if (_editables.ByUuid.TryGetValue(id, out val)) { SelectEditable(val); } else { SelectEditable(null); } }; UpdateFilter(); }
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; } }
public void ExportDefault() { FileManagerSecure.CreateDirectory(_saveFolder); Export(_defaultKeybindingsFile); }