Start showing location of challenges on minimap. Atm state (locked on not) is not shown
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10658 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c86a92efb1
commit
26b9d63103
@ -54,38 +54,16 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
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;
|
||||
const float scaling = irr_driver->getFrameSize().Height / 420.0f;
|
||||
// Marker texture has to be power-of-two for (old) OpenGL compliance
|
||||
m_marker_rendered_size = 2 << ((int) ceil(1.0 + log(32.0 * scaling)));
|
||||
m_marker_ai_size = (int)( 14.0f * scaling);
|
||||
m_marker_challenge_size = (int)( 12.0f * scaling);
|
||||
m_marker_player_size = (int)( 24.0f * scaling);
|
||||
m_map_width = (int)(250.0f * scaling);
|
||||
m_map_height = (int)(250.0f * scaling);
|
||||
|
||||
// The location of the minimap varies with number of
|
||||
// splitscreen players:
|
||||
switch(race_manager->getNumLocalPlayers())
|
||||
{
|
||||
case 0 : // In case of profile mode
|
||||
case 1 : // Lower left corner
|
||||
m_map_left = 10;
|
||||
m_map_bottom = UserConfigParams::m_height-10;
|
||||
break;
|
||||
case 2: // Middle of left side
|
||||
m_map_left = 10;
|
||||
m_map_bottom = UserConfigParams::m_height/2 + m_map_height/2;
|
||||
break;
|
||||
case 3: // Lower right quarter (which is not used by a player)
|
||||
m_map_left = UserConfigParams::m_width/2 + 10;
|
||||
m_map_bottom = UserConfigParams::m_height-10;
|
||||
break;
|
||||
case 4: // Middle of the screen.
|
||||
m_map_left = UserConfigParams::m_width/2-m_map_width/2;
|
||||
m_map_bottom = UserConfigParams::m_height/2 + m_map_height/2;
|
||||
break;
|
||||
}
|
||||
m_map_left = 20;
|
||||
m_map_bottom = UserConfigParams::m_height-10;
|
||||
|
||||
// Minimap is also rendered bigger via OpenGL, so find power-of-two again
|
||||
const int map_texture = 2 << ((int) ceil(1.0 + log(128.0 * scaling)));
|
||||
@ -114,6 +92,15 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
// 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;
|
||||
|
||||
const std::vector<const ChallengeData*>& v = unlock_manager->getCurrentSlot()->getLockedChallenges();
|
||||
for (unsigned int n=0; n<v.size(); n++)
|
||||
{
|
||||
m_locked_challenges.insert(v[n]);
|
||||
}
|
||||
|
||||
m_lock = irr_driver->getTexture( file_manager->getTextureFile("gui_lock.png") );
|
||||
|
||||
} // RaceGUIOverworld
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -255,6 +242,8 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
irr_driver->getVideoDriver()->draw2DImage(mini_map, dest, source, 0, 0, true);
|
||||
}
|
||||
|
||||
Track* t = world->getTrack();
|
||||
|
||||
// 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.
|
||||
@ -271,7 +260,7 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
!=(only_draw_player_kart==1)) continue;
|
||||
const Vec3& xyz = kart->getXYZ();
|
||||
Vec3 draw_at;
|
||||
world->getTrack()->mapPoint2MiniMap(xyz, &draw_at);
|
||||
t->mapPoint2MiniMap(xyz, &draw_at);
|
||||
|
||||
core::rect<s32> source(i *m_marker_rendered_size,
|
||||
0,
|
||||
@ -279,7 +268,7 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
m_marker_rendered_size);
|
||||
int marker_half_size = (kart->getController()->isPlayerController()
|
||||
? m_marker_player_size
|
||||
: m_marker_ai_size )>>1;
|
||||
: m_marker_challenge_size )>>1;
|
||||
core::rect<s32> position(m_map_left+(int)(draw_at.getX()-marker_half_size),
|
||||
lower_y -(int)(draw_at.getY()+marker_half_size),
|
||||
m_map_left+(int)(draw_at.getX()+marker_half_size),
|
||||
@ -296,15 +285,35 @@ void RaceGUIOverworld::drawGlobalMiniMap()
|
||||
const core::rect<s32> rect(core::position2d<s32>(0,0),
|
||||
m_icons_frame->getTexture()->getOriginalSize());
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(
|
||||
m_icons_frame->getTexture(), position, rect,
|
||||
NULL, colors, true);
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_icons_frame->getTexture(), position,
|
||||
rect, NULL, colors, true);
|
||||
} // if isPlayerController
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_marker, position, source,
|
||||
NULL, NULL, true);
|
||||
} // for i<getNumKarts
|
||||
} // for only_draw_player_kart
|
||||
|
||||
|
||||
const std::vector<OverworldChallenge>& challenges = t->getChallengeList();
|
||||
for (unsigned int n=0; n<challenges.size(); n++)
|
||||
{
|
||||
Vec3 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());
|
||||
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0),
|
||||
m_lock->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(m_lock, dest,
|
||||
source, NULL, NULL, true);
|
||||
}
|
||||
} // drawGlobalMiniMap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <irrString.h>
|
||||
using namespace irr;
|
||||
@ -33,6 +34,7 @@ class InputMap;
|
||||
class Kart;
|
||||
class Material;
|
||||
class RaceSetup;
|
||||
class ChallengeData;
|
||||
|
||||
/**
|
||||
* \brief Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)
|
||||
@ -57,10 +59,11 @@ private:
|
||||
video::ITexture *m_mini_map;
|
||||
|
||||
video::ITexture *m_trophy;
|
||||
video::ITexture *m_lock;
|
||||
|
||||
/** The size of a single marker on the screen for AI karts,
|
||||
* need not be a power of 2. */
|
||||
int m_marker_ai_size;
|
||||
int m_marker_challenge_size;
|
||||
|
||||
/** The size of a single marker on the screen or player karts,
|
||||
* need not be a power of 2. */
|
||||
@ -86,7 +89,8 @@ private:
|
||||
|
||||
int m_trophy_points_width;
|
||||
|
||||
|
||||
std::set<const ChallengeData*> m_locked_challenges;
|
||||
|
||||
/* Display informat for one player on the screen. */
|
||||
void drawEnergyMeter (int x, int y, const Kart *kart,
|
||||
const core::recti &viewport,
|
||||
|
@ -610,8 +610,12 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
{
|
||||
assert(m_track_mesh==NULL);
|
||||
assert(m_gfx_effect_mesh==NULL);
|
||||
|
||||
m_challenges.clear();
|
||||
|
||||
m_track_mesh = new TriangleMesh();
|
||||
m_gfx_effect_mesh = new TriangleMesh();
|
||||
|
||||
const XMLNode *track_node= root.getNode("track");
|
||||
std::string model_name;
|
||||
track_node->get("model", &model_name);
|
||||
@ -852,6 +856,9 @@ bool Track::loadMainTrack(const XMLNode &root)
|
||||
fprintf(stderr, "[WARNING] Cannot find challenge named <%s>\n", challenge.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
m_challenges.push_back( OverworldChallenge(xyz, challenge) );
|
||||
|
||||
Track* t = track_manager->getTrack(c->getTrackName());
|
||||
if (t == NULL)
|
||||
{
|
||||
|
@ -64,6 +64,18 @@ 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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup tracks
|
||||
*/
|
||||
@ -80,6 +92,9 @@ private:
|
||||
std::string m_screenshot;
|
||||
std::vector<MusicInformation*> m_music;
|
||||
|
||||
/** Will only be sued on overworld */
|
||||
std::vector<OverworldChallenge> m_challenges;
|
||||
|
||||
/** Start transforms of karts (either the default, or the ones taken
|
||||
* from the scene file). */
|
||||
AlignedArray<btTransform> m_start_transforms;
|
||||
@ -399,6 +414,10 @@ public:
|
||||
|
||||
TrackObjectManager* getTrackObjectManager() { return m_track_object_manager; }
|
||||
|
||||
/** Get list of challenges placed on that world. Works only for overworld. */
|
||||
const std::vector<OverworldChallenge>& getChallengeList() const
|
||||
{ return m_challenges; }
|
||||
|
||||
}; // class Track
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user