ClickSound and ClickDisabledSound and ChatLine are optional ui sounds.

This commit is contained in:
Andre Mohren
2018-07-26 15:37:25 +02:00
committed by reaperrr
parent 28623ce54c
commit 48248266a8
14 changed files with 68 additions and 18 deletions

View File

@@ -40,6 +40,8 @@ namespace OpenRA.Mods.Common.Widgets
public bool Shadow = ChromeMetrics.Get<bool>("ButtonTextShadow"); public bool Shadow = ChromeMetrics.Get<bool>("ButtonTextShadow");
public Color ContrastColorDark = ChromeMetrics.Get<Color>("ButtonTextContrastColorDark"); public Color ContrastColorDark = ChromeMetrics.Get<Color>("ButtonTextContrastColorDark");
public Color ContrastColorLight = ChromeMetrics.Get<Color>("ButtonTextContrastColorLight"); public Color ContrastColorLight = ChromeMetrics.Get<Color>("ButtonTextContrastColorLight");
public string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
public bool Disabled = false; public bool Disabled = false;
public bool Highlighted = false; public bool Highlighted = false;
public Func<string> GetText; public Func<string> GetText;
@@ -144,10 +146,10 @@ namespace OpenRA.Mods.Common.Widgets
{ {
OnKeyPress(e); OnKeyPress(e);
if (!DisableKeySound) if (!DisableKeySound)
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null); Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null);
} }
else if (!DisableKeySound) else if (!DisableKeySound)
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null); Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickDisabledSound, null);
return true; return true;
} }
@@ -185,12 +187,12 @@ namespace OpenRA.Mods.Common.Widgets
{ {
OnMouseDown(mi); OnMouseDown(mi);
Depressed = true; Depressed = true;
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null); Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null);
} }
else else
{ {
YieldMouseFocus(mi); 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) else if (mi.Event == MouseInputEvent.Move && HasMouseFocus)

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets
// Mask to prevent any clicks from being sent to other widgets // Mask to prevent any clicks from being sent to other widgets
fullscreenMask = new MaskWidget(); fullscreenMask = new MaskWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height); 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) if (onCancel != null)
fullscreenMask.OnMouseDown += _ => onCancel(); fullscreenMask.OnMouseDown += _ => onCancel();

View File

@@ -25,6 +25,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
readonly Selection selection; readonly Selection selection;
readonly World world; readonly World world;
readonly string clickSound = ChromeMetrics.Get<string>("ClickSound");
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CycleProductionActorsHotkeyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, World world, Dictionary<string, MiniYaml> logicArgs) public CycleProductionActorsHotkeyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, World world, Dictionary<string, MiniYaml> logicArgs)
: base(widget, modData, "CycleProductionActorsKey", "WORLD_KEYHANDLER", logicArgs) : base(widget, modData, "CycleProductionActorsKey", "WORLD_KEYHANDLER", logicArgs)
@@ -32,6 +34,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
viewport = worldRenderer.Viewport; viewport = worldRenderer.Viewport;
selection = world.Selection; selection = world.Selection;
this.world = world; this.world = world;
MiniYaml yaml;
if (logicArgs.TryGetValue("ClickSound", out yaml))
clickSound = yaml.Value;
} }
protected override bool OnHotkeyActivated(KeyInput e) protected override bool OnHotkeyActivated(KeyInput e)
@@ -54,7 +60,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
if (next == null) if (next == null)
next = facilities.First(); 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); selection.Combine(world, new Actor[] { next }, false, true);
viewport.Center(selection.Actors); viewport.Center(selection.Actors);

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Commands; using OpenRA.Mods.Common.Commands;
@@ -36,11 +37,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly TabCompletionLogic tabCompletion = new TabCompletionLogic(); readonly TabCompletionLogic tabCompletion = new TabCompletionLogic();
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");
bool disableTeamChat; bool disableTeamChat;
bool teamChat; bool teamChat;
[ObjectCreator.UseCtor] [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<string, MiniYaml> logicArgs)
{ {
this.orderManager = orderManager; this.orderManager = orderManager;
this.modRules = modData.DefaultRules; this.modRules = modData.DefaultRules;
@@ -167,6 +170,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return false; return false;
}); });
} }
MiniYaml yaml;
if (logicArgs.TryGetValue("ChatLineSound", out yaml))
chatLineSound = yaml.Value;
} }
bool SwitchTeamChat() bool SwitchTeamChat()
@@ -239,7 +246,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatScrollPanel.ScrollToBottom(smooth: true); chatScrollPanel.ScrollToBottom(smooth: true);
if (!suppressSound) if (!suppressSound)
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null); Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
} }
bool disposed = false; bool disposed = false;

