Show the name of who made the fastest lap (#3683)

* implemented showing the name who made the fastest lap in race result screen (only for offline play yet)

* also support online races, using english and added translation note

* added comment

* Fix typo
This commit is contained in:
Mrxx99
2019-01-06 15:17:48 +01:00
committed by Alayan-stk-2
parent cbb26b73d9
commit 9fb90d0c31
3 changed files with 23 additions and 0 deletions

View File

@@ -76,6 +76,8 @@ void LinearWorld::init()
m_last_lap_sfx_played = false;
m_last_lap_sfx_playing = false;
m_fastest_lap_kart_name = "";
// The values are initialised in reset()
m_kart_info.resize(m_karts.size());
} // init
@@ -497,6 +499,7 @@ void LinearWorld::newLap(unsigned int kart_index)
// Store the temporary string because clang would mess this up
// (remove the stringw before the wchar_t* is used).
const core::stringw &kart_name = kart->getController()->getName();
m_fastest_lap_kart_name = kart_name;
//I18N: as in "fastest lap: 60 seconds by Wilber"
irr::core::stringw m_fastest_lap_message =

View File

@@ -46,6 +46,8 @@ private:
/** The fastest lap time, in ticks of physics dt. */
int m_fastest_lap_ticks;
core::stringw m_fastest_lap_kart_name;
/** The track length returned by Track::getLength() only covers the
* distance from start line to finish line, i.e. it does not include
* the distance the karts actually start behind the start line (the
@@ -194,6 +196,12 @@ public:
return stk_config->ticks2Time(m_fastest_lap_ticks);
}
// ------------------------------------------------------------------------
/** Returns the kart name that made the fastest lap time */
stringw getFastestLapKartName() const
{
return m_fastest_lap_kart_name;
}
// ------------------------------------------------------------------------
/** Network use: get fastest lap in ticks */
int getFastestLapTicks() const
{

View File

@@ -1657,6 +1657,18 @@ void RaceResultGUI::displayCTFResults()
GUIEngine::getFont()->draw(best_lap_string,
core::recti(x, current_y, 0, 0), white_color, false, false,
nullptr, true);
core::stringw best_lap_by = dynamic_cast<LinearWorld*>(World::getWorld())->getFastestLapKartName();
if (best_lap_by != NULL)
{
//I18N: is used to indicate who has the bast laptime (best laptime "by kart_name")
core::stringw best_lap_by_string = _("by %s", best_lap_by);
current_y += int(m_distance_between_meta_rows * 0.6f);
GUIEngine::getFont()->draw(best_lap_by_string,
core::recti(x, current_y, 0, 0), white_color, false, false,
nullptr, true);
}
}
} // if mode has laps
} // if not soccer mode