diff --git a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs index c41c8aa0a4..cd037cc220 100644 --- a/OpenRA.Mods.Common/Widgets/ButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ButtonWidget.cs @@ -40,6 +40,8 @@ namespace OpenRA.Mods.Common.Widgets public bool Shadow = ChromeMetrics.Get("ButtonTextShadow"); public Color ContrastColorDark = ChromeMetrics.Get("ButtonTextContrastColorDark"); public Color ContrastColorLight = ChromeMetrics.Get("ButtonTextContrastColorLight"); + public string ClickSound = ChromeMetrics.Get("ClickSound"); + public string ClickDisabledSound = ChromeMetrics.Get("ClickDisabledSound"); public bool Disabled = false; public bool Highlighted = false; public Func GetText; @@ -144,10 +146,10 @@ namespace OpenRA.Mods.Common.Widgets { OnKeyPress(e); if (!DisableKeySound) - Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); } else if (!DisableKeySound) - Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null); + Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickDisabledSound, null); return true; } @@ -185,12 +187,12 @@ namespace OpenRA.Mods.Common.Widgets { OnMouseDown(mi); Depressed = true; - Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); } else { YieldMouseFocus(mi); - Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null); + Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickDisabledSound, null); } } else if (mi.Event == MouseInputEvent.Move && HasMouseFocus) diff --git a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs index 88ebc0d581..68ef2b7324 100644 --- a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets // Mask to prevent any clicks from being sent to other widgets fullscreenMask = new MaskWidget(); fullscreenMask.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height); - fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null); RemovePanel(); }; + fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); RemovePanel(); }; if (onCancel != null) fullscreenMask.OnMouseDown += _ => onCancel(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/CycleProductionActorsHotkeyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/CycleProductionActorsHotkeyLogic.cs index 08fbc18bb9..b4330e4724 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/CycleProductionActorsHotkeyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/Hotkeys/CycleProductionActorsHotkeyLogic.cs @@ -25,6 +25,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame readonly Selection selection; readonly World world; + readonly string clickSound = ChromeMetrics.Get("ClickSound"); + [ObjectCreator.UseCtor] public CycleProductionActorsHotkeyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, World world, Dictionary logicArgs) : base(widget, modData, "CycleProductionActorsKey", "WORLD_KEYHANDLER", logicArgs) @@ -32,6 +34,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame viewport = worldRenderer.Viewport; selection = world.Selection; this.world = world; + + MiniYaml yaml; + if (logicArgs.TryGetValue("ClickSound", out yaml)) + clickSound = yaml.Value; } protected override bool OnHotkeyActivated(KeyInput e) @@ -54,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame if (next == null) next = facilities.First(); - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null); selection.Combine(world, new Actor[] { next }, false, true); viewport.Center(selection.Actors); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index 5496135828..8ed8470e62 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -10,6 +10,7 @@ #endregion using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.Mods.Common.Commands; @@ -36,11 +37,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly TabCompletionLogic tabCompletion = new TabCompletionLogic(); + readonly string chatLineSound = ChromeMetrics.Get("ChatLineSound"); + bool disableTeamChat; bool teamChat; [ObjectCreator.UseCtor] - public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData, bool isMenuChat) + public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData, bool isMenuChat, Dictionary logicArgs) { this.orderManager = orderManager; this.modRules = modData.DefaultRules; @@ -167,6 +170,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic return false; }); } + + MiniYaml yaml; + if (logicArgs.TryGetValue("ChatLineSound", out yaml)) + chatLineSound = yaml.Value; } bool SwitchTeamChat() @@ -239,7 +246,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic chatScrollPanel.ScrollToBottom(smooth: true); if (!suppressSound) - Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null); + Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null); } bool disposed = false; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs index 25db464cae..37046f0fcb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs @@ -24,6 +24,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly World world; readonly Widget worldRoot; readonly Widget menuRoot; + readonly string clickSound = ChromeMetrics.Get("ClickSound"); + bool disableSystemButtons; Widget currentWidget; @@ -107,7 +109,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { if (statsHotkeys[i].IsActivatedBy(e)) { - Game.Sound.PlayNotification(modData.DefaultRules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(modData.DefaultRules, null, "Sounds", clickSound, null); OpenMenuPanel(stats, new WidgetArgs() { { "activePanel", i } }); return true; } @@ -117,6 +119,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic return false; }); } + + if (logicArgs.TryGetValue("ClickSound", out yaml)) + clickSound = yaml.Value; } void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index 7f62567c82..53298e5805 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -43,6 +43,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly World world; readonly WorldRenderer worldRenderer; + readonly string clickSound = ChromeMetrics.Get("ClickSound"); + [ObjectCreator.UseCtor] public ObserverStatsLogic(World world, ModData modData, WorldRenderer worldRenderer, Widget widget, Action onExit, ObserverStatsPanel activePanel, Dictionary logicArgs) @@ -128,7 +130,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { if (statsHotkeys[i].IsActivatedBy(e)) { - Game.Sound.PlayNotification(modData.DefaultRules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(modData.DefaultRules, null, "Sounds", clickSound, null); statsDropDownOptions[i].OnClick(); return true; } @@ -137,6 +139,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic return false; }); + + if (logicArgs.TryGetValue("ClickSound", out yaml)) + clickSound = yaml.Value; } void ClearStats() diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 474a7ccd25..c4b615d3a7 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -63,6 +63,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool addBotOnMapLoad; bool teamChat; + readonly string chatLineSound = ChromeMetrics.Get("ChatLineSound"); + // Listen for connection failures void ConnectionStateChanged(OrderManager om) { @@ -95,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager, - Action onExit, Action onStart, bool skirmishMode) + Action onExit, Action onStart, bool skirmishMode, Dictionary logicArgs) { map = MapCache.UnknownMap; lobby = widget; @@ -433,6 +435,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic // Add a bot on the first lobbyinfo update if (skirmishMode) addBotOnMapLoad = true; + + MiniYaml yaml; + if (logicArgs.TryGetValue("ChatLineSound", out yaml)) + chatLineSound = yaml.Value; } bool disposed; @@ -472,7 +478,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (scrolledToBottom) lobbyChatPanel.ScrollToBottom(smooth: true); - Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null); + Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null); } bool SwitchTeamChat() diff --git a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs index 7b4df75fae..924078eb66 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs @@ -73,6 +73,9 @@ namespace OpenRA.Mods.Common.Widgets public readonly int TabWidth = 30; public readonly int ArrowWidth = 20; + public readonly string ClickSound = ChromeMetrics.Get("ClickSound"); + public readonly string ClickDisabledSound = ChromeMetrics.Get("ClickDisabledSound"); + public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference(); public readonly HotkeyReference NextProductionTabKey = new HotkeyReference(); @@ -270,9 +273,9 @@ namespace OpenRA.Mods.Common.Widgets if (leftPressed || rightPressed) { if ((leftPressed && !leftDisabled) || (rightPressed && !rightDisabled)) - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickSound, null); else - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickDisabledSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickDisabledSound, null); } // Check production tabs @@ -280,7 +283,7 @@ namespace OpenRA.Mods.Common.Widgets if (offsetloc.X > 0 && offsetloc.X < contentWidth) { CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue; - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickSound, null); } return true; @@ -293,13 +296,13 @@ namespace OpenRA.Mods.Common.Widgets if (PreviousProductionTabKey.IsActivatedBy(e)) { - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickSound, null); return SelectNextTab(true); } if (NextProductionTabKey.IsActivatedBy(e)) { - Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickSound, null); return SelectNextTab(false); } diff --git a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs index ea1360bd1e..6ef6c90bf5 100644 --- a/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ScrollPanelWidget.cs @@ -38,6 +38,7 @@ namespace OpenRA.Mods.Common.Widgets public int TopBottomSpacing = 2; public int ItemSpacing = 0; public int ButtonDepth = ChromeMetrics.Get("ButtonDepth"); + public string ClickSound = ChromeMetrics.Get("ClickSound"); public string Background = "scrollpanel-bg"; public string Button = "scrollpanel-button"; public int ContentHeight; @@ -323,7 +324,7 @@ namespace OpenRA.Mods.Common.Widgets lastMouseLocation = mi.Location; if (mi.Event == MouseInputEvent.Down && ((upPressed && !upDisabled) || (downPressed && !downDisabled) || thumbPressed)) - Game.Sound.PlayNotification(modRules, null, "Sounds", "ClickSound", null); + Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null); } return upPressed || downPressed || thumbPressed; diff --git a/mods/cnc/metrics.yaml b/mods/cnc/metrics.yaml index 49380eabed..6fd88eb70d 100644 --- a/mods/cnc/metrics.yaml +++ b/mods/cnc/metrics.yaml @@ -7,3 +7,6 @@ Metrics: ColorPickerActorType: fact.colorpicker ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 TextfieldColorHighlight: 800000 + ChatLineSound: ChatLine + ClickDisabledSound: ClickDisabledSound + ClickSound: ClickSound diff --git a/mods/d2k/metrics.yaml b/mods/d2k/metrics.yaml index 019bb57634..57687d07bd 100644 --- a/mods/d2k/metrics.yaml +++ b/mods/d2k/metrics.yaml @@ -7,3 +7,6 @@ Metrics: FactionSuffix-smuggler: ordos FactionSuffix-mercenary: ordos TextfieldColorHighlight: 7f4d29 + ChatLineSound: ChatLine + ClickDisabledSound: ClickDisabledSound + ClickSound: ClickSound diff --git a/mods/modcontent/metrics.yaml b/mods/modcontent/metrics.yaml index 89115b11ae..f1d27b6522 100644 --- a/mods/modcontent/metrics.yaml +++ b/mods/modcontent/metrics.yaml @@ -6,3 +6,6 @@ Metrics: ButtonFont: Bold CheckboxPressedState: true ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 + ChatLineSound: ChatLine + ClickDisabledSound: ClickDisabledSound + ClickSound: ClickSound diff --git a/mods/ra/metrics.yaml b/mods/ra/metrics.yaml index 3f3c77b4e2..9df9256251 100644 --- a/mods/ra/metrics.yaml +++ b/mods/ra/metrics.yaml @@ -16,3 +16,6 @@ Metrics: IncompatibleProtectedGameColor: B22222 IncompatibleVersionColor: D3D3D3 TextfieldColorHighlight: 562020 + ChatLineSound: ChatLine + ClickDisabledSound: ClickDisabledSound + ClickSound: ClickSound diff --git a/mods/ts/metrics.yaml b/mods/ts/metrics.yaml index fe7d275abb..a424ec2b0e 100644 --- a/mods/ts/metrics.yaml +++ b/mods/ts/metrics.yaml @@ -3,3 +3,6 @@ Metrics: ColorPickerActorType: mmch.colorpicker ColorPickerRemapIndices: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 TextfieldColorHighlight: 1a1a1a + ChatLineSound: ChatLine + ClickDisabledSound: ClickDisabledSound + ClickSound: ClickSound