From eb4de47362191d582f2ebf698c65c366c26fdedc Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Wed, 22 Dec 2021 19:29:53 +0200 Subject: [PATCH] Add support for disabled click sound in scrollbar widget --- OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs index eabc6db7f4..74730636e4 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs @@ -45,6 +45,7 @@ namespace OpenRA.Mods.Common.Widgets public int ItemSpacing = 0; public int ButtonDepth = ChromeMetrics.Get("ButtonDepth"); public string ClickSound = ChromeMetrics.Get("ClickSound"); + public string ClickDisabledSound = ChromeMetrics.Get("ClickDisabledSound"); public string Background = "scrollpanel-bg"; public string ScrollBarBackground = "scrollpanel-bg"; public string Button = "scrollpanel-button"; @@ -385,8 +386,13 @@ namespace OpenRA.Mods.Common.Widgets if (thumbPressed) lastMouseLocation = mi.Location; - if (mi.Event == MouseInputEvent.Down && ((upPressed && !upDisabled) || (downPressed && !downDisabled) || thumbPressed)) - Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null); + if (mi.Event == MouseInputEvent.Down) + { + if (thumbPressed || (upPressed && !upDisabled) || (downPressed && !downDisabled)) + Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null); + else if ((upPressed && upDisabled) || (downPressed && downDisabled)) + Game.Sound.PlayNotification(modRules, null, "Sounds", ClickDisabledSound, null); + } } return upPressed || downPressed || thumbPressed;