From 7b524ebba018fd1db5062ba48bb03d4d57cce9be Mon Sep 17 00:00:00 2001 From: Fernando Arzola <17498701+Arufonsu@users.noreply.github.com> Date: Wed, 17 Jul 2024 08:32:42 -0400 Subject: [PATCH] enhancement: press enter key to select character to play (#2328) --- Intersect.Client/Core/Input.cs | 14 ++++++++++++++ Intersect.Client/Interface/Menu/MainMenu.cs | 2 +- .../Interface/Menu/SelectCharacterWindow.cs | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Intersect.Client/Core/Input.cs b/Intersect.Client/Core/Input.cs index c3e9fa52f9..8a728fbcdc 100644 --- a/Intersect.Client/Core/Input.cs +++ b/Intersect.Client/Core/Input.cs @@ -210,6 +210,20 @@ public static void OnKeyPressed(Keys modifier, Keys key) break; case GameStates.Menu: + var selectCharacterWindow = Interface.Interface.MenuUi.MainMenu.mSelectCharacterWindow; + + switch (control) + { + case Control.Enter: + if (!selectCharacterWindow.IsHidden && selectCharacterWindow.Characters[selectCharacterWindow.mSelectedChar] != null) + { + selectCharacterWindow.PlayButton_Clicked(null, null); + consumeKey = true; + } + + break; + } + break; case GameStates.InGame: diff --git a/Intersect.Client/Interface/Menu/MainMenu.cs b/Intersect.Client/Interface/Menu/MainMenu.cs index 4069675813..03b047d1bd 100644 --- a/Intersect.Client/Interface/Menu/MainMenu.cs +++ b/Intersect.Client/Interface/Menu/MainMenu.cs @@ -43,7 +43,7 @@ public static void HandleReceivedConfiguration() private readonly ResetPasswordWindow mResetPasswordWindow; - private readonly SelectCharacterWindow mSelectCharacterWindow; + public readonly SelectCharacterWindow mSelectCharacterWindow; //Character creation feild check private bool mHasMadeCharacterCreation; diff --git a/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs b/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs index dd6ef8781c..bb66c34af7 100644 --- a/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs +++ b/Intersect.Client/Interface/Menu/SelectCharacterWindow.cs @@ -51,7 +51,7 @@ public partial class SelectCharacterWindow private Button mPrevCharButton; //Selected Char - private int mSelectedChar = 0; + public int mSelectedChar = 0; //Init public SelectCharacterWindow(Canvas parent, MainMenu mainMenu) @@ -88,7 +88,7 @@ public SelectCharacterWindow(Canvas parent, MainMenu mainMenu) //Play Button mPlayButton = new Button(mCharacterSelectionPanel, "PlayButton"); mPlayButton.SetText(Strings.CharacterSelection.Play); - mPlayButton.Clicked += _playButton_Clicked; + mPlayButton.Clicked += PlayButton_Clicked; mPlayButton.Hide(); //Delete Button @@ -366,7 +366,7 @@ private void _nextCharButton_Clicked(Base sender, ClickedEventArgs arguments) UpdateDisplay(); } - private void _playButton_Clicked(Base sender, ClickedEventArgs arguments) + public void PlayButton_Clicked(Base? sender, ClickedEventArgs? arguments) { if (Globals.WaitingOnServer) {