public void Save() { Debug.Log("SAVING!!"); SettingsValues settings = new SettingsValues(); settings.volume = volumeSlider.value; settings.music = musicVolumeSlider.value; settings.ambient = ambientVolumeSlider.value; settings.sfx = sfxVolumeSlider.value; settings.shots = shotsVolumeSlider.value; settings.fps = System.Convert.ToInt32(fpsSlider.value); if (vsyncToggle.isOn) { settings.VSYNC = 1; } else { settings.VSYNC = 0; } if (fullScreenToggle.isOn) { settings.FullScreen = 1; } else { settings.FullScreen = 0; } settings.resolutionIndex = dropDownResolution.value; Settings.SaveSettings(settings); }
public void Property_returns_same_value_from_set_method(SettingsProvider sut) { var settings = new SettingsValues(); sut.UseSettings(settings); sut.Settings.Should().Be(settings); }
/// <summary> /// Find references. Get initial values for settings. /// </summary> private void Awake() { reference = FindObjectOfType <ReferenceManager>(); menuTransitionManager = reference.menuTransitionManager; source = reference.mainCanvasAudioSource; settingsValues = reference.settingsValues; if (settingsValues.colorBlindMode == ColorBlindMode.Mode.Standard) { colorBlindModeToggle.isOn = false; foreach (ColorBlindModeButton button in colorBlindModeButtons) { button.buttonGO.SetActive(false); } } else { colorBlindModeToggle.isOn = true; foreach (ColorBlindModeButton button in colorBlindModeButtons) { button.buttonGO.SetActive(true); if (button.mode == settingsValues.colorBlindMode) { button.buttonGO.GetComponent <UIHover>().Select(); } } } volumeSlider.value = settingsValues.masterVolume; tutorialToggle.isOn = settingsValues.tutorialOn; }
void DoMyWindow(int windowID) { style.fontSize = 12; style.normal.textColor = Color.white; if (tempSettings.Count() == 0) { tempSettings = Settings.GetDictionarySettings(); } int count = 0; foreach (KeyValuePair <string, string> kvp in new Dictionary <string, string>(tempSettings)) { GUI.Label(new Rect(10, guiTopOffset + count * guiIncrement, 150, 30), kvp.Key + ": ", style); string stringValue = GUI.TextField(new Rect(175, guiTopOffset + count * guiIncrement, 50, 20), kvp.Value.ToString(), style); stringValue = Regex.Replace(stringValue, @"[^0-9.]", ""); if (stringValue != kvp.Value) { tempSettings[kvp.Key] = stringValue; } if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { float tryParse = 0.0f; if (float.TryParse(stringValue, out tryParse)) { tempSettings[kvp.Key] = tryParse.ToString(); } else { print("Input field parsing failed"); tempSettings[kvp.Key] = "0"; } } count++; } if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { print("Applying and Saving Settings"); string json = JsonConvert.SerializeObject(tempSettings); SettingsValues v = JsonConvert.DeserializeObject <SettingsValues>(json); Settings.Values = (SettingsValues)v.Clone(); Settings.SaveSettings(); } windowRect.height = guiTopOffset + guiDownOffset + count * guiIncrement; GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
void Awake() { if (instance != null) { Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); instance = this; } }
public static Dictionary <string, string> GetDictionarySettings() { Dictionary <string, string> values = new Dictionary <string, string>(); string json = GetStringSettings(); if (json != "" && json != "null") { values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); } return(values); }
public static void LoadSettings() { string json = System.IO.File.ReadAllText(Settings.Instance.settingsFilePath); if (json != "" && json != "null") { SettingsValues values = JsonConvert.DeserializeObject <SettingsValues>(json); Settings.Values = (SettingsValues)values.Clone(); } else { print("The settings file is not valid"); } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); // Adds PlayerPrefs if non-existent. if (!PlayerPrefs.HasKey("Volume")) { PlayerPrefs.SetInt("Volume", 80); } if (!PlayerPrefs.HasKey("Start_Lives")) { PlayerPrefs.SetInt("Start_Lives", 3); } if (!PlayerPrefs.HasKey("Game_Speed")) { PlayerPrefs.SetInt("Game_Speed", 2); } if (!PlayerPrefs.HasKey("UI_Size")) { PlayerPrefs.SetFloat("UI_Size", 1.0F); } if (!PlayerPrefs.HasKey("Hover_On")) { PlayerPrefs.SetInt("Hover_On", 1); } if (!PlayerPrefs.HasKey("Hover_Time")) { PlayerPrefs.SetFloat("Hover_Time", 1.0F); } if (!PlayerPrefs.HasKey("Font_Color")) { PlayerPrefs.SetInt("Font_Color", 0); } // Sets values to the PlayerPrefs mixer.SetFloat("Volume", PlayerPrefs.GetInt("Volume")); startLives = PlayerPrefs.GetInt("Start_Lives"); gameSpeed = PlayerPrefs.GetInt("Game_Speed"); UiSize = PlayerPrefs.GetFloat("UI_Size"); hoverOn = PlayerPrefs.GetInt("Hover_On"); hoverTime = PlayerPrefs.GetFloat("Hover_Time"); fontColor = PlayerPrefs.GetInt("Font_Color"); } else { Destroy(gameObject); } }
public void Load_defaults_when_file_does_not_exist( [Frozen(Matching.ImplementedInterfaces)] MockFileSystem fileSystem, [Frozen(Matching.ImplementedInterfaces)] YamlSerializerFactory serializerFactory, [Frozen(Matching.ImplementedInterfaces)] SettingsProvider settingsProvider, [Frozen] IResourcePaths paths, SettingsPersister sut) { paths.SettingsPath.Returns("test_path"); sut.Load(); var expectedSettings = new SettingsValues(); settingsProvider.Settings.Should().BeEquivalentTo(expectedSettings); }
protected Settings() { settingsFilePath = "C:/PerceptionStudySettings/Study2/" + settingsFileName; values = new SettingsValues(); }
/// <summary> /// Gets xml the value by tag. /// </summary> /// <param name="settingsValue">Tag name.</param> /// <param name="fileName">Settings file name.</param> /// <returns>String.</returns> public static string GetValue(SettingsValues settingsValue, string fileName = SettingsFileName) => GetValue(settingsValue.ToString(), fileName);
protected Settings() { settingsFilePath = "C:/PerceptionStudySettings/ComparativeStudy/" + settingsFileName; values = new SettingsValues(); }
private async void TestButton_Clicked(object sender, EventArgs eventArgs) { SetInputEnabled(false); bool printJobFinished = false; MultichannelConnection multichannelConnection = null; try { multichannelConnection = CreateMultichannelConnection(); if (multichannelConnection == null) { return; } ZebraPrinter linkOsPrinter = null; await Task.Factory.StartNew(() => { multichannelConnection.Open(); linkOsPrinter = ZebraPrinterFactory.GetLinkOsPrinter(multichannelConnection.StatusChannel); }); Task statusTask = Task.Factory.StartNew(() => { int queryCount = 0; List <string> odometerSettings = new List <string> { "odometer.total_label_count", "odometer.total_print_length" }; while (multichannelConnection.StatusChannel.Connected && !printJobFinished) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); LinkOsInformation linkOsInformation = new LinkOsInformation(SGD.GET("appl.link_os_version", multichannelConnection)); Dictionary <string, string> odometerSettingsMap = new SettingsValues().GetValues(odometerSettings, multichannelConnection.StatusChannel, linkOsPrinter.PrinterControlLanguage, linkOsInformation); PrinterStatus printerStatus = linkOsPrinter.GetCurrentStatus(); queryCount++; stopwatch.Stop(); Device.BeginInvokeOnMainThread(() => { UpdateResult(queryCount, stopwatch.ElapsedMilliseconds, printerStatus, odometerSettingsMap); }); } }); Task printingTask = Task.Factory.StartNew(async() => { try { multichannelConnection.PrintingChannel.Write(GetTestLabelBeginningBytes(linkOsPrinter.PrinterControlLanguage)); await Task.Delay(500); multichannelConnection.PrintingChannel.Write(GetTestLabelEndBytes(linkOsPrinter.PrinterControlLanguage)); await Task.Delay(3000); } catch (Exception e) { throw e; } finally { printJobFinished = true; } }); Task aggregateTask = Task.WhenAll(statusTask, printingTask); await aggregateTask; if (aggregateTask.Exception != null) { throw aggregateTask.Exception; } } catch (Exception e) { ResultLabel.Text = $"Error: {e.Message}"; await DisplayAlert("Error", e.Message, "OK"); } finally { try { multichannelConnection?.Close(); } catch (ConnectionException) { } SetInputEnabled(true); } }
private void Start() { slider = gameObject.GetComponent <Slider>(); settingsValues = FindObjectOfType <SettingsValues>(); }
private void Start() { settingsValues = FindObjectOfType <SettingsValues>(); }
private void Awake() { LogicObject = gameObject; settingsValues = FindObjectOfType <SettingsValues>(); buttonComponent = GetComponent <Button>(); }