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 Func<Color> GetColor;
|
||||||
public Action<MouseInput> OnMouseDown = _ => { };
|
public Action<MouseInput> OnMouseDown = _ => { };
|
||||||
public Action<MouseInput> OnMouseUp = _ => { };
|
public Action<MouseInput> OnMouseUp = _ => { };
|
||||||
|
public string ClickSound = null;
|
||||||
|
|
||||||
public ColorBlockWidget()
|
readonly Ruleset modRules;
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public ColorBlockWidget(ModData modData)
|
||||||
{
|
{
|
||||||
|
modRules = modData.DefaultRules;
|
||||||
GetColor = () => Color;
|
GetColor = () => Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ColorBlockWidget(ColorBlockWidget widget)
|
protected ColorBlockWidget(ColorBlockWidget widget)
|
||||||
: base(widget)
|
: base(widget)
|
||||||
{
|
{
|
||||||
|
modRules = widget.modRules;
|
||||||
GetColor = widget.GetColor;
|
GetColor = widget.GetColor;
|
||||||
|
ClickSound = widget.ClickSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone()
|
||||||
@@ -63,6 +70,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
// OnMouseDown returns false if the button shouldn't be pressed
|
// OnMouseDown returns false if the button shouldn't be pressed
|
||||||
OnMouseDown(mi);
|
OnMouseDown(mi);
|
||||||
|
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
public class ColorMixerWidget : Widget
|
public class ColorMixerWidget : Widget
|
||||||
{
|
{
|
||||||
|
readonly Ruleset modRules;
|
||||||
|
|
||||||
|
public string ClickSound = ChromeMetrics.Get<string>("ClickSound");
|
||||||
|
|
||||||
public event Action OnChange = () => { };
|
public event Action OnChange = () => { };
|
||||||
|
|
||||||
public float H { get; private set; }
|
public float H { get; private set; }
|
||||||
@@ -30,14 +34,18 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
Sprite mixerSprite;
|
Sprite mixerSprite;
|
||||||
bool isMoving;
|
bool isMoving;
|
||||||
|
|
||||||
public ColorMixerWidget()
|
[ObjectCreator.UseCtor]
|
||||||
|
public ColorMixerWidget(ModData modData)
|
||||||
{
|
{
|
||||||
|
modRules = modData.DefaultRules;
|
||||||
V = 1.0f;
|
V = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorMixerWidget(ColorMixerWidget other)
|
public ColorMixerWidget(ColorMixerWidget other)
|
||||||
: base(other)
|
: base(other)
|
||||||
{
|
{
|
||||||
|
modRules = other.modRules;
|
||||||
|
ClickSound = other.ClickSound;
|
||||||
OnChange = other.OnChange;
|
OnChange = other.OnChange;
|
||||||
H = other.H;
|
H = other.H;
|
||||||
S = other.S;
|
S = other.S;
|
||||||
@@ -126,6 +134,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
isMoving = true;
|
isMoving = true;
|
||||||
SetValueFromPx(mi.Location - RenderOrigin);
|
SetValueFromPx(mi.Location - RenderOrigin);
|
||||||
OnChange();
|
OnChange();
|
||||||
|
|
||||||
|
Game.Sound.PlayNotification(modRules, null, "Sounds", ClickSound, null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseInputEvent.Move:
|
case MouseInputEvent.Move:
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 27
|
Width: 27
|
||||||
Height: 27
|
Height: 27
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
Background@CUSTOM_HEADER:
|
Background@CUSTOM_HEADER:
|
||||||
Background: panel-black
|
Background: panel-black
|
||||||
Width: PARENT_RIGHT - 4
|
Width: PARENT_RIGHT - 4
|
||||||
@@ -123,3 +124,4 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 27
|
Width: 27
|
||||||
Height: 27
|
Height: 27
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 29
|
Width: 29
|
||||||
Height: 29
|
Height: 29
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
Background@CUSTOM_HEADER:
|
Background@CUSTOM_HEADER:
|
||||||
Background: dialog2
|
Background: dialog2
|
||||||
Width: PARENT_RIGHT - 4
|
Width: PARENT_RIGHT - 4
|
||||||
@@ -117,3 +118,4 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 29
|
Width: 29
|
||||||
Height: 29
|
Height: 29
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 29
|
Width: 29
|
||||||
Height: 29
|
Height: 29
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
Background@CUSTOM_HEADER:
|
Background@CUSTOM_HEADER:
|
||||||
Background: dialog2
|
Background: dialog2
|
||||||
Width: PARENT_RIGHT - 4
|
Width: PARENT_RIGHT - 4
|
||||||
@@ -118,3 +119,4 @@ Background@COLOR_CHOOSER:
|
|||||||
Width: 29
|
Width: 29
|
||||||
Height: 29
|
Height: 29
|
||||||
Visible: false
|
Visible: false
|
||||||
|
ClickSound: ClickSound
|
||||||
|
|||||||
Reference in New Issue
Block a user