Add support for disabled click sound in scrollbar widget

This commit is contained in:
Ivaylo Draganov
2021-12-22 19:29:53 +02:00
committed by abcdefg30
parent c3dfac7ade
commit eb4de47362

View File

@@ -45,6 +45,7 @@ namespace OpenRA.Mods.Common.Widgets
public int ItemSpacing = 0;
public int ButtonDepth = ChromeMetrics.Get<int>("ButtonDepth");
public string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public string ClickDisabledSound = ChromeMetrics.Get<string>("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;