Fixed bug 1804393 "kart model for incorrectly shares transformations"
This patch removes previously selected karts from the GUI so they cannot be selected more than once. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1413 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
25db1ea889
commit
b182a4ff27
@ -52,8 +52,19 @@ CharSel::CharSel(int whichPlayer)
|
||||
ssgContext* oldContext = ssgGetCurrentContext();
|
||||
m_context = new ssgContext;
|
||||
oldContext->makeCurrent();
|
||||
|
||||
widget_manager->setInitialActivationState(false);
|
||||
|
||||
// If m_player_index is 0 then this is a single player game or the first
|
||||
// player of a multiplayer game so we need to ensure that all karts are available.
|
||||
// If m_player_index is less than the number of elements in selected_karts then
|
||||
// the user is moving back through the menus and the last value in the vector
|
||||
// needs to be made available again.
|
||||
if (m_player_index == 0)
|
||||
kart_properties_manager->m_selected_karts.clear();
|
||||
|
||||
if (m_player_index < (int)kart_properties_manager->m_selected_karts.size())
|
||||
kart_properties_manager->m_selected_karts.pop_back();
|
||||
|
||||
widget_manager->setInitialActivationState(false);
|
||||
widget_manager->addWgt( WTOK_TITLE, 60, 10);
|
||||
widget_manager->showWgtRect( WTOK_TITLE );
|
||||
char HEADING[MAX_MESSAGE_LENGTH];
|
||||
@ -69,14 +80,18 @@ CharSel::CharSel(int whichPlayer)
|
||||
|
||||
for (unsigned int i = 0; i < kart_properties_manager->getNumberOfKarts(); i++)
|
||||
{
|
||||
const KartProperties* kp= kart_properties_manager->getKartById(i);
|
||||
Material *m = material_manager->getMaterial(kp->getIconFile());
|
||||
widget_manager->addWgt( WTOK_RACER0 + i, 10, 13);
|
||||
widget_manager->showWgtRect( WTOK_RACER0 + i);
|
||||
widget_manager->setWgtColor( WTOK_RACER0 + i, WGT_GRAY);
|
||||
widget_manager->setWgtTexture( WTOK_RACER0 + i, m->getState()->getTextureHandle());
|
||||
widget_manager->showWgtTexture( WTOK_RACER0 + i );
|
||||
widget_manager->activateWgt( WTOK_RACER0 + i );
|
||||
// Check if i has been previously selected
|
||||
if (kartAvailable(i))
|
||||
{
|
||||
const KartProperties* kp= kart_properties_manager->getKartById(i);
|
||||
Material *m = material_manager->getMaterial(kp->getIconFile());
|
||||
widget_manager->addWgt( WTOK_RACER0 + i, 10, 13);
|
||||
widget_manager->showWgtRect( WTOK_RACER0 + i);
|
||||
widget_manager->setWgtColor( WTOK_RACER0 + i, WGT_GRAY);
|
||||
widget_manager->setWgtTexture( WTOK_RACER0 + i, m->getState()->getTextureHandle());
|
||||
widget_manager->showWgtTexture( WTOK_RACER0 + i );
|
||||
widget_manager->activateWgt( WTOK_RACER0 + i );
|
||||
}
|
||||
}
|
||||
|
||||
widget_manager->breakLine();
|
||||
@ -95,7 +110,7 @@ CharSel::CharSel(int whichPlayer)
|
||||
m_current_kart = -1;
|
||||
|
||||
const int LAST_KART = user_config->m_player[m_player_index].getLastKartId();
|
||||
if( LAST_KART != -1 )
|
||||
if( LAST_KART != -1 && kartAvailable(LAST_KART))// is LAST_KART not in vector of selected karts
|
||||
{
|
||||
widget_manager->setSelectedWgt(WTOK_RACER0 + LAST_KART);
|
||||
switchCharacter(LAST_KART);
|
||||
@ -188,6 +203,9 @@ void CharSel::select()
|
||||
{
|
||||
race_manager->setPlayerKart(m_player_index, KP->getIdent());
|
||||
user_config->m_player[m_player_index].setLastKartId(TOKEN);
|
||||
// Add selected kart (TOKEN) to selected karts vector so it cannot be
|
||||
// selected again
|
||||
kart_properties_manager->m_selected_karts.push_back(TOKEN);
|
||||
}
|
||||
|
||||
if (race_manager->getNumPlayers() > 1)
|
||||
@ -222,3 +240,21 @@ void CharSel::select()
|
||||
else
|
||||
race_manager->start();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
// Function checks the vector of previously selected karts and returns true if
|
||||
// kart i is in the vector and false if it is not.
|
||||
|
||||
bool CharSel::kartAvailable(int kart)
|
||||
{
|
||||
if (!kart_properties_manager->m_selected_karts.empty())
|
||||
{
|
||||
std::vector<int>::iterator it;
|
||||
for (it = kart_properties_manager->m_selected_karts.begin();
|
||||
it < kart_properties_manager->m_selected_karts.end(); it++)
|
||||
{
|
||||
if ( kart == *it)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ private:
|
||||
float m_clock;
|
||||
|
||||
int m_player_index;
|
||||
|
||||
bool kartAvailable(int kart);
|
||||
|
||||
public:
|
||||
CharSel(int which_player);
|
||||
|
@ -36,7 +36,12 @@ protected:
|
||||
public:
|
||||
KartPropertiesManager();
|
||||
~KartPropertiesManager();
|
||||
|
||||
|
||||
// vector containing kart numbers that have been selected in multiplayer
|
||||
// games. This it used to ensure the same kart can not be selected more
|
||||
// than once.
|
||||
std::vector<int> m_selected_karts;
|
||||
|
||||
const KartProperties* getKartById (int i);
|
||||
const KartProperties* getKart (const std::string IDENT);
|
||||
const int getKartId (const std::string IDENT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user