/// <summary> /// Option to load user data on application load in order you want. /// </summary> /// <remarks> /// Try to get data of each section... /// if the data cannot be loaded, create a new data instance with triggered <see cref="ADataContentBaseViewModel.SetDefaults"/> method. /// The method should be called only during initialization here! /// </remarks> public void Setup() { // Preferences. PreferencesData = IoC.SettingsStorage.PreferencesData ?? PreferencesDataViewModel.NewDataInstance; PreferencesData.Init(); PreferencesData.SetDefaults(); // APM Calculator ApmCalculatorData = IoC.SettingsStorage.ApmCalculatorData ?? ApmCalculatorDataViewModel.NewDataInstance; ApmCalculatorData.Init(); ApmCalculatorData.SetDefaults(); // Timer TimerData = IoC.SettingsStorage.TimerData ?? TimerDataViewModel.NewDataInstance; TimerData.Init(); TimerData.SetDefaults(); // Schedule ScheduleData = IoC.SettingsStorage.ScheduleData ?? ScheduleDataViewModel.NewDataInstance; ScheduleData.Init(); ScheduleData.SetDefaults(); // Watchdog WatchdogData = IoC.SettingsStorage.WatchdogData ?? WatchdogDataViewModel.NewDataInstance; WatchdogData.Init(); WatchdogData.SetDefaults(); // Overlay OverlayData = IoC.SettingsStorage.OverlayData ?? OverlayDataViewModel.NewDataInstance; OverlayData.Init(); OverlayData.SetDefaults(); }
public void OnAddButtonPressed() { CurrentData = data[data.Count - 1]; removeButton.interactable = false; title.text = currentData.dataName; title.interactable = true; }
private void Start() { pd = GameManager.instance.saveData.pd; ud = GameManager.instance.saveData.ud; SetButtonValues(); SetPlayerCustomization(); }
public void OnPreferencesChange(PreferencesData change) { foreach (InteractionUI <T> uI in prefabUIList) { Destroy(uI.gameObject); } prefabUIList = new List <InteractionUI <T> >(); LoadTargetPrefabOptions(); }
} // end of method GetPreferencesData /// <summary> /// Creates the default user preferences file for the program /// </summary> private static void CreateDefaultUserPreferences() { // if the directory does not exist then no previous configuration exists if (!Directory.Exists(SETTING_DIRECTORY)) { Directory.CreateDirectory(SETTING_DIRECTORY); try { using (var stream = File.Create(PREFERENCE_FILE)) { }; }// end of try block catch (IOException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"{TAG}::CreatedefaultPreferencesPropertiesFile [line: " + $"{UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of catch block } // end of if block else if (!File.Exists(PREFERENCE_FILE)) { try { using (var stream = File.Create(PREFERENCE_FILE)) { }; }// end of try block catch (IOException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"{TAG}::CreatedefaultPreferencesPropertiesFile [line: " + $"{UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of catch block } // end of if block try { using (StreamWriter swWriter = File.CreateText(PREFERENCE_FILE)) { m_widget_preferences = new PreferencesData(WeatherLionMain.authorizedProviders[0], 1800000, "not set", false, false, "default", "miui"); Type tType = m_widget_preferences.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); xsSerializer.Serialize(swWriter, m_widget_preferences); } // end of using block } // end of try block catch (FileNotFoundException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"{TAG}::CreatedefaultPreferencesPropertiesFile [line: " + $"{UtilityMethod.GetExceptionLineNumber(e)}]"); }// end of catch block catch (IOException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"{TAG}::CreatedefaultPreferencesPropertiesFile [line: " + $"{UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of catch block } // end of method CreateDefaultUserPreferences
public Preferences(TestStartInfo teststartinfo, DataManager datamanager) { _PreferencesData = new PreferencesData(datamanager); _PreferencesPage = new PreferencesPage(teststartinfo); _ModesData = new ModesData(datamanager); _AvailableEquipmentData = new AvailableEquipmentData(datamanager); _PreferredlaneData = new PreferredlaneData(datamanager); _driver = teststartinfo.Driver; }
void CheckNullPreferences(PreferencesData data) { if (data.CompositeBehavior == null) { data.CompositeBehavior = ScriptableObject.CreateInstance <CompositeBehavior>(); } if (data.compositeGene == null) { data.compositeGene = ScriptableObject.CreateInstance <CompositeGenetic>(); } data.VRInteractions = new System.Collections.Generic.List <BoidInteraction>(); if (data.VRInteractionsData != null) { foreach (BoidInteraction.Data item in data.VRInteractionsData) { BoidInteraction interaction; switch (item.regexName) { case "System.Boolean": interaction = ScriptableObject.CreateInstance <BoolVRInteraction>(); break; case "System.Single": interaction = ScriptableObject.CreateInstance <FloatVRInteraction>(); break; case "UnityEngine.Vector2": interaction = ScriptableObject.CreateInstance <Vector2VRInteraction>(); break; case "UnityEngine.Vector3": interaction = ScriptableObject.CreateInstance <Vector3VRInteraction>(); break; default: interaction = ScriptableObject.CreateInstance <QuaternionVRInteraction>(); break; } interaction.data = item; data.VRInteractions.Add(interaction); } } if (data.VRInteractionsData == null) { data.VRInteractionsData = new System.Collections.Generic.List <BoidInteraction.Data>(); } if (data.GenesInteractions == null) { data.GenesInteractions = new System.Collections.Generic.List <GeneVRInteractionUI.Data>(); } if (data.behaviorInteractionsData == null) { data.behaviorInteractionsData = new System.Collections.Generic.List <BehaviorVRInteractionUI.Data>(); } data.UpdateScriptableObjectName(); }
public void OnDown() { if (data.IndexOf(currentData) - 1 < 0) { CurrentData = data[data.Count - 1]; } else { CurrentData = data[data.IndexOf(CurrentData) - 1]; } }
public void OnUp() { if (data.IndexOf(currentData) + 1 > 3) { CurrentData = data[0]; } else { CurrentData = data[data.IndexOf(CurrentData) + 1]; } }
/// <summary> /// Given preferences data overwrite old one and save to file /// </summary> /// <param name="path"></param> /// <param name="newPrefs"></param> public bool Save(string path, PreferencesData newPrefs) { try { pd.Overwrite(newPrefs); return(Save(path)); } catch (Exception ex) { Debug.LogError("Could not save preference data.\nException: " + ex.Message); return(false); } }
/// <summary> /// Manual overwrite of PreferenceData object with given new one /// </summary> /// <param name="newData"></param> public void Overwrite(PreferencesData newData) { this.isFullscreen = newData.isFullscreen; this.resolutionIndex = newData.resolutionIndex; this.fullscreenModeIndex = newData.fullscreenModeIndex; this.fpsCap = newData.fpsCap; this.textureQualityIndex = newData.textureQualityIndex; this.anisotropicIndex = newData.anisotropicIndex; this.antiAliasIndex = newData.antiAliasIndex; this.shadowResIndex = newData.shadowResIndex; this.shadowDistance = newData.shadowDistance; this.vsyncIndex = newData.vsyncIndex; this.langIndex = newData.langIndex; }
private void Start() { data = new List <PreferencesData>(); data.Add(defaultData); data.Add(defaultData1); data.Add(defaultData2); data.Add(defaultData3); title.onValueChanged.AddListener(delegate { OnNameChanged(title); }); upButton.onClick.AddListener(OnUp); downButton.onClick.AddListener(OnDown); saveButton.onClick.AddListener(delegate { SaveData(); }); data[0] = LoadData("0"); data[1] = LoadData("1"); data[2] = LoadData("2"); data[3] = LoadData("3"); CurrentData = data[0]; }
public static void SetGameSettings(PreferencesData pd) { //Set resolution Resolution temp = Screen.resolutions[pd.resolutionIndex]; Screen.SetResolution(temp.width, temp.height, pd.isFullscreen); //Other Screen.fullScreen = pd.isFullscreen; Screen.fullScreenMode = (FullScreenMode)pd.fullscreenModeIndex; Application.targetFrameRate = pd.fpsCap; QualitySettings.anisotropicFiltering = (AnisotropicFiltering)pd.anisotropicIndex; QualitySettings.antiAliasing = pd.antiAliasIndex; QualitySettings.shadowResolution = (ShadowResolution)pd.shadowResIndex; QualitySettings.shadowDistance = pd.shadowDistance; QualitySettings.vSyncCount = pd.vsyncIndex; GameManager.instance.languageIndex = pd.langIndex; }
private void OnPreferencesChange(PreferencesData newval) { sizeInput.text = saveSystem.currentData.scale.ToString(CultureInfo.InvariantCulture); speedInput.text = saveSystem.currentData.maxSpeed.ToString(CultureInfo.InvariantCulture); sightRadiusInput.text = saveSystem.currentData.sightRadius.ToString(CultureInfo.InvariantCulture); avoidsRadiusInput.text = saveSystem.currentData.sqrtAvoidanceRadius.ToString(CultureInfo.InvariantCulture); colorPicker.UpdateColor(saveSystem.currentData.MeanColor); leftHand.SetIsOnWithoutNotify(saveSystem.currentData.followLeft); rightHand.SetIsOnWithoutNotify(saveSystem.currentData.followRight); head.SetIsOnWithoutNotify(saveSystem.currentData.followHead); matchShape.SetIsOnWithoutNotify(saveSystem.CurrentData.matchShape); matchSize.SetIsOnWithoutNotify(saveSystem.CurrentData.matchSize); matchTriggerL.SetIsOnWithoutNotify(saveSystem.CurrentData.triggerLeft); matchTriggerR.SetIsOnWithoutNotify(saveSystem.CurrentData.triggerRight); OnSizeInputChanged(); OnSpeedInputChanged(); OnRadiusInputChanged(); OnAvoidRadiusInputChanged(); }
private void LoadScriptableObjectByName(PreferencesData data) { Debug.Log("NewSession, load from name"); FlockBehavior[] behaviors = new FlockBehavior[data.behaviorsName.Count]; for (int i = 0; i < data.behaviorsName.Count; i++) { behaviors[i] = Resources.Load <FlockBehavior>("UIPrefab" + Path.DirectorySeparatorChar + "BoidsBehaviors" + Path.DirectorySeparatorChar + data.behaviorsName[i]); } data.CompositeBehavior.behaviors = behaviors; data.CompositeBehavior.weights = data.weigth.ToArray(); GeneticBehavior[] genes = new GeneticBehavior[data.genesName.Count]; for (int i = 0; i < data.genesName.Count; i++) { genes[i] = Resources.Load <GeneticBehavior>("UIPrefab" + Path.DirectorySeparatorChar + "Genetic" + Path.DirectorySeparatorChar + data.genesName[i]); } data.compositeGene.genes = genes; }
/// <summary> /// Unset application's data. /// "Prepare to die." /// </summary> public void Unset() { // Preferences. PreferencesData.Dispose(); // APM Calculator. ApmCalculatorData.Dispose(); // Timer. TimerData.Dispose(); // Schedule. ScheduleData.Dispose(); // Watchdog. WatchdogData.Dispose(); // Overlay. OverlayData.Dispose(); }
} // end of method GetConfigurationData /// <summary> /// /// </summary> private void GetPreferencesData() { if (File.Exists(PREFERENCE_FILE)) { try { StreamReader srReader = File.OpenText(PREFERENCE_FILE); Type tType = m_widget_preferences.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); object oData = xsSerializer.Deserialize(srReader); m_widget_preferences = (PreferencesData)oData; srReader.Close(); }// end of try block catch (Exception e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"{TAG}::GetPreferencesData [line: {UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of catch block } // end of if block } // end of method GetPreferencesData
public static void Load() { try { data = JsonConvert.DeserializeObject <PreferencesData>(File.ReadAllText(FilePath)); if (data == null) { data = new PreferencesData(); } data.Fix(); } catch (Exception) { data = new PreferencesData(); try { Save(); } catch (Exception) { } } }
public SaveData() { this.ud = new UserData(); this.pd = new PreferencesData(); this.levels = new List <LevelSaveData>(); }
public void Save(PreferencesData pd) { saveData.Save(applicationPath, pd); }
} // end of method SaveProgramConfiguration public static Preference GetSavedPreferences() { try { if (File.Exists(PREFERENCE_FILE)) { using (StreamReader srReader = File.OpenText(PREFERENCE_FILE)) { Type tType = m_widget_preferences.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); object oData = xsSerializer.Deserialize(srReader); m_widget_preferences = (PreferencesData)oData; } // end of using block } // end of if block else { // file does not exist so create the default one CreateDefaultAppPreferences(); } // end of else block } // end of try block catch (FileNotFoundException) { // file does not exist so create the default one CreateDefaultAppPreferences(); try { using (StreamReader srReader = File.OpenText(PREFERENCE_FILE)) { Type tType = m_widget_preferences.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); object oData = xsSerializer.Deserialize(srReader); m_widget_preferences = (PreferencesData)oData; } // end of using block } // end of try block catch (FileNotFoundException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(e)}]"); }// end of try block catch (IOException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of try block } // end of try block catch (IOException ex) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, ex.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(ex)}]"); }// end of try block try { if (File.Exists(CONFIG_FILE)) { using (StreamReader srReader = File.OpenText(CONFIG_FILE)) { Type tType = m_widget_config.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); object oData = xsSerializer.Deserialize(srReader); m_widget_config = (ConfigurationData)oData; } // end of using block } // end of if block else { // file does not exist so create the default one CreateDefaultAppConfiguration(); } // end of else block } // end of try block catch (FileNotFoundException) { // file does not exist so create the default one CreateDefaultAppConfiguration(); try { using (StreamReader srReader = File.OpenText(CONFIG_FILE)) { Type tType = m_widget_config.GetType(); XmlSerializer xsSerializer = new XmlSerializer(tType); object oData = xsSerializer.Deserialize(srReader); m_widget_config = (ConfigurationData)oData; } // end of using block } // end of try block catch (FileNotFoundException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(e)}]"); }// end of try block catch (IOException e) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(e)}]"); } // end of try block } // end of try block catch (IOException ex) { UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, ex.Message, $"Preference::GetSavedPreferences [line: {UtilityMethod.GetExceptionLineNumber(ex)}]"); }// end of try block return(new Preference()); } // end of method GetSavedPreferences