public GameManager() { CVars.Initialize(); ProcessManager = new ProcessManager(); Graphics = new GraphicsDeviceManager(this); Graphics.GraphicsProfile = GraphicsProfile.HiDef; Graphics.PreferMultiSampling = false; Content.RootDirectory = "Content"; Graphics.PreferredBackBufferWidth = CVars.Get <int>("initial_window_width"); Graphics.PreferredBackBufferHeight = CVars.Get <int>("initial_window_height"); Window.AllowUserResizing = true; Window.ClientSizeChanged += Window_ClientSizeChanged; IsFixedTimeStep = CVars.Get <bool>("update_xna_fixed"); #if DEBUG StatisticsProfiler = new StatisticsProfiler(); #endif Console.WriteLine(typeof(UIWidgetsReader).AssemblyQualifiedName); }
protected override void Draw(GameTime gameTime) { #if DEBUG StatisticsProfiler.BeginDraw(gameTime); #endif Graphics.GraphicsDevice.Clear(Color.Black); GraphicsDevice.RasterizerState = RasterizerState.CullNone; foreach (Process process in ProcessManager.Processes) { RenderProcess renderProcess = process as RenderProcess; if (renderProcess != null) { renderProcess.Render((float)gameTime.ElapsedGameTime.TotalSeconds * CVars.Get <float>("debug_update_time_scale") * (CVars.Get <bool>("debug_pause_game_updates") ? 0 : 1)); } } #if DEBUG StatisticsProfiler.EndDraw(); #endif base.Draw(gameTime); }
protected override void Update(GameTime gameTime) { #if DEBUG StatisticsProfiler.BeginUpdate(gameTime); #endif if (!CVars.Get <bool>("debug_pause_game_updates")) { Update((float)gameTime.ElapsedGameTime.TotalSeconds * CVars.Get <float>("debug_update_time_scale")); } #if DEBUG StatisticsProfiler.EndUpdate(); #endif base.Update(gameTime); }
public bool Handle(IEvent evt) { if (evt is StepGameUpdateEvent) { Update(CVars.Get <float>("debug_game_step_period")); } if (evt is GameShutdownEvent) { Exit(); } if (evt is ReloadDisplayOptionsEvent) { ReloadDisplayOptions(); } return(false); }
private void ReloadDisplayOptions() { bool applyChanges = false; DisplayModeCollection displayModes = Graphics.GraphicsDevice.Adapter.SupportedDisplayModes; // Windowed/Borderless/Fullscreen if (CVars.Get <bool>("display_fullscreen")) { if (!Graphics.IsFullScreen) { if (CVars.Get <int>("display_fullscreen_width") < 0 || CVars.Get <int>("display_fullscreen_height") < 0) { CVars.Get <int>("display_fullscreen_width") = Graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width; CVars.Get <int>("display_fullscreen_height") = Graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height; CVars.Save(); } Graphics.PreferredBackBufferWidth = CVars.Get <int>("display_fullscreen_width"); Graphics.PreferredBackBufferHeight = CVars.Get <int>("display_fullscreen_height"); Graphics.IsFullScreen = true; Graphics.HardwareModeSwitch = true; applyChanges = true; } CVars.Get <bool>("display_borderless") = false; CVars.Get <bool>("display_windowed") = false; CVars.Save(); } else if (CVars.Get <bool>("display_borderless")) { if (!Graphics.IsFullScreen) { Graphics.IsFullScreen = true; Graphics.HardwareModeSwitch = false; applyChanges = true; } CVars.Get <bool>("display_windowed") = false; CVars.Save(); } else { if (Graphics.IsFullScreen) { Graphics.IsFullScreen = false; } Graphics.HardwareModeSwitch = false; applyChanges = true; CVars.Get <bool>("display_windowed") = true; CVars.Save(); } // V-sync if (Graphics.SynchronizeWithVerticalRetrace != CVars.Get <bool>("display_vsync")) { Graphics.SynchronizeWithVerticalRetrace = CVars.Get <bool>("display_vsync"); applyChanges = true; } if (applyChanges) { Graphics.ApplyChanges(); } }