diff --git a/06-monogame/GUI/Content/Content.mgcb b/06-monogame/GUI/Content/Content.mgcb index 8a4a692..0058d6a 100644 --- a/06-monogame/GUI/Content/Content.mgcb +++ b/06-monogame/GUI/Content/Content.mgcb @@ -25,3 +25,10 @@ /processorParam:TextureFormat=Color /build:button-default-texture.png +#begin Fonts/default.spritefont +/importer:FontDescriptionImporter +/processor:LocalizedFontProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/default.spritefont + diff --git a/06-monogame/GUI/Content/Fonts/HackNerdFont.ttf b/06-monogame/GUI/Content/Fonts/HackNerdFont.ttf new file mode 100644 index 0000000..4fb90aa Binary files /dev/null and b/06-monogame/GUI/Content/Fonts/HackNerdFont.ttf differ diff --git a/06-monogame/GUI/Content/Fonts/default.spritefont b/06-monogame/GUI/Content/Fonts/default.spritefont new file mode 100755 index 0000000..291fd1f --- /dev/null +++ b/06-monogame/GUI/Content/Fonts/default.spritefont @@ -0,0 +1,70 @@ + + + + + + + HackNerdFont.ttf + + + 12 + + + 0 + + + true + + + + + + A + + + + + + + + + + + + + + diff --git a/06-monogame/GUI/Game1.cs b/06-monogame/GUI/Game1.cs index 6129ad4..eff4948 100644 --- a/06-monogame/GUI/Game1.cs +++ b/06-monogame/GUI/Game1.cs @@ -30,7 +30,8 @@ public class Game1 : Game mainScene = new Scene(); DrawableData drawableData = new DrawableData(null); - drawableData.scale = new Vector2(80.0f, 40.0f); + drawableData.scale = new Vector2(120.0f, 40.0f); + drawableData.position = new Vector2(100.0f, 100.0f); void buttonOnClick(Button obj) { @@ -40,11 +41,13 @@ public class Game1 : Game ButtonData buttonData = new ButtonData(buttonOnClick); buttonData.bgColor = Color.Red; buttonData.fgColor = Color.White; + buttonData.text = "Click me!"; Button mainButton = new Button(drawableData, buttonData); mainScene.drawables.Add(mainButton); - + + mainScene.Initialize(); base.Initialize(); } diff --git a/06-monogame/GUI/UI/Button.cs b/06-monogame/GUI/UI/Button.cs index b98e250..e220603 100644 --- a/06-monogame/GUI/UI/Button.cs +++ b/06-monogame/GUI/UI/Button.cs @@ -1,5 +1,6 @@ using System; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Vector2 = Microsoft.Xna.Framework.Vector2; @@ -16,14 +17,21 @@ public class ButtonData public Color pressedBgColor; public Color pressedFgColor; + + public Color idleBgColor; + public Color idleFgColor; public bool isPressed = false; public bool isReleased = false; public bool isHovered = false; - public bool isNone = false; + public bool isIdle = false; public Action