diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios.suo
Binary file axios.suo has changed
diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios/Axios_Windows.csproj.user
--- a/axios/Axios_Windows.csproj.user Tue Apr 17 23:34:46 2012 -0500
+++ b/axios/Axios_Windows.csproj.user Sat Apr 28 22:00:15 2012 -0500
@@ -1,6 +1,6 @@
- ShowAllFiles
+ ProjectFiles
\ No newline at end of file
diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios/ScreenSystem/GameScreen.cs
--- a/axios/ScreenSystem/GameScreen.cs Tue Apr 17 23:34:46 2012 -0500
+++ b/axios/ScreenSystem/GameScreen.cs Sat Apr 28 22:00:15 2012 -0500
@@ -41,7 +41,7 @@
HasVirtualStick = false;
HasCursor = false;
}
- protected bool HasCursor = false;
+ public bool HasCursor = false;
///
/// Normally when one screen is brought up over the top of another,
/// the first screen will transition off to make room for the new
diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios/ScreenSystem/InputState.cs
--- a/axios/ScreenSystem/InputState.cs Tue Apr 17 23:34:46 2012 -0500
+++ b/axios/ScreenSystem/InputState.cs Sat Apr 28 22:00:15 2012 -0500
@@ -14,6 +14,7 @@
using Microsoft.Xna.Framework.Input.Touch;
using FarseerPhysics.SamplesFramework;
using Microsoft.Xna.Framework.Graphics;
+using System;
namespace GameStateManagement
{
@@ -244,11 +245,32 @@
return new GamePadState(_stick, Vector2.Zero, 0f, 0f, _buttons.ToArray());
}
+ public void Draw()
+ {
+ if (_cursorIsVisible && _cursorIsValid)
+ {
+ _manager.SpriteBatch.Begin();
+ _manager.SpriteBatch.Draw(_cursorSprite.Texture, _cursor, null, Color.White, 0f, _cursorSprite.Origin, 1f, SpriteEffects.None, 0f);
+ _manager.SpriteBatch.End();
+ }
+#if WINDOWS_PHONE
+ if (_handleVirtualStick)
+ {
+ _manager.SpriteBatch.Begin();
+ _phoneA.Draw(_manager.SpriteBatch);
+ _phoneB.Draw(_manager.SpriteBatch);
+ _phoneStick.Draw(_manager.SpriteBatch);
+ _manager.SpriteBatch.End();
+ }
+#endif
+ }
+
///
/// Reads the latest state user input.
///
public void Update(GameTime gameTime)
{
+ PlayerIndex p;
_lastMouseState = _currentMouseState;
if (_handleVirtualStick)
{
@@ -297,8 +319,10 @@
Gestures.Clear();
while (TouchPanel.IsGestureAvailable)
{
+ //System.Diagnostics.Debugger.Break();
Gestures.Add(TouchPanel.ReadGesture());
}
+ //System.Diagnostics.Debugger.Break();
// Update cursor
Vector2 oldCursor = _cursor;
@@ -314,9 +338,16 @@
_cursor.X = _currentMouseState.X;
_cursor.Y = _currentMouseState.Y;
}
+
+ if (this.IsNewKeyPress(Keys.P, PlayerIndex.One, out p))
+ Console.WriteLine(_cursor.ToString());
+
_cursor.X = MathHelper.Clamp(_cursor.X, 0f, _viewport.Width);
_cursor.Y = MathHelper.Clamp(_cursor.Y, 0f, _viewport.Height);
+ if (this.IsNewKeyPress(Keys.P, PlayerIndex.One, out p))
+ Console.WriteLine(_cursor.ToString());
+
if (_cursorIsValid && oldCursor != _cursor)
{
_cursorMoved = true;
@@ -345,6 +376,9 @@
_cursorIsValid = false;
}
#endif
+
+ if (this.IsNewKeyPress(Keys.P, PlayerIndex.One, out p))
+ Console.WriteLine(_viewport.ToString());
}
diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios/ScreenSystem/MenuScreen.cs
--- a/axios/ScreenSystem/MenuScreen.cs Tue Apr 17 23:34:46 2012 -0500
+++ b/axios/ScreenSystem/MenuScreen.cs Sat Apr 28 22:00:15 2012 -0500
@@ -27,6 +27,9 @@
{
#region Fields
+ // the number of pixels to pad above and below menu entries for touch input
+ const int menuEntryPadding = 10;
+
private List menuEntries = new List();
int selectedEntry = 0;
string menuTitle;
@@ -62,6 +65,8 @@
public MenuScreen(string menuTitle)
{
this.menuTitle = menuTitle;
+ // menus generally only need Tap for menu selection
+ EnabledGestures = GestureType.Tap;
TransitionOnTime = TimeSpan.FromSeconds(0.5);
TransitionOffTime = TimeSpan.FromSeconds(0.5);
@@ -95,6 +100,19 @@
#region Handle Input
+ ///
+ /// Allows the screen to create the hit bounds for a particular menu entry.
+ ///
+ protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
+ {
+ // the hit bounds are the entire width of the screen, and the height of the entry
+ // with some additional padding above and below.
+ return new Rectangle(
+ 0,
+ (int)entry.Position.Y - menuEntryPadding,
+ ScreenManager.GraphicsDevice.Viewport.Width,
+ entry.GetHeight(this) + (menuEntryPadding * 2));
+ }
///
/// Responds to user input, changing the selected entry and accepting
@@ -107,8 +125,10 @@
// If we pass a null controlling player, the InputState helper returns to
// us which player actually provided the input. We pass that through to
// OnSelectEntry and OnCancel, so they can tell which player triggered them.
+
+
+#if WINDOWS || XBOX360
PlayerIndex playerIndex;
-
// Move to the previous menu entry?
if (menuUp.Evaluate(input, ControllingPlayer, out playerIndex))
{
@@ -135,6 +155,42 @@
{
OnCancel(playerIndex);
}
+#endif
+
+#if WINDOWS_PHONE
+ //selectedEntry = 1;
+
+ PlayerIndex player;
+ if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
+ {
+ OnCancel(player);
+ }
+
+ // look for any taps that occurred and select any entries that were tapped
+ foreach (GestureSample gesture in input.Gestures)
+ {
+ //System.Diagnostics.Debugger.Break();
+ if (gesture.GestureType == GestureType.Tap)
+ {
+ // convert the position to a Point that we can test against a Rectangle
+ Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);
+
+ // iterate the entries to see if any were tapped
+ for (int i = 0; i < menuEntries.Count; i++)
+ {
+ MenuEntry menuEntry = menuEntries[i];
+
+ if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
+ {
+ // select the entry. since gestures are only available on Windows Phone,
+ // we can safely pass PlayerIndex.One to all entries since there is only
+ // one player on Windows Phone.
+ OnSelectEntry(i, PlayerIndex.One);
+ }
+ }
+ }
+ }
+#endif
}
diff -r f000cc621ad997d73b69905fd80193e74a5132f0 -r 8995482f3489ed6eeea1bb9a07c75d60a4141462 axios/ScreenSystem/ScreenManager.cs
--- a/axios/ScreenSystem/ScreenManager.cs Tue Apr 17 23:34:46 2012 -0500
+++ b/axios/ScreenSystem/ScreenManager.cs Sat Apr 28 22:00:15 2012 -0500
@@ -144,7 +144,7 @@
spriteBatch = new SpriteBatch(GraphicsDevice);
font = content.Load("menufont");
blankTexture = Game.Content.Load("Materials/blank");
-
+ input.LoadContent();
// Tell each of the screens to load their content.
foreach (GameScreen screen in screens)
{
@@ -207,6 +207,8 @@
// give it a chance to handle input.
if (!otherScreenHasFocus)
{
+ input.ShowCursor = screen.HasCursor;
+ input.EnableVirtualStick = screen.HasVirtualStick;
screen.HandleInput(gameTime, input);
otherScreenHasFocus = true;
@@ -244,6 +246,7 @@
///
public override void Draw(GameTime gameTime)
{
+
foreach (GameScreen screen in screens)
{
if (screen.ScreenState == ScreenState.Hidden)
@@ -251,6 +254,7 @@
screen.Draw(gameTime);
}
+ input.Draw();
}