summaryrefslogtreecommitdiff
path: root/Penguloon/Controls/MuteButton.cs
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2018-01-17 11:41:31 +0100
committeraldrikboy <aldrikboy@gmail.com>2018-01-17 11:41:31 +0100
commita9daa029db68962603905eded0e29c2a2e2abd91 (patch)
tree8c17edcbc99e393a923e6f90ac16e929457776a3 /Penguloon/Controls/MuteButton.cs
parentf03a7cf3e3beab8964cd142ce64fd6dc3cd0735f (diff)
Mute sound button
Diffstat (limited to 'Penguloon/Controls/MuteButton.cs')
-rw-r--r--Penguloon/Controls/MuteButton.cs44
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