From: <au...@us...> - 2009-10-31 01:00:01
|
Revision: 4178 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4178&view=rev Author: auria Date: 2009-10-31 00:59:52 +0000 (Sat, 31 Oct 2009) Log Message: ----------- Fixed selections confused when switching kart group tab Modified Paths: -------------- main/branches/irrlicht/src/states_screens/kart_selection.cpp Modified: main/branches/irrlicht/src/states_screens/kart_selection.cpp =================================================================== --- main/branches/irrlicht/src/states_screens/kart_selection.cpp 2009-10-31 00:47:28 UTC (rev 4177) +++ main/branches/irrlicht/src/states_screens/kart_selection.cpp 2009-10-31 00:59:52 UTC (rev 4178) @@ -592,6 +592,10 @@ { m_kartInternalName = whichKart; } + const std::string& getKartInternalName() const + { + return m_kartInternalName; + } }; #if 0 @@ -1068,7 +1072,35 @@ } w->updateItemDisplay(); - + + // update players selections + const int num_players = m_kart_widgets.size(); + for (int n=0; n<num_players; n++) + { + if (GUIEngine::g_focus_for_player[n] != NULL) + { + GUIEngine::g_focus_for_player[n]->unsetFocusForPlayer(n); + } + GUIEngine::g_focus_for_player[n] = NULL; + + const std::string& selection = m_kart_widgets[n].getKartInternalName(); + if (!w->setSelection( selection, n )) + { + std::cout << "Player " << n << " lost their selection when switching tabs!!!\n"; + // For now, select a random kart in this case (TODO : maybe do something better? ) + RandomGenerator random; + const int count = w->getItems().size(); + if (count > 0) + { + const int randomID = random.get( count ); + w->setSelection( randomID, n ); + } + else + { + std::cerr << "WARNING : kart selection screen has 0 items in the ribbon\n"; + } + } + } } else if (name == "karts") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |