From e727b8866695efc9cacc416bf26bc5a78dcfb21e Mon Sep 17 00:00:00 2001 From: sorokya Date: Sun, 27 Mar 2022 12:27:59 +0200 Subject: [PATCH] Switch to IsKeyPressedOnce --- EndlessClient/ControlSets/LoggedInControlSet.cs | 1 + EndlessClient/UIControls/CharacterInfoPanel.cs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/EndlessClient/ControlSets/LoggedInControlSet.cs b/EndlessClient/ControlSets/LoggedInControlSet.cs index 08d4d6032..3c8f29287 100644 --- a/EndlessClient/ControlSets/LoggedInControlSet.cs +++ b/EndlessClient/ControlSets/LoggedInControlSet.cs @@ -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); diff --git a/EndlessClient/UIControls/CharacterInfoPanel.cs b/EndlessClient/UIControls/CharacterInfoPanel.cs index 74912ab58..37a35994e 100644 --- a/EndlessClient/UIControls/CharacterInfoPanel.cs +++ b/EndlessClient/UIControls/CharacterInfoPanel.cs @@ -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 @@ -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()); }