/// <summary> /// initialize verything /// required to run this /// </summary> /// <param name="contentManager">the XNA content Manager</param> /// <param name="graphicDeviceManager">the XNA graphic manager</param> /// /// <param name="displayModes">possible display modes</param> public void Run(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window, Microsoft.Xna.Framework.Game game) { this.Properties = new GameProperties(contentManager, graphicDeviceManager, window); // load bare media to initialize loadingscreen // Cursor textures FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorRegular, "Texture/Cursor/Default"); FenrirGame.Instance.Properties.ContentManager.AddTextureToLibrary(DataIdentifier.textureCursorCamera, "Texture/Cursor/Camera"); this.game = game; this.renderer = new Renderer(); this.cursor = new Cursor(); this.menuLoader = new LoadingScreen.LoadMenu(); this.gameLoader = new LoadingScreen.LoadGame(); }
/// <summary> /// Setup the game properties /// </summary> /// <param name="contentManager">the XNA content manager to be used</param> /// <param name="graphicDeviceManager">the XNA graphic manager to be used</param> public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window) { // load game properties System.Xml.XmlDocument config = new System.Xml.XmlDocument(); config.Load(@"Content/config.xml"); // try resolution try { graphicDeviceManager.PreferredBackBufferWidth = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText); graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText); Screen screen = Screen.PrimaryScreen; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2); } catch (Exception) { graphicDeviceManager.PreferredBackBufferWidth = 1280; graphicDeviceManager.PreferredBackBufferHeight = 720; } // try fullscreen try { int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText); if (fullscreen == 1) { Screen screen = Screen.PrimaryScreen; window.IsBorderless = true; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y); graphicDeviceManager.PreferredBackBufferWidth = screen.Bounds.Width; graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height; this.isFullscreen = true; } else { this.isFullscreen = false; } } catch (Exception) { } graphicDeviceManager.ApplyChanges(); // try language settings try { this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText; } catch (Exception) { } this.currentGameState = GameState.LoadMenu; this.input = new InputHandler(); this.contentManager = new Helper.ContentManager(contentManager); this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice); this.graphicDeviceManager = graphicDeviceManager; this.gameWindow = window; System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open)); this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length)); }
/// <summary> /// Setup the game properties /// </summary> /// <param name="contentManager">the XNA content manager to be used</param> /// <param name="graphicDeviceManager">the XNA graphic manager to be used</param> public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window) { // load game properties System.Xml.XmlDocument config = new System.Xml.XmlDocument(); config.Load(@"Content/config.xml"); // try resolution try { graphicDeviceManager.PreferredBackBufferWidth = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText); graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText); Screen screen = Screen.PrimaryScreen; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2); } catch (Exception) { graphicDeviceManager.PreferredBackBufferWidth = 1280; graphicDeviceManager.PreferredBackBufferHeight = 720; } // try fullscreen try { int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText); if (fullscreen == 1) { Screen screen = Screen.PrimaryScreen; window.IsBorderless = true; window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y); graphicDeviceManager.PreferredBackBufferWidth = screen.Bounds.Width; graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height; this.isFullscreen = true; } else { this.isFullscreen = false; } } catch (Exception) { } graphicDeviceManager.ApplyChanges(); // try language settings try { this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText; } catch(Exception){ } this.currentGameState = GameState.LoadMenu; this.input = new InputHandler(); this.contentManager = new Helper.ContentManager(contentManager); this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice); this.graphicDeviceManager = graphicDeviceManager; this.gameWindow = window; System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open)); this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length)); }