Enable grand prix races in high score dialog (#4626)
This commit is contained in:
parent
95de01a8fb
commit
d5f8496abc
@ -4,7 +4,7 @@
|
||||
|
||||
<div width="100%" height="58%" layout="vertical-row">
|
||||
<div width="100%" height="15%" align="center" layout="vertical-row" >
|
||||
<label id="name" width="100%" text_align="center"/>
|
||||
<header id="name" width="100%" text_align="center"/>
|
||||
</div>
|
||||
<!-- This is filled in programmatically -->
|
||||
<div width="100%" height="85%" layout="horizontal-row">
|
||||
|
@ -165,8 +165,8 @@ void Highscores::writeEntry(UTFWriter &writer)
|
||||
writer << " number-of-laps=\"" << m_number_of_laps << "\"\n";
|
||||
if (m_highscore_type == "HST_GRANDPRIX")
|
||||
{
|
||||
writer << " reverse-type=\"" << m_gp_reverse_type << "\"\n";
|
||||
writer << " minor-mode=\"" << m_gp_minor_mode << "\">\n";
|
||||
writer << " reverse-type =\"" << m_gp_reverse_type << "\"\n";
|
||||
writer << " minor-mode =\"" << m_gp_minor_mode << "\">\n";
|
||||
}
|
||||
else
|
||||
writer << " reverse =\"" << m_reverse << "\">\n";
|
||||
|
@ -64,16 +64,19 @@ HighScoreInfoDialog::HighScoreInfoDialog(Highscores* highscore, bool is_linear,
|
||||
|
||||
if (m_major_mode == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
m_gp = grand_prix_manager->getGrandPrix(m_hs->m_track);
|
||||
track = track_manager->getTrack(m_gp->getTrackId(0));
|
||||
track_name = m_gp->getName();
|
||||
m_gp = *grand_prix_manager->getGrandPrix(m_hs->m_track);
|
||||
m_gp.checkConsistency();
|
||||
track = track_manager->getTrack(m_gp.getTrackId(0));
|
||||
track_name = m_gp.getName();
|
||||
track_type_name = _("Grand Prix");
|
||||
m_minor_mode = (RaceManager::MinorRaceModeType)m_hs->m_gp_minor_mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
track = track_manager->getTrack(m_hs->m_track);
|
||||
track_name = track->getName();
|
||||
track_type_name = _("Track");
|
||||
m_minor_mode = HighScoreSelection::getInstance()->getActiveMode();
|
||||
}
|
||||
|
||||
irr::video::ITexture* image = STKTexManager::getInstance()
|
||||
@ -121,19 +124,17 @@ HighScoreInfoDialog::HighScoreInfoDialog(Highscores* highscore, bool is_linear,
|
||||
m_num_karts_label->setVisible(true);
|
||||
m_num_karts_label->setText(_("Number of karts: %d", m_hs->m_number_of_karts), true);
|
||||
|
||||
if (m_major_mode != RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
m_num_laps_label->setVisible(true);
|
||||
m_num_laps_label->setText(_("Laps: %d", m_hs->m_number_of_laps), true);
|
||||
}
|
||||
stringw is_reverse;
|
||||
if (m_major_mode == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
is_reverse = GrandPrixData::reverseTypeToString((GrandPrixData::GPReverseType)m_hs->m_gp_reverse_type);
|
||||
m_num_laps_label->setText(_("Game mode: %d", RaceManager::getNameOf(m_minor_mode)), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
is_reverse = m_hs->m_reverse ? _("Yes") : _("No");
|
||||
m_num_laps_label->setText(_("Laps: %d", m_hs->m_number_of_laps), true);
|
||||
|
||||
}
|
||||
m_reverse_label->setVisible(true);
|
||||
m_reverse_label->setText(_("Reverse: %s", is_reverse), true);
|
||||
@ -147,9 +148,8 @@ HighScoreInfoDialog::HighScoreInfoDialog(Highscores* highscore, bool is_linear,
|
||||
|
||||
m_start_widget = getWidget<IconButtonWidget>("start");
|
||||
|
||||
// Disable starting a grand prix, as there is currently no way to tell the minor mode used
|
||||
if (m_major_mode == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
m_start_widget->setActive(false);
|
||||
m_start_widget->setActive(!PlayerManager::getCurrentPlayer()->isLocked(m_gp.getId()));
|
||||
else
|
||||
m_start_widget->setActive(!PlayerManager::getCurrentPlayer()->isLocked(track->getIdent()));
|
||||
|
||||
@ -244,13 +244,8 @@ GUIEngine::EventPropagation
|
||||
// Create player and associate player with device
|
||||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), device);
|
||||
|
||||
RaceManager::get()->setMinorMode(HighScoreSelection::getInstance()->getActiveMode());
|
||||
|
||||
bool reverse = m_hs->m_reverse;
|
||||
std::string track_name = m_hs->m_track;
|
||||
int laps = m_hs->m_number_of_laps;
|
||||
|
||||
RaceManager::get()->setDifficulty((RaceManager::Difficulty) m_hs->m_difficulty);
|
||||
RaceManager::get()->setMinorMode(m_minor_mode);
|
||||
RaceManager::get()->setDifficulty((RaceManager::Difficulty)m_hs->m_difficulty);
|
||||
|
||||
RaceManager::get()->setNumKarts(m_hs->m_number_of_karts);
|
||||
RaceManager::get()->setNumPlayers(1);
|
||||
@ -266,16 +261,30 @@ GUIEngine::EventPropagation
|
||||
// Disable accidentally unlocking of a challenge
|
||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
||||
|
||||
RaceManager::get()->setReverseTrack(reverse);
|
||||
|
||||
// ASSIGN should make sure that only input from assigned devices is read
|
||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
||||
input_manager->getDeviceManager()
|
||||
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||
|
||||
bool reverse = m_hs->m_reverse;
|
||||
GrandPrixData::GPReverseType gp_reverse = (GrandPrixData::GPReverseType)m_hs->m_gp_reverse_type;
|
||||
std::string track_name = m_hs->m_track;
|
||||
int laps = m_hs->m_number_of_laps;
|
||||
RaceManager::MajorRaceModeType major_mode = m_major_mode;
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
RaceManager::get()->startSingleRace(track_name, laps, false);
|
||||
if (major_mode == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
GrandPrixData gp = *grand_prix_manager->getGrandPrix(track_name);
|
||||
gp.changeReverse(gp_reverse);
|
||||
RaceManager::get()->startGP(gp, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RaceManager::get()->setReverseTrack(reverse);
|
||||
RaceManager::get()->startSingleRace(track_name, laps, false);
|
||||
}
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "remove")
|
||||
@ -309,7 +318,7 @@ void HighScoreInfoDialog::onUpdate(float dt)
|
||||
m_curr_time += dt;
|
||||
int frame_after = (int)(m_curr_time / 1.5f);
|
||||
|
||||
const std::vector<std::string> tracks = m_gp->getTrackNames();
|
||||
const std::vector<std::string> tracks = m_gp.getTrackNames();
|
||||
if (frame_after >= (int)tracks.size())
|
||||
{
|
||||
frame_after = 0;
|
||||
|
@ -49,10 +49,11 @@ private:
|
||||
void updateHighscoreEntries();
|
||||
|
||||
RaceManager::MajorRaceModeType m_major_mode;
|
||||
RaceManager::MinorRaceModeType m_minor_mode;
|
||||
|
||||
float m_curr_time;
|
||||
|
||||
const GrandPrixData* m_gp;
|
||||
GrandPrixData m_gp;
|
||||
|
||||
public:
|
||||
HighScoreInfoDialog(Highscores* highscore, bool is_linear, RaceManager::MajorRaceModeType major_mode);
|
||||
|
Loading…
Reference in New Issue
Block a user