From c18343f60b2dcc71741079b4c4987f16661c8eeb Mon Sep 17 00:00:00 2001 From: "auria.mg" Date: Tue, 12 Apr 2016 19:25:45 -0400 Subject: [PATCH] Improvements to login screen : properly center buttons, and allow logging in by pressing enter --- data/gui/user_screen.stkgui | 31 +++++++++++++++++------------- src/states_screens/user_screen.cpp | 21 ++++++++++++++++++++ src/states_screens/user_screen.hpp | 8 +++++++- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui index 588486c8b..fda946f5f 100644 --- a/data/gui/user_screen.stkgui +++ b/data/gui/user_screen.stkgui @@ -48,19 +48,24 @@
- - - - - - - - + + + +
+ + + + + + + +
+ diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 293e28903..91071c597 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -181,6 +181,27 @@ void BaseUserScreen::tearDown() Screen::tearDown(); } // tearDown +// ---------------------------------------------------------------------------- + +EventPropagation BaseUserScreen::filterActions(PlayerAction action, + int deviceID, + const unsigned int value, + Input::InputType type, + int playerId) +{ + if (action == PA_MENU_SELECT) + { + if ((m_username_tb != NULL && m_username_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)) + || (m_password_tb != NULL && m_password_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))) + { + login(); + } + return EVENT_BLOCK; + } + + return EVENT_LET; +} + // ---------------------------------------------------------------------------- /** Called when a user is selected. It updates the online checkbox and * entry fields. diff --git a/src/states_screens/user_screen.hpp b/src/states_screens/user_screen.hpp index 7b98bdfb5..a54dab37e 100644 --- a/src/states_screens/user_screen.hpp +++ b/src/states_screens/user_screen.hpp @@ -23,7 +23,7 @@ #include "guiengine/screen.hpp" #include "guiengine/widgets/spinner_widget.hpp" - +#include "input/input.hpp" namespace GUIEngine { class CheckBoxWidget; @@ -125,6 +125,12 @@ public: void loginError(const irr::core::stringw &error_message); void logoutSuccessful(); void logoutError(const irr::core::stringw &error_message); + + virtual GUIEngine::EventPropagation filterActions(PlayerAction action, + int deviceID, + const unsigned int value, + Input::InputType type, + int playerId) OVERRIDE; }; // class BaseUserScreen // ============================================================================