Fix issues with the new "reverse grand prix" feature and user defined GPs

This commit is contained in:
Marc Coll Carrillo 2014-09-19 23:25:03 +02:00
parent 12977c3764
commit bbbe0ddf8d
3 changed files with 20 additions and 14 deletions

View File

@ -158,14 +158,20 @@ void GrandPrixData::changeReverse(const GrandPrixData::GPReverseType use_reverse
for (unsigned int i = 0; i < m_tracks.size(); i++)
{
if (use_reverse == GP_NO_REVERSE)
{
m_reversed[i] = false;
}
else if (use_reverse == GP_ALL_REVERSE) // all reversed
{
m_reversed[i] = track_manager->getTrack(m_tracks[i])->reverseAvailable();
}
else if (use_reverse == GP_RANDOM_REVERSE)
{
if (track_manager->getTrack(m_tracks[i])->reverseAvailable())
m_reversed[i] = (rand() % 2 != 0);
else
m_reversed[i] = false;
else // all reversed
m_reversed[i] = track_manager->getTrack(m_tracks[i])->reverseAvailable();
}
} // for i < m_tracks.size()
} // changeReverse

View File

@ -90,7 +90,8 @@ public:
{
GP_NO_REVERSE = 0,
GP_ALL_REVERSE = 1,
GP_RANDOM_REVERSE = 2
GP_RANDOM_REVERSE = 2,
GP_DEFAULT_REVERSE = 3
}; // GPReverseType
public:

View File

@ -71,8 +71,9 @@ void GPInfoScreen::loadedFromFile()
// (since the groups can change if addons are added/deleted).
m_group_spinner = getWidget<SpinnerWidget>("group-spinner");
m_reverse_spinner = getWidget<SpinnerWidget>("reverse-spinner");
m_reverse_spinner->addLabel(_("No"));
m_reverse_spinner->addLabel(_("Yes"));
m_reverse_spinner->addLabel(_("Default"));
m_reverse_spinner->addLabel(_("None"));
m_reverse_spinner->addLabel(_("All"));
m_reverse_spinner->addLabel(_("Random"));
m_reverse_spinner->setValue(0);
@ -108,13 +109,14 @@ GrandPrixData::GPReverseType GPInfoScreen::getReverse() const
{
switch (m_reverse_spinner->getValue())
{
case 0: return GrandPrixData::GP_NO_REVERSE; break;
case 1: return GrandPrixData::GP_ALL_REVERSE; break;
case 2: return GrandPrixData::GP_RANDOM_REVERSE; break;
default: assert(false);
case 0: return GrandPrixData::GP_DEFAULT_REVERSE; break;
case 1: return GrandPrixData::GP_NO_REVERSE; break;
case 2: return GrandPrixData::GP_ALL_REVERSE; break;
case 3: return GrandPrixData::GP_RANDOM_REVERSE; break;
default: assert(false);
} // switch
// Avoid compiler warning
return GrandPrixData::GP_NO_REVERSE;
return GrandPrixData::GP_DEFAULT_REVERSE;
} // getReverse
// ----------------------------------------------------------------------------
void GPInfoScreen::beforeAddingWidget()
@ -296,6 +298,7 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
// Normal GP: start/continue a saved GP
int n = getWidget<SpinnerWidget>("ai-spinner")->getValue();
m_gp.changeReverse(getReverse());
race_manager->setNumKarts(race_manager->getNumLocalPlayers() + n);
race_manager->startGP(m_gp, false, (name == "continue"));
}
@ -326,10 +329,6 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
m_gp.changeTrackNumber(m_num_tracks_spinner->getValue(), m_group_name);
addTracks();
}
else if (name=="reverse-spinner")
{
m_gp.changeReverse(getReverse());
}
else if(name=="back")
{
StateManager::get()->escapePressed();