Apply patch by Steel to make the timer count down during a timed challenge. Thanks\!

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11757 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-10-25 00:21:54 +00:00
parent 6c1e4e8846
commit 44a36a8bbf
3 changed files with 44 additions and 9 deletions

View File

@ -386,6 +386,11 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
race_manager->setNumLocalPlayers(1);
race_manager->setCoinTarget(m_energy[d]);
race_manager->setDifficulty(d);
if (m_time[d] >= 0.0f)
{
race_manager->setTimeTarget(m_time[d]);
}
}
else // GP
{

View File

@ -307,6 +307,8 @@ private:
unsigned int m_num_finished_karts;
unsigned int m_num_finished_players;
int m_coin_target;
bool m_has_time_target;
float m_time_target;
void startNextRace(); // start a next race
@ -360,6 +362,8 @@ public:
* doesn't exist */
int getLocalPlayerGPRank(const int playerID) const;
bool hasTimeTarget() const { return m_has_time_target; }
/** Sort karts and update the m_gp_rank KartStatus member, in preparation
* for future calls to RaceManager::getKartGPRank or
* RaceManager::getKartWithGPRank
@ -402,9 +406,10 @@ public:
m_reverse_track.push_back(r_t);
}
// ------------------------------------------------------------------------
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
// ------------------------------------------------------------------------
void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode; }
void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode;
m_has_time_target = false; }
// ------------------------------------------------------------------------
void setNumKarts(int num)
{
@ -413,8 +418,10 @@ public:
m_ai_superpower = SUPERPOWER_NONE;
}
// ------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; }
void setCoinTarget(int num) { m_coin_target = num; }
// ------------------------------------------------------------------------
void setTimeTarget(float num) { m_has_time_target = true;
m_time_target = num; }
/** \} */
// ------------------------------------------------------------------------
@ -509,6 +516,8 @@ public:
// ------------------------------------------------------------------------
int getCoinTarget() const { return m_coin_target; }
// ------------------------------------------------------------------------
float getTimeTarget() const { return m_time_target; }
// ------------------------------------------------------------------------
int getPositionScore(int p) const { return m_score_for_position[p-1]; }
// ------------------------------------------------------------------------
int getTrackNumber() const { return m_track_number; }

View File

@ -246,13 +246,34 @@ void RaceGUI::drawGlobalTimer()
{
return;
}
std::string s = StringUtils::timeToString(World::getWorld()->getTime());
core::stringw sw(s.c_str());
static video::SColor time_color = video::SColor(255, 255, 255, 255);
core::stringw sw;
video::SColor time_color = video::SColor(255, 255, 255, 255);
int dist_from_right = 10 + m_timer_width;
float elapsed_time = World::getWorld()->getTime();
if (!race_manager->hasTimeTarget())
{
sw = core::stringw (
StringUtils::timeToString(elapsed_time).c_str() );
}
else
{
float time_target = race_manager->getTimeTarget();
if (elapsed_time < time_target)
{
sw = core::stringw (
StringUtils::timeToString(time_target - elapsed_time).c_str());
}
else
{
sw = _("Challenge Failed");
int string_width =
GUIEngine::getFont()->getDimension(_("Challenge Failed")).Width;
dist_from_right = 10 + string_width;
time_color = video::SColor(255,255,0,0);
}
}
core::rect<s32> pos(UserConfigParams::m_width - dist_from_right, 10,
UserConfigParams::m_width , 50);