Refactored information exchange between modes and race GUIs:
instead of each mode maintaining an array of data for each kart which is used by the race GUI, use one array in race_gui_base, which is then filled by the game mode. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12186 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b81f1333f9
commit
d77471b446
@ -443,9 +443,9 @@ void CutsceneWorld::restartRace()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the data to display in the race gui.
|
||||
*/
|
||||
RaceGUIBase::KartIconDisplayInfo* CutsceneWorld::getKartsDisplayInfo()
|
||||
void CutsceneWorld::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
return NULL;
|
||||
} // getKartDisplayInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -78,7 +78,8 @@ public:
|
||||
// overriding World methods
|
||||
virtual void restartRace() OVERRIDE;
|
||||
|
||||
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo() OVERRIDE;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
virtual bool raceHasLaps() OVERRIDE { return false; }
|
||||
virtual void moveKartAfterRescue(AbstractKart* kart) OVERRIDE;
|
||||
|
||||
|
@ -206,9 +206,9 @@ const std::string& FollowTheLeaderRace::getIdent() const
|
||||
/** Sets the title for all karts that is displayed in the icon list. In
|
||||
* this mode the title for the first kart is set to 'leader'.
|
||||
*/
|
||||
RaceGUIBase::KartIconDisplayInfo* FollowTheLeaderRace::getKartsDisplayInfo()
|
||||
void FollowTheLeaderRace::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
LinearWorld::getKartsDisplayInfo();
|
||||
m_kart_display_info[0].special_title = _("Leader");
|
||||
return m_kart_display_info;
|
||||
LinearWorld::getKartsDisplayInfo(info);
|
||||
(*info)[0].special_title = _("Leader");
|
||||
} // getKartsDisplayInfo
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
virtual const std::string& getIdent() const OVERRIDE;
|
||||
virtual float getClockStartTime();
|
||||
virtual bool useFastMusicNearEnd() const OVERRIDE { return false; }
|
||||
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo() OVERRIDE;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
virtual void init() OVERRIDE;
|
||||
|
||||
virtual bool isRaceOver() OVERRIDE;
|
||||
|
@ -41,7 +41,6 @@
|
||||
*/
|
||||
LinearWorld::LinearWorld() : WorldWithRank()
|
||||
{
|
||||
m_kart_display_info = NULL;
|
||||
m_last_lap_sfx = sfx_manager->createSoundSource("last_lap_fanfare");
|
||||
m_last_lap_sfx_played = false;
|
||||
m_last_lap_sfx_playing = false;
|
||||
@ -62,8 +61,6 @@ void LinearWorld::init()
|
||||
m_last_lap_sfx_played = false;
|
||||
m_last_lap_sfx_playing = false;
|
||||
const unsigned int kart_amount = m_karts.size();
|
||||
|
||||
m_kart_display_info = new RaceGUIBase::KartIconDisplayInfo[kart_amount];
|
||||
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
@ -78,11 +75,6 @@ void LinearWorld::init()
|
||||
LinearWorld::~LinearWorld()
|
||||
{
|
||||
sfx_manager->deleteSFX(m_last_lap_sfx);
|
||||
|
||||
// In case that a track is not found, m_kart_display info was never
|
||||
// initialised.
|
||||
if(m_kart_display_info)
|
||||
delete[] m_kart_display_info;
|
||||
} // ~LinearWorld
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -415,7 +407,8 @@ float LinearWorld::getTimeAtLapForKart(const int kart_id) const
|
||||
} // getTimeAtLapForKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
|
||||
void LinearWorld::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
int laps_of_leader = -1;
|
||||
float time_of_leader = -1;
|
||||
@ -425,7 +418,7 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
|
||||
const unsigned int kart_amount = getNumKarts();
|
||||
for(unsigned int i = 0; i < kart_amount ; i++)
|
||||
{
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = (*info)[i];
|
||||
AbstractKart* kart = m_karts[i];
|
||||
|
||||
// reset color
|
||||
@ -455,7 +448,7 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
|
||||
// we now know the best time of the lap. fill the remaining bits of info
|
||||
for(unsigned int i = 0; i < kart_amount ; i++)
|
||||
{
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = (*info)[i];
|
||||
KartInfo& kart_info = m_kart_info[i];
|
||||
AbstractKart* kart = m_karts[i];
|
||||
|
||||
@ -503,7 +496,6 @@ RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
|
||||
} // next kart
|
||||
|
||||
|
||||
return m_kart_display_info;
|
||||
} // getKartsDisplayInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -95,7 +95,6 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
protected:
|
||||
RaceGUIBase::KartIconDisplayInfo* m_kart_display_info;
|
||||
|
||||
/** This vector contains an 'KartInfo' struct for every kart in the race.
|
||||
* This member is not strictly private but try not to use it directly outside
|
||||
@ -128,8 +127,8 @@ public:
|
||||
int getLapForKart(const int kart_id) const;
|
||||
float getTimeAtLapForKart(const int kart_id) const;
|
||||
|
||||
virtual RaceGUIBase::KartIconDisplayInfo*
|
||||
getKartsDisplayInfo() OVERRIDE;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
virtual void moveKartAfterRescue(AbstractKart* kart) OVERRIDE;
|
||||
virtual void restartRace() OVERRIDE;
|
||||
virtual void newLap(unsigned int kart_index) OVERRIDE;
|
||||
@ -154,7 +153,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of laps a kart has completed.
|
||||
* \param kart_index World index of the kart. */
|
||||
int getKartLap(unsigned int kart_index) const
|
||||
int getKartLaps(unsigned int kart_index) const
|
||||
{
|
||||
assert(kart_index < m_kart_info.size());
|
||||
return m_kart_info[kart_index].m_race_lap;
|
||||
|
@ -62,7 +62,6 @@ void ThreeStrikesBattle::init()
|
||||
}
|
||||
|
||||
const unsigned int kart_amount = m_karts.size();
|
||||
m_kart_display_info = new RaceGUIBase::KartIconDisplayInfo[kart_amount];
|
||||
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
@ -90,8 +89,6 @@ void ThreeStrikesBattle::init()
|
||||
ThreeStrikesBattle::~ThreeStrikesBattle()
|
||||
{
|
||||
m_tires.clearWithoutDeleting();
|
||||
|
||||
delete[] m_kart_display_info;
|
||||
|
||||
irr_driver->grabAllTextures(m_tire);
|
||||
// Remove the mesh from the cache so that the mesh is properly
|
||||
@ -427,12 +424,13 @@ void ThreeStrikesBattle::restartRace()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the data to display in the race gui.
|
||||
*/
|
||||
RaceGUIBase::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
|
||||
void ThreeStrikesBattle::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
const unsigned int kart_amount = getNumKarts();
|
||||
for(unsigned int i = 0; i < kart_amount ; i++)
|
||||
{
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
|
||||
RaceGUIBase::KartIconDisplayInfo& rank_info = (*info)[i];
|
||||
|
||||
// reset color
|
||||
rank_info.lap = -1;
|
||||
@ -466,9 +464,7 @@ RaceGUIBase::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
|
||||
|
||||
rank_info.m_text = lives;
|
||||
}
|
||||
|
||||
return m_kart_display_info;
|
||||
} // getKartDisplayInfo
|
||||
} // getKartsDisplayInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Moves a kart to its rescue position.
|
||||
|
@ -41,8 +41,6 @@ private:
|
||||
{
|
||||
int m_lives;
|
||||
};
|
||||
|
||||
RaceGUIBase::KartIconDisplayInfo* m_kart_display_info;
|
||||
|
||||
/** This vector contains an 'BattleInfo' struct for every kart in the race.
|
||||
*/
|
||||
@ -96,7 +94,8 @@ public:
|
||||
|
||||
//virtual void getDefaultCollectibles(int& collectible_type, int& amount);
|
||||
virtual bool useFastMusicNearEnd() const { return false; }
|
||||
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
|
||||
virtual bool raceHasLaps(){ return false; }
|
||||
virtual void moveKartAfterRescue(AbstractKart* kart);
|
||||
|
||||
|
@ -30,128 +30,13 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
TutorialRace::TutorialRace() : LinearWorld()
|
||||
{
|
||||
// We have to make sure that no kart finished the set number of laps
|
||||
// in a FTL race (since otherwise its distance will not be computed
|
||||
// correctly, and as a result e.g. a leader might suddenly fall back
|
||||
// after crossing the start line
|
||||
race_manager->setNumLaps(99999);
|
||||
|
||||
m_leader_intervals = stk_config->m_leader_intervals;
|
||||
for(unsigned int i=0; i<m_leader_intervals.size(); i++)
|
||||
m_leader_intervals[i] +=
|
||||
stk_config->m_leader_time_per_kart*race_manager->getNumberOfKarts();
|
||||
m_use_highscores = false; // disable high scores
|
||||
setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]);
|
||||
}
|
||||
} // TutorialRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
TutorialRace::~TutorialRace()
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#pragma mark clock events
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the original time at which the countdown timer started. This is
|
||||
* used by the race_gui to display the music credits in FTL mode correctly.
|
||||
*/
|
||||
float TutorialRace::getClockStartTime()
|
||||
{
|
||||
return m_leader_intervals[0];
|
||||
} // getClockStartTime
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart must be eliminated.
|
||||
*/
|
||||
void TutorialRace::countdownReachedZero()
|
||||
{
|
||||
if(m_leader_intervals.size()>1)
|
||||
m_leader_intervals.erase(m_leader_intervals.begin());
|
||||
WorldStatus::setTime(m_leader_intervals[0]);
|
||||
|
||||
// If the leader kart is not the first kart, remove the first
|
||||
// kart, otherwise remove the last kart.
|
||||
int position_to_remove = m_karts[0]->getPosition()==1
|
||||
? getCurrentNumKarts() : 1;
|
||||
AbstractKart *kart = getKartAtPosition(position_to_remove);
|
||||
if(!kart || kart->isEliminated())
|
||||
{
|
||||
fprintf(stderr,"Problem with removing leader: position %d not found\n",
|
||||
position_to_remove);
|
||||
for(unsigned int i=0; i<m_karts.size(); i++)
|
||||
{
|
||||
fprintf(stderr,"kart %d: eliminated %d position %d\n",
|
||||
i,m_karts[i]->isEliminated(), m_karts[i]->getPosition());
|
||||
} // for i
|
||||
} //
|
||||
else
|
||||
{
|
||||
eliminateKart(kart->getWorldKartId());
|
||||
|
||||
// In case that the kart on position 1 was removed, we have
|
||||
// to set the correct position (which equals the remaining
|
||||
// number of karts) for the removed kart, as well as recompute
|
||||
// the position for all other karts
|
||||
if(position_to_remove==1)
|
||||
{
|
||||
// We have to add 1 to the number of karts to get the correct
|
||||
// position, since the eliminated kart was already removed
|
||||
// from the value returned by getCurrentNumKarts (and we have
|
||||
// to remove the kart before we can call updateRacePosition).
|
||||
// Note that we can not call WorldWithRank::setKartPosition
|
||||
// here, since it would not properly support debugging kart
|
||||
// ranks (since this kart would get its position set again
|
||||
// in updateRacePosition). We only set the rank of the eliminated
|
||||
// kart, and updateRacePosition will then call setKartPosition
|
||||
// for the now eliminated kart.
|
||||
kart->setPosition(getCurrentNumKarts()+1);
|
||||
updateRacePosition();
|
||||
}
|
||||
}
|
||||
|
||||
// almost over, use fast music
|
||||
if(getCurrentNumKarts()==3)
|
||||
{
|
||||
music_manager->switchToFastMusic();
|
||||
}
|
||||
|
||||
if (isRaceOver())
|
||||
{
|
||||
// Handle special FTL situation: the leader is kart number 3 when
|
||||
// the last kart gets eliminated. In this case kart on position 1
|
||||
// is eliminated, and the kart formerly on position 2 is on
|
||||
// position 1, the leader now position 2. In this case the kart
|
||||
// on position 1 would get more points for this victory. So if
|
||||
// this is the case, change the position
|
||||
if(m_karts[0]->getPosition()!=1)
|
||||
{
|
||||
// Adjust the position of all still driving karts except
|
||||
// the leader by +1, and move the leader to position 1.
|
||||
for (unsigned int i=1; i<m_karts.size(); i++)
|
||||
{
|
||||
if(!m_karts[i]->hasFinishedRace() &&
|
||||
!m_karts[i]->isEliminated() )
|
||||
m_karts[i]->setPosition(m_karts[i]->getPosition()+1);
|
||||
}
|
||||
m_karts[0]->setPosition(1);
|
||||
}
|
||||
|
||||
// Mark all still racing karts to be finished.
|
||||
for (unsigned int n=0; n<m_karts.size(); n++)
|
||||
{
|
||||
if (!m_karts[n]->isEliminated() &&
|
||||
!m_karts[n]->hasFinishedRace())
|
||||
{
|
||||
m_karts[n]->finishedRace(getTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of race is detected from World::updateWorld()
|
||||
|
||||
} // countdownReachedZero
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** The follow the leader race is over if there is only one kart left (plus
|
||||
* the leader), or if all (human) players have been eliminated.
|
||||
@ -166,13 +51,6 @@ bool TutorialRace::isRaceOver()
|
||||
void TutorialRace::restartRace()
|
||||
{
|
||||
LinearWorld::restartRace();
|
||||
m_leader_intervals.clear();
|
||||
m_leader_intervals = stk_config->m_leader_intervals;
|
||||
for(unsigned int i=0; i<m_leader_intervals.size(); i++)
|
||||
m_leader_intervals[i] +=
|
||||
stk_config->m_leader_time_per_kart*race_manager->getNumberOfKarts();
|
||||
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,
|
||||
m_leader_intervals[0]);
|
||||
} // restartRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -187,9 +65,9 @@ const std::string& TutorialRace::getIdent() const
|
||||
/** Sets the title for all karts that is displayed in the icon list. In
|
||||
* this mode the title for the first kart is set to 'leader'.
|
||||
*/
|
||||
RaceGUIBase::KartIconDisplayInfo* TutorialRace::getKartsDisplayInfo()
|
||||
void TutorialRace::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
LinearWorld::getKartsDisplayInfo();
|
||||
m_kart_display_info[0].special_title = _("Leader");
|
||||
return m_kart_display_info;
|
||||
LinearWorld::getKartsDisplayInfo(info);
|
||||
(*info)[0].special_title = _("Leader");
|
||||
} // getKartsDisplayInfo
|
||||
|
@ -29,22 +29,18 @@ class TutorialRace : public LinearWorld
|
||||
{
|
||||
private:
|
||||
|
||||
std::vector <float> m_leader_intervals; // time till elimination in follow leader
|
||||
|
||||
public:
|
||||
|
||||
TutorialRace();
|
||||
virtual ~TutorialRace();
|
||||
|
||||
// clock events
|
||||
virtual void countdownReachedZero();
|
||||
|
||||
|
||||
// overriding World methods
|
||||
virtual void restartRace();
|
||||
virtual const std::string& getIdent() const;
|
||||
float getClockStartTime();
|
||||
virtual bool useFastMusicNearEnd() const { return false; }
|
||||
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
|
||||
|
||||
virtual bool isRaceOver();
|
||||
virtual bool raceHasLaps(){ return false; }
|
||||
|
@ -196,11 +196,19 @@ public:
|
||||
/** Called when it is needed to know whether this kind of race involves
|
||||
* counting laps. */
|
||||
virtual bool raceHasLaps() = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the number of laps for a given kart. Only valid when
|
||||
* raceHasLaps() - otherwise STK will abort. */
|
||||
virtual int getKartLaps(unsigned int kart_index) const
|
||||
{
|
||||
assert(false); return -1; // remove compiler warning
|
||||
} // getKartLaps
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called by the code that draws the list of karts on the race GUI
|
||||
* to know what needs to be drawn in the current mode. */
|
||||
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo() = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)= 0;
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// Virtual functions
|
||||
// =================
|
||||
|
@ -189,8 +189,7 @@ void MinimalRaceGUI::renderGlobal(float dt)
|
||||
// in 3 strikes mode we need to see the lives
|
||||
if (world->getIdent() == IDENT_STRIKES)
|
||||
{
|
||||
KartIconDisplayInfo* info = world->getKartsDisplayInfo();
|
||||
drawGlobalPlayerIcons(info, m_map_height);
|
||||
drawGlobalPlayerIcons(m_map_height);
|
||||
}
|
||||
} // renderGlobal
|
||||
|
||||
@ -212,11 +211,9 @@ void MinimalRaceGUI::renderPlayerView(const AbstractKart *kart, float dt)
|
||||
drawAllMessages (kart, viewport, scaling);
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
MinimalRaceGUI::KartIconDisplayInfo* info = World::getWorld()->getKartsDisplayInfo();
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
drawEnergyMeter (kart, viewport, scaling);
|
||||
drawRankLap (info, kart, viewport);
|
||||
drawRankLap (kart, viewport);
|
||||
|
||||
RaceGUIBase::renderPlayerView(kart, dt);
|
||||
} // renderPlayerView
|
||||
@ -418,8 +415,7 @@ void MinimalRaceGUI::drawEnergyMeter(const AbstractKart *kart,
|
||||
/** Displays the rank and the lap of the kart.
|
||||
* \param info Info object c
|
||||
*/
|
||||
void MinimalRaceGUI::drawRankLap(const KartIconDisplayInfo* info,
|
||||
const AbstractKart* kart,
|
||||
void MinimalRaceGUI::drawRankLap(const AbstractKart* kart,
|
||||
const core::recti &viewport)
|
||||
{
|
||||
// Don't display laps or ranks if the kart has already finished the race.
|
||||
@ -464,7 +460,7 @@ void MinimalRaceGUI::drawRankLap(const KartIconDisplayInfo* info,
|
||||
// Don't display laps in follow the leader mode
|
||||
if(world->raceHasLaps())
|
||||
{
|
||||
const int lap = info[kart->getWorldKartId()].lap;
|
||||
const int lap = world->getKartLaps(kart->getWorldKartId());
|
||||
|
||||
// don't display 'lap 0/...'
|
||||
if(lap>=0)
|
||||
|
@ -107,8 +107,7 @@ private:
|
||||
void drawEnergyMeter (const AbstractKart *kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawRankLap (const KartIconDisplayInfo* info,
|
||||
const AbstractKart* kart,
|
||||
void drawRankLap (const AbstractKart* kart,
|
||||
const core::recti &viewport);
|
||||
/** Display items that are shown once only (for all karts). */
|
||||
void drawGlobalMiniMap ();
|
||||
|
@ -168,14 +168,8 @@ void RaceGUI::renderGlobal(float dt)
|
||||
drawGlobalMusicDescription();
|
||||
}
|
||||
|
||||
// minimap has no mipmaps so disable material2D
|
||||
//irr_driver->getVideoDriver()->enableMaterial2D(false);
|
||||
drawGlobalMiniMap();
|
||||
//irr_driver->getVideoDriver()->enableMaterial2D();
|
||||
|
||||
KartIconDisplayInfo* info = world->getKartsDisplayInfo();
|
||||
|
||||
drawGlobalPlayerIcons(info, m_map_height);
|
||||
drawGlobalMiniMap();
|
||||
drawGlobalPlayerIcons(m_map_height);
|
||||
} // renderGlobal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -198,11 +192,9 @@ void RaceGUI::renderPlayerView(const AbstractKart *kart, float dt)
|
||||
|
||||
if(!World::getWorld()->isRacePhase()) return;
|
||||
|
||||
RaceGUI::KartIconDisplayInfo* info = World::getWorld()->getKartsDisplayInfo();
|
||||
|
||||
drawPowerupIcons (kart, viewport, scaling);
|
||||
drawSpeedAndEnergy (kart, viewport, scaling);
|
||||
drawRankLap (info, kart, viewport);
|
||||
drawRankLap (kart, viewport);
|
||||
|
||||
RaceGUIBase::renderPlayerView(kart, dt);
|
||||
} // renderPlayerView
|
||||
@ -494,8 +486,7 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
|
||||
/** Displays the rank and the lap of the kart.
|
||||
* \param info Info object c
|
||||
*/
|
||||
void RaceGUI::drawRankLap(const KartIconDisplayInfo* info,
|
||||
const AbstractKart* kart,
|
||||
void RaceGUI::drawRankLap(const AbstractKart* kart,
|
||||
const core::recti &viewport)
|
||||
{
|
||||
// Don't display laps or ranks if the kart has already finished the race.
|
||||
@ -539,7 +530,7 @@ void RaceGUI::drawRankLap(const KartIconDisplayInfo* info,
|
||||
// Don't display laps in follow the leader mode
|
||||
if(world->raceHasLaps())
|
||||
{
|
||||
const int lap = info[kart->getWorldKartId()].lap;
|
||||
const int lap = world->getKartLaps(kart->getWorldKartId());
|
||||
|
||||
// don't display 'lap 0/...'
|
||||
if(lap>=0)
|
||||
|
@ -97,8 +97,7 @@ private:
|
||||
void drawSpeedAndEnergy (const AbstractKart* kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawRankLap (const KartIconDisplayInfo* info,
|
||||
const AbstractKart* kart,
|
||||
void drawRankLap (const AbstractKart* kart,
|
||||
const core::recti &viewport);
|
||||
|
||||
/** Display items that are shown once only (for all karts). */
|
||||
|
@ -105,6 +105,8 @@ RaceGUIBase::RaceGUIBase()
|
||||
*/
|
||||
void RaceGUIBase::init()
|
||||
{
|
||||
m_kart_display_infos.resize(race_manager->getNumberOfKarts());
|
||||
|
||||
// While we actually only need the positions for local players,
|
||||
// we add all karts, since it's easier to get a world kart id from
|
||||
// the kart then the local player id (and it avoids problems in
|
||||
@ -716,8 +718,7 @@ void RaceGUIBase::drawGlobalReadySetGo()
|
||||
/** Draw players icons and their times (if defined in the current mode).
|
||||
* Also takes care of icon looking different due to plumber, squashing, ...
|
||||
*/
|
||||
void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
int bottom_margin)
|
||||
void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
|
||||
{
|
||||
int x_base = 10;
|
||||
int y_base = 20;
|
||||
@ -784,8 +785,9 @@ void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
int y_icons_limit=UserConfigParams::m_height-bottom_margin-ICON_PLAYER_WIDTH;
|
||||
if (race_manager->getNumLocalPlayers() == 3)
|
||||
y_icons_limit=UserConfigParams::m_height-ICON_WIDTH;
|
||||
|
||||
|
||||
|
||||
world->getKartsDisplayInfo(&m_kart_display_infos);
|
||||
|
||||
for(int position = 1; position <= (int)kart_amount ; position++)
|
||||
{
|
||||
AbstractKart *kart = world->getKartAtPosition(position);
|
||||
@ -800,8 +802,9 @@ void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
if(kart->isEliminated()) continue;
|
||||
unsigned int kart_id = kart->getWorldKartId();
|
||||
|
||||
KartIconDisplayInfo &info = m_kart_display_infos[kart_id];
|
||||
//x,y is the target position
|
||||
int lap = info[kart_id].lap;
|
||||
int lap = info.lap;
|
||||
|
||||
// In battle mode there is no distance along track etc.
|
||||
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES)
|
||||
@ -865,25 +868,25 @@ void RaceGUIBase::drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
break;
|
||||
}
|
||||
|
||||
if (info[kart_id].m_text.size() > 0)
|
||||
if (m_kart_display_infos[kart_id].m_text.size() > 0)
|
||||
{
|
||||
video::SColor color = video::SColor(255,
|
||||
(int)(255*info[kart_id].r),
|
||||
(int)(255*info[kart_id].g),
|
||||
(int)(255*info[kart_id].b) );
|
||||
(int)(255*info.r),
|
||||
(int)(255*info.g),
|
||||
(int)(255*info.b) );
|
||||
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
|
||||
x+ICON_PLAYER_WIDTH, y+5);
|
||||
core::stringw s=info[kart_id].m_text.c_str();
|
||||
core::stringw s=info.m_text.c_str();
|
||||
|
||||
font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
|
||||
}
|
||||
|
||||
if (info[kart_id].special_title.size() > 0)
|
||||
if (info.special_title.size() > 0)
|
||||
{
|
||||
static video::SColor color = video::SColor(255, 255, 0, 0);
|
||||
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5,
|
||||
x+ICON_PLAYER_WIDTH, y+5);
|
||||
core::stringw s(info[kart_id].special_title.c_str());
|
||||
core::stringw s(info.special_title.c_str());
|
||||
font->draw(s.c_str(), pos, color, false, false, NULL, true /* ignore RTL */);
|
||||
}
|
||||
|
||||
@ -1110,4 +1113,4 @@ void RaceGUIBase::drawPlungerInFace(const AbstractKart *kart, float dt)
|
||||
&viewport /* clip */,
|
||||
NULL /* color */,
|
||||
true /* alpha */ );
|
||||
} // drawPlungerInFace
|
||||
} // drawPlungerInFace
|
||||
|
@ -206,7 +206,11 @@ protected:
|
||||
|
||||
/** previous position of icons */
|
||||
std::vector< core::vector2d<s32> > m_previous_icons_position;
|
||||
|
||||
|
||||
/** This vector is passed to world to be filled with the current
|
||||
* race data information. */
|
||||
std::vector<KartIconDisplayInfo> m_kart_display_infos;
|
||||
|
||||
public:
|
||||
|
||||
bool m_enabled;
|
||||
@ -235,8 +239,7 @@ public:
|
||||
/** Set the flag that a lightning should be shown. */
|
||||
void doLightning() { m_lightning = 1.0f; }
|
||||
|
||||
void drawGlobalPlayerIcons(const KartIconDisplayInfo* info,
|
||||
int bottom_margin);
|
||||
void drawGlobalPlayerIcons(int bottom_margin);
|
||||
|
||||
}; // RaceGUIBase
|
||||
|
||||
|
@ -76,26 +76,7 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
|
||||
assert( tabs != NULL );
|
||||
|
||||
if (m_random_track_list.empty()) return;
|
||||
|
||||
/*
|
||||
const std::vector<int>& curr_group = track_manager->getTracksInGroup( tabs->getSelectionIDString(0) );
|
||||
|
||||
RandomGenerator random;
|
||||
|
||||
int attempts = 0; // just to avoid an infinite loop, in case all tracks are locked...
|
||||
int randomID;
|
||||
do
|
||||
{
|
||||
randomID = random.get(curr_group.size());
|
||||
attempts++;
|
||||
if (attempts > 100) return;
|
||||
}
|
||||
while (unlock_manager->isLocked( track_manager->getTrack(curr_group[randomID])->getIdent()));
|
||||
|
||||
Track* clickedTrack = track_manager->getTrack( curr_group[randomID] );
|
||||
*/
|
||||
|
||||
|
||||
|
||||
std::string track = m_random_track_list.front();
|
||||
m_random_track_list.pop_front();
|
||||
m_random_track_list.push_back(track);
|
||||
|
Loading…
Reference in New Issue
Block a user