diff options
Diffstat (limited to 'Penguloon/Controls/MuteButton.cs')
| -rw-r--r-- | Penguloon/Controls/MuteButton.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Penguloon/Controls/MuteButton.cs b/Penguloon/Controls/MuteButton.cs new file mode 100644 index 0000000..fdd1d91 --- /dev/null +++ b/Penguloon/Controls/MuteButton.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class MuteButton : ControlBase + { + public bool Muted { get; set; } = false; + + public MuteButton(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/BtnMuteIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/BtnMutePressed"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/BtnMutePressed"); + + 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) + { + Muted = !Muted; + + SoundManager.Muted = Muted; + + if (Muted) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/BtnUnmuteIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/BtnUnmutePressed"); + } + else + { + this.BackgroundIdle = ContentManager.GetTexture("UI/BtnMuteIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/BtnMutePressed"); + } + + SoundManager.PlayClickSound(); + } + } +}
\ No newline at end of file |
