Skip to content

Commit

Permalink
v0.3.0.3: ignoring input if window isn't active
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis committed Jan 28, 2016
1 parent d8149ff commit f5c2dbf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.0.2")]
[assembly: AssemblyFileVersion("0.3.0.2")]
[assembly: AssemblyVersion("0.3.0.3")]
[assembly: AssemblyFileVersion("0.3.0.3")]
5 changes: 5 additions & 0 deletions Subsurface/Source/GameMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class GameMain : Game

public static GameMain Instance;

public static bool WindowActive
{
get { return Instance == null ? true : GameMain.Instance.IsActive; }
}

public static bool DebugDraw;

public static GraphicsDevice CurrGraphicsDevice;
Expand Down
28 changes: 14 additions & 14 deletions Subsurface/Source/PlayerInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static Vector2 MouseSpeed
{
get
{
return GameMain.Instance.IsActive ? MousePosition - new Vector2(oldMouseState.X, oldMouseState.Y) : Vector2.Zero;
return GameMain.WindowActive ? MousePosition - new Vector2(oldMouseState.X, oldMouseState.Y) : Vector2.Zero;
}
}

Expand All @@ -248,72 +248,72 @@ public static KeyboardState GetOldKeyboardState

public static int ScrollWheelSpeed
{
get { return GameMain.Instance.IsActive ? mouseState.ScrollWheelValue - oldMouseState.ScrollWheelValue : 0; }
get { return GameMain.WindowActive ? mouseState.ScrollWheelValue - oldMouseState.ScrollWheelValue : 0; }

}

public static bool LeftButtonDown()
{
return GameMain.Instance.IsActive && mouseState.LeftButton == ButtonState.Pressed;
return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Pressed;
}

public static bool LeftButtonReleased()
{
return GameMain.Instance.IsActive && mouseState.LeftButton == ButtonState.Released;
return GameMain.WindowActive && mouseState.LeftButton == ButtonState.Released;
}

public static bool LeftButtonClicked()
{
return (GameMain.Instance.IsActive &&
return (GameMain.WindowActive &&
oldMouseState.LeftButton == ButtonState.Pressed
&& mouseState.LeftButton == ButtonState.Released);
}

public static bool RightButtonDown()
{
return GameMain.Instance.IsActive && mouseState.RightButton == ButtonState.Pressed;
return GameMain.WindowActive && mouseState.RightButton == ButtonState.Pressed;
}

public static bool RightButtonClicked()
{
return (GameMain.Instance.IsActive &&
return (GameMain.WindowActive &&
oldMouseState.RightButton == ButtonState.Pressed
&& mouseState.RightButton == ButtonState.Released);
}

public static bool DoubleClicked()
{
return GameMain.Instance.IsActive && doubleClicked;
return GameMain.WindowActive && doubleClicked;
}

public static bool KeyHit(InputType inputType)
{
return GameMain.Instance.IsActive && GameMain.Config.KeyBind(inputType).IsHit();
return GameMain.WindowActive && GameMain.Config.KeyBind(inputType).IsHit();
}

public static bool KeyDown(InputType inputType)
{
return GameMain.Instance.IsActive && GameMain.Config.KeyBind(inputType).IsDown();
return GameMain.WindowActive && GameMain.Config.KeyBind(inputType).IsDown();
}

public static bool KeyUp(InputType inputType)
{
return GameMain.Instance.IsActive && !GameMain.Config.KeyBind(inputType).IsDown();
return GameMain.WindowActive && !GameMain.Config.KeyBind(inputType).IsDown();
}

public static bool KeyHit(Keys button)
{
return (GameMain.Instance.IsActive && oldKeyboardState.IsKeyDown(button) && keyboardState.IsKeyUp(button));
return (GameMain.WindowActive && oldKeyboardState.IsKeyDown(button) && keyboardState.IsKeyUp(button));
}

public static bool KeyDown(Keys button)
{
return (GameMain.Instance.IsActive && keyboardState.IsKeyDown(button));
return (GameMain.WindowActive && keyboardState.IsKeyDown(button));
}

public static bool KeyUp(Keys button)
{
return GameMain.Instance.IsActive && keyboardState.IsKeyUp(button);
return GameMain.WindowActive && keyboardState.IsKeyUp(button);
}

public static void Update(double deltaTime)
Expand Down
10 changes: 10 additions & 0 deletions Subsurface/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---------------------------------------------------------------------------------------------------------
v0.3.0.3
---------------------------------------------------------------------------------------------------------

- fixed selecting stairs and items outside the sub in editor
- fixed crashing when pressing the ''start'' button while no route is chosen in single player
- fixed fire syncing
- fixed another bug that crashed the game if in the lobby when a round ends
- camera keeps moving with the sub when typing into chatbox in spectator mode

---------------------------------------------------------------------------------------------------------
v0.3.0.2
---------------------------------------------------------------------------------------------------------
Expand Down
Binary file modified Subsurface_Solution.v12.suo
Binary file not shown.

0 comments on commit f5c2dbf

Please sign in to comment.