A popup message box screen, used to display "are you sure?" confirmation messages. More...
Public Member Functions | |
| MontyHallMessageBoxScreen (string message) | |
| Constructor automatically includes the standard "A=ok, B=cancel" usage text prompt. | |
| MontyHallMessageBoxScreen (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 |
A popup message box screen, used to display "are you sure?" confirmation messages.
Definition at line 20 of file MontyHallMessageBoxScreen.cs.
| MontyHallGame.MontyHallMessageBoxScreen.MontyHallMessageBoxScreen | ( | string | message | ) |
Constructor automatically includes the standard "A=ok, B=cancel" usage text prompt.
Definition at line 43 of file MontyHallMessageBoxScreen.cs.
| MontyHallGame.MontyHallMessageBoxScreen.MontyHallMessageBoxScreen | ( | string | message, | |
| bool | includeUsageText | |||
| ) |
Constructor lets the caller specify whether to include the standard "A=ok, B=cancel" usage text prompt.
Definition at line 52 of file MontyHallMessageBoxScreen.cs.
00053 { 00054 const string usageText = "\nOK : (A) button or [Enter]" + 00055 "\nCancel : (B) button or [Esc]"; 00056 00057 if (includeUsageText) 00058 { 00059 this.message = message + usageText; 00060 } 00061 else 00062 { 00063 this.message = message; 00064 } 00065 00066 IsPopup = true; 00067 00068 TransitionOnTime = TimeSpan.FromSeconds(0.2); 00069 TransitionOffTime = TimeSpan.FromSeconds(0.2); 00070 }
| override void MontyHallGame.MontyHallMessageBoxScreen.Draw | ( | GameTime | gameTime | ) | [virtual] |
Draws the message box.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 130 of file MontyHallMessageBoxScreen.cs.
00131 { 00132 SpriteBatch spriteBatch = ScreenManager.SpriteBatch; 00133 SpriteFont font = ScreenManager.Fonts["menu"]; 00134 00135 // Darken down any other screens that were drawn beneath the popup. 00136 ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3); 00137 00138 // Center the message text in the viewport. 00139 Viewport viewport = ScreenManager.GraphicsDevice.Viewport; 00140 Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); 00141 Vector2 textSize = font.MeasureString(message); 00142 Vector2 textPosition = (viewportSize - textSize) / 2; 00143 00144 // The background includes a border somewhat larger than the text itself. 00145 const int hPad = 32; 00146 const int vPad = 16; 00147 00148 Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad, 00149 (int)textPosition.Y - vPad, 00150 (int)textSize.X + hPad * 2, 00151 (int)textSize.Y + vPad * 2); 00152 00153 // Fade the popup alpha during transitions. 00154 Color color = new Color(255, 255, 255, TransitionAlpha); 00155 00156 spriteBatch.Begin(); 00157 00158 // Draw the background rectangle. 00159 spriteBatch.Draw(gradientTexture, backgroundRectangle, color); 00160 00161 // Draw the message box text. 00162 spriteBatch.DrawString(font, message, textPosition, color); 00163 00164 spriteBatch.End(); 00165 }
| override void MontyHallGame.MontyHallMessageBoxScreen.HandleInput | ( | InputState | input | ) | [virtual] |
Responds to user input, accepting or cancelling the message box.
Reimplemented from NewGamePhysics.StateManager.GameScreen.
Definition at line 95 of file MontyHallMessageBoxScreen.cs.
00096 { 00097 PlayerIndex playerIndex; 00098 00099 // We pass in our ControllingPlayer, which may either be null (to 00100 // accept input from any player) or a specific index. If we pass a null 00101 // controlling player, the InputState helper returns to us which player 00102 // actually provided the input. We pass that through to our Accepted and 00103 // Cancelled events, so they can tell which player triggered them. 00104 if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) 00105 { 00106 // Raise the accepted event, then exit the message box. 00107 if (Accepted != null) 00108 Accepted(this, new PlayerIndexEventArgs(playerIndex)); 00109 00110 ExitScreen(); 00111 } 00112 else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) 00113 { 00114 // Raise the cancelled event, then exit the message box. 00115 if (Cancelled != null) 00116 Cancelled(this, new PlayerIndexEventArgs(playerIndex)); 00117 00118 ExitScreen(); 00119 } 00120 }
| override void MontyHallGame.MontyHallMessageBoxScreen.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 79 of file MontyHallMessageBoxScreen.cs.
00080 { 00081 ContentManager content = ScreenManager.Game.Content; 00082 00083 gradientTexture = content.Load<Texture2D>(@"Sprites\gradient"); 00084 }
1.6.2