public bool LoadText() { Game1 master = Program.GetTheGame(); if (!File.Exists(master.sAppData + "Config.txt")) { return false; } try { FileStream readStream = new FileStream(master.sAppData + "Config.txt", FileMode.Open, FileAccess.Read); StreamReader tr = new StreamReader(readStream); tr.ReadLine(); int iLoadedIteration = int.Parse(tr.ReadLine()); tr.ReadLine(); this.fMusicVolume = float.Parse(tr.ReadLine()); tr.ReadLine(); this.fSoundVolume = float.Parse(tr.ReadLine()); tr.ReadLine(); this.enFullScreen = (Options.FullScreenOption)byte.Parse(tr.ReadLine()); tr.ReadLine(); this.iZoom = int.Parse(tr.ReadLine()); if (this.iZoom == 1) { this.iBackBufferWidth = 640; this.iBackBufferHeight = 360; } else if (this.iZoom == 3) { this.iBackBufferWidth = 1920; this.iBackBufferHeight = 1080; } else { this.iZoom = 2; } tr.ReadLine(); this.iMessageDelay = short.Parse(tr.ReadLine()); this.byPlayerBars = byte.Parse(tr.ReadLine()); this.byEnemyBars = byte.Parse(tr.ReadLine()); tr.ReadLine(); this.iDefaultPort = int.Parse(tr.ReadLine()); tr.ReadLine(); LocalInputHelper xHelper = Program.GetTheGame().xInput_Game; LocalInputHelper xMenu = Program.GetTheGame().xInput_Menu; for (int i = 0; i < xHelper.lxAllButtons.Count; i++) { Keys keya = (Keys)int.Parse(tr.ReadLine()); Keys modifier = (Keys)int.Parse(tr.ReadLine()); xHelper.lxAllButtons[i].Key = keya; xHelper.lxAllButtons[i].Modifier = modifier; xMenu.lxAllButtons[i].Key = keya; xMenu.lxAllButtons[i].Modifier = modifier; if (modifier == Keys.LeftControl) { LocalInputHelper.lxBoundWithControl.Add(xMenu.lxAllButtons[i]); } if (modifier == Keys.LeftShift) { LocalInputHelper.lxBoundWithShift.Add(xMenu.lxAllButtons[i]); } } if (iLoadedIteration >= 7) { tr.ReadLine(); this.bShowIpAsHost = bool.Parse(tr.ReadLine()); } tr.Close(); } catch { return false; } return true; }
public bool LoadBinary() { Game1 master = Program.GetTheGame(); if (!File.Exists(master.sAppData + "Config.cfg")) { return false; } try { FileStream readStream = new FileStream(master.sAppData + "Config.cfg", FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(readStream); int iLoadedIteration = br.ReadInt32(); this.fMusicVolume = br.ReadSingle(); this.fSoundVolume = br.ReadSingle(); if (iLoadedIteration >= 4) { this.enFullScreen = (Options.FullScreenOption)br.ReadByte(); } else { br.ReadBoolean(); } this.iZoom = br.ReadInt32(); if (this.iZoom == 1) { this.iBackBufferWidth = 640; this.iBackBufferHeight = 360; } else if (this.iZoom == 3) { this.iBackBufferWidth = 1920; this.iBackBufferHeight = 1080; } else { this.iZoom = 2; } this.iMessageDelay = br.ReadInt16(); if (iLoadedIteration >= 2) { this.byPlayerBars = br.ReadByte(); this.byEnemyBars = br.ReadByte(); } if (iLoadedIteration >= 6) { this.iDefaultPort = br.ReadInt32(); } if (iLoadedIteration >= 3 && iLoadedIteration < 5) { LocalInputHelper xHelper = Program.GetTheGame().xInput_Game; LocalInputHelper xMenu = Program.GetTheGame().xInput_Menu; for (int i = 0; i < xHelper.lxAllButtons.Count; i++) { Keys keya = (Keys)br.ReadInt32(); xHelper.lxAllButtons[i].Key = keya; xMenu.lxAllButtons[i].Key = keya; } } else if (iLoadedIteration == 5) { LocalInputHelper xHelper2 = Program.GetTheGame().xInput_Game; LocalInputHelper xMenu2 = Program.GetTheGame().xInput_Menu; for (int j = 0; j < xHelper2.lxAllButtons.Count; j++) { Keys keya2 = (Keys)br.ReadInt32(); Keys modifier = (Keys)br.ReadInt32(); xHelper2.lxAllButtons[j].Key = keya2; xHelper2.lxAllButtons[j].Modifier = modifier; xMenu2.lxAllButtons[j].Key = keya2; xMenu2.lxAllButtons[j].Modifier = modifier; if (modifier == Keys.LeftControl) { LocalInputHelper.lxBoundWithControl.Add(xMenu2.lxAllButtons[j]); } if (modifier == Keys.LeftShift) { LocalInputHelper.lxBoundWithShift.Add(xMenu2.lxAllButtons[j]); } } } br.Close(); } catch { return false; } return true; }
public void Init() { Random rand = Program.GetTheGame().randomInVisual; this.axClouds[0] = new GlobalData.MainMenu.Cloud(new Vector2((float)(rand.Next(500) + 500), (float)(-50 + rand.Next(240))), this.txFarCloudA, 0.2f); this.axClouds[1] = new GlobalData.MainMenu.Cloud(new Vector2((float)rand.Next(500), (float)(-50 + rand.Next(240))), this.txFarCloudB, 0.3f); this.axClouds[2] = new GlobalData.MainMenu.Cloud(new Vector2((float)rand.Next(500), (float)(-50 + rand.Next(240))), this.txFarCloudC, 0.32f); this.axClouds[3] = new GlobalData.MainMenu.Cloud(new Vector2((float)(rand.Next(100) + 200), (float)(-50 + rand.Next(240))), this.txCloseCloudC, 0.4f); this.axClouds[4] = new GlobalData.MainMenu.Cloud(new Vector2((float)(rand.Next(200) + 300), (float)(-50 + rand.Next(240))), this.txCloseCloudC, 0.45f); this.axClouds[5] = new GlobalData.MainMenu.Cloud(new Vector2((float)(rand.Next(100) + 800), (float)(-50 + rand.Next(240))), this.txCloseCloudA, 0.5f); this.axClouds[6] = new GlobalData.MainMenu.Cloud(new Vector2((float)(rand.Next(640) - 50), (float)(134 + rand.Next(30))), this.txCloseCloudB, 0.55f); this.enFullScreenOption = Program.GetTheGame().xOptions.enFullScreen; this.iZoomOption = Program.GetTheGame().xOptions.iZoom; }