View File

@@ -24,6 +24,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world; readonly World world;
readonly Widget worldRoot; readonly Widget worldRoot;
readonly Widget menuRoot; readonly Widget menuRoot;
readonly string clickSound = ChromeMetrics.Get<string>("ClickSound");
bool disableSystemButtons; bool disableSystemButtons;
Widget currentWidget; Widget currentWidget;
@@ -107,7 +109,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
if (statsHotkeys[i].IsActivatedBy(e)) 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 } }); OpenMenuPanel(stats, new WidgetArgs() { { "activePanel", i } });
return true; return true;
} }
@@ -117,6 +119,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return false; return false;
}); });
} }
if (logicArgs.TryGetValue("ClickSound", out yaml))
clickSound = yaml.Value;
} }
void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null) void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)

View File

@@ -43,6 +43,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world; readonly World world;
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly string clickSound = ChromeMetrics.Get<string>("ClickSound");
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ObserverStatsLogic(World world, ModData modData, WorldRenderer worldRenderer, Widget widget, public ObserverStatsLogic(World world, ModData modData, WorldRenderer worldRenderer, Widget widget,
Action onExit, ObserverStatsPanel activePanel, Dictionary<string, MiniYaml> logicArgs) Action onExit, ObserverStatsPanel activePanel, Dictionary<string, MiniYaml> logicArgs)
@@ -128,7 +130,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
if (statsHotkeys[i].IsActivatedBy(e)) 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(); statsDropDownOptions[i].OnClick();
return true; return true;
} }
@@ -137,6 +139,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return false; return false;
}); });
if (logicArgs.TryGetValue("ClickSound", out yaml))
clickSound = yaml.Value;
} }
void ClearStats() void ClearStats()

View File

@@ -63,6 +63,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
bool addBotOnMapLoad; bool addBotOnMapLoad;
bool teamChat; bool teamChat;
readonly string chatLineSound = ChromeMetrics.Get<string>("ChatLineSound");
// Listen for connection failures // Listen for connection failures
void ConnectionStateChanged(OrderManager om) void ConnectionStateChanged(OrderManager om)
{ {
@@ -95,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager, internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager,
Action onExit, Action onStart, bool skirmishMode) Action onExit, Action onStart, bool skirmishMode, Dictionary<string, MiniYaml> logicArgs)
{ {
map = MapCache.UnknownMap; map = MapCache.UnknownMap;
lobby = widget; lobby = widget;
@@ -433,6 +435,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Add a bot on the first lobbyinfo update // Add a bot on the first lobbyinfo update
if (skirmishMode) if (skirmishMode)
addBotOnMapLoad = true; addBotOnMapLoad = true;
MiniYaml yaml;
if (logicArgs.TryGetValue("ChatLineSound", out yaml))
chatLineSound = yaml.Value;
} }
bool disposed; bool disposed;
@@ -472,7 +478,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (scrolledToBottom) if (scrolledToBottom)
lobbyChatPanel.ScrollToBottom(smooth: true); lobbyChatPanel.ScrollToBottom(smooth: true);
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null); Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
} }
bool SwitchTeamChat() bool SwitchTeamChat()

View File

