Merge pull request #6621 from steelphase-forks/bleed-soundfix

Sound Fix for DropDownButton Widget
This commit is contained in:
Paul Chote
2014-10-01 22:12:55 +13:00
2 changed files with 8 additions and 8 deletions

View File

@@ -52,12 +52,12 @@ namespace OpenRA.Widgets
public Action OnDoubleClick = () => {}; public Action OnDoubleClick = () => {};
public Action<KeyInput> OnKeyPress = _ => {}; public Action<KeyInput> OnKeyPress = _ => {};
readonly Ruleset modRules; protected readonly Ruleset ModRules;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ButtonWidget(Ruleset modRules) public ButtonWidget(Ruleset modRules)
{ {
this.modRules = modRules; ModRules = modRules;
GetText = () => Text; GetText = () => Text;
GetColor = () => TextColor; GetColor = () => TextColor;
@@ -74,7 +74,7 @@ namespace OpenRA.Widgets
protected ButtonWidget(ButtonWidget other) protected ButtonWidget(ButtonWidget other)
: base(other) : base(other)
{ {
this.modRules = other.modRules; ModRules = other.ModRules;
Text = other.Text; Text = other.Text;
Font = other.Font; Font = other.Font;
@@ -119,10 +119,10 @@ namespace OpenRA.Widgets
if (!IsDisabled()) if (!IsDisabled())
{ {
OnKeyPress(e); OnKeyPress(e);
Sound.PlayNotification(modRules, null, "Sounds", "ClickSound", null); Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
} }
else else
Sound.PlayNotification(modRules, null, "Sounds", "ClickDisabledSound", null); Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
return true; return true;
} }
@@ -159,12 +159,12 @@ namespace OpenRA.Widgets
{ {
OnMouseDown(mi); OnMouseDown(mi);
Depressed = true; Depressed = true;
Sound.PlayNotification(modRules, null, "Sounds", "ClickSound", null); Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
} }
else else
{ {
YieldMouseFocus(mi); YieldMouseFocus(mi);
Sound.PlayNotification(modRules, null, "Sounds", "ClickDisabledSound", null); Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
} }
} }
else if (mi.Event == MouseInputEvent.Move && HasMouseFocus) else if (mi.Event == MouseInputEvent.Move && HasMouseFocus)

View File

@@ -76,7 +76,7 @@ namespace OpenRA.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 => RemovePanel(); fullscreenMask.OnMouseDown += mi => { Sound.PlayNotification(this.ModRules, null, "Sounds", "ClickSound", null); RemovePanel(); };
if (onCancel != null) if (onCancel != null)
fullscreenMask.OnMouseDown += _ => onCancel(); fullscreenMask.OnMouseDown += _ => onCancel();