Skip to content

Commit

Permalink
Switch to IsKeyPressedOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Mar 27, 2022
1 parent 2231663 commit 73a7efc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions EndlessClient/ControlSets/LoggedInControlSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected override void InitializeControlsHelper(IControlSet currentControlSet)
_changePasswordButton = GetControl(currentControlSet, GameControlIdentifier.ChangePasswordButton, GetPasswordButton);
_characterInfoPanels.AddRange(_characterInfoPanelFactory.CreatePanels(_characterSelectorProvider.Characters));

_allComponents.Add(new PreviousUserInputTracker(_endlessGameProvider, _userInputRepository));
_allComponents.Add(new CurrentUserInputTracker(_endlessGameProvider, _userInputRepository));
_allComponents.Add(_changePasswordButton);
_allComponents.AddRange(_characterInfoPanels);
Expand Down
6 changes: 4 additions & 2 deletions EndlessClient/UIControls/CharacterInfoPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using EOLib.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XNAControls;

namespace EndlessClient.UIControls
Expand Down Expand Up @@ -175,8 +176,9 @@ protected virtual void DoUpdateLogic(GameTime gameTime)
{
_characterControl.Update(gameTime);

var keyboardState = _userInputProvider.CurrentKeyState;
if (keyboardState.IsKeyDown((Microsoft.Xna.Framework.Input.Keys)49+_characterIndex))
var previousKeyState = _userInputProvider.PreviousKeyState;
var currentKeyState = _userInputProvider.CurrentKeyState;
if (currentKeyState.IsKeyPressedOnce(previousKeyState, Keys.D1 + _characterIndex))
{
Task.Run(async () => await LoginButtonClick());
}
Expand Down

0 comments on commit 73a7efc

Please sign in to comment.