protected override void Initialize() { Window.Title = "Asciipocalypse"; resolutions = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes .Where((DisplayMode dm) => dm.Width >= 1000 && dm.Height >= 400).ToArray(); bool firstRun = false; if (!GameSave.LoadOptions(graphics)) { graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; graphics.IsFullScreen = true; graphics.ApplyChanges(); firstRun = true; } int charsX = (int)Math.Floor((double)graphics.PreferredBackBufferWidth / Console.FONT_SIZE); int charsY = (int)Math.Floor((double)graphics.PreferredBackBufferHeight / Console.FONT_SIZE); console = new Console(charsX, charsY); rasterizer = new Rasterizer(console); HUD = new HUD(this, console); menuGroup = new MainMenuGroup() { NewGame = () => { ResetGame(Difficulty); gameState = GameState.Game; }, LoadGame = () => { try { LoadGame(); gameState = GameState.Game; } catch (GameSave.BadVersionException e) { menuGroup.ToggleBadVersionPopup(e.SaveVersionID); } }, ExitGame = Exit, ChangeFullScreen = ChangeFullScreen, ChangeResolution = (int id) => { ChangeResolution(resolutions[id].Width, resolutions[id].Height); }, ContinueEntryPred = () => { return(!SaveExists); }, SaveOptions = () => { GameSave.SaveOptions(graphics); } }; menuGroup.Init(firstRun); base.Initialize(); }
private void ChangeResolution(int resX, int resY) { int charsX = (int)Math.Floor((double)resX / Console.FONT_SIZE); int charsY = (int)Math.Floor((double)resY / Console.FONT_SIZE); console = new Console(charsX, charsY); rasterizer = new Rasterizer(console); HUD = new HUD(this, console); graphics.PreferredBackBufferWidth = resX; graphics.PreferredBackBufferHeight = resY; graphics.ApplyChanges(); }