@@ -73,6 +73,9 @@ namespace OpenRA.Mods.Common.Widgets
public readonly int TabWidth = 30; public readonly int TabWidth = 30;
public readonly int ArrowWidth = 20; public readonly int ArrowWidth = 20;
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference(); public readonly HotkeyReference PreviousProductionTabKey = new HotkeyReference();
public readonly HotkeyReference NextProductionTabKey = new HotkeyReference(); public readonly HotkeyReference NextProductionTabKey = new HotkeyReference();
@@ -270,9 +273,9 @@ namespace OpenRA.Mods.Common.Widgets
if (leftPressed || rightPressed) if (leftPressed || rightPressed)
{ {
if ((leftPressed && !leftDisabled) || (rightPressed && !rightDisabled)) 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 else
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickDisabledSound", null); Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", ClickDisabledSound, null);
} }
// Check production tabs // Check production tabs
@@ -280,7 +283,7 @@ namespace OpenRA.Mods.Common.Widgets
if (offsetloc.X > 0 && offsetloc.X < contentWidth) if (offsetloc.X > 0 && offsetloc.X < contentWidth)
{ {
CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue; 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; return true;
@@ -293,13 +296,13 @@ namespace OpenRA.Mods.Common.Widgets
if (PreviousProductionTabKey.IsActivatedBy(e)) 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); return SelectNextTab(true);
} }
if (NextProductionTabKey.IsActivatedBy(e)) 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); return SelectNextTab(false);
} }

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Mods.Common.Widgets
public int TopBottomSpacing = 2; public int TopBottomSpacing = 2;
public int ItemSpacing = 0; public int ItemSpacing = 0;
public int ButtonDepth = ChromeMetrics.Get<int>("ButtonDepth"); public int ButtonDepth = ChromeMetrics.Get<int>("ButtonDepth");
public string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public string Background = "scrollpanel-bg"; public string Background = "scrollpanel-bg";
public string Button = "scrollpanel-button"; public string Button = "scrollpanel-button";
public int ContentHeight; public int ContentHeight;
@@ -323,7 +324,7 @@ namespace OpenRA.Mods.Common.Widgets
lastMouseLocation = mi.Location; lastMouseLocation = mi.Location;
if (mi.Event == MouseInputEvent.Down && ((upPressed && !upDisabled) || (downPressed && !downDisabled) || thumbPressed)) 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; return upPressed || downPressed || thumbPressed;

View File

@@ -7,3 +7,6 @@ Metrics:
ColorPickerActorType: fact.colorpicker ColorPickerActorType: fact.colorpicker
ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
TextfieldColorHighlight: 800000 TextfieldColorHighlight: 800000
ChatLineSound: ChatLine
ClickDisabledSound: ClickDisabledSound
ClickSound: ClickSound

View File

@@ -7,3 +7,6 @@ Metrics:
FactionSuffix-smuggler: ordos FactionSuffix-smuggler: ordos
FactionSuffix-mercenary: ordos FactionSuffix-mercenary: ordos
TextfieldColorHighlight: 7f4d29 TextfieldColorHighlight: 7f4d29
ChatLineSound: ChatLine
ClickDisabledSound: ClickDisabledSound
ClickSound: ClickSound

View File

@@ -6,3 +6,6 @@ Metrics:
ButtonFont: Bold ButtonFont: Bold
CheckboxPressedState: true CheckboxPressedState: true
ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
ChatLineSound: ChatLine
ClickDisabledSound: ClickDisabledSound
ClickSound: ClickSound

View File

@@ -16,3 +16,6 @@ Metrics:
IncompatibleProtectedGameColor: B22222 IncompatibleProtectedGameColor: B22222
IncompatibleVersionColor: D3D3D3 IncompatibleVersionColor: D3D3D3
TextfieldColorHighlight: 562020 TextfieldColorHighlight: 562020
ChatLineSound: ChatLine
ClickDisabledSound: ClickDisabledSound
ClickSound: ClickSound

View File

@@ -3,3 +3,6 @@ Metrics:
ColorPickerActorType: mmch.colorpicker ColorPickerActorType: mmch.colorpicker
ColorPickerRemapIndices: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ColorPickerRemapIndices: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
TextfieldColorHighlight: 1a1a1a TextfieldColorHighlight: 1a1a1a
ChatLineSound: ChatLine
ClickDisabledSound: ClickDisabledSound
ClickSound: ClickSound