From f8fa66385de45cecd8c599a9ca9c5ab39a39a377 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 26 Feb 2020 17:43:31 -0500 Subject: [PATCH] Display "Paused" message when paused. Add a new "Banner" style font for the pause message. GitOrigin-RevId: 62f9537574351b961d7a2bd74f12e218f1047062 --- Shared/Scene.cs | 24 +++++++++++++++++++++++- Shared/SneakGame.cs | 3 ++- Shared/Textures.cs | 4 +++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Shared/Scene.cs b/Shared/Scene.cs index a08fb4f..1bc7bb0 100644 --- a/Shared/Scene.cs +++ b/Shared/Scene.cs @@ -45,7 +45,7 @@ namespace SemiColinGames { GC.SuppressFinalize(this); } - public void Draw(World world, Player player, LinesOfSight linesOfSight) { + public void Draw(World world, Player player, LinesOfSight linesOfSight, bool paused) { graphics.SetRenderTarget(null); graphics.Clear(backgroundColor); if (!Enabled) { @@ -94,6 +94,28 @@ namespace SemiColinGames { // Draw debug rects & lines on top. Debug.Draw(graphics, basicEffect); + // Draw in-world UI on top of everything. + // TODO: make a Text.cs file and move things like "black outlined text" there. + if (paused) { + string text = "Paused"; + Vector2 size = Textures.BannerFont.MeasureString(text); + Vector2 position = new Vector2((camera.Width - size.X) / 2, (camera.Height - size.Y) / 2); + + spriteBatch.Begin( + SpriteSortMode.Deferred, null, SamplerState.LinearWrap, null, null, null, null); + for (int i = -1; i <= 1; i++) { + for (int j = -1; j <= 1; j++) { + if (i == 0 && j == 0) { + continue; + } + Vector2 stencilPos = new Vector2(position.X + i, position.Y + j); + spriteBatch.DrawString(Textures.BannerFont, text, stencilPos, Color.Black); + } + } + spriteBatch.DrawString(Textures.BannerFont, text, position, Color.White); + spriteBatch.End(); + } + // Get ready to draw sceneTarget to screen. graphics.SetRenderTarget(null); diff --git a/Shared/SneakGame.cs b/Shared/SneakGame.cs index 8273113..d42c56c 100644 --- a/Shared/SneakGame.cs +++ b/Shared/SneakGame.cs @@ -133,6 +133,7 @@ namespace SemiColinGames { drawTimer.Start(); // Enable the scene after we've gotten enough non-slow frames. + // TODO: the Scene should handle this, really. if (framesToSuppress > 0 && !gameTime.IsRunningSlowly) { framesToSuppress--; if (framesToSuppress == 0) { @@ -151,7 +152,7 @@ namespace SemiColinGames { Debug.SetFpsText(fpsText); - scene.Draw(world, player, linesOfSight); + scene.Draw(world, player, linesOfSight, paused); base.Draw(gameTime); drawTimer.Stop(); diff --git a/Shared/Textures.cs b/Shared/Textures.cs index 08494b1..77806d4 100644 --- a/Shared/Textures.cs +++ b/Shared/Textures.cs @@ -31,6 +31,7 @@ namespace SemiColinGames { class Textures { public static SpriteFont DebugFont; + public static SpriteFont BannerFont; public static TextureRef Player = new TextureRef("sprites/ccg/ninja_female"); @@ -54,7 +55,8 @@ namespace SemiColinGames { public static TextureRef Village = new TextureRef("tiles/anokolisa/village"); public static void Load(ContentManager content) { - DebugFont = content.Load("font"); + DebugFont = content.Load("fonts/debug"); + BannerFont = content.Load("fonts/banner"); TextureRef.LoadAll(content); } }