diff --git a/src/guiengine/widget.cpp b/src/guiengine/widget.cpp index 9ccb5e59c..6a85ab64c 100644 --- a/src/guiengine/widget.cpp +++ b/src/guiengine/widget.cpp @@ -111,6 +111,11 @@ void Widget::setFocusForPlayer(const int playerID) m_player_focus[playerID] = true; GUIEngine::g_focus_for_player[playerID] = this; } + +void Widget::unsetFocusForPlayer(const int playerID) +{ + m_player_focus[playerID] = false; +} /** * \param playerID ID of the player you want to set/unset focus for, starting from 0 diff --git a/src/guiengine/widget.hpp b/src/guiengine/widget.hpp index 2beeb79e4..66e7aacdf 100644 --- a/src/guiengine/widget.hpp +++ b/src/guiengine/widget.hpp @@ -251,6 +251,8 @@ namespace GUIEngine */ bool isFocusedForPlayer(const int playerID); + void unsetFocusForPlayer(const int playerID); + /** * Call to resize/move the widget. Not all widgets can resize gracefully. */ diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index cba62f544..f7dd42359 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -525,6 +525,13 @@ bool playerQuit(ActivePlayer* player) // between g_player_karts and the active player array assert( g_player_karts.size() == StateManager::get()->activePlayerCount() ); + // unset selection of this player + if (GUIEngine::g_focus_for_player[playerID] != NULL) + { + GUIEngine::g_focus_for_player[playerID]->unsetFocusForPlayer(playerID); + } + GUIEngine::g_focus_for_player[playerID] = NULL; + removedWidget = g_player_karts.remove(playerID); StateManager::get()->removeActivePlayer(playerID); renumberKarts();