Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[191] Button gemacht! Mit Hover!! Hurra
- Loading branch information
Tom Wendel
committed
Jul 9, 2015
1 parent
526a77f
commit fc8f882
Showing
10 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
OctoAwesome/OctoAwesome.Client/Components/Hud/ButtonControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.Xna.Framework; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace OctoAwesome.Client.Components.Hud | ||
{ | ||
internal class ButtonControl : Control | ||
{ | ||
public Brush Background { get; set; } | ||
|
||
public Brush Hovered { get; set; } | ||
|
||
public string Text { get; set; } | ||
|
||
public SpriteFont Font { get; set; } | ||
|
||
public Color Color { get; set; } | ||
|
||
public ButtonControl(IScreenManager screenManager) : base(screenManager) { } | ||
|
||
public override void Draw(SpriteBatch batch, GameTime gameTime) | ||
{ | ||
if (IsHovered) | ||
{ | ||
if (Hovered != null) | ||
Hovered.Draw(batch, new Rectangle(Position.X, Position.Y, Size.X, Size.Y)); | ||
else if (Background != null) | ||
Background.Draw(batch, new Rectangle(Position.X, Position.Y, Size.X, Size.Y)); | ||
} | ||
else | ||
{ | ||
if (Background != null) | ||
Background.Draw(batch, new Rectangle(Position.X, Position.Y, Size.X, Size.Y)); | ||
} | ||
|
||
batch.Begin(); | ||
Vector2 textSize = Font.MeasureString(Text); | ||
batch.DrawString(Font, Text, new Vector2( | ||
Position.X + ((Size.X - textSize.X) / 2), | ||
Position.Y + ((Size.Y - textSize.Y) / 2)), Color); | ||
batch.End(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters