Fixed player name spinner to contain the correct default value

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5079 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-03-27 16:03:11 +00:00
parent f9cb8b125d
commit 53df3f4cee
3 changed files with 26 additions and 3 deletions

View File

@@ -301,3 +301,19 @@ stringw SpinnerWidget::getStringValue() const
// -----------------------------------------------------------------------------
void SpinnerWidget::setValue(irr::core::stringw new_value)
{
const int size = m_labels.size();
for (int n=0; n<size; n++)
{
if (m_labels[n] == new_value)
{
setValue(n);
return;
}
}
assert(false);
}
// -----------------------------------------------------------------------------

View File

@@ -63,6 +63,11 @@ namespace GUIEngine
void add();
void setValue(const int new_value);
/**
* @precondition the 'new_value' string passed must be the name of an item in the spinner
*/
void setValue(irr::core::stringw new_value);
bool isGauge() const { return m_gauge; }
int getValue() const { return m_value; }
int getMax() const { return m_max; }

View File

@@ -273,8 +273,6 @@ public:
//playerName->m_event_handler = this;
m_children.push_back(playerName);
//TODO: select the right player profile in the spinner
//associatedPlayer->getProfile()->getName()
// ----- Kart model view
modelView = new ModelViewWidget();
@@ -388,11 +386,15 @@ public:
playerName->clearLabels();
const int playerAmount = UserConfigParams::m_all_players.size();
for(int n=0; n<playerAmount; n++)
for (int n=0; n<playerAmount; n++)
{
playerName->addLabel( UserConfigParams::m_all_players[n].getName() );
}
// select the right player profile in the spinner
playerName->setValue(m_associatedPlayer->getProfile()->getName());
assert(playerName->getStringValue() == m_associatedPlayer->getProfile()->getName());
}
/** Get the associated ActivePlayer object*/