GravityChooser.GravityChooserMessageBoxScreen Class Reference

A popup message box screen, used to display "are you sure?" confirmation messages. More...

Inheritance diagram for GravityChooser.GravityChooserMessageBoxScreen:
NewGamePhysics.StateManager.GameScreen

List of all members.

Public Member Functions

 GravityChooserMessageBoxScreen (string message)
 Constructor automatically includes the standard "A=ok, B=cancel" usage text prompt.
 GravityChooserMessageBoxScreen (string message, bool includeUsageText)
 Constructor lets the caller specify whether to include the standard "A=ok, B=cancel" usage text prompt.
override void LoadContent ()
 Loads graphics content for this screen.
override void HandleInput (InputState input)
 Responds to user input, accepting or cancelling the message box.
override void Draw (GameTime gameTime)
 Draws the message box.

Events

EventHandler
< PlayerIndexEventArgs
Accepted
 Event handler for user acceptance.
EventHandler
< PlayerIndexEventArgs
Cancelled
 Event handler for user cancellation.

Detailed Description

A popup message box screen, used to display "are you sure?" confirmation messages.

Definition at line 20 of file GravityChooserMessageBoxScreen.cs.


Constructor & Destructor Documentation

GravityChooser.GravityChooserMessageBoxScreen.GravityChooserMessageBoxScreen ( string  message  ) 

Constructor automatically includes the standard "A=ok, B=cancel" usage text prompt.

Definition at line 56 of file GravityChooserMessageBoxScreen.cs.

00057             : this(message, true)
00058         { }

GravityChooser.GravityChooserMessageBoxScreen.GravityChooserMessageBoxScreen ( string  message,
bool  includeUsageText 
)

Constructor lets the caller specify whether to include the standard "A=ok, B=cancel" usage text prompt.

Definition at line 64 of file GravityChooserMessageBoxScreen.cs.

00065         {
00066             const string usageText = "\nOK      : (A) button or [Enter]" +
00067                                      "\nCancel  : (B) button or [Esc]";
00068 
00069             if (includeUsageText)
00070             {
00071                 this.message = message + usageText;
00072             }
00073             else
00074             {
00075                 this.message = message;
00076             }
00077 
00078             IsPopup = true;
00079 
00080             TransitionOnTime = TimeSpan.FromSeconds(0.2);
00081             TransitionOffTime = TimeSpan.FromSeconds(0.2);
00082         }


Member Function Documentation

override void GravityChooser.GravityChooserMessageBoxScreen.Draw ( GameTime  gameTime  )  [virtual]

Draws the message box.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 137 of file GravityChooserMessageBoxScreen.cs.

00138         {
00139             SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
00140             SpriteFont font = ScreenManager.Fonts["menu"];
00141 
00142             // Darken down any other screens that were drawn beneath the popup.
00143             ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);
00144 
00145             // Center the message text in the viewport.
00146             Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
00147             Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
00148             Vector2 textSize = font.MeasureString(message);
00149             Vector2 textPosition = (viewportSize - textSize) / 2;
00150 
00151             // The background includes a border somewhat larger than the text itself.
00152             const int hPad = 32;
00153             const int vPad = 16;
00154 
00155             Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad,
00156                                                           (int)textPosition.Y - vPad,
00157                                                           (int)textSize.X + hPad * 2,
00158                                                           (int)textSize.Y + vPad * 2);
00159 
00160             // Fade the popup alpha during transitions.
00161             Color color = new Color(255, 255, 255, TransitionAlpha);
00162 
00163             spriteBatch.Begin();
00164 
00165             // Draw the background rectangle.
00166             spriteBatch.Draw(gradientTexture, backgroundRectangle, color);
00167 
00168             // Draw the message box text.
00169             spriteBatch.DrawString(font, message, textPosition, color);
00170 
00171             spriteBatch.End();
00172         }

override void GravityChooser.GravityChooserMessageBoxScreen.HandleInput ( InputState  input  )  [virtual]

Responds to user input, accepting or cancelling the message box.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 102 of file GravityChooserMessageBoxScreen.cs.

00103         {
00104             PlayerIndex playerIndex;
00105 
00106             // We pass in our ControllingPlayer, which may either be null (to
00107             // accept input from any player) or a specific index. If we pass a null
00108             // controlling player, the InputState helper returns to us which player
00109             // actually provided the input. We pass that through to our Accepted and
00110             // Cancelled events, so they can tell which player triggered them.
00111             if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
00112             {
00113                 // Raise the accepted event, then exit the message box.
00114                 if (Accepted != null)
00115                     Accepted(this, new PlayerIndexEventArgs(playerIndex));
00116 
00117                 ExitScreen();
00118             }
00119             else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
00120             {
00121                 // Raise the cancelled event, then exit the message box.
00122                 if (Cancelled != null)
00123                     Cancelled(this, new PlayerIndexEventArgs(playerIndex));
00124 
00125                 ExitScreen();
00126             }
00127         }

override void GravityChooser.GravityChooserMessageBoxScreen.LoadContent (  )  [virtual]

Loads graphics content for this screen.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 88 of file GravityChooserMessageBoxScreen.cs.

00089         {
00090             ContentManager content = ScreenManager.Game.Content;
00091 
00092             gradientTexture = content.Load<Texture2D>(@"Sprites\gradient");
00093         }


Event Documentation

EventHandler<PlayerIndexEventArgs> GravityChooser.GravityChooserMessageBoxScreen.Accepted

Event handler for user acceptance.

Definition at line 41 of file GravityChooserMessageBoxScreen.cs.

EventHandler<PlayerIndexEventArgs> GravityChooser.GravityChooserMessageBoxScreen.Cancelled

Event handler for user cancellation.

Definition at line 46 of file GravityChooserMessageBoxScreen.cs.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2