Add click sounds to color widgets.
This commit is contained in:
@@ -21,16 +21,23 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public Func<Color> GetColor;
|
||||
public Action<MouseInput> OnMouseDown = _ => { };
|
||||
public Action<MouseInput> OnMouseUp = _ => { };
|
||||
public string ClickSound = null;
|
||||
|
||||
public ColorBlockWidget()
|
||||
readonly Ruleset modRules;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ColorBlockWidget(ModData modData)
|
||||
{
|
||||
modRules = modData.DefaultRules;
|
||||
GetColor = () => Color;
|
||||
}
|
||||
|
||||
protected ColorBlockWidget(ColorBlockWidget widget)
|
||||
: base(widget)
|
||||
{
|
||||
modRules = widget.modRules;
|
||||
GetColor = widget.GetColor;
|
||||
ClickSound = widget.ClickSound;
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
@@ -63,6 +70,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
// OnMouseDown returns false if the button shouldn't be pressed
|
||||
OnMouseDown(mi);
|
||||
|
||||
Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user