/// <summary> /// Draws the message box. /// </summary> public override void Draw(GameTime gameTime) { // Darken down any other screens that were drawn beneath the popup. ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3); // Center the message text in the viewport. Viewport viewport = SharedResources.Game.GraphicsDevice.Viewport; Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 textSize = SharedResources.FontManager.MeasureString(FontType.ArialMedium, message); Vector2 textPosition = (viewportSize - textSize) / 2; // The background includes a border somewhat larger than the text itself. const int hPad = 32; const int vPad = 16; Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad, (int)textPosition.Y - vPad, (int)textSize.X + hPad * 2, (int)textSize.Y + vPad * 2); // Fade the popup alpha during transitions. Color color = Color.White * TransitionAlpha; SharedResources.FontManager.BeginText(); // Draw the background rectangle. SharedResources.FontManager.DrawTexture(gradientTexture, backgroundRectangle, color, BlendState.AlphaBlend); // Draw the message box text. SharedResources.FontManager.DrawText(FontType.ArialMedium, message, textPosition, color, false); SharedResources.FontManager.EndText(); }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { mFrameCounter++; GraphicsDevice gd = SharedResources.Game.GraphicsDevice; Viewport wholeScreen = gd.Viewport; for (int d = 0; d < mDrawSegments.Count; ++d) { gd.Viewport = GetViewport(d, mScreenLayout, wholeScreen); mDrawSegments[d].Draw(gd.Viewport.AspectRatio, gameTime); } gd.Viewport = wholeScreen; if (mPrevFrameTime < 0) { mPrevFrameTime = gameTime.TotalGameTime.TotalMilliseconds; } else { double nowTime = gameTime.TotalGameTime.TotalMilliseconds; mFrameTimes.Dequeue(); mFrameTimes.Enqueue(nowTime - mPrevFrameTime); mPrevFrameTime = nowTime; } string fps = string.Format("fps: {0} ({1:F3} ms/frame)", mFrameRate, mFrameTimes.Average()); Color fpsColor = gameTime.IsRunningSlowly == true ? Color.Orange : Color.White; SharedResources.FontManager.BeginText(); SharedResources.FontManager.DrawText(FontType.ArialSmall, fps, new Vector2(32, 32), fpsColor, true); SharedResources.FontManager.EndText(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || mPauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, mPauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }