From 27c5a59a252a64f6c89527db4d18ca069f5a8642 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 31 Oct 2009 00:45:59 +0000 Subject: [PATCH] Players quitting is now a bit better handled (selections shouldnt be messed up anymore) but hard to test since I only have a keyboard + a gamepad. Folks with lots of gamepads, testing please\! git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4176 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/states_screens/kart_selection.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index f06d02cfc..6cf15cd1f 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -303,6 +303,12 @@ FocusDispatcher* g_dispatcher = NULL; ~PlayerKartWidget() { + if (GUIEngine::g_focus_for_player[m_playerID] == this) + { + unsetFocusForPlayer(m_playerID); + GUIEngine::g_focus_for_player[m_playerID] = NULL; + } + if (playerIDLabel->getIrrlichtElement() != NULL) playerIDLabel->getIrrlichtElement()->remove(); @@ -328,8 +334,14 @@ FocusDispatcher* g_dispatcher = NULL; assert(false); } + Widget* focus = GUIEngine::g_focus_for_player[m_playerID]; + if (focus != NULL) focus->unsetFocusForPlayer(m_playerID); + GUIEngine::g_focus_for_player[m_playerID] = NULL; + m_playerID = newPlayerID; + if (focus != NULL) focus->setFocusForPlayer(m_playerID); + //I18N: In kart selection screen (Will read like 'Player 1 (foobartech gamepad)') irr::core::stringw newLabel = StringUtils::insertValues(_("Player %i (%s)"), m_playerID + 1, deviceName.c_str()); playerIDLabel->setText( newLabel ); @@ -788,7 +800,7 @@ bool KartSelectionScreen::playerQuit(ActivePlayer* player) StateManager::get()->removeActivePlayer(playerID); // Karts count changed, maybe order too, so renumber them - renumberKarts(); + renumberKarts(); // Tell the removed widget to perform the shrinking animation (which will be updated in onUpdate, // and will stop when the widget has disappeared)