Initial tests are looking good, cursor seems to be the only thing that doesn't work.
Tested with Axios Tennis and the new menu looks pretty slick. --HG-- branch : axios-newgsm
This commit is contained in:
parent
7cc7e9130c
commit
bf3950b0c5
@ -235,6 +235,7 @@
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="system.data.linq, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
@ -243,7 +244,7 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
|
@ -242,7 +242,6 @@
|
||||
<Compile Include="ScreenSystem\GameScreen.cs" />
|
||||
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
||||
<Compile Include="ScreenSystem\InputAction.cs" />
|
||||
<Compile Include="ScreenSystem\InputHelper.cs" />
|
||||
<Compile Include="Engine\AxiosGameScreen.cs" />
|
||||
<Compile Include="ScreenSystem\InputState.cs" />
|
||||
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
||||
@ -274,7 +273,7 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
<PostBuildEvent>if not exist "$(TargeDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -191,7 +191,6 @@
|
||||
<Compile Include="ScreenSystem\GameScreen.cs" />
|
||||
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
||||
<Compile Include="ScreenSystem\InputAction.cs" />
|
||||
<Compile Include="ScreenSystem\InputHelper.cs" />
|
||||
<Compile Include="ScreenSystem\InputState.cs" />
|
||||
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
||||
<Compile Include="ScreenSystem\LoadingScreen.cs" />
|
||||
@ -238,7 +237,7 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
||||
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
|
@ -336,7 +336,7 @@ namespace Axios.Engine
|
||||
|
||||
public override void HandleInput(GameTime gameTime, InputState input)
|
||||
{
|
||||
base.HandleInput(input, gameTime);
|
||||
base.HandleInput(gameTime, input);
|
||||
|
||||
foreach (AxiosGameObject g in _gameObjects.ToList())
|
||||
g.HandleInput(this, input, gameTime);
|
||||
@ -347,7 +347,7 @@ namespace Axios.Engine
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
base.UnloadContent();
|
||||
base.Deactivate();
|
||||
//AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
||||
foreach (AxiosGameObject g in _gameObjects)
|
||||
g.UnloadContent(this);
|
||||
|
@ -22,7 +22,7 @@ namespace GameStateManagement
|
||||
/// It draws a background image that remains fixed in place regardless
|
||||
/// of whatever transitions the screens on top of it may be doing.
|
||||
/// </summary>
|
||||
class BackgroundScreen : GameScreen
|
||||
public class BackgroundScreen : GameScreen
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -35,6 +35,12 @@ namespace GameStateManagement
|
||||
/// </summary>
|
||||
public abstract class GameScreen
|
||||
{
|
||||
|
||||
public GameScreen()
|
||||
{
|
||||
HasVirtualStick = false;
|
||||
HasCursor = false;
|
||||
}
|
||||
protected bool HasCursor = false;
|
||||
/// <summary>
|
||||
/// Normally when one screen is brought up over the top of another,
|
||||
@ -50,7 +56,7 @@ namespace GameStateManagement
|
||||
}
|
||||
|
||||
bool isPopup = false;
|
||||
|
||||
public bool HasVirtualStick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates how long the screen takes to
|
||||
|
@ -1,11 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework.Input.Touch;
|
||||
using FarseerPhysics.SamplesFramework;
|
||||
using GameStateManagement;
|
||||
|
||||
namespace FarseerPhysics.SamplesFramework
|
||||
namespace FarseerPhysics.SamplesFramework2
|
||||
{
|
||||
/// <summary>
|
||||
/// an enum of all available mouse buttons.
|
||||
@ -147,13 +149,13 @@ namespace FarseerPhysics.SamplesFramework
|
||||
public void LoadContent()
|
||||
{
|
||||
|
||||
_cursorSprite = new Sprite(_manager.Content.Load<Texture2D>("Common/cursor"));
|
||||
_cursorSprite = new Sprite(_manager.Game.Content.Load<Texture2D>("Common/cursor"));
|
||||
#if WINDOWS_PHONE
|
||||
// virtual stick content
|
||||
_phoneStick = new VirtualStick(_manager.Content.Load<Texture2D>("Common/socket"),
|
||||
_manager.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
|
||||
_phoneStick = new VirtualStick(_manager.Game.Content.Load<Texture2D>("Common/socket"),
|
||||
_manager.Game.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
|
||||
|
||||
Texture2D temp = _manager.Content.Load<Texture2D>("Common/buttons");
|
||||
Texture2D temp = _manager.Game.Content.Load<Texture2D>("Common/buttons");
|
||||
_phoneA = new VirtualButton(temp, new Vector2(695f, 380f), new Rectangle(0, 0, 40, 40), new Rectangle(0, 40, 40, 40));
|
||||
_phoneB = new VirtualButton(temp, new Vector2(745f, 360f), new Rectangle(40, 0, 40, 40), new Rectangle(40, 40, 40, 40));
|
||||
#endif
|
||||
|
@ -432,6 +432,28 @@ namespace GameStateManagement
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewKeyRelease(Keys key, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
|
||||
{
|
||||
if (controllingPlayer.HasValue)
|
||||
{
|
||||
// Read input from the specified player.
|
||||
playerIndex = controllingPlayer.Value;
|
||||
|
||||
int i = (int)playerIndex;
|
||||
|
||||
return (CurrentKeyboardStates[i].IsKeyUp(key) &&
|
||||
LastKeyboardStates[i].IsKeyDown(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Accept input from any player.
|
||||
return (IsNewKeyRelease(key, PlayerIndex.One, out playerIndex) ||
|
||||
IsNewKeyRelease(key, PlayerIndex.Two, out playerIndex) ||
|
||||
IsNewKeyRelease(key, PlayerIndex.Three, out playerIndex) ||
|
||||
IsNewKeyRelease(key, PlayerIndex.Four, out playerIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Helper for checking if a button was newly pressed during this update.
|
||||
@ -461,6 +483,28 @@ namespace GameStateManagement
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewButtonRelease(Buttons button, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
|
||||
{
|
||||
if (controllingPlayer.HasValue)
|
||||
{
|
||||
// Read input from the specified player.
|
||||
playerIndex = controllingPlayer.Value;
|
||||
|
||||
int i = (int)playerIndex;
|
||||
|
||||
return (CurrentGamePadStates[i].IsButtonUp(button) &&
|
||||
LastGamePadStates[i].IsButtonDown(button));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Accept input from any player.
|
||||
return (IsNewButtonRelease(button, PlayerIndex.One, out playerIndex) ||
|
||||
IsNewButtonRelease(button, PlayerIndex.Two, out playerIndex) ||
|
||||
IsNewButtonRelease(button, PlayerIndex.Three, out playerIndex) ||
|
||||
IsNewButtonRelease(button, PlayerIndex.Four, out playerIndex));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNewVirtualButtonPress(Buttons button)
|
||||
{
|
||||
return (_lastVirtualState.IsButtonUp(button) &&
|
||||
|
@ -22,7 +22,7 @@ namespace GameStateManagement
|
||||
/// entries in different ways. This also provides an event that will be raised
|
||||
/// when the menu entry is selected.
|
||||
/// </summary>
|
||||
class MenuEntry
|
||||
public class MenuEntry
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -23,11 +23,11 @@ namespace GameStateManagement
|
||||
/// Base class for screens that contain a menu of options. The user can
|
||||
/// move up and down to select an entry, or cancel to back out of the screen.
|
||||
/// </summary>
|
||||
abstract class MenuScreen : GameScreen
|
||||
public class MenuScreen : GameScreen
|
||||
{
|
||||
#region Fields
|
||||
|
||||
List<MenuEntry> menuEntries = new List<MenuEntry>();
|
||||
private List<MenuEntry> menuEntries = new List<MenuEntry>();
|
||||
int selectedEntry = 0;
|
||||
string menuTitle;
|
||||
|
||||
@ -87,6 +87,12 @@ namespace GameStateManagement
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddMenuItem(string name)
|
||||
{
|
||||
|
||||
menuEntries.Add(new MenuEntry(name));
|
||||
}
|
||||
|
||||
#region Handle Input
|
||||
|
||||
|
||||
|
@ -185,7 +185,8 @@ namespace GameStateManagement
|
||||
HandleCursor(input);
|
||||
}
|
||||
|
||||
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
|
||||
PlayerIndex i;
|
||||
if (input.IsNewButtonPress(Buttons.Back, PlayerIndex.One, out i) || input.IsNewKeyPress(Keys.Escape, PlayerIndex.One, out i))
|
||||
{
|
||||
if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
|
||||
{ //Give the screens a chance to transition
|
||||
@ -195,7 +196,7 @@ namespace GameStateManagement
|
||||
|
||||
}
|
||||
}
|
||||
base.HandleInput(input, gameTime);
|
||||
base.HandleInput(gameTime, input);
|
||||
}
|
||||
|
||||
public virtual void HandleCursor(InputState input)
|
||||
@ -203,7 +204,7 @@ namespace GameStateManagement
|
||||
PlayerIndex player;
|
||||
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
|
||||
|
||||
if ((input.IsNewButtonPress(Buttons.A) ||
|
||||
if ((input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out player) ||
|
||||
input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
|
||||
_fixedMouseJoint == null)
|
||||
{
|
||||
@ -220,7 +221,7 @@ namespace GameStateManagement
|
||||
|
||||
|
||||
if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
|
||||
input.IsNewMouseButtonRelease(MouseButtons.LeftButton, ControllingPlayer.Value, out player)) &&
|
||||
input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
|
||||
_fixedMouseJoint != null)
|
||||
{
|
||||
World.RemoveJoint(_fixedMouseJoint);
|
||||
@ -234,32 +235,32 @@ namespace GameStateManagement
|
||||
|
||||
}
|
||||
|
||||
private void HandleCamera(InputHelper input, GameTime gameTime)
|
||||
private void HandleCamera(InputState input, GameTime gameTime)
|
||||
{
|
||||
Vector2 camMove = Vector2.Zero;
|
||||
|
||||
|
||||
if (input.KeyboardState.IsKeyDown(Keys.Up))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up))
|
||||
{
|
||||
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.Down))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down))
|
||||
{
|
||||
camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.Left))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
|
||||
{
|
||||
camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.Right))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
|
||||
{
|
||||
camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.PageUp))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageUp))
|
||||
{
|
||||
Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.PageDown))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageDown))
|
||||
{
|
||||
Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
||||
}
|
||||
@ -267,19 +268,20 @@ namespace GameStateManagement
|
||||
{
|
||||
Camera.MoveCamera(camMove);
|
||||
}
|
||||
if (input.IsNewKeyPress(Keys.Home))
|
||||
PlayerIndex i;
|
||||
if (input.IsNewKeyPress(Keys.Home, PlayerIndex.One, out i))
|
||||
{
|
||||
Camera.ResetCamera();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void HandleUserAgent(InputHelper input)
|
||||
private void HandleUserAgent(InputState input)
|
||||
{
|
||||
|
||||
Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X,
|
||||
-input.GamePadState.ThumbSticks.Right.Y);
|
||||
float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left);
|
||||
Vector2 force = _agentForce * new Vector2(input.CurrentGamePadStates[0].ThumbSticks.Right.X,
|
||||
-input.CurrentGamePadStates[0].ThumbSticks.Right.Y);
|
||||
float torque = _agentTorque * (input.CurrentGamePadStates[0].Triggers.Right - input.CurrentGamePadStates[0].Triggers.Left);
|
||||
|
||||
_userAgent.ApplyForce(force);
|
||||
_userAgent.ApplyTorque(torque);
|
||||
@ -289,27 +291,27 @@ namespace GameStateManagement
|
||||
force = Vector2.Zero;
|
||||
torque = 0;
|
||||
|
||||
if (input.KeyboardState.IsKeyDown(Keys.A))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.A))
|
||||
{
|
||||
force += new Vector2(-forceAmount, 0);
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.S))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.S))
|
||||
{
|
||||
force += new Vector2(0, forceAmount);
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.D))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.D))
|
||||
{
|
||||
force += new Vector2(forceAmount, 0);
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.W))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.W))
|
||||
{
|
||||
force += new Vector2(0, -forceAmount);
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.Q))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Q))
|
||||
{
|
||||
torque -= _agentTorque;
|
||||
}
|
||||
if (input.KeyboardState.IsKeyDown(Keys.E))
|
||||
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.E))
|
||||
{
|
||||
torque += _agentTorque;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace GameStateManagement
|
||||
/// Custom event argument which includes the index of the player who
|
||||
/// triggered the event. This is used by the MenuEntry.Selected event.
|
||||
/// </summary>
|
||||
class PlayerIndexEventArgs : EventArgs
|
||||
public class PlayerIndexEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
|
@ -139,11 +139,11 @@ namespace GameStateManagement
|
||||
protected override void LoadContent()
|
||||
{
|
||||
// Load content belonging to the screen manager.
|
||||
ContentManager content = Game.Content;
|
||||
|
||||
ContentManager content = new ContentManager(this.Game.Services, "Content/Fonts");
|
||||
_spriteFonts = new SpriteFonts(content);
|
||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
font = content.Load<SpriteFont>("menufont");
|
||||
blankTexture = content.Load<Texture2D>("blank");
|
||||
blankTexture = Game.Content.Load<Texture2D>("Materials/blank");
|
||||
|
||||
// Tell each of the screens to load their content.
|
||||
foreach (GameScreen screen in screens)
|
||||
@ -177,7 +177,7 @@ namespace GameStateManagement
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
// Read the keyboard and gamepad.
|
||||
input.Update();
|
||||
input.Update(gameTime);
|
||||
|
||||
// Make a copy of the master screen list, to avoid confusion if
|
||||
// the process of updating one screen adds or removes others.
|
||||
|
@ -11,9 +11,9 @@ namespace FarseerPhysics.SamplesFramework
|
||||
|
||||
public SpriteFonts(ContentManager contentManager)
|
||||
{
|
||||
MenuSpriteFont = contentManager.Load<SpriteFont>("Fonts/menuFont");
|
||||
FrameRateCounterFont = contentManager.Load<SpriteFont>("Fonts/frameRateCounterFont");
|
||||
DetailsFont = contentManager.Load<SpriteFont>("Fonts/detailsFont");
|
||||
MenuSpriteFont = contentManager.Load<SpriteFont>("menuFont");
|
||||
FrameRateCounterFont = contentManager.Load<SpriteFont>("frameRateCounterFont");
|
||||
DetailsFont = contentManager.Load<SpriteFont>("detailsFont");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user