Display when you get a highscore (it's a little subtle for now but at least the infrastructure is there)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8707 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c285f67dba
commit
624d050571
@ -52,6 +52,9 @@ public:
|
||||
/** Returns the active player for this controller (NULL
|
||||
* if this controller does not belong to a player. */
|
||||
StateManager::ActivePlayer *getPlayer () {return m_player;}
|
||||
|
||||
const StateManager::ActivePlayer *getPlayer () const { return m_player; }
|
||||
|
||||
virtual void reset () {};
|
||||
virtual void update (float dt) {};
|
||||
virtual void handleZipper (bool play_sound) {};
|
||||
|
@ -321,7 +321,8 @@ void World::terminateRace()
|
||||
int best_highscore_rank = -1;
|
||||
int best_finish_time = -1;
|
||||
std::string highscore_who = "";
|
||||
updateHighscores(&best_highscore_rank, &best_finish_time, &highscore_who);
|
||||
StateManager::ActivePlayer* best_player = NULL;
|
||||
updateHighscores(&best_highscore_rank, &best_finish_time, &highscore_who, &best_player);
|
||||
|
||||
unlock_manager->raceFinished();
|
||||
|
||||
@ -339,7 +340,7 @@ void World::terminateRace()
|
||||
|
||||
if (best_highscore_rank > 0)
|
||||
{
|
||||
results->setHighscore(highscore_who, best_highscore_rank, best_finish_time);
|
||||
results->setHighscore(highscore_who, best_player, best_highscore_rank, best_finish_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -655,10 +656,12 @@ Highscores* World::getHighscores() const
|
||||
* score, if so it notifies the HighscoreManager so the new score is added
|
||||
* and saved.
|
||||
*/
|
||||
void World::updateHighscores(int* best_highscore_rank, int* best_finish_time, std::string* highscore_who)
|
||||
void World::updateHighscores(int* best_highscore_rank, int* best_finish_time, std::string* highscore_who,
|
||||
StateManager::ActivePlayer** best_player)
|
||||
{
|
||||
*best_highscore_rank = -1;
|
||||
|
||||
*best_player = NULL;
|
||||
|
||||
if(!m_use_highscores) return;
|
||||
|
||||
// Add times to highscore list. First compute the order of karts,
|
||||
@ -719,6 +722,7 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time, st
|
||||
{
|
||||
*best_highscore_rank = highscore_rank;
|
||||
*best_finish_time = (int)(k->getFinishTime());
|
||||
*best_player = controller->getPlayer();
|
||||
*highscore_who = k->getIdent();
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ protected:
|
||||
*/
|
||||
bool m_use_highscores;
|
||||
|
||||
void updateHighscores (int* best_highscore_rank, int* best_finish_time, std::string* highscore_who);
|
||||
void updateHighscores (int* best_highscore_rank, int* best_finish_time, std::string* highscore_who,
|
||||
StateManager::ActivePlayer** best_player);
|
||||
void resetAllKarts ();
|
||||
void removeKart (int kart_number, bool notifyOfElimination=true);
|
||||
Controller*
|
||||
|
@ -244,7 +244,8 @@ void RaceResultGUI::determineTableLayout()
|
||||
RowInfo *ri = &(m_all_row_infos[position-first_position]);
|
||||
ri->m_is_player_kart = kart->getController()->isPlayerController();
|
||||
ri->m_kart_name = translations->fribidize(kart->getName());
|
||||
|
||||
ri->m_player = (ri->m_is_player_kart ? kart->getController()->getPlayer() : NULL);
|
||||
|
||||
video::ITexture *icon =
|
||||
kart->getKartProperties()->getIconMaterial()->getTexture();
|
||||
ri->m_kart_icon = icon;
|
||||
@ -547,6 +548,7 @@ void RaceResultGUI::determineGPLayout()
|
||||
kart->getKartProperties()->getIconMaterial()->getTexture();
|
||||
ri->m_kart_name = translations->fribidize(kart->getName());
|
||||
ri->m_is_player_kart = kart->getController()->isPlayerController();
|
||||
ri->m_player = (ri->m_is_player_kart ? kart->getController()->getPlayer() : NULL);
|
||||
|
||||
float time = race_manager->getOverallTime(kart_id);
|
||||
ri->m_finish_time_string
|
||||
@ -631,6 +633,14 @@ void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
|
||||
m_font->draw(ri->m_finish_time_string, dest_rect, color, false, false, NULL, true /* ignoreRTL */);
|
||||
current_x += m_width_finish_time + m_width_column_space;
|
||||
}
|
||||
|
||||
if (m_highscore_player != NULL && ri->m_player == m_highscore_player)
|
||||
{
|
||||
core::recti dest_rect = core::recti(current_x, y, current_x+100, y+10);
|
||||
m_font->draw(_("New highscore!"), dest_rect, color, false, false, NULL, true /* ignoreRTL */);
|
||||
|
||||
//printf("==== Highscore by %s ====\n", core::stringc(m_highscore_player->getProfile()->getName().c_str()).c_str());
|
||||
}
|
||||
|
||||
// Only display points in GP mode and when the GP results are displayed.
|
||||
// =====================================================================
|
||||
@ -669,12 +679,18 @@ void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
|
||||
|
||||
void RaceResultGUI::clearHighscores()
|
||||
{
|
||||
// TODO
|
||||
m_highscore_who = "";
|
||||
m_highscore_player = NULL;
|
||||
m_highscore_rank = 0;
|
||||
m_highscore_time = -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RaceResultGUI::setHighscore(std::string who, int rank, int time)
|
||||
void RaceResultGUI::setHighscore(std::string who, StateManager::ActivePlayer* player, int rank, int time)
|
||||
{
|
||||
// TODO
|
||||
m_highscore_who = who;
|
||||
m_highscore_player = player;
|
||||
m_highscore_rank = rank;
|
||||
m_highscore_time = time;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -76,6 +77,8 @@ private:
|
||||
float m_y_pos;
|
||||
/** True if kart is a player kart. */
|
||||
bool m_is_player_kart;
|
||||
/** Only if m_is_player_kart is true */
|
||||
const StateManager::ActivePlayer* m_player;
|
||||
/** The radius to use when sorting the entries. Positive values
|
||||
will rotate downwards, negatives are upwards. */
|
||||
float m_radius;
|
||||
@ -162,6 +165,18 @@ private:
|
||||
|
||||
SFXBase* m_finish_sound;
|
||||
|
||||
/** For highscores */
|
||||
std::string m_highscore_who;
|
||||
|
||||
/** For highscores */
|
||||
StateManager::ActivePlayer* m_highscore_player;
|
||||
|
||||
/** For highscores */
|
||||
int m_highscore_rank;
|
||||
|
||||
/** For highscores */
|
||||
int m_highscore_time;
|
||||
|
||||
void displayOneEntry(unsigned int x, unsigned int y,
|
||||
unsigned int n, bool display_points);
|
||||
void determineTableLayout();
|
||||
@ -217,11 +232,12 @@ public:
|
||||
|
||||
/**
|
||||
* To call if the user got a new highscore
|
||||
* \param who identity of the kart that made the highscore
|
||||
* \param kart identity of the kart that made the highscore
|
||||
* \param player identity of the player that made the highscore
|
||||
* \param rank Highscore rank (first highscore, second highscore, etc.). This is not the race rank
|
||||
* \param time Finish time in seconds
|
||||
*/
|
||||
void setHighscore(std::string who, int rank, int time);
|
||||
void setHighscore(std::string kart, StateManager::ActivePlayer* player, int rank, int time);
|
||||
|
||||
}; // RaceResultGUI
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user