DebugHUD
This commit is contained in:
parent
180fdae2ec
commit
cbdabf794f
5 changed files with 129 additions and 2 deletions
|
@ -87,6 +87,13 @@
|
|||
/processorParam:Quality=Best
|
||||
/build:DoomTestSong.mp3
|
||||
|
||||
#begin Font_12.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
/processorParam:PremultiplyAlpha=True
|
||||
/processorParam:TextureFormat=Compressed
|
||||
/build:Font_12.spritefont
|
||||
|
||||
#begin Font_25.spritefont
|
||||
/importer:FontDescriptionImporter
|
||||
/processor:FontDescriptionProcessor
|
||||
|
|
64
DangerousD/Content/Font_12.spritefont
Normal file
64
DangerousD/Content/Font_12.spritefont
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
This file contains an xml description of a font, and will be read by the XNA
|
||||
Framework Content Pipeline. Follow the comments to customize the appearance
|
||||
of the font in your game, and to change the characters which are available to draw
|
||||
with.
|
||||
-->
|
||||
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
|
||||
<Asset Type="Graphics:FontDescription">
|
||||
|
||||
<!--
|
||||
Modify this string to change the font that will be imported.
|
||||
-->
|
||||
<FontName>Arial</FontName>
|
||||
|
||||
<!--
|
||||
Size is a float value, measured in points. Modify this value to change
|
||||
the size of the font.
|
||||
-->
|
||||
<Size>12</Size>
|
||||
|
||||
<!--
|
||||
Spacing is a float value, measured in pixels. Modify this value to change
|
||||
the amount of spacing in between characters.
|
||||
-->
|
||||
<Spacing>0</Spacing>
|
||||
|
||||
<!--
|
||||
UseKerning controls the layout of the font. If this value is true, kerning information
|
||||
will be used when placing characters.
|
||||
-->
|
||||
<UseKerning>true</UseKerning>
|
||||
|
||||
<!--
|
||||
Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
|
||||
and "Bold, Italic", and are case sensitive.
|
||||
-->
|
||||
<Style>Regular</Style>
|
||||
|
||||
<!--
|
||||
If you uncomment this line, the default character will be substituted if you draw
|
||||
or measure text that contains characters which were not included in the font.
|
||||
-->
|
||||
<!-- <DefaultCharacter>*</DefaultCharacter> -->
|
||||
|
||||
<!--
|
||||
CharacterRegions control what letters are available in the font. Every
|
||||
character from Start to End will be built and made available for drawing. The
|
||||
default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
|
||||
character set. The characters are ordered according to the Unicode standard.
|
||||
See the documentation for more information.
|
||||
-->
|
||||
<CharacterRegions>
|
||||
<CharacterRegion>
|
||||
<Start> </Start>
|
||||
<End>~</End>
|
||||
</CharacterRegion>
|
||||
<CharacterRegion>
|
||||
<Start>а</Start>
|
||||
<End>я</End>
|
||||
</CharacterRegion>
|
||||
</CharacterRegions>
|
||||
</Asset>
|
||||
</XnaContent>
|
50
DangerousD/GameCore/GUI/DebugHUD.cs
Normal file
50
DangerousD/GameCore/GUI/DebugHUD.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonogameLibrary.UI.Elements;
|
||||
using static System.String;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
public class DebugHUD : IDrawableObject
|
||||
{
|
||||
private SpriteFont _spriteFont;
|
||||
private Dictionary<string, string> _text = new();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadContent()
|
||||
{
|
||||
_spriteFont = AppManager.Instance.Content.Load<SpriteFont>("Font_12");
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
_spriteFont,
|
||||
Join(",", _text.Select(el => el.Key + ": " + el.Value).ToList()),
|
||||
new Vector2(10, 10),
|
||||
Color.Cyan,
|
||||
0,
|
||||
Vector2.Zero,
|
||||
1,
|
||||
SpriteEffects.None,
|
||||
0
|
||||
);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void Set(string key, string value)
|
||||
{
|
||||
_text[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
interface IDrawableObject
|
||||
public interface IDrawableObject
|
||||
{
|
||||
void Initialize();
|
||||
void LoadContent();
|
||||
|
|
|
@ -24,12 +24,13 @@ namespace DangerousD.GameCore
|
|||
public GameState gameState { get; private set; }
|
||||
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
||||
public Point resolution = new Point(1920, 1080);
|
||||
public Point inGameResolution = new Point(1920, 1080);
|
||||
public Point inGameResolution = new Point(1366, 768);
|
||||
IDrawableObject MenuGUI;
|
||||
IDrawableObject OptionsGUI;
|
||||
IDrawableObject LoginGUI;
|
||||
IDrawableObject LobbyGUI;
|
||||
IDrawableObject DeathGUI;
|
||||
public DebugHUD DebugHUD;
|
||||
|
||||
public GameManager GameManager { get; private set; } = new();
|
||||
public AnimationBuilder AnimationBuilder { get; private set; } = new AnimationBuilder();
|
||||
|
@ -62,6 +63,7 @@ namespace DangerousD.GameCore
|
|||
OptionsGUI = new OptionsGUI();
|
||||
LobbyGUI = new LobbyGUI();
|
||||
DeathGUI = new DeathGUI();
|
||||
DebugHUD = new DebugHUD();
|
||||
UIManager.resolution = resolution;
|
||||
UIManager.resolutionInGame = inGameResolution;
|
||||
}
|
||||
|
@ -72,6 +74,7 @@ namespace DangerousD.GameCore
|
|||
MenuGUI.Initialize();
|
||||
LoginGUI.Initialize();
|
||||
|
||||
DebugHUD.Initialize();
|
||||
OptionsGUI.Initialize();
|
||||
|
||||
LobbyGUI.Initialize();
|
||||
|
@ -82,6 +85,7 @@ namespace DangerousD.GameCore
|
|||
protected override void LoadContent()
|
||||
{
|
||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||
DebugHUD.LoadContent();
|
||||
MenuGUI.LoadContent();
|
||||
LoginGUI.LoadContent();
|
||||
OptionsGUI.LoadContent();
|
||||
|
@ -125,6 +129,7 @@ namespace DangerousD.GameCore
|
|||
default:
|
||||
break;
|
||||
}
|
||||
DebugHUD.Update(gameTime);
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
@ -165,6 +170,7 @@ namespace DangerousD.GameCore
|
|||
_spriteBatch.End();
|
||||
|
||||
|
||||
DebugHUD.Draw(_spriteBatch);
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue