Add click sounds to ingame buttons

This commit is contained in:
Paul Chote
2011-07-09 17:56:47 +12:00
parent 195aecec0e
commit 47ba4cb285
5 changed files with 31 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ namespace OpenRA.Widgets
public bool Depressed = false;
public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth");
public string Font = ChromeMetrics.Get<string>("ButtonFont");
public string ClickSound = null;
public string ClickDisabledSound = null;
public Func<string> GetText;
public Func<bool> IsDisabled = () => false;
public Action<MouseInput> OnMouseDown = _ => {};
@@ -65,7 +67,12 @@ namespace OpenRA.Widgets
return false;
if (!IsDisabled())
{
OnKeyPress(e);
Sound.Play(ClickSound);
}
else
Sound.Play(ClickDisabledSound);
return true;
}
@@ -94,9 +101,13 @@ namespace OpenRA.Widgets
{
OnMouseDown(mi);
Depressed = true;
Sound.Play(ClickSound);
}
else
{
LoseFocus(mi);
Sound.Play(ClickDisabledSound);
}
}
else if (mi.Event == MouseInputEvent.Move && Focused)
Depressed = RenderBounds.Contains(mi.Location.X, mi.Location.Y);

View File

@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
chatPanel.AddChild(template);
chatPanel.ScrollToBottom();
Sound.Play("scold2.aud");
Sound.Play("scold1.aud");
}
void UpdateCurrentMap()

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public class ProductionPaletteWidget : Widget
{
public readonly int Columns = 3;
public readonly string TabClick = "button.aud";
public readonly string TabClick = null;
public readonly string TooltipContainer;
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";

View File

@@ -19,7 +19,7 @@ Container@INGAME_ROOT:
DrawBackground: False
RemoveTime:250
UseContrast: yes
Notification: scold2.aud
Notification: scold1.aud
ChatEntry@CHAT_ENTRY:
Id:CHAT_ENTRY
X:250
@@ -137,6 +137,8 @@ Container@PLAYER_WIDGETS:
Font:Bold
TooltipText: Menu
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -154,6 +156,8 @@ Container@PLAYER_WIDGETS:
Font:Bold
TooltipText: Sell
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -170,6 +174,8 @@ Container@PLAYER_WIDGETS:
Font:Bold
TooltipText: Repair
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -247,6 +253,8 @@ Container@PLAYER_WIDGETS:
Key: y
TooltipText: Buildings
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -261,6 +269,8 @@ Container@PLAYER_WIDGETS:
Key: u
TooltipText: Defense
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -275,6 +285,8 @@ Container@PLAYER_WIDGETS:
Key: i
TooltipText: Infantry
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -289,6 +301,8 @@ Container@PLAYER_WIDGETS:
Key: o
TooltipText: Vehicles
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON
@@ -303,6 +317,8 @@ Container@PLAYER_WIDGETS:
Key: p
TooltipText: Aircraft
TooltipContainer:TOOLTIP_CONTAINER
ClickSound:button.aud
ClickDisabledSound:scold2.aud
Children:
Image:
Id:ICON