Don't let players switch identity in single player mode. In single player mode this should be changed in the options screen

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11950 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-11-15 00:56:11 +00:00
parent 04c3b93bb1
commit 7921acc4aa
2 changed files with 52 additions and 22 deletions

View File

@ -1136,6 +1136,8 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
const bool pressed, bool focused)
{
if (!widget->isVisible()) return;
if (!focused)
{
IGUIElement* focused_widget = NULL;
@ -1268,6 +1270,8 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
void Skin::drawSpinnerChild(const core::recti &rect, Widget* widget,
const bool pressed, bool focused)
{
if (!widget->isVisible()) return;
if (pressed)
{
Widget* spinner = widget->m_event_handler;

View File

@ -247,6 +247,8 @@ public:
ModelViewWidget* m_model_view;
LabelWidget* m_kart_name;
KartSelectionScreen* m_parent_screen;
gui::IGUIStaticText* m_ready_text;
//LabelWidget *getPlayerIDLabel() {return m_player_ID_label;}
@ -264,6 +266,7 @@ public:
m_magic_number = 0x33445566;
#endif
m_ready_text = NULL;
m_parent_screen = parent;
m_associatedPlayer = associatedPlayer;
x_speed = 1.0f;
@ -310,12 +313,20 @@ public:
spinnerID = StringUtils::insertValues("@p%i_spinner", m_playerID);
m_player_ident_spinner->m_properties[PROP_ID] = spinnerID;
if (parent->m_multiplayer)
{
const int playerAmount = UserConfigParams::m_all_players.size();
m_player_ident_spinner->m_properties[PROP_MIN_VALUE] = "0";
m_player_ident_spinner->m_properties[PROP_MAX_VALUE] =
StringUtils::toString(playerAmount-1);
m_player_ident_spinner->m_properties[PROP_ID] = spinnerID;
m_player_ident_spinner->m_properties[PROP_WRAP_AROUND] = "true";
}
else
{
m_player_ident_spinner->m_properties[PROP_MIN_VALUE] = "0";
m_player_ident_spinner->m_properties[PROP_MAX_VALUE] = "0";
}
//m_player_ident_spinner->m_event_handler = this;
m_children.push_back(m_player_ident_spinner);
@ -509,6 +520,8 @@ public:
m_model_view->update(0);
m_player_ident_spinner->clearLabels();
if (m_parent_screen->m_multiplayer)
{
const int playerAmount = UserConfigParams::m_all_players.size();
for (int n=0; n<playerAmount; n++)
{
@ -519,6 +532,12 @@ public:
// select the right player profile in the spinner
m_player_ident_spinner->setValue(m_associatedPlayer->getProfile()
->getName() );
}
else
{
m_player_ident_spinner->addLabel( m_associatedPlayer->getProfile()->getName() );
m_player_ident_spinner->setVisible(false);
}
assert(m_player_ident_spinner->getStringValue() ==
m_associatedPlayer->getProfile()->getName());
@ -720,10 +739,14 @@ public:
.c_str()).c_str()
<< std::endl;
}
if (m_parent_screen->m_multiplayer)
{
m_associatedPlayer->setPlayerProfile(
UserConfigParams::m_all_players.get(m_player_ident_spinner
->getValue()) );
}
}
return EVENT_LET; // continue propagating the event
} // transmitEvent
@ -1810,11 +1833,14 @@ bool KartSelectionScreen::validateIdentChoices()
m_kart_widgets[n].m_player_ident_spinner->markAsCorrect();
// verify internal consistency in debug mode
if (m_multiplayer)
{
assert( m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
UserConfigParams::m_all_players.get(m_kart_widgets[n]
.m_player_ident_spinner->getValue()) );
}
}
}
// perform actual checking
for (int n=0; n<amount; n++)