diff --git a/06-monogame/GUI/Content/Content.mgcb b/06-monogame/GUI/Content/Content.mgcb index 0058d6a..3665bdb 100644 --- a/06-monogame/GUI/Content/Content.mgcb +++ b/06-monogame/GUI/Content/Content.mgcb @@ -25,6 +25,18 @@ /processorParam:TextureFormat=Color /build:button-default-texture.png +#begin button.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:button.png + #begin Fonts/default.spritefont /importer:FontDescriptionImporter /processor:LocalizedFontProcessor diff --git a/06-monogame/GUI/Content/button.png b/06-monogame/GUI/Content/button.png new file mode 100644 index 0000000..eb09edf Binary files /dev/null and b/06-monogame/GUI/Content/button.png differ diff --git a/06-monogame/GUI/Game1.cs b/06-monogame/GUI/Game1.cs index eff4948..77ccbfd 100644 --- a/06-monogame/GUI/Game1.cs +++ b/06-monogame/GUI/Game1.cs @@ -29,8 +29,7 @@ public class Game1 : Game Scene.content = Content; mainScene = new Scene(); - DrawableData drawableData = new DrawableData(null); - drawableData.scale = new Vector2(120.0f, 40.0f); + DrawableData drawableData = new DrawableData("button"); drawableData.position = new Vector2(100.0f, 100.0f); void buttonOnClick(Button obj) @@ -39,8 +38,6 @@ 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); diff --git a/06-monogame/GUI/UI/Button.cs b/06-monogame/GUI/UI/Button.cs index e220603..6d727cf 100644 --- a/06-monogame/GUI/UI/Button.cs +++ b/06-monogame/GUI/UI/Button.cs @@ -12,14 +12,14 @@ public class ButtonData public Color bgColor; public Color fgColor; - public Color hoverBgColor; - public Color hoverFgColor; + public Color? hoverBgColor; + public Color? hoverFgColor; - public Color pressedBgColor; - public Color pressedFgColor; + public Color? pressedBgColor; + public Color? pressedFgColor; - public Color idleBgColor; - public Color idleFgColor; + public Color idleBgColor = Color.Black; + public Color idleFgColor = Color.White; public bool isPressed = false; public bool isReleased = false; @@ -31,6 +31,7 @@ public class ButtonData public string text = ""; public Vector2 textPosition; public Vector2 textResolution; + public Vector2 textScale; public ButtonData(Action