diff options
Diffstat (limited to 'Penguloon/Controls/Checkbox.cs')
| -rw-r--r-- | Penguloon/Controls/Checkbox.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Penguloon/Controls/Checkbox.cs b/Penguloon/Controls/Checkbox.cs new file mode 100644 index 0000000..7db93f5 --- /dev/null +++ b/Penguloon/Controls/Checkbox.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class Checkbox : ControlBase + { + public bool Selected { get; set; } = false; + + public Checkbox(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/checkbox-empty"); + this.BackgroundPressed = ContentManager.GetTexture("UI/checkbox-empty"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/checkbox-empty"); + + this.ForeColor = Color.White; + this.BorderColor = Color.Gray; + this.BorderWidth = 0; + this.Font = ContentManager.GetFont(StaticUIValues.MenuFont); + + OnClick += Button_OnClick; + } + + private void Button_OnClick(object sender, ClickArgs e) + { + Selected = !Selected; + + if (Selected) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/checkbox-selected"); + this.BackgroundPressed = ContentManager.GetTexture("UI/checkbox-selected"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/checkbox-selected"); + } + else + { + this.BackgroundIdle = ContentManager.GetTexture("UI/checkbox-empty"); + this.BackgroundPressed = ContentManager.GetTexture("UI/checkbox-empty"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/checkbox-empty"); + } + + SoundManager.PlayClickSound(); + } + } +}
\ No newline at end of file |
