From a9daa029db68962603905eded0e29c2a2e2abd91 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Wed, 17 Jan 2018 11:41:31 +0100 Subject: Mute sound button --- Penguloon/Controls/MuteButton.cs | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Penguloon/Controls/MuteButton.cs (limited to 'Penguloon/Controls/MuteButton.cs') 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 -- cgit v1.2.3-70-g09d2