Display number of trophies in overworld HUD
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10461 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
16b7918f84
commit
c2d69b24f9
@ -62,6 +62,8 @@ const std::vector<const ChallengeData*> GameSlot::getLockedChallenges()
|
||||
//-----------------------------------------------------------------------------
|
||||
void GameSlot::computeActive()
|
||||
{
|
||||
m_points = 0;
|
||||
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
for(i = m_challenges_state.begin();
|
||||
i != m_challenges_state.end(); i++)
|
||||
@ -75,6 +77,7 @@ void GameSlot::computeActive()
|
||||
// save the state, since we are currently reading it)
|
||||
|
||||
unlockFeature(i->second, /*save*/ false);
|
||||
m_points++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -52,11 +52,14 @@ class GameSlot
|
||||
|
||||
void computeActive();
|
||||
|
||||
int m_points;
|
||||
|
||||
public:
|
||||
|
||||
GameSlot(const irr::core::stringw& player_name)
|
||||
{
|
||||
m_player_name = player_name;
|
||||
m_points = 0;
|
||||
}
|
||||
|
||||
const irr::core::stringw& getPlayerName() const { return m_player_name; }
|
||||
@ -91,6 +94,8 @@ public:
|
||||
void grandPrixFinished ();
|
||||
|
||||
void save (XMLWriter& file);
|
||||
|
||||
int getPoints () const { return m_points; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@ void OverWorld::init()
|
||||
{
|
||||
LinearWorld::init();
|
||||
m_display_rank = false;
|
||||
m_draw_trophy_points = true;
|
||||
} // init
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -81,14 +81,15 @@ World* World::m_world = NULL;
|
||||
*/
|
||||
World::World() : WorldStatus(), m_clear_color(255,100,101,140)
|
||||
{
|
||||
m_physics = NULL;
|
||||
m_race_gui = NULL;
|
||||
m_saved_race_gui = NULL;
|
||||
m_use_highscores = true;
|
||||
m_track = NULL;
|
||||
m_clear_back_buffer = false;
|
||||
m_schedule_pause = false;
|
||||
m_schedule_unpause = false;
|
||||
m_physics = NULL;
|
||||
m_race_gui = NULL;
|
||||
m_saved_race_gui = NULL;
|
||||
m_use_highscores = true;
|
||||
m_track = NULL;
|
||||
m_clear_back_buffer = false;
|
||||
m_schedule_pause = false;
|
||||
m_schedule_unpause = false;
|
||||
m_draw_trophy_points = false;
|
||||
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
} // World
|
||||
|
@ -85,6 +85,8 @@ protected:
|
||||
*/
|
||||
bool m_use_highscores;
|
||||
|
||||
bool m_draw_trophy_points;
|
||||
|
||||
void updateHighscores (int* best_highscore_rank, int* best_finish_time,
|
||||
std::string* highscore_who,
|
||||
StateManager::ActivePlayer** best_player);
|
||||
@ -249,11 +251,13 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the track. */
|
||||
Track *getTrack() const { return m_track; }
|
||||
// ------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------
|
||||
/** The code that draws the timer should call this first to know
|
||||
* whether the game mode wants a timer drawn. */
|
||||
virtual bool shouldDrawTimer() const { return isRacePhase() &&
|
||||
getClockMode() != CLOCK_NONE; }
|
||||
getClockMode() != CLOCK_NONE; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool shouldDrawTrophyPoints() const { return m_draw_trophy_points; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** \return whether this world can generate/have highscores */
|
||||
bool useHighScores() const { return m_use_highscores; }
|
||||
|
@ -23,6 +23,7 @@ using namespace irr;
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
@ -53,6 +54,7 @@ using namespace irr;
|
||||
RaceGUI::RaceGUI()
|
||||
{
|
||||
m_enabled = true;
|
||||
m_trophy = irr_driver->getTexture( file_manager->getTextureFile("cup_gold.png") );
|
||||
|
||||
// Originally m_map_height was 100, and we take 480 as minimum res
|
||||
const float scaling = irr_driver->getFrameSize().Height / 480.0f;
|
||||
@ -94,6 +96,7 @@ RaceGUI::RaceGUI()
|
||||
m_rank_lap_width = font->getDimension(m_string_lap.c_str()).Width;
|
||||
|
||||
m_timer_width = font->getDimension(L"99:99:99").Width;
|
||||
m_trophy_points_width = font->getDimension(L"100").Width;
|
||||
|
||||
font = (race_manager->getNumLocalPlayers() > 2 ? GUIEngine::getSmallFont() : GUIEngine::getFont());
|
||||
|
||||
@ -238,13 +241,32 @@ void RaceGUI::drawGlobalTimer()
|
||||
{
|
||||
assert(World::getWorld() != NULL);
|
||||
|
||||
if(!World::getWorld()->shouldDrawTimer()) return;
|
||||
std::string s = StringUtils::timeToString(World::getWorld()->getTime());
|
||||
bool draw_trophy_points = World::getWorld()->shouldDrawTrophyPoints();
|
||||
|
||||
if (!World::getWorld()->shouldDrawTimer() && !draw_trophy_points)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string s;
|
||||
|
||||
if (draw_trophy_points)
|
||||
{
|
||||
const int points = unlock_manager->getCurrentSlot()->getPoints();
|
||||
s = StringUtils::toString(points);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = StringUtils::timeToString(World::getWorld()->getTime());
|
||||
}
|
||||
core::stringw sw(s.c_str());
|
||||
|
||||
static video::SColor time_color = video::SColor(255, 255, 255, 255);
|
||||
core::rect<s32> pos(UserConfigParams::m_width - m_timer_width - 10, 10,
|
||||
UserConfigParams::m_width, 50);
|
||||
|
||||
int dist_from_right = 10 + (draw_trophy_points ? m_trophy_points_width : m_timer_width);
|
||||
|
||||
core::rect<s32> pos(UserConfigParams::m_width - dist_from_right, 10,
|
||||
UserConfigParams::m_width , 50);
|
||||
|
||||
// special case : when 3 players play, use available 4th space for such things
|
||||
if (race_manager->getNumLocalPlayers() == 3)
|
||||
@ -252,8 +274,34 @@ void RaceGUI::drawGlobalTimer()
|
||||
pos += core::vector2d<s32>(0, UserConfigParams::m_height/2);
|
||||
}
|
||||
|
||||
bool vcenter = false;
|
||||
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
font->draw(sw.c_str(), pos, time_color, false, false, NULL, true /* ignore RTL */);
|
||||
|
||||
if (draw_trophy_points)
|
||||
{
|
||||
vcenter = true;
|
||||
|
||||
const int size = UserConfigParams::m_width/20.0f;
|
||||
core::rect<s32> dest(pos.UpperLeftCorner.X - size - 5, pos.UpperLeftCorner.Y,
|
||||
pos.UpperLeftCorner.X - 5, pos.UpperLeftCorner.Y + size);
|
||||
core::rect<s32> source(core::position2di(0, 0), m_trophy->getSize());
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_trophy, dest, source, NULL,
|
||||
NULL, true /* alpha */);
|
||||
|
||||
pos.LowerRightCorner.Y = dest.LowerRightCorner.Y;
|
||||
pos.UpperLeftCorner.X += 5;
|
||||
font->setShadow(video::SColor(255,0,0,0));
|
||||
}
|
||||
|
||||
font->draw(sw.c_str(), pos, time_color, false, vcenter, NULL, true /* ignore RTL */);
|
||||
|
||||
if (draw_trophy_points)
|
||||
{
|
||||
font->disableShadow();
|
||||
}
|
||||
|
||||
} // drawGlobalTimer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
/** The mini map of the track. */
|
||||
video::ITexture *m_mini_map;
|
||||
|
||||
video::ITexture *m_trophy;
|
||||
|
||||
/** The size of a single marker on the screen for AI karts,
|
||||
* need not be a power of 2. */
|
||||
int m_marker_ai_size;
|
||||
@ -89,6 +91,8 @@ private:
|
||||
/** Maximum string length for the timer */
|
||||
int m_timer_width;
|
||||
|
||||
int m_trophy_points_width;
|
||||
|
||||
|
||||
/* Display informat for one player on the screen. */
|
||||
void drawEnergyMeter (int x, int y, const Kart *kart,
|
||||
|
Loading…
Reference in New Issue
Block a user