PendulumGame.PendulumMessageBoxScreen Class Reference

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

Inheritance diagram for PendulumGame.PendulumMessageBoxScreen:
NewGamePhysics.StateManager.GameScreen

List of all members.

Public Member Functions

 PendulumMessageBoxScreen (string message)
 Constructor automatically includes the standard "A=ok, B=cancel" usage text prompt.
 PendulumMessageBoxScreen (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. This uses the shared ContentManager provided by the Game class, so the content will remain loaded forever. Whenever a subsequent MessageBoxScreen tries to load this same content, it will just get back another reference to the already loaded data.
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
EventHandler
< PlayerIndexEventArgs
Cancelled

Detailed Description

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

Definition at line 19 of file PendulumMessageBoxScreen.cs.


Constructor & Destructor Documentation

PendulumGame.PendulumMessageBoxScreen.PendulumMessageBoxScreen ( string  message  ) 

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

Definition at line 42 of file PendulumMessageBoxScreen.cs.

00043             : this(message, true)
00044         { }

PendulumGame.PendulumMessageBoxScreen.PendulumMessageBoxScreen ( string  message,
bool  includeUsageText 
)

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

Definition at line 51 of file PendulumMessageBoxScreen.cs.

00052         {
00053             const string usageText = "\nOK      : (A) button or [Enter]" +
00054                                      "\nCancel  : (B) button or [Esc]";
00055 
00056             if (includeUsageText)
00057                 this.message = message + usageText;
00058             else
00059                 this.message = message;
00060 
00061             IsPopup = true;
00062 
00063             TransitionOnTime = TimeSpan.FromSeconds(0.2);
00064             TransitionOffTime = TimeSpan.FromSeconds(0.2);
00065         }


Member Function Documentation

override void PendulumGame.PendulumMessageBoxScreen.Draw ( GameTime  gameTime  )  [virtual]

Draws the message box.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 124 of file PendulumMessageBoxScreen.cs.

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

override void PendulumGame.PendulumMessageBoxScreen.HandleInput ( InputState  input  )  [virtual]

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

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 89 of file PendulumMessageBoxScreen.cs.

00090         {
00091             PlayerIndex playerIndex;
00092 
00093             // We pass in our ControllingPlayer, which may either be null (to
00094             // accept input from any player) or a specific index. If we pass a null
00095             // controlling player, the InputState helper returns to us which player
00096             // actually provided the input. We pass that through to our Accepted and
00097             // Cancelled events, so they can tell which player triggered them.
00098             if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
00099             {
00100                 // Raise the accepted event, then exit the message box.
00101                 if (Accepted != null)
00102                     Accepted(this, new PlayerIndexEventArgs(playerIndex));
00103 
00104                 ExitScreen();
00105             }
00106             else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
00107             {
00108                 // Raise the cancelled event, then exit the message box.
00109                 if (Cancelled != null)
00110                     Cancelled(this, new PlayerIndexEventArgs(playerIndex));
00111 
00112                 ExitScreen();
00113             }
00114         }

override void PendulumGame.PendulumMessageBoxScreen.LoadContent (  )  [virtual]

Loads graphics content for this screen. This uses the shared ContentManager provided by the Game class, so the content will remain loaded forever. Whenever a subsequent MessageBoxScreen tries to load this same content, it will just get back another reference to the already loaded data.

Reimplemented from NewGamePhysics.StateManager.GameScreen.

Definition at line 74 of file PendulumMessageBoxScreen.cs.

00075         {
00076             ContentManager content = ScreenManager.Game.Content;
00077 
00078             gradientTexture = content.Load<Texture2D>(@"Sprites\gradient");
00079         }


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

Generated by  doxygen 1.6.2