Adding default Font if one is not provided
Adding a flag to AxiosGameScreen to allow a developer to disable input across everything if the console is visible/active. Changing Deactivate to Unload because Unload is what is gets called when a screen is told to go away --HG-- branch : xnacc-integration
This commit is contained in:
		| @@ -92,6 +92,7 @@ | |||||||
|  * - Changing AxiosTitleFile.GetStream() to return Stream instead of FileStream |  * - Changing AxiosTitleFile.GetStream() to return Stream instead of FileStream | ||||||
|  * - Changing IAxiosFile.GetStream() to return Stream instead of FileStream |  * - Changing IAxiosFile.GetStream() to return Stream instead of FileStream | ||||||
|  * - Adding support for XNACC |  * - Adding support for XNACC | ||||||
|  |  * - Fixed a bug where cleanup actions were being performed in Deactivate instead of Unload in AxiosGameScreen | ||||||
|  *  |  *  | ||||||
|  */ |  */ | ||||||
| #endregion | #endregion | ||||||
|   | |||||||
| @@ -20,27 +20,40 @@ using Microsoft.Xna.Framework; | |||||||
|  |  | ||||||
| namespace Axios.Engine | namespace Axios.Engine | ||||||
| { | { | ||||||
|     class AxiosCommandConsole : CommandConsoleBase |     public class AxiosCommandConsole : CommandConsoleBase | ||||||
|     { |     { | ||||||
|  |         //private AxiosGameScreen _gameScreen; | ||||||
|         public AxiosCommandConsole(AxiosGameScreen gameScreen) |         public AxiosCommandConsole(AxiosGameScreen gameScreen) | ||||||
|             : base(gameScreen.ScreenManager.Game) |             : base(gameScreen.ScreenManager.Game) | ||||||
|         { |         { | ||||||
|  |             //_gameScreen = gameScreen; | ||||||
|             Keyboard = gameScreen.ScreenManager.InputState; |             Keyboard = gameScreen.ScreenManager.InputState; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public AxiosCommandConsole(AxiosGameScreen gameScreen, SpriteFont font) |         public AxiosCommandConsole(AxiosGameScreen gameScreen, SpriteFont font) | ||||||
|             : base(gameScreen.ScreenManager.Game, font) |             : base(gameScreen.ScreenManager.Game, font) | ||||||
|         { |         { | ||||||
|  |             //_gameScreen = gameScreen; | ||||||
|             Keyboard = gameScreen.ScreenManager.InputState; |             Keyboard = gameScreen.ScreenManager.InputState; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         protected override void LoadContent() |         protected void LoadDefault() | ||||||
|         { |         { | ||||||
|             FadeColor = Color.White * 0.5f; |             FadeColor = Color.White * 0.5f; | ||||||
|             Texture2D tmp = new Texture2D(GraphicsDevice, 1, 1); |             Texture2D tmp = new Texture2D(GraphicsDevice, 1, 1); | ||||||
|             tmp.SetData<Color>(new Color[] { Color.Black }); |             tmp.SetData<Color>(new Color[] { Color.Black }); | ||||||
|             FadeImage = tmp; |             FadeImage = tmp; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         public override void LoadContent(ContentManager content) | ||||||
|  |         { | ||||||
|  |             base.LoadContent(content); | ||||||
|  |         } | ||||||
|  |         protected override void LoadContent() | ||||||
|  |         { | ||||||
|  |             if (Font == null) | ||||||
|  |                 Font = Game.Content.Load<SpriteFont>("Console"); | ||||||
|             base.LoadContent(); |             base.LoadContent(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -53,8 +66,9 @@ using System.Text; | |||||||
| using Microsoft.Xna.Framework.Graphics; | using Microsoft.Xna.Framework.Graphics; | ||||||
| namespace Axios.Engine | namespace Axios.Engine | ||||||
| { | { | ||||||
|     class AxiosCommandConsole |     public class AxiosCommandConsole | ||||||
|     { |     { | ||||||
|  |         public bool Active = false; | ||||||
|         public AxiosCommandConsole(AxiosGameScreen gameScreen) |         public AxiosCommandConsole(AxiosGameScreen gameScreen) | ||||||
|         { |         { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,6 +43,14 @@ namespace Axios.Engine | |||||||
|  |  | ||||||
|         AxiosCommandConsole _console = null; |         AxiosCommandConsole _console = null; | ||||||
|  |  | ||||||
|  |         protected bool AllowKeyboardWhileConsoleIsActive = false; | ||||||
|  |  | ||||||
|  |         public AxiosCommandConsole Console | ||||||
|  |         { | ||||||
|  |             get { return _console; } | ||||||
|  |             private set { _console = value; } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         public AxiosGameScreen() |         public AxiosGameScreen() | ||||||
|             : base() |             : base() | ||||||
|         { |         { | ||||||
| @@ -110,6 +118,7 @@ namespace Axios.Engine | |||||||
|                 _console = (AxiosCommandConsole)obj; |                 _console = (AxiosCommandConsole)obj; | ||||||
| #if WINDOWS | #if WINDOWS | ||||||
|                 ScreenManager.Game.Components.Add(_console); |                 ScreenManager.Game.Components.Add(_console); | ||||||
|  |                 _console.LoadContent(ScreenManager.Game.Content); | ||||||
| #endif | #endif | ||||||
|             } |             } | ||||||
|             if (obj is AxiosGameObject || obj is AxiosUIObject || obj is AxiosTimer) |             if (obj is AxiosGameObject || obj is AxiosUIObject || obj is AxiosTimer) | ||||||
| @@ -230,7 +239,7 @@ namespace Axios.Engine | |||||||
|         public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) |         public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) | ||||||
|         { |         { | ||||||
|             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); |             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); | ||||||
|  |              | ||||||
|             if (this._objectstoremove.Count > 0) |             if (this._objectstoremove.Count > 0) | ||||||
|             { |             { | ||||||
|                 List<AxiosGameObject> list = this._objectstoremove.ToList<AxiosGameObject>(); |                 List<AxiosGameObject> list = this._objectstoremove.ToList<AxiosGameObject>(); | ||||||
| @@ -379,17 +388,21 @@ namespace Axios.Engine | |||||||
|  |  | ||||||
|         public override void HandleInput(GameTime gameTime, InputState input) |         public override void HandleInput(GameTime gameTime, InputState input) | ||||||
|         { |         { | ||||||
|             base.HandleInput(gameTime, input); |             if ((AllowKeyboardWhileConsoleIsActive && _console.Active) || !_console.Active) | ||||||
|  |             { | ||||||
|  |                 base.HandleInput(gameTime, input); | ||||||
|  |  | ||||||
|             foreach (AxiosGameObject g in _gameObjects.ToList()) |                 foreach (AxiosGameObject g in _gameObjects.ToList()) | ||||||
|                 g.HandleInput(this, input, gameTime); |                     g.HandleInput(this, input, gameTime); | ||||||
|  |  | ||||||
|             foreach (AxiosUIObject g in _uiobjects.ToList()) |                 foreach (AxiosUIObject g in _uiobjects.ToList()) | ||||||
|                 g.HandleInput(this, input, gameTime); |                     g.HandleInput(this, input, gameTime); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public override void Deactivate() |         public override void Unload() | ||||||
|         { |         { | ||||||
|  |             //System.Diagnostics.Debugger.Break(); | ||||||
|             base.Deactivate(); |             base.Deactivate(); | ||||||
|             AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG); |             AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG); | ||||||
|             foreach (AxiosGameObject g in _gameObjects) |             foreach (AxiosGameObject g in _gameObjects) | ||||||
| @@ -409,6 +422,13 @@ namespace Axios.Engine | |||||||
|             //AxiosIsolatedFile f = new AxiosIsolatedFile("log.log"); |             //AxiosIsolatedFile f = new AxiosIsolatedFile("log.log"); | ||||||
|             //f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append); |             //f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append); | ||||||
|             //CleanUp(); |             //CleanUp(); | ||||||
|  | #if WINDOWS | ||||||
|  |             if (_console != null) | ||||||
|  |             { | ||||||
|  |                 ScreenManager.Game.Components.Remove(_console); | ||||||
|  |                 _console.Dispose(); | ||||||
|  |             } | ||||||
|  | #endif | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user