Skip to content

Commit

Permalink
Add sound on keyboard shortcut for selecting character
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Nov 4, 2024
1 parent 14562ac commit 0920a88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion EndlessClient/UIControls/CharacterInfoPanel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EndlessClient.Audio;
using EndlessClient.Controllers;
using EndlessClient.Dialogs.Services;
using EndlessClient.Input;
Expand Down Expand Up @@ -29,6 +30,7 @@ public class CharacterInfoPanel : XNAControl
private readonly ISpriteSheet _adminGraphic;
private readonly IUserInputProvider _userInputProvider;
private readonly IXnaControlSoundMapper _xnaControlSoundMapper;
private readonly ISfxPlayer _sfxPlayer;
private readonly Texture2D _backgroundImage;

private readonly IXNAButton _loginButton, _deleteButton;
Expand Down Expand Up @@ -74,7 +76,8 @@ public CharacterInfoPanel(int characterIndex,
ICharacterRendererFactory rendererFactory,
IRendererRepositoryResetter rendererRepositoryResetter,
IUserInputProvider userInputProvider,
IXnaControlSoundMapper xnaControlSoundMapper)
IXnaControlSoundMapper xnaControlSoundMapper,
ISfxPlayer sfxPlayer)
: this(characterIndex, gfxManager, dialogButtonService)
{
_character = character;
Expand All @@ -83,6 +86,7 @@ public CharacterInfoPanel(int characterIndex,
_rendererRepositoryResetter = rendererRepositoryResetter;
_userInputProvider = userInputProvider;
_xnaControlSoundMapper = xnaControlSoundMapper;
_sfxPlayer = sfxPlayer;

_characterControl = new CharacterControl(character, rendererFactory)
{
Expand Down Expand Up @@ -172,6 +176,7 @@ protected virtual void DoUpdateLogic(GameTime gameTime)
if (currentKeyState.IsKeyPressedOnce(previousKeyState, Keys.D1 + _characterIndex) &&
!Game.Components.OfType<IXNADialog>().Any())
{
_sfxPlayer.PlaySfx(SoundEffectID.ButtonClick);
AsyncButtonClick(() => _loginController.LoginToCharacter(_character));
}
}
Expand Down
10 changes: 8 additions & 2 deletions EndlessClient/UIControls/CharacterInfoPanelFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using AutomaticTypeMapper;
using EndlessClient.Audio;
using EndlessClient.Controllers;
using EndlessClient.Dialogs.Services;
using EndlessClient.Input;
Expand All @@ -20,6 +21,8 @@ public class CharacterInfoPanelFactory : ICharacterInfoPanelFactory
private readonly IEODialogButtonService _eoDialogButtonService;
private readonly IUserInputProvider _userInputProvider;
private readonly IXnaControlSoundMapper _xnaControlSoundMapper;
private readonly ISfxPlayer _sfxPlayer;

private ILoginController _loginController;
private ICharacterManagementController _characterManagementController;

Expand All @@ -28,14 +31,16 @@ public CharacterInfoPanelFactory(INativeGraphicsManager nativeGraphicsManager,
IRendererRepositoryResetter rendererRepositoryResetter,
IEODialogButtonService eoDialogButtonService,
IUserInputProvider userInputProvider,
IXnaControlSoundMapper xnaControlSoundMapper)
IXnaControlSoundMapper xnaControlSoundMapper,
ISfxPlayer sfxPlayer)
{
_nativeGraphicsManager = nativeGraphicsManager;
_characterRendererFactory = characterRendererFactory;
_rendererRepositoryResetter = rendererRepositoryResetter;
_eoDialogButtonService = eoDialogButtonService;
_userInputProvider = userInputProvider;
_xnaControlSoundMapper = xnaControlSoundMapper;
_sfxPlayer = sfxPlayer;
}

public void InjectLoginController(ILoginController loginController)
Expand Down Expand Up @@ -65,7 +70,8 @@ public IEnumerable<CharacterInfoPanel> CreatePanels(IEnumerable<Character> chara
_characterRendererFactory,
_rendererRepositoryResetter,
_userInputProvider,
_xnaControlSoundMapper);
_xnaControlSoundMapper,
_sfxPlayer);
}

for (; i < 3; ++i)
Expand Down

0 comments on commit 0920a88

Please sign in to comment.