Better show in overworld GUI how trophies become points
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11195 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -34,6 +34,10 @@ bool GameSlot::isLocked(const std::string& feature)
|
||||
void GameSlot::computeActive()
|
||||
{
|
||||
m_points = 0;
|
||||
m_easy_challenges = 0;
|
||||
m_medium_challenges = 0;
|
||||
m_hard_challenges = 0;
|
||||
|
||||
m_locked_features.clear(); // start afresh
|
||||
|
||||
std::map<std::string, Challenge*>::const_iterator i;
|
||||
@@ -64,14 +68,17 @@ void GameSlot::computeActive()
|
||||
if (i->second->isSolved(RaceManager::RD_HARD))
|
||||
{
|
||||
m_points += 10;
|
||||
m_hard_challenges++;
|
||||
}
|
||||
else if (i->second->isSolved(RaceManager::RD_MEDIUM))
|
||||
{
|
||||
m_points += 9;
|
||||
m_medium_challenges++;
|
||||
}
|
||||
else if (i->second->isSolved(RaceManager::RD_EASY))
|
||||
{
|
||||
m_points += 8;
|
||||
m_easy_challenges;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -63,6 +63,10 @@ class GameSlot
|
||||
/** Set to false after the initial stuff (intro, select kart, etc.) */
|
||||
bool m_first_time;
|
||||
|
||||
int m_easy_challenges;
|
||||
int m_medium_challenges;
|
||||
int m_hard_challenges;
|
||||
|
||||
public:
|
||||
|
||||
// do NOT attempt to pass 'player_unique_id' by reference here. I don't know why (compiler bug
|
||||
@@ -72,6 +76,9 @@ public:
|
||||
m_player_unique_id = player_unique_id;
|
||||
m_points = 0;
|
||||
m_first_time = true;
|
||||
m_easy_challenges = 0;
|
||||
m_medium_challenges = 0;
|
||||
m_hard_challenges = 0;
|
||||
}
|
||||
|
||||
const std::string& getPlayerID() const { return m_player_unique_id; }
|
||||
@@ -100,6 +107,10 @@ public:
|
||||
|
||||
int getPoints () const { return m_points; }
|
||||
|
||||
int getNumEasyTrophies () const { return m_easy_challenges; }
|
||||
int getNumMediumTrophies() const { return m_medium_challenges; }
|
||||
int getNumHardTrophies () const { return m_hard_challenges; }
|
||||
|
||||
void setFirstTime(bool ft) { m_first_time = ft; }
|
||||
bool isFirstTime() const { return m_first_time; }
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
m_trophy_points_width = font->getDimension(L"100").Width;
|
||||
m_trophy_points_width = font->getDimension(L"1000").Width;
|
||||
|
||||
m_lock = irr_driver->getTexture( file_manager->getTextureFile("gui_lock.png") );
|
||||
m_open_challenge = irr_driver->getTexture( file_manager->getGUIDir() + "challenge.png" );
|
||||
@@ -200,7 +200,8 @@ void RaceGUIOverworld::renderPlayerView(const AbstractKart *kart)
|
||||
*/
|
||||
void RaceGUIOverworld::drawTrophyPoints()
|
||||
{
|
||||
const int points = unlock_manager->getCurrentSlot()->getPoints();
|
||||
GameSlot* slot = unlock_manager->getCurrentSlot();
|
||||
const int points = slot->getPoints();
|
||||
std::string s = StringUtils::toString(points);
|
||||
core::stringw sw(s.c_str());
|
||||
|
||||
@@ -218,16 +219,45 @@ void RaceGUIOverworld::drawTrophyPoints()
|
||||
vcenter = true;
|
||||
|
||||
const int size = UserConfigParams::m_width/20;
|
||||
core::rect<s32> dest(pos.UpperLeftCorner.X - size - 5, pos.UpperLeftCorner.Y,
|
||||
pos.UpperLeftCorner.X - 5, pos.UpperLeftCorner.Y + size);
|
||||
core::rect<s32> dest(size, pos.UpperLeftCorner.Y,
|
||||
size*2, pos.UpperLeftCorner.Y + size);
|
||||
core::rect<s32> source(core::position2di(0, 0), m_trophy3->getSize());
|
||||
|
||||
font->setShadow(video::SColor(255,0,0,0));
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_trophy1, dest, source, NULL,
|
||||
NULL, true /* alpha */);
|
||||
|
||||
dest += core::position2di(size*1.5, 0);
|
||||
std::string easyTrophies = StringUtils::toString(slot->getNumEasyTrophies());
|
||||
core::stringw easyTrophiesW(easyTrophies.c_str());
|
||||
font->draw(easyTrophiesW.c_str(), dest, time_color, false, vcenter, NULL, true /* ignore RTL */);
|
||||
|
||||
dest += core::position2di(size*2, 0);
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_trophy2, dest, source, NULL,
|
||||
NULL, true /* alpha */);
|
||||
|
||||
dest += core::position2di(size*1.5, 0);
|
||||
std::string mediumTrophies = StringUtils::toString(slot->getNumMediumTrophies());
|
||||
core::stringw mediumTrophiesW(mediumTrophies.c_str());
|
||||
font->draw(mediumTrophiesW.c_str(), dest, time_color, false, vcenter, NULL, true /* ignore RTL */);
|
||||
|
||||
dest += core::position2di(size*2, 0);
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_trophy3, dest, source, NULL,
|
||||
NULL, true /* alpha */);
|
||||
dest += core::position2di(size*1.5, 0);
|
||||
std::string hardTrophies = StringUtils::toString(slot->getNumHardTrophies());
|
||||
core::stringw hardTrophiesW(hardTrophies.c_str());
|
||||
font->draw(hardTrophiesW.c_str(), dest, time_color, false, vcenter, NULL, true /* ignore RTL */);
|
||||
|
||||
dest = core::rect<s32>(pos.UpperLeftCorner.X - size - 5, pos.UpperLeftCorner.Y,
|
||||
pos.UpperLeftCorner.X - 5, pos.UpperLeftCorner.Y + size);
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_open_challenge, 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 */);
|
||||
|
||||
Reference in New Issue
Block a user