public static GameSettings DefaultSettings() { GameSettings settings = new GameSettings(); #if!DEBUG settings._fullScreen = false; settings._windowWidth = 800; settings._windowHeight = 480; settings._preferMultiSampling = false; settings._skinColor = Color.HotPink; #else settings._fullScreen = false; settings._windowWidth = 1024; settings._windowHeight = 768; settings._preferMultiSampling = true; settings._skinColor = Color.Violet; #endif return settings; }
public static GameSettings LoadData() { const string FileName = @"Settings\config.eec"; GameSettings settings; if (!File.Exists(FileName)) { settings = DefaultSettings(); settings.SaveData(); return settings; } else { FileStream fs = null; settings = new GameSettings(); fs = File.OpenRead(FileName); using (BinaryReader br = new BinaryReader(fs)) { try { settings._windowWidth = br.ReadInt32(); settings._windowHeight = br.ReadInt32(); settings._fullScreen = br.ReadBoolean(); settings._preferMultiSampling = br.ReadBoolean(); byte r, g, b; r = br.ReadByte(); g = br.ReadByte(); b = br.ReadByte(); settings._skinColor = new Color(r, g, b); } catch { br.Close(); fs.Close(); fs.Dispose(); } } return settings; } }