Different display for locked challenges; link toghether force field and challenge
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10667 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
bf01c05412
commit
d7eff73234
@ -96,6 +96,8 @@ public:
|
||||
void save (XMLWriter& file);
|
||||
|
||||
int getPoints () const { return m_points; }
|
||||
|
||||
const Challenge* getChallenge(const std::string& id) { return m_challenges_state[id]; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -46,6 +46,10 @@ using namespace irr;
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
const int LOCKED = 0;
|
||||
const int OPEN = 1;
|
||||
const int COMPLETED = 2;
|
||||
|
||||
/** The constructor is called before anything is attached to the scene node.
|
||||
* So rendering to a texture can be done here. But world is not yet fully
|
||||
* created, so only the race manager can be accessed safely.
|
||||
@ -102,6 +106,10 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
|
||||
m_lock = irr_driver->getTexture( file_manager->getTextureFile("gui_lock.png") );
|
||||
m_open_challenge = irr_driver->getTexture( file_manager->getGUIDir() + "challenge.png" );
|
||||
|
||||
m_icons[0] = m_lock;
|
||||
m_icons[1] = m_open_challenge;
|
||||
m_icons[2] = m_trophy;
|
||||
} // RaceGUIOverworld
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -298,32 +306,33 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
} // for only_draw_player_kart
|
||||
|
||||
|
||||
//const std::vector<OverworldChallenge>& challenges = t->getChallengeList();
|
||||
const std::vector<OverworldForceField>& forcefields = t->getForceFieldList();
|
||||
const std::vector<OverworldChallenge>& challenges = t->getChallengeList();
|
||||
|
||||
for (unsigned int n=0; n<forcefields.size(); n++)
|
||||
for (unsigned int n=0; n<challenges.size(); n++)
|
||||
{
|
||||
Vec3 draw_at;
|
||||
t->mapPoint2MiniMap(forcefields[n].m_position, &draw_at);
|
||||
t->mapPoint2MiniMap(challenges[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 = forcefields[n].m_is_locked;
|
||||
int state = (challenges[n].m_force_field.m_is_locked ? LOCKED : OPEN);
|
||||
|
||||
const Challenge* c = unlock_manager->getCurrentSlot()->getChallenge(challenges[n].m_challenge_id);
|
||||
if (c->isSolved()) state = COMPLETED;
|
||||
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
(locked ? m_lock : m_open_challenge)->getOriginalSize());
|
||||
m_icons[state]->getOriginalSize());
|
||||
|
||||
core::rect<s32> dest(m_map_left+(int)(draw_at.getX()-m_marker_challenge_size/2),
|
||||
lower_y -(int)(draw_at.getY()+m_marker_challenge_size/2),
|
||||
m_map_left+(int)(draw_at.getX()+m_marker_challenge_size/2),
|
||||
lower_y -(int)(draw_at.getY()-m_marker_challenge_size/2));
|
||||
irr_driver->getVideoDriver()->draw2DImage(locked ? m_lock : m_open_challenge,
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_icons[state],
|
||||
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)
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
video::ITexture *m_lock;
|
||||
video::ITexture *m_open_challenge;
|
||||
|
||||
video::ITexture* m_icons[3];
|
||||
|
||||
/** The size of a single marker on the screen for AI karts,
|
||||
* need not be a power of 2. */
|
||||
int m_marker_challenge_size;
|
||||
|
@ -901,6 +901,27 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
|
||||
} // for i
|
||||
|
||||
// Associate force fields and challenges
|
||||
for (unsigned int c=0; c<m_challenges.size(); c++)
|
||||
{
|
||||
int closest_field_id = -1;
|
||||
float closest_distance = 99999.0f;
|
||||
for (unsigned int f=0; f<m_force_fields.size(); f++)
|
||||
{
|
||||
float dist = m_force_fields[f].m_position.getDistanceFromSQ(m_challenges[c].m_position);
|
||||
if (closest_field_id == -1 || dist < closest_distance)
|
||||
{
|
||||
closest_field_id = f;
|
||||
closest_distance = dist;
|
||||
}
|
||||
}
|
||||
|
||||
assert(closest_field_id >= 0);
|
||||
assert(closest_field_id < (int)m_force_fields.size());
|
||||
m_challenges[c].m_force_field = m_force_fields[closest_field_id];
|
||||
}
|
||||
|
||||
// Create LOD nodes
|
||||
std::vector<LODNode*> lod_nodes;
|
||||
lodLoader.done(m_root, m_all_cached_meshes, lod_nodes);
|
||||
for (unsigned int n=0; n<lod_nodes.size(); n++)
|
||||
|
@ -64,28 +64,33 @@ enum WeatherType
|
||||
WEATHER_RAIN
|
||||
};
|
||||
|
||||
struct OverworldChallenge
|
||||
{
|
||||
core::vector3df m_position;
|
||||
std::string m_challenge_id;
|
||||
|
||||
OverworldChallenge(core::vector3df position, std::string challenge_id)
|
||||
{
|
||||
m_position = position;
|
||||
m_challenge_id = challenge_id;
|
||||
}
|
||||
};
|
||||
struct OverworldForceField
|
||||
{
|
||||
core::vector3df m_position;
|
||||
bool m_is_locked;
|
||||
|
||||
OverworldForceField()
|
||||
{
|
||||
}
|
||||
|
||||
OverworldForceField(core::vector3df position, bool is_locked)
|
||||
{
|
||||
m_position = position;
|
||||
m_is_locked = is_locked;
|
||||
}
|
||||
};
|
||||
struct OverworldChallenge
|
||||
{
|
||||
core::vector3df m_position;
|
||||
std::string m_challenge_id;
|
||||
OverworldForceField m_force_field;
|
||||
|
||||
OverworldChallenge(core::vector3df position, std::string challenge_id)
|
||||
{
|
||||
m_position = position;
|
||||
m_challenge_id = challenge_id;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@ -431,10 +436,6 @@ public:
|
||||
/** Get list of challenges placed on that world. Works only for overworld. */
|
||||
const std::vector<OverworldChallenge>& getChallengeList() const
|
||||
{ return m_challenges; }
|
||||
|
||||
/** Get list of force fields placed on that world. Works only for overworld. */
|
||||
const std::vector<OverworldForceField>& getForceFieldList() const
|
||||
{ return m_force_fields; }
|
||||
|
||||
|
||||
}; // class Track
|
||||
|
Loading…
x
Reference in New Issue
Block a user