Show summary of challenge when approaching orb
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10664 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
25716c2b5b
commit
55b18bdbba
@ -41,9 +41,9 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
m_difficulty = RaceManager::RD_EASY;
|
||||
m_num_laps = -1;
|
||||
m_num_karts = -1;
|
||||
|
||||
m_position = -1;
|
||||
m_time = -1.0f;
|
||||
m_track_name = "";
|
||||
m_track_id = "";
|
||||
m_gp_id = "";
|
||||
m_energy = -1;
|
||||
m_version = 0;
|
||||
@ -94,10 +94,12 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
//std::cout << " // Challenge name = <" << s.c_str() << ">\n";
|
||||
setName( s.c_str() );
|
||||
|
||||
if(!root->get("description", &s) ) error("description");
|
||||
setChallengeDescription( s.c_str() );
|
||||
//if(!root->get("description", &s) ) error("description");
|
||||
//setChallengeDescription( s.c_str() );
|
||||
//std::cout << " // Challenge description = <" << s.c_str() << ">\n";
|
||||
|
||||
|
||||
|
||||
if(!root->get("karts", &m_num_karts) ) error("karts");
|
||||
|
||||
// Position is optional except in GP and FTL
|
||||
@ -124,11 +126,11 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
root->get("energy", &m_energy ); // This is optional
|
||||
if(m_major==RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
if (!root->get("track", &m_track_name ))
|
||||
if (!root->get("track", &m_track_id ))
|
||||
{
|
||||
error("track");
|
||||
}
|
||||
if (track_manager->getTrack(m_track_name) == NULL)
|
||||
if (track_manager->getTrack(m_track_id) == NULL)
|
||||
{
|
||||
error("track");
|
||||
}
|
||||
@ -163,6 +165,34 @@ ChallengeData::ChallengeData(const std::string& filename)
|
||||
}
|
||||
delete root;
|
||||
|
||||
|
||||
|
||||
core::stringw description;
|
||||
//I18N: number of laps to race in a challenge
|
||||
description += _("Laps : %i", m_num_laps);
|
||||
description += core::stringw(L"\n");
|
||||
//I18N: number of AI karts in a challenge
|
||||
description += _("AI Karts : %i", m_num_karts - 1);
|
||||
if (m_position > 0)
|
||||
{
|
||||
description += core::stringw(L"\n");
|
||||
//I18N: position required to win in a challenge
|
||||
description += _("Required rank : %i", m_position);
|
||||
}
|
||||
if (m_time > 0)
|
||||
{
|
||||
description += core::stringw(L"\n");
|
||||
//I18N: time required to win a challenge
|
||||
description += _("Time to achieve : %s", StringUtils::timeToString(m_time).c_str());
|
||||
}
|
||||
if (m_energy > 0)
|
||||
{
|
||||
description += core::stringw(L"\n");
|
||||
//I18N: nitro points needed to win a challenge
|
||||
description += _("Collect %i points of nitr", m_energy);
|
||||
}
|
||||
|
||||
m_challenge_description = description;
|
||||
} // ChallengeData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -188,7 +218,7 @@ void ChallengeData::check() const
|
||||
{
|
||||
try
|
||||
{
|
||||
track_manager->getTrack(m_track_name);
|
||||
track_manager->getTrack(m_track_id);
|
||||
}
|
||||
catch(std::exception&)
|
||||
{
|
||||
@ -270,7 +300,7 @@ void ChallengeData::setRace() const
|
||||
if(m_major==RaceManager::MAJOR_MODE_SINGLE)
|
||||
{
|
||||
race_manager->setMinorMode(m_minor);
|
||||
race_manager->setTrack(m_track_name);
|
||||
race_manager->setTrack(m_track_id);
|
||||
race_manager->setDifficulty(m_difficulty);
|
||||
race_manager->setNumLaps(m_num_laps);
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
@ -298,7 +328,7 @@ bool ChallengeData::raceFinished()
|
||||
// ------------
|
||||
World *world = World::getWorld();
|
||||
std::string track_name = world->getTrack()->getIdent();
|
||||
if(track_name!=m_track_name ) return false;
|
||||
if(track_name!=m_track_id ) return false;
|
||||
if((int)world->getNumKarts()<m_num_karts ) return false;
|
||||
Kart* kart = world->getPlayerKart(0);
|
||||
if(m_energy>0 && kart->getEnergy() < m_energy ) return false;
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
int m_num_karts;
|
||||
float m_time;
|
||||
std::string m_gp_id;
|
||||
std::string m_track_name;
|
||||
std::string m_track_id;
|
||||
int m_energy;
|
||||
std::string m_filename;
|
||||
/** Version number of the challenge. */
|
||||
@ -105,9 +105,6 @@ public:
|
||||
const std::vector<UnlockableFeature>&
|
||||
getFeatures() const { return m_feature; }
|
||||
|
||||
void setChallengeDescription(const irr::core::stringw& d)
|
||||
{m_challenge_description=d; }
|
||||
|
||||
const irr::core::stringw getChallengeDescription() const
|
||||
{return _(m_challenge_description.c_str()); }
|
||||
|
||||
@ -129,7 +126,7 @@ public:
|
||||
/** Sets the id of this challenge. */
|
||||
void setId(const std::string& s) { m_id = s; }
|
||||
|
||||
const std::string& getTrackName() const { return m_track_name; }
|
||||
const std::string& getTrackId() const { return m_track_id; }
|
||||
|
||||
|
||||
void addUnlockTrackReward(const std::string &track_name);
|
||||
@ -141,6 +138,16 @@ public:
|
||||
void addUnlockKartReward(const std::string &internal_name,
|
||||
const irr::core::stringw &user_name);
|
||||
|
||||
|
||||
RaceManager::MajorRaceModeType getMajorMode() const { return m_major; }
|
||||
RaceManager::MinorRaceModeType getMinorMode() const { return m_minor; }
|
||||
RaceManager::Difficulty getDifficulty() const { return m_difficulty; }
|
||||
int getNumLaps() const { return m_num_laps; }
|
||||
int getPosition() const { return m_position; }
|
||||
int getNumKarts() const { return m_num_karts; }
|
||||
float getTime() const { return m_time; }
|
||||
int getEnergy() const { return m_energy; }
|
||||
|
||||
}; // ChallengeData
|
||||
|
||||
#endif // HEADER_CHALLENGE_DATA_HPP
|
||||
|
@ -41,6 +41,7 @@ using namespace irr;
|
||||
#include "modes/world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -244,6 +245,8 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
|
||||
Track* t = world->getTrack();
|
||||
|
||||
Vec3 kart_xyz;
|
||||
|
||||
// In the first iteration, only draw AI karts, then only draw
|
||||
// player karts. This guarantees that player kart icons are always
|
||||
// on top of AI kart icons.
|
||||
@ -258,9 +261,9 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
// only player karts.
|
||||
if(kart->getController()->isPlayerController()
|
||||
!=(only_draw_player_kart==1)) continue;
|
||||
const Vec3& xyz = kart->getXYZ();
|
||||
kart_xyz= kart->getXYZ();
|
||||
Vec3 draw_at;
|
||||
t->mapPoint2MiniMap(xyz, &draw_at);
|
||||
t->mapPoint2MiniMap(kart_xyz, &draw_at);
|
||||
|
||||
core::rect<s32> source(i *m_marker_rendered_size,
|
||||
0,
|
||||
@ -296,16 +299,16 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
|
||||
|
||||
//const std::vector<OverworldChallenge>& challenges = t->getChallengeList();
|
||||
const std::vector<OverworldForceField>& challenges = t->getForceFieldList();
|
||||
const std::vector<OverworldForceField>& forcefields = t->getForceFieldList();
|
||||
|
||||
for (unsigned int n=0; n<challenges.size(); n++)
|
||||
for (unsigned int n=0; n<forcefields.size(); n++)
|
||||
{
|
||||
Vec3 draw_at;
|
||||
t->mapPoint2MiniMap(challenges[n].m_position, &draw_at);
|
||||
t->mapPoint2MiniMap(forcefields[n].m_position, &draw_at);
|
||||
|
||||
//const ChallengeData* c = unlock_manager->getChallenge(challenges[n].m_challenge_id);
|
||||
// bool locked = (m_locked_challenges.find(c) != m_locked_challenges.end());
|
||||
bool locked = challenges[n].m_is_locked;
|
||||
bool locked = forcefields[n].m_is_locked;
|
||||
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
(locked ? m_lock : m_open_challenge)->getOriginalSize());
|
||||
@ -317,6 +320,52 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
irr_driver->getVideoDriver()->draw2DImage(locked ? m_lock : m_open_challenge,
|
||||
dest, source, NULL, NULL, true);
|
||||
}
|
||||
|
||||
|
||||
// ---- Draw nearby challenge if any
|
||||
const std::vector<OverworldChallenge>& challenges = t->getChallengeList();
|
||||
for (unsigned int n=0; n<challenges.size(); n++)
|
||||
{
|
||||
if ((kart_xyz - Vec3(challenges[n].m_position)).length2_2d() < 20)
|
||||
{
|
||||
core::rect<s32> pos(15,
|
||||
10,
|
||||
15 + UserConfigParams::m_width/2,
|
||||
10 + GUIEngine::getTitleFontHeight());
|
||||
|
||||
const ChallengeData* challenge = unlock_manager->getChallenge(challenges[n].m_challenge_id);
|
||||
|
||||
if (challenge == NULL)
|
||||
{
|
||||
fprintf(stderr, "[RaceGUIOverworld] ERROR: Cannot find challenge <%s>\n",
|
||||
challenges[n].m_challenge_id.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
Track* track = track_manager->getTrack(challenge->getTrackId());
|
||||
if (track == NULL)
|
||||
{
|
||||
fprintf(stderr, "[RaceGUIOverworld] ERROR: Cannot find track <%s>, "
|
||||
"referenced from challenge <%s>\n",
|
||||
challenge->getTrackId().c_str(),
|
||||
challenges[n].m_challenge_id.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
gui::ScalableFont* font = GUIEngine::getTitleFont();
|
||||
font->draw(track->getName(), pos, video::SColor(255,255,255,255),
|
||||
false, true /* vcenter */, NULL);
|
||||
|
||||
|
||||
pos.UpperLeftCorner.Y += GUIEngine::getTitleFontHeight();
|
||||
pos.LowerRightCorner.Y = UserConfigParams::m_height;
|
||||
GUIEngine::getFont()->draw(challenge->getChallengeDescription().c_str(),
|
||||
pos, video::SColor(255,255,255,255),
|
||||
false, false /* vcenter */, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // drawGlobalMiniMap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -857,10 +857,10 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
|
||||
m_challenges.push_back( OverworldChallenge(xyz, challenge) );
|
||||
|
||||
Track* t = track_manager->getTrack(c->getTrackName());
|
||||
Track* t = track_manager->getTrack(c->getTrackId());
|
||||
if (t == NULL)
|
||||
{
|
||||
fprintf(stderr, "[WARNING] Cannot find track named <%s>\n", c->getTrackName().c_str());
|
||||
fprintf(stderr, "[WARNING] Cannot find track named <%s>\n", c->getTrackId().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user