From e23503cd007430a84fe718634598f4f850cae726 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 4 Jan 2015 16:40:19 -0600 Subject: [PATCH] Adding Deactivate event for when the screen leaves focus Added flag to enable/disable moving camera with gamepad --- axios/Axios_settings.cs | 2 ++ axios/Engine/AxiosGameScreen.cs | 5 +++-- axios/ScreenSystem/InputState.cs | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/axios/Axios_settings.cs b/axios/Axios_settings.cs index cbc7ab9..76a4b4d 100644 --- a/axios/Axios_settings.cs +++ b/axios/Axios_settings.cs @@ -140,6 +140,8 @@ * - Adding dispose methods to AxiosFile objects * - Adding extended log to AxiosLog * - Fixing issue in CommandConsole where the first line would not be displayed + * - Adding Deactivate event for when the screen leaves focus + * - Added flag to enable/disable moving camera with gamepad * */ #endregion diff --git a/axios/Engine/AxiosGameScreen.cs b/axios/Engine/AxiosGameScreen.cs index 223919b..6fa516c 100644 --- a/axios/Engine/AxiosGameScreen.cs +++ b/axios/Engine/AxiosGameScreen.cs @@ -330,9 +330,10 @@ namespace Axios.Engine public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { - if (otherScreenHasFocus) + if (otherScreenHasFocus && !screenHidden) { screenHidden = true; + this.Deactivate(); } if (screenHidden && !otherScreenHasFocus) @@ -508,7 +509,6 @@ namespace Axios.Engine { //this.IsExiting = true; //System.Diagnostics.Debugger.Break(); - base.Deactivate(); ScreenState = GameStateManagement.ScreenState.TransitionOff; AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG); foreach (AxiosGameObject g in _gameObjects) @@ -538,6 +538,7 @@ namespace Axios.Engine } #endif + } diff --git a/axios/ScreenSystem/InputState.cs b/axios/ScreenSystem/InputState.cs index 5ad4586..15c2ad9 100644 --- a/axios/ScreenSystem/InputState.cs +++ b/axios/ScreenSystem/InputState.cs @@ -104,6 +104,7 @@ namespace GameStateManagement * -- Nathan Adams [adamsna@datanethost.net] - 4/12/2012 */ + public bool MoveCursorWithController = false; /* * Adding variables for the cursor @@ -391,7 +392,7 @@ namespace GameStateManagement // Update cursor Vector2 oldCursor = _cursor; - if (CurrentGamePadStates[0].IsConnected && CurrentGamePadStates[0].ThumbSticks.Left != Vector2.Zero) + if (CurrentGamePadStates[0].IsConnected && CurrentGamePadStates[0].ThumbSticks.Left != Vector2.Zero && MoveCursorWithController) { Vector2 temp = CurrentGamePadStates[0].ThumbSticks.Left; _cursor += temp * new Vector2(300f, -300f) * (float)gameTime.ElapsedGameTime.TotalSeconds;