/* * Settings as follows: * [0] IP * [1] Port * [2] Match Duration * [3] Seed * [4] Use seed? * [5] Fullscreen state * [6] Competition Name * [7] Show whats new popup */ public Settings() { InitializeComponent(); loadedSettings = loadSettings(); if (loadSuccess) { Console.WriteLine("Settings were loaded properly! Now applying"); try { Networking.IP = loadedSettings[0]; Networking.port = int.Parse(loadedSettings[1]); GameUtility.gameTime = int.Parse(loadedSettings[2]); GameUtility.SEED = int.Parse(loadedSettings[3]); GameUtility.compName = loadedSettings[6]; if (loadedSettings[7].Equals("true")) { GameUtility.showChanges = true; showChanges.Checked = true; } else if (loadedSettings[7].Equals("false")) { GameUtility.showChanges = false; showChanges.Checked = false; } else { GameUtility.showChanges = true; showChanges.Checked = true; } timerCount.Value = GameUtility.gameTime; compName.Text = GameUtility.compName; if (int.Parse(loadedSettings[5]) == 1) { Display.screenMode = true; fullScreenBox.Checked = true; } else { Display.screenMode = false; fullScreenBox.Checked = false; } if (int.Parse(loadedSettings[4]) == 1) { GameUtility.useSeeded = true; seedBox.Checked = true; GameUtility.setSeed(); } else { GameUtility.useSeeded = false; seedBox.Checked = false; } } catch (Exception e) { Console.WriteLine("Exception! {0}. Something wierd happened while trying to apply settings.", e.Message); } Console.WriteLine("Settings loaded and applied."); } }
private void applyButton_Click(object sender, EventArgs e) { Console.WriteLine("Applying setting changes."); GameUtility.alterGameTime((int)timerCount.Value); GameUtility.useSeeded = seedBox.Checked; Display.screenMode = fullScreenBox.Checked; try // this try will keep the parsing of the SEED value from crashing the program incase the user enters a letter or symbol { GameUtility.SEED = int.Parse(seedText.Text); GameUtility.setSeed(); } catch (Exception e1) { Console.WriteLine("Exception! {0}", e1.ToString()); } if (GameUtility.useSeeded) { settings[4] = "1"; } else { settings[4] = "0"; } if (fullScreenBox.Checked) { settings[5] = "1"; } else { settings[5] = "0"; } if (compName.Text.Equals(GameUtility.compName)) { settings[6] = compName.Text; } else { settings[6] = compName.Text; GameUtility.compName = compName.Text; } settings[3] = GameUtility.SEED.ToString(); settings[2] = GameUtility.gameTime.ToString(); settings[1] = Networking.port.ToString(); settings[0] = Networking.IP; GameUtility.setSeed(); if (showChanges.Checked == true) { settings[7] = "true"; } else { settings[7] = "false"; } this.Hide(); saveSettings(); isShowing = false; }