Skip to content

Commit

Permalink
fix KeyNotFoundException for sound handling
Browse files Browse the repository at this point in the history
  • Loading branch information
WeylonSantana committed Feb 26, 2025
1 parent 8d9e55e commit 7d67782
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected override void OnMouseEntered()
{
base.OnMouseEntered();

if (ShouldDrawHover)
if (ShouldDrawHover && _stateSoundNames.TryGetValue(ButtonSoundState.Hover, out var value))
{
PlaySound(_stateSoundNames[ButtonSoundState.Hover]);
PlaySound(value);
}
}

Expand All @@ -74,9 +74,9 @@ protected override void OnMouseDown(MouseButton mouseButton, Point mousePosition
return;
}

if (userAction)
if (userAction && _stateSoundNames.TryGetValue(ButtonSoundState.MouseDown, out var value))
{
PlaySound(_stateSoundNames[ButtonSoundState.MouseDown]);
PlaySound(value);
}

mHoldPos = _target.CanvasPosToLocal(mousePosition);
Expand All @@ -87,9 +87,9 @@ protected override void OnMouseUp(MouseButton mouseButton, Point mousePosition,
{
base.OnMouseUp(mouseButton, mousePosition, userAction);

if (userAction)
if (userAction && _stateSoundNames.TryGetValue(ButtonSoundState.MouseUp, out var value))
{
PlaySound(_stateSoundNames[ButtonSoundState.MouseUp]);
PlaySound(value);
}

InputHandler.MouseFocus = null;
Expand Down Expand Up @@ -269,9 +269,10 @@ public void SetSound(ButtonSoundState state, string? soundName)
}
}

public string GetMouseUpSound()
public string? GetMouseUpSound()
{
return _stateSoundNames[ButtonSoundState.MouseUp];
_ = _stateSoundNames.TryGetValue(ButtonSoundState.MouseUp, out var value)

Check failure on line 274 in Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 274 in Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 274 in Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs

View workflow job for this annotation

GitHub Actions / build

; expected
return value;
}

/// <summary>
Expand Down

0 comments on commit 7d67782

Please sign in to comment.