axiosengine 

axiosengine Commit Details


Date:2012-04-28 22:00:15 (12 years 5 months ago)
Author:nathan@daedalus
Branch:master
Commit:de79e014ad283a7f42109f6c2c2bcf44fd132113
Parents: bf3950b0c5f845ca02bab576147d1410f1c2ae0c
Message:Final commits for new GSM.

--HG--
branch : axios-newgsm
extra : close : 1
Changes:

File differences

axios/Axios_Windows.csproj.user
11
22
33
4
4
55
66
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
axios/ScreenSystem/GameScreen.cs
4141
4242
4343
44
44
4545
4646
4747
HasVirtualStick = false;
HasCursor = false;
}
protected bool HasCursor = false;
public bool HasCursor = false;
/// <summary>
/// Normally when one screen is brought up over the top of another,
/// the first screen will transition off to make room for the new
axios/ScreenSystem/InputState.cs
1414
1515
1616
17
1718
1819
1920
......
244245
245246
246247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
247268
248269
249270
250271
251272
273
252274
253275
254276
......
297319
298320
299321
322
300323
301324
325
302326
303327
304328
......
314338
315339
316340
341
342
343
344
317345
318346
319347
348
349
350
320351
321352
322353
......
345376
346377
347378
379
380
381
348382
349383
350384
using Microsoft.Xna.Framework.Input.Touch;
using FarseerPhysics.SamplesFramework;
using Microsoft.Xna.Framework.Graphics;
using System;
namespace GameStateManagement
{
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
}
/// <summary>
/// Reads the latest state user input.
/// </summary>
public void Update(GameTime gameTime)
{
PlayerIndex p;
_lastMouseState = _currentMouseState;
if (_handleVirtualStick)
{
Gestures.Clear();
while (TouchPanel.IsGestureAvailable)
{
//System.Diagnostics.Debugger.Break();
Gestures.Add(TouchPanel.ReadGesture());
}
//System.Diagnostics.Debugger.Break();
// Update cursor
Vector2 oldCursor = _cursor;
_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;
_cursorIsValid = false;
}
#endif
if (this.IsNewKeyPress(Keys.P, PlayerIndex.One, out p))
Console.WriteLine(_viewport.ToString());
}
axios/ScreenSystem/MenuScreen.cs
2727
2828
2929
30
31
32
3033
3134
3235
......
6265
6366
6467
68
69
6570
6671
6772
......
95100
96101
97102
103
104
105
106
107
108
109
110
111
112
113
114
115
98116
99117
100118
......
107125
108126
109127
110
128
111129
130
131
112132
113133
114134
......
135155
136156
137157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
138194
139195
140196
{
#region Fields
// the number of pixels to pad above and below menu entries for touch input
const int menuEntryPadding = 10;
private List<MenuEntry> menuEntries = new List<MenuEntry>();
int selectedEntry = 0;
string menuTitle;
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);
#region Handle Input
/// <summary>
/// Allows the screen to create the hit bounds for a particular menu entry.
/// </summary>
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));
}
/// <summary>
/// Responds to user input, changing the selected entry and accepting
// 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.
PlayerIndex playerIndex;
#if WINDOWS || XBOX360
PlayerIndex playerIndex;
// Move to the previous menu entry?
if (menuUp.Evaluate(input, ControllingPlayer, out playerIndex))
{
{
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
}
axios/ScreenSystem/ScreenManager.cs
144144
145145
146146
147
147
148148
149149
150150
......
207207
208208
209209
210
211
210212
211213
212214
......
244246
245247
246248
249
247250
248251
249252
......
251254
252255
253256
257
254258
255259
256260
spriteBatch = new SpriteBatch(GraphicsDevice);
font = content.Load<SpriteFont>("menufont");
blankTexture = Game.Content.Load<Texture2D>("Materials/blank");
input.LoadContent();
// Tell each of the screens to load their content.
foreach (GameScreen screen in screens)
{
// give it a chance to handle input.
if (!otherScreenHasFocus)
{
input.ShowCursor = screen.HasCursor;
input.EnableVirtualStick = screen.HasVirtualStick;
screen.HandleInput(gameTime, input);
otherScreenHasFocus = true;
/// </summary>
public override void Draw(GameTime gameTime)
{
foreach (GameScreen screen in screens)
{
if (screen.ScreenState == ScreenState.Hidden)
screen.Draw(gameTime);
}
input.Draw();
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.08027s using 13 queries.