2007-05-27 12:01:53 -04:00
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
|
|
|
// Copyright (C) 2006 Joerg Henrichs, SuperTuxKart-Team, Steve Baker
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
2008-06-12 20:53:52 -04:00
|
|
|
// as published by the Free Software Foundation; either version 3
|
2007-05-27 12:01:53 -04:00
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
2009-07-18 13:48:36 -04:00
|
|
|
#include "states_screens/race_gui.hpp"
|
2007-11-26 09:28:15 -05:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
#include "irrlicht.h"
|
|
|
|
using namespace irr;
|
|
|
|
|
2008-09-17 23:24:19 -04:00
|
|
|
#include "audio/sound_manager.hpp"
|
2009-06-11 06:00:43 -04:00
|
|
|
#include "config/user_config.hpp"
|
2009-03-11 01:10:56 -04:00
|
|
|
#include "graphics/irr_driver.hpp"
|
2009-06-02 08:37:29 -04:00
|
|
|
#include "graphics/material_manager.hpp"
|
|
|
|
#include "input/input.hpp"
|
|
|
|
#include "input/input_manager.hpp"
|
2009-07-27 07:56:09 -04:00
|
|
|
#include "karts/kart_properties_manager.hpp"
|
2009-06-02 21:36:48 -04:00
|
|
|
#include "race/race_manager.hpp"
|
2009-01-22 17:27:13 -05:00
|
|
|
#include "tracks/track.hpp"
|
|
|
|
#include "utils/constants.hpp"
|
2009-07-08 08:34:39 -04:00
|
|
|
#include "utils/string_utils.hpp"
|
2009-01-23 00:23:22 -05:00
|
|
|
#include "utils/translation.hpp"
|
2008-01-12 20:26:30 -05:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
/** 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.
|
|
|
|
*/
|
2008-02-10 18:17:25 -05:00
|
|
|
RaceGUI::RaceGUI()
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-29 22:40:30 -04:00
|
|
|
m_marker_rendered_size = 32;
|
|
|
|
m_marker_ai_size = 14;
|
|
|
|
m_marker_player_size = 16;
|
|
|
|
m_map_rendered_width = 128;
|
|
|
|
m_map_rendered_height = 128;
|
|
|
|
m_map_width = 100;
|
|
|
|
m_map_height = 100;
|
|
|
|
m_map_left = 10;
|
|
|
|
m_map_bottom = 10;
|
2009-03-11 20:57:00 -04:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
m_speed_meter_icon = material_manager->getMaterial("speedback.png");
|
|
|
|
m_speed_bar_icon = material_manager->getMaterial("speedfore.png");
|
|
|
|
m_plunger_face = material_manager->getMaterial("plungerface.png");
|
|
|
|
createMarkerTexture();
|
2007-05-27 12:01:53 -04:00
|
|
|
} // RaceGUI
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
RaceGUI::~RaceGUI()
|
|
|
|
{
|
2009-07-27 07:56:09 -04:00
|
|
|
irr_driver->removeTexture(m_marker);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // ~Racegui
|
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Creates a texture with the markers for all karts in the current race
|
|
|
|
* on it. This assumes that nothing is attached to the scene node at
|
|
|
|
* this stage.
|
|
|
|
*/
|
|
|
|
void RaceGUI::createMarkerTexture()
|
|
|
|
{
|
|
|
|
unsigned int n=race_manager->getNumKarts();
|
|
|
|
unsigned int npower2 = 1;
|
|
|
|
// Textures must be power of 2, so
|
|
|
|
while(npower2<n) npower2*=2;
|
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
int radius = (m_marker_rendered_size>>1)-1;
|
2009-08-05 08:45:11 -04:00
|
|
|
#ifdef IRR_SVN
|
|
|
|
irr_driver->beginRenderToTexture(core::dimension2du(m_marker_rendered_size * npower2,
|
|
|
|
m_marker_rendered_size),
|
|
|
|
"RaceGUI::markers");
|
|
|
|
#else
|
2009-07-29 22:40:30 -04:00
|
|
|
irr_driver->beginRenderToTexture(core::dimension2di(m_marker_rendered_size * npower2,
|
|
|
|
m_marker_rendered_size),
|
2009-07-27 07:56:09 -04:00
|
|
|
"RaceGUI::markers");
|
2009-08-05 08:45:11 -04:00
|
|
|
#endif
|
2009-07-27 07:56:09 -04:00
|
|
|
for(unsigned int i=0; i<race_manager->getNumKarts(); i++)
|
|
|
|
{
|
2009-08-13 00:53:51 -04:00
|
|
|
const std::string& kart_ident = race_manager->getKartIdent(i);
|
|
|
|
const KartProperties *kp = kart_properties_manager->getKart(kart_ident);
|
2009-07-29 22:40:30 -04:00
|
|
|
core::vector2df center((float)((m_marker_rendered_size>>1)+i*m_marker_rendered_size),
|
|
|
|
(float)(m_marker_rendered_size>>1) );
|
2009-07-27 07:56:09 -04:00
|
|
|
int count = kp->getShape();
|
|
|
|
core::array<core::vector2df> vertices;
|
|
|
|
createRegularPolygon(count, (float)radius, center,&vertices);
|
|
|
|
|
|
|
|
video::SColor color = kp->getColor();
|
|
|
|
core::array<video::SColor> colors;
|
|
|
|
colors.push_back(color);
|
|
|
|
#ifdef IRRLICHT_HAS_SUPERTUXKART_POLYGON
|
|
|
|
irr_driver->getVideoDriver()->draw2DPolygon(vertices, &colors);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
m_marker = irr_driver->endRenderToTexture();
|
|
|
|
} // createMarkerTexture
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Creates the 2D vertices for a regular polygon. Adopted from Irrlicht.
|
|
|
|
* \param n Number of vertices to use.
|
|
|
|
* \param radius Radius of the polygon.
|
|
|
|
* \param center The center point of the polygon.
|
|
|
|
* \param v Pointer to the array of vertices.
|
|
|
|
*/
|
|
|
|
void RaceGUI::createRegularPolygon(unsigned int n, float radius,
|
|
|
|
const core::vector2df ¢er,
|
|
|
|
core::array<core::vector2df> *v)
|
|
|
|
{
|
|
|
|
float f = 2*M_PI/(float)n;
|
|
|
|
for (unsigned int i=0; i<n; i++)
|
|
|
|
{
|
|
|
|
float p = i*f;
|
|
|
|
core::vector2df X = center + core::vector2df(sin(p)*radius, -cos(p)*radius);
|
|
|
|
v->push_back(X);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // createRegularPolygon
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-12 07:54:21 -04:00
|
|
|
/** Called before rendering, so no direct output to the screen can be done
|
|
|
|
* here.
|
|
|
|
* \param dt Time step size.
|
|
|
|
*/
|
2007-05-27 12:01:53 -04:00
|
|
|
void RaceGUI::update(float dt)
|
|
|
|
{
|
2008-10-04 14:50:45 -04:00
|
|
|
cleanupMessages(dt);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // update
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-12 07:54:21 -04:00
|
|
|
/** Render the race gui. Direct access to the screen is possible here, since
|
|
|
|
* this is called during irrlicht rendering.
|
|
|
|
*/
|
|
|
|
void RaceGUI::render()
|
|
|
|
{
|
|
|
|
drawStatusText();
|
|
|
|
} // render
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Displays the racing time on the screen.s
|
2009-03-11 01:10:56 -04:00
|
|
|
*/
|
2007-05-27 12:01:53 -04:00
|
|
|
void RaceGUI::drawTimer ()
|
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
assert(RaceManager::getWorld() != NULL);
|
|
|
|
|
|
|
|
if(!RaceManager::getWorld()->shouldDrawTimer()) return;
|
2009-07-08 08:34:39 -04:00
|
|
|
std::string s = StringUtils::timeToString(RaceManager::getWorld()->getTime());
|
2009-07-12 07:54:21 -04:00
|
|
|
core::stringw sw(s.c_str());
|
|
|
|
|
|
|
|
static video::SColor time_color = video::SColor(255, 255, 255, 255);
|
|
|
|
core::rect<s32> pos(UserConfigParams::m_width-120, 10,
|
|
|
|
UserConfigParams::m_width, 50);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
|
|
|
font->draw(sw.c_str(), pos, time_color);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawTimer
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-29 22:40:30 -04:00
|
|
|
/** Draws the mini map and the position of all karts on it.
|
|
|
|
*/
|
|
|
|
void RaceGUI::drawMiniMap()
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-10-14 16:20:54 -04:00
|
|
|
// arenas currently don't have a map.
|
|
|
|
if(RaceManager::getTrack()->isArena()) return;
|
2009-07-29 22:40:30 -04:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
const video::ITexture *mini_map=RaceManager::getTrack()->getMiniMap();
|
2008-10-14 16:20:54 -04:00
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
int upper_y = UserConfigParams::m_height-m_map_bottom-m_map_height;
|
|
|
|
int lower_y = UserConfigParams::m_height-m_map_bottom;
|
|
|
|
core::rect<s32> dest(m_map_left, upper_y,
|
|
|
|
m_map_left + m_map_width, lower_y);
|
2009-07-27 07:56:09 -04:00
|
|
|
core::rect<s32> source(core::position2di(0, 0), mini_map->getOriginalSize());
|
2009-07-29 22:40:30 -04:00
|
|
|
irr_driver->getVideoDriver()->draw2DImage(mini_map, dest, source, 0, 0, true);
|
2009-07-16 20:22:58 -04:00
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
for(unsigned int i=0; i<race_manager->getNumKarts(); i++)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-29 22:40:30 -04:00
|
|
|
const Kart *kart = RaceManager::getKart(i);
|
2008-04-15 09:57:18 -04:00
|
|
|
if(kart->isEliminated()) continue; // don't draw eliminated kart
|
2009-07-29 22:40:30 -04:00
|
|
|
const Vec3& xyz = kart->getXYZ();
|
|
|
|
Vec3 draw_at;
|
|
|
|
RaceManager::getTrack()->mapPoint2MiniMap(xyz, &draw_at);
|
|
|
|
int marker_height = m_marker->getOriginalSize().Height;
|
|
|
|
core::rect<s32> source(i *m_marker_rendered_size, 0,
|
|
|
|
(i+1)*m_marker_rendered_size, m_marker_rendered_size);
|
|
|
|
int marker_half_size = (kart->isPlayerKart() ? m_marker_player_size
|
|
|
|
: m_marker_ai_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),
|
|
|
|
lower_y -(int)(draw_at.getY()-marker_half_size));
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(m_marker, position, source, NULL, NULL, true);
|
|
|
|
} // for i<getNumKarts
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawMap
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-13 08:25:38 -04:00
|
|
|
// Draw players icons and their times (if defined in the current mode).
|
2008-09-27 15:43:57 -04:00
|
|
|
void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
assert(RaceManager::getWorld() != NULL);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
int x = 5;
|
|
|
|
int y;
|
2009-01-06 08:29:48 -05:00
|
|
|
int ICON_WIDTH=40;
|
|
|
|
int ICON_PLAYER_WIDTH=50;
|
2009-06-20 21:10:43 -04:00
|
|
|
if(UserConfigParams::m_height<600)
|
2009-01-06 08:29:48 -05:00
|
|
|
{
|
|
|
|
ICON_WIDTH = 27;
|
|
|
|
ICON_PLAYER_WIDTH = 35;
|
|
|
|
}
|
2008-09-30 20:46:00 -04:00
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-09-28 22:29:33 -04:00
|
|
|
const unsigned int kart_amount = race_manager->getNumKarts();
|
2008-09-27 15:43:57 -04:00
|
|
|
for(unsigned int i = 0; i < kart_amount ; i++)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
Kart* kart = RaceManager::getKart(i);
|
2008-04-15 09:57:18 -04:00
|
|
|
if(kart->isEliminated()) continue;
|
2008-10-14 16:20:54 -04:00
|
|
|
const int position = kart->getPosition();
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
y = 20 + ( (position == -1 ? i : position-1)*(ICON_PLAYER_WIDTH+2));
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
if(info[i].time.length()>0)
|
2008-04-16 20:20:06 -04:00
|
|
|
{
|
2009-07-13 08:25:38 -04:00
|
|
|
static video::SColor color = video::SColor(255, (int)(255*info[i].r),
|
|
|
|
(int)(255*info[i].g),
|
|
|
|
(int)(255*info[i].b) );
|
|
|
|
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, x+ICON_PLAYER_WIDTH, y+5);
|
|
|
|
core::stringw s=info[i].time.c_str();
|
|
|
|
font->draw(s.c_str(), pos, color);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2008-09-27 15:43:57 -04:00
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
if(info[i].special_title.length() >0)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-13 08:25:38 -04:00
|
|
|
static video::SColor color = video::SColor(255, 255, 0, 0);
|
|
|
|
core::rect<s32> pos(x+ICON_PLAYER_WIDTH, y+5, x+ICON_PLAYER_WIDTH, y+5);
|
|
|
|
core::stringw s(info[i].special_title.c_str());
|
|
|
|
font->draw(s.c_str(), pos, color);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
// draw icon
|
|
|
|
video::ITexture *icon = kart->getKartProperties()->getIconMaterial()->getTexture();
|
|
|
|
int w = kart->isPlayerKart() ? ICON_PLAYER_WIDTH : ICON_WIDTH;
|
|
|
|
const core::rect<s32> pos(x, y, x+w, y+w);
|
|
|
|
const core::rect<s32> rect(core::position2d<s32>(0,0), icon->getOriginalSize());
|
2009-07-30 06:20:11 -04:00
|
|
|
irr_driver->getVideoDriver()->draw2DImage(icon, pos, rect, NULL, NULL, true);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-09-30 20:46:00 -04:00
|
|
|
} // next kart
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawPlayerIcons
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-13 20:26:18 -04:00
|
|
|
void RaceGUI::drawPowerupIcons(Kart* player_kart, int offset_x,
|
|
|
|
int offset_y, float ratio_x,
|
|
|
|
float ratio_y )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2007-06-08 05:19:27 -04:00
|
|
|
// If player doesn't have anything, do nothing.
|
2008-10-29 22:02:56 -04:00
|
|
|
Powerup* powerup=player_kart->getPowerup();
|
|
|
|
if(powerup->getType() == POWERUP_NOTHING) return;
|
2009-07-13 20:26:18 -04:00
|
|
|
int n = player_kart->getNumPowerup() ;
|
|
|
|
if(n<1) return; // shouldn't happen, but just in case
|
|
|
|
if(n>5) n=5; // Display at most 5 items
|
2007-06-08 05:19:27 -04:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
// Originally the hardcoded sizes were 320-32 and 400
|
2009-07-13 20:26:18 -04:00
|
|
|
int x1 = (int)((UserConfigParams::m_width/2-32) * ratio_x) + offset_x;
|
|
|
|
int y1 = (int)(20 * ratio_y) + offset_y;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
int nSize=(int)(64.0f*std::min(ratio_x, ratio_y));
|
|
|
|
|
2009-07-13 20:26:18 -04:00
|
|
|
video::ITexture *t=powerup->getIcon()->getTexture();
|
|
|
|
core::rect<s32> rect(core::position2di(0, 0), t->getOriginalSize());
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
for ( int i = 0 ; i < n ; i++ )
|
|
|
|
{
|
2009-07-13 20:26:18 -04:00
|
|
|
core::rect<s32> pos(x1+i*30, y1, x1+i*30+nSize, y1+nSize);
|
2009-07-30 06:20:11 -04:00
|
|
|
irr_driver->getVideoDriver()->draw2DImage(t, pos, rect, NULL,
|
|
|
|
NULL, true);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // for i
|
2008-10-29 22:02:56 -04:00
|
|
|
} // drawPowerupIcons
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/* Energy meter that gets filled with coins */
|
|
|
|
void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
|
|
|
|
float ratio_x, float ratio_y )
|
|
|
|
{
|
2009-07-14 08:57:04 -04:00
|
|
|
float state = (float)(player_kart->getEnergy()) / MAX_ITEMS_COLLECTED;
|
2009-06-20 21:10:43 -04:00
|
|
|
int x = (int)((UserConfigParams::m_width-24) * ratio_x) + offset_x;
|
2007-05-27 12:01:53 -04:00
|
|
|
int y = (int)(250 * ratio_y) + offset_y;
|
|
|
|
int w = (int)(16 * ratio_x);
|
2009-06-20 21:10:43 -04:00
|
|
|
int h = (int)(UserConfigParams::m_height/4 * ratio_y);
|
2008-05-11 13:32:41 -04:00
|
|
|
float coin_target = (float)race_manager->getCoinTarget();
|
2008-10-29 11:55:54 -04:00
|
|
|
int th = (int)(h*(coin_target/MAX_ITEMS_COLLECTED));
|
2009-07-14 08:57:04 -04:00
|
|
|
|
|
|
|
video::SColor black_border(255, 0, 0, 0);
|
|
|
|
video::SColor white_border(255, 255, 255, 255);
|
|
|
|
video::IVideoDriver *video = irr_driver->getVideoDriver();
|
|
|
|
#define LINE(x0,y0,x1,y1, color) video->draw2DLine(core::position2di(x0,y0), \
|
|
|
|
core::position2di(x1,y1), color)
|
|
|
|
|
|
|
|
// Left side:
|
|
|
|
LINE(x-1, y+1, x-1, y-h-1, black_border);
|
|
|
|
LINE(x, y, x, y-h-2, white_border);
|
2009-07-27 07:56:09 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
// Right side:
|
|
|
|
LINE(x+w, y+1, x+w, y-h-1, black_border);
|
|
|
|
LINE(x+w+1, y, x+w+1, y-h-2, white_border);
|
2009-07-27 07:56:09 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
// Bottom
|
|
|
|
LINE(x, y+1, x+w, y+1, black_border);
|
|
|
|
LINE(x+1, y, x+w+1, y, white_border);
|
2009-07-27 07:56:09 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
// Top
|
|
|
|
LINE(x, y-h, x+w, y-h, black_border);
|
|
|
|
LINE(x, y-h-1, x+w, y-h-1, white_border);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
const int GRADS = (int)(MAX_ITEMS_COLLECTED/5); // each graduation equals 5 items
|
|
|
|
int gh = (int)(h/GRADS); //graduation height
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
// 'Meter marks;
|
2008-05-10 09:30:55 -04:00
|
|
|
int gh_incr = gh;
|
|
|
|
for (int i=0; i<GRADS-1; i++)
|
|
|
|
{
|
2009-07-14 08:57:04 -04:00
|
|
|
LINE(x+1, y-1-gh, x+1+w, y-1-gh, white_border);
|
2008-05-10 09:30:55 -04:00
|
|
|
gh+=gh_incr;
|
|
|
|
}
|
2009-07-14 08:57:04 -04:00
|
|
|
|
2008-05-11 13:32:41 -04:00
|
|
|
//Target line
|
|
|
|
if (coin_target > 0)
|
|
|
|
{
|
2009-07-14 08:57:04 -04:00
|
|
|
LINE(x+1, y-1-th, x+1+w, y-1-th, video::SColor(255, 255, 0, 0));
|
2008-05-11 13:32:41 -04:00
|
|
|
}
|
2009-07-14 08:57:04 -04:00
|
|
|
#undef LINE
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-14 08:57:04 -04:00
|
|
|
// The actual energy meter
|
|
|
|
core::rect<s32> energy(x+1, y-1-(int)(state*h), x+1+w, y-1);
|
|
|
|
video::SColor bottom(255, 240, 0, 0);
|
|
|
|
video::SColor top (160, 240, 200, 0);
|
|
|
|
video->draw2DRectangle(energy, top, top, bottom, bottom);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawEnergyMeter
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
|
|
|
float ratio_x, float ratio_y )
|
|
|
|
{
|
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
float minRatio = std::min(ratio_x, ratio_y);
|
|
|
|
const int SPEEDWIDTH = 128;
|
|
|
|
int meter_width = (int)(SPEEDWIDTH*minRatio);
|
|
|
|
int meter_height = (int)(SPEEDWIDTH*minRatio);
|
|
|
|
offset_x += (int)((UserConfigParams::m_width-10)*ratio_x) - meter_width;
|
|
|
|
offset_y += (int)(10*ratio_y);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
// First draw the meter (i.e. the background which contains the numbers etc.
|
|
|
|
// -------------------------------------------------------------------------
|
2009-07-15 09:40:22 -04:00
|
|
|
video::IVideoDriver *video = irr_driver->getVideoDriver();
|
2009-07-27 07:56:09 -04:00
|
|
|
const core::rect<s32> meter_pos(offset_x, UserConfigParams::m_height-offset_y-meter_height,
|
|
|
|
offset_x+meter_width, UserConfigParams::m_height-offset_y);
|
|
|
|
video::ITexture *meter_texture = m_speed_meter_icon->getTexture();
|
|
|
|
const core::rect<s32> meter_texture_coords(core::position2d<s32>(0,0),
|
|
|
|
meter_texture->getOriginalSize());
|
|
|
|
video->draw2DImage(meter_texture, meter_pos, meter_texture_coords, NULL, NULL, true);
|
|
|
|
|
|
|
|
// Indicate when the kart is off ground
|
|
|
|
// ------------------------------------
|
2007-05-27 12:01:53 -04:00
|
|
|
if ( !kart->isOnGround() )
|
|
|
|
{
|
2009-07-15 09:40:22 -04:00
|
|
|
static video::SColor color = video::SColor(255, 255, 255, 255);
|
|
|
|
core::rect<s32> pos(offset_x-(int)(30*minRatio),
|
|
|
|
UserConfigParams::m_height-(offset_y-(int)(10*minRatio)),
|
|
|
|
offset_x-(int)(30*minRatio),
|
|
|
|
UserConfigParams::m_height-(offset_y-(int)(10*minRatio)) );
|
|
|
|
irr_driver->getRaceFont()->draw(core::stringw("!").c_str(), pos, color);
|
|
|
|
}
|
2009-07-27 07:56:09 -04:00
|
|
|
|
2009-07-15 09:40:22 -04:00
|
|
|
const float speed = kart->getSpeed();
|
2009-07-27 07:56:09 -04:00
|
|
|
if(speed <=0) return; // Nothing to do if speed is negative.
|
|
|
|
|
|
|
|
// Draw the actual speed bar (if the speed is >0)
|
|
|
|
// ----------------------------------------------
|
|
|
|
float speed_ratio = speed/KILOMETERS_PER_HOUR/110.0f;
|
|
|
|
if(speed_ratio>1) speed_ratio = 1;
|
|
|
|
|
|
|
|
video::ITexture *bar_texture = m_speed_bar_icon->getTexture();
|
2009-08-05 08:45:11 -04:00
|
|
|
#ifdef IRR_SVN
|
|
|
|
core::dimension2du bar_size = bar_texture->getOriginalSize();
|
|
|
|
#else
|
2009-07-27 07:56:09 -04:00
|
|
|
core::dimension2di bar_size = bar_texture->getOriginalSize();
|
2009-08-05 08:45:11 -04:00
|
|
|
#endif
|
2009-07-27 07:56:09 -04:00
|
|
|
core::array<core::vector2di> tex_coords; // texture coordinates
|
|
|
|
core::array<core::vector2df> bar_vertices; // screen coordinates
|
|
|
|
|
|
|
|
tex_coords.push_back(core::vector2di(bar_size.Width, bar_size.Height));
|
|
|
|
bar_vertices.push_back(core::vector2df((float)meter_pos.LowerRightCorner.X,
|
|
|
|
(float)meter_pos.LowerRightCorner.Y));
|
|
|
|
tex_coords.push_back(core::vector2di(0,bar_size.Height));
|
|
|
|
bar_vertices.push_back(core::vector2df((float)meter_pos.UpperLeftCorner.X,
|
|
|
|
(float)meter_pos.LowerRightCorner.Y));
|
|
|
|
|
|
|
|
if(speed_ratio<=0.5f)
|
2009-07-15 09:40:22 -04:00
|
|
|
{
|
2009-07-27 07:56:09 -04:00
|
|
|
core::vector2di v0(0, bar_size.Height-(int)(2*(speed_ratio)*bar_size.Height));
|
|
|
|
tex_coords.push_back(v0);
|
|
|
|
bar_vertices.push_back(core::vector2df((float)meter_pos.UpperLeftCorner.X,
|
|
|
|
(float)meter_pos.LowerRightCorner.Y-speed_ratio*2*meter_height));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tex_coords.push_back(core::vector2di(0, 0));
|
|
|
|
bar_vertices.push_back(core::vector2df((float)offset_x,
|
|
|
|
(float)(UserConfigParams::m_height-offset_y-meter_height)));
|
|
|
|
|
|
|
|
core::vector2di v0((int)(2*(speed_ratio-0.5f)*bar_size.Width), 0);
|
|
|
|
tex_coords.push_back(v0);
|
|
|
|
bar_vertices.push_back(core::vector2df(offset_x+2*(speed_ratio-0.5f)*meter_width,
|
|
|
|
(float)(UserConfigParams::m_height-offset_y-meter_height)));
|
|
|
|
}
|
|
|
|
#ifdef IRRLICHT_HAS_SUPERTUXKART_POLYGON
|
|
|
|
irr_driver->getVideoDriver()->draw2DPolygon(bar_vertices, NULL, bar_texture, true, &tex_coords);
|
2009-02-10 00:30:59 -05:00
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawSpeed
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-09-27 15:43:57 -04:00
|
|
|
void RaceGUI::drawLap(const KartIconDisplayInfo* info, Kart* kart, int offset_x,
|
|
|
|
int offset_y, float ratio_x, float ratio_y )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
1) Removed race_setup and race_mode data structures. All this
information is now only managed by the race_manager, no
more in-between objects to transfer information along.
2) The scores for grand prix are now defined in the stk_config.dat
file (10, 8, 6, 5, 4, .., 1, 0, 0) points
3) Bugfix: unlock information wasn't saved anymore. Added specific
saving after unlocking, plus re-inserted the 'generic' save
at the end of STK again.
4) bugfix/work around: Visual Studio complains about incompatible
iterators in sdldrv - apparently caused by using erase, and
then keep on using the iterator.
5) Fixed bug when running a race in a GP again (scores/times
were added each time).
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1681 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2008-04-09 09:52:48 -04:00
|
|
|
// Don't display laps in follow the leader mode
|
2008-09-30 21:53:35 -04:00
|
|
|
if(!RaceManager::getWorld()->raceHasLaps()) return;
|
2008-09-27 15:43:57 -04:00
|
|
|
|
|
|
|
const int lap = info[kart->getWorldKartId()].lap;
|
|
|
|
|
|
|
|
if(lap<0) return; // don't display 'lap 0/...', or do nothing if laps are disabled (-1)
|
2009-01-17 22:27:44 -05:00
|
|
|
float minRatio = std::min(ratio_x, ratio_y);
|
2007-05-27 12:01:53 -04:00
|
|
|
offset_x += (int)(120*ratio_x);
|
2009-07-13 20:26:18 -04:00
|
|
|
offset_y += (int)(UserConfigParams::m_height*5/6*minRatio);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-13 20:26:18 -04:00
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-05-19 23:33:48 -04:00
|
|
|
if(kart->hasFinishedRace())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-13 20:26:18 -04:00
|
|
|
static video::SColor color = video::SColor(255, 255, 255, 255);
|
|
|
|
core::rect<s32> pos(offset_x, offset_y, offset_x, offset_y);
|
|
|
|
core::stringw s=_("Finished");
|
|
|
|
font->draw(s.c_str(), pos, color);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-13 20:26:18 -04:00
|
|
|
static video::SColor color = video::SColor(255, 255, 255, 255);
|
|
|
|
core::rect<s32> pos(offset_x, offset_y, offset_x, offset_y);
|
|
|
|
core::stringw s = _("Lap");
|
|
|
|
font->draw(core::stringw(_("Lap")).c_str(), pos, color);
|
|
|
|
|
|
|
|
char str[256];
|
|
|
|
sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps());
|
|
|
|
pos.UpperLeftCorner.Y += (int)(40*ratio_y);
|
|
|
|
pos.LowerRightCorner.Y += (int)(40*ratio_y);
|
|
|
|
font->draw(core::stringw(str).c_str(), pos, color);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
} // drawLap
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Removes messages which have been displayed long enough. This function
|
2008-10-04 14:50:45 -04:00
|
|
|
* must be called after drawAllMessages, otherwise messages which are only
|
2007-05-27 12:01:53 -04:00
|
|
|
* displayed once will not be drawn!
|
|
|
|
**/
|
|
|
|
|
2008-10-04 14:50:45 -04:00
|
|
|
void RaceGUI::cleanupMessages(const float dt)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
AllMessageType::iterator p =m_messages.begin();
|
|
|
|
while(p!=m_messages.end())
|
|
|
|
{
|
2008-10-04 14:50:45 -04:00
|
|
|
if((*p).done(dt))
|
2007-09-10 10:11:08 -04:00
|
|
|
{
|
|
|
|
p = m_messages.erase(p);
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
else
|
2007-09-10 10:11:08 -04:00
|
|
|
{
|
|
|
|
++p;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
} // cleanupMessages
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Displays all messages in the message queue
|
|
|
|
**/
|
|
|
|
void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
|
|
|
float ratio_x, float ratio_y )
|
|
|
|
{
|
2007-11-19 21:13:53 -05:00
|
|
|
int y;
|
2007-05-27 12:01:53 -04:00
|
|
|
// First line of text somewhat under the top of the screen. For now
|
|
|
|
// start just under the timer display
|
2009-07-15 23:24:17 -04:00
|
|
|
y = (int)(ratio_y*164+offset_y);
|
2007-05-27 12:01:53 -04:00
|
|
|
// The message are displayed in reverse order, so that a multi-line
|
|
|
|
// message (addMessage("1", ...); addMessage("2",...) is displayed
|
|
|
|
// in the right order: "1" on top of "2"
|
2007-09-10 10:11:08 -04:00
|
|
|
for(AllMessageType::const_iterator i=m_messages.begin();i!=m_messages.end(); ++i)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2007-09-10 10:11:08 -04:00
|
|
|
TimedMessage const &msg = *i;
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
// Display only messages for all karts, or messages for this kart
|
2007-09-10 10:11:08 -04:00
|
|
|
if( msg.m_kart && msg.m_kart!=player_kart) continue;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-15 23:24:17 -04:00
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, y,
|
|
|
|
UserConfigParams::m_width>>1, y);
|
|
|
|
irr_driver->getRaceFont()->draw(core::stringw(msg.m_message.c_str()).c_str(),
|
|
|
|
pos, msg.m_color, true, true);
|
|
|
|
y+=40;
|
2007-05-27 12:01:53 -04:00
|
|
|
} // for i in all messages
|
|
|
|
} // drawAllMessages
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Adds a message to the message queue. The message is displayed for a
|
|
|
|
* certain amount of time (unless time<0, then the message is displayed
|
|
|
|
* once).
|
|
|
|
**/
|
2009-01-23 00:23:22 -05:00
|
|
|
void RaceGUI::addMessage(const std::string &msg, const Kart *kart, float time,
|
2009-07-15 23:24:17 -04:00
|
|
|
int font_size, const video::SColor &color)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-15 23:24:17 -04:00
|
|
|
m_messages.push_back(TimedMessage(msg, kart, time, font_size, color));
|
2007-05-27 12:01:53 -04:00
|
|
|
} // addMessage
|
|
|
|
|
2008-02-10 18:17:25 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Displays the description given for the music currently being played -
|
|
|
|
// usually the title and composer.
|
|
|
|
void RaceGUI::drawMusicDescription()
|
|
|
|
{
|
2008-03-14 05:49:17 -04:00
|
|
|
const MusicInformation* mi=sound_manager->getCurrentMusic();
|
2008-05-11 01:45:02 -04:00
|
|
|
if(!mi) return;
|
2009-07-15 09:40:22 -04:00
|
|
|
int y=UserConfigParams::m_height-40;
|
2009-07-27 07:56:09 -04:00
|
|
|
static const video::SColor white = video::SColor(255, 255, 255, 255);
|
2009-07-15 09:40:22 -04:00
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-03-14 05:49:17 -04:00
|
|
|
if(mi->getComposer()!="")
|
2008-02-10 18:17:25 -05:00
|
|
|
{
|
2009-07-15 23:24:17 -04:00
|
|
|
core::rect<s32> pos_by(UserConfigParams::m_width>>1, y,
|
|
|
|
UserConfigParams::m_width>>1, y);
|
2008-03-14 05:49:17 -04:00
|
|
|
std::string s="by "+mi->getComposer();
|
2009-07-15 09:40:22 -04:00
|
|
|
font->draw(core::stringw(s.c_str()).c_str(), pos_by, white, true, true);
|
|
|
|
y-=40;
|
2008-03-14 05:49:17 -04:00
|
|
|
}
|
2009-07-15 09:40:22 -04:00
|
|
|
|
2008-03-14 05:49:17 -04:00
|
|
|
std::string s="\""+mi->getTitle()+"\"";
|
2009-07-15 09:40:22 -04:00
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, y,
|
|
|
|
UserConfigParams::m_width>>1, y);
|
|
|
|
font->draw(core::stringw(s.c_str()).c_str(), pos, white, true, true);
|
2008-02-10 18:17:25 -05:00
|
|
|
} // drawMusicDescription
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2009-07-12 07:54:21 -04:00
|
|
|
void RaceGUI::drawStatusText()
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
assert(RaceManager::getWorld() != NULL);
|
|
|
|
switch (RaceManager::getWorld()->getPhase())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-20 19:45:22 -04:00
|
|
|
case READY_PHASE:
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
static video::SColor color = video::SColor(255, 230, 168, 158);
|
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, UserConfigParams::m_height>>1,
|
|
|
|
UserConfigParams::m_width>>1, UserConfigParams::m_height>>1);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2009-07-12 07:54:21 -04:00
|
|
|
core::stringw s=_("Ready!");
|
|
|
|
font->draw(s.c_str(), pos, color, true, true);
|
2008-04-24 03:06:09 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-09-20 19:45:22 -04:00
|
|
|
case SET_PHASE:
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
static video::SColor color = video::SColor(255, 230, 230, 158);
|
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, UserConfigParams::m_height>>1,
|
|
|
|
UserConfigParams::m_width>>1, UserConfigParams::m_height>>1);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2009-07-12 07:54:21 -04:00
|
|
|
core::stringw s=_("Set!");
|
|
|
|
font->draw(s.c_str(), pos, color, true, true);
|
2008-04-24 03:06:09 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-09-20 19:45:22 -04:00
|
|
|
case GO_PHASE:
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
static video::SColor color = video::SColor(255, 100, 209, 100);
|
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, UserConfigParams::m_height>>1,
|
|
|
|
UserConfigParams::m_width>>1, UserConfigParams::m_height>>1);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2009-07-12 07:54:21 -04:00
|
|
|
core::stringw s=_("Go!");
|
|
|
|
font->draw(s.c_str(), pos, color, true, true);
|
2008-04-24 03:06:09 -04:00
|
|
|
}
|
|
|
|
break;
|
2008-02-12 20:02:02 -05:00
|
|
|
default:
|
|
|
|
break;
|
2007-05-27 12:01:53 -04:00
|
|
|
} // switch
|
|
|
|
|
|
|
|
for(int i = 0; i < 10; ++i)
|
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
if(RaceManager::getWorld()->m_debug_text[i] != "")
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
static video::SColor color = video::SColor(255, 100, 209, 100);
|
|
|
|
core::rect<s32> pos(20, i*20, 20, (i+1)*20);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
|
|
|
font->draw(RaceManager::getWorld()->m_debug_text[i].c_str(), pos, color);
|
2008-04-24 03:06:09 -04:00
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2009-01-19 23:26:24 -05:00
|
|
|
|
|
|
|
float split_screen_ratio_x, split_screen_ratio_y;
|
|
|
|
split_screen_ratio_x = split_screen_ratio_y = 1.0;
|
|
|
|
if(race_manager->getNumLocalPlayers() >= 2)
|
|
|
|
split_screen_ratio_y = 0.5;
|
|
|
|
if(race_manager->getNumLocalPlayers() >= 3)
|
|
|
|
split_screen_ratio_x = 0.5;
|
|
|
|
|
2008-05-14 20:44:59 -04:00
|
|
|
// The penalty message needs to be displayed for up to one second
|
|
|
|
// after the start of the race, otherwise it disappears if
|
|
|
|
// "Go" is displayed and the race starts
|
2009-07-12 07:54:21 -04:00
|
|
|
const unsigned int num_players = race_manager->getNumLocalPlayers();
|
2008-10-04 13:32:40 -04:00
|
|
|
if(RaceManager::getWorld()->isStartPhase() || RaceManager::getWorld()->getTime()<1.0f)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
for(unsigned int i=0; i<num_players; i++)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
if(RaceManager::getWorld()->getLocalPlayerKart(i)->earlyStartPenalty())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
static video::SColor color = video::SColor(255, 179, 6, 6);
|
|
|
|
// FIXME: the position should take split screen into account!
|
|
|
|
core::rect<s32> pos(UserConfigParams::m_width>>1, (UserConfigParams::m_height>>1)-40,
|
|
|
|
UserConfigParams::m_width>>1, (UserConfigParams::m_height>>1)-40);
|
|
|
|
gui::IGUIFont* font = irr_driver->getRaceFont();
|
|
|
|
core::stringw s=_("Penalty time!!");
|
|
|
|
font->draw(s.c_str(), pos, color, true, true);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // if penalty
|
2009-07-12 07:54:21 -04:00
|
|
|
} // for i < getNum_players
|
2007-05-27 12:01:53 -04:00
|
|
|
} // if not RACE_PHASE
|
|
|
|
|
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
if(!RaceManager::getWorld()->isRacePhase()) return;
|
|
|
|
|
|
|
|
|
|
|
|
KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
|
|
|
|
|
2009-07-13 08:25:38 -04:00
|
|
|
for(unsigned int pla = 0; pla < num_players; pla++)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-13 20:26:18 -04:00
|
|
|
int offset_x = 0;
|
|
|
|
int offset_y = 0;
|
2007-09-24 08:28:19 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
if(num_players == 2)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-12 07:54:21 -04:00
|
|
|
if(pla == 0) offset_y = UserConfigParams::m_height/2;
|
|
|
|
}
|
|
|
|
else if (num_players == 3)
|
|
|
|
{
|
|
|
|
if (pla == 0 || pla == 1)
|
2009-06-20 21:10:43 -04:00
|
|
|
offset_y = UserConfigParams::m_height/2;
|
2009-07-12 07:54:21 -04:00
|
|
|
else
|
|
|
|
{
|
2007-09-24 08:28:19 -04:00
|
|
|
// Fixes width for player 3
|
|
|
|
split_screen_ratio_x = 1.0;
|
2009-07-12 07:54:21 -04:00
|
|
|
}
|
2007-09-24 08:28:19 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
if (pla == 1)
|
2009-06-20 21:10:43 -04:00
|
|
|
offset_x = UserConfigParams::m_width/2;
|
2007-09-24 08:28:19 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
}
|
|
|
|
else if(num_players == 4)
|
|
|
|
{
|
|
|
|
if(pla == 0 || pla == 1)
|
2009-06-20 21:10:43 -04:00
|
|
|
offset_y = UserConfigParams::m_height/2;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
if((pla == 1) || pla == 3)
|
2009-06-20 21:10:43 -04:00
|
|
|
offset_x = UserConfigParams::m_width/2;
|
2009-07-12 07:54:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(pla);
|
2009-07-13 20:26:18 -04:00
|
|
|
drawPowerupIcons(player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2009-07-14 08:57:04 -04:00
|
|
|
drawEnergyMeter (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2009-07-27 07:56:09 -04:00
|
|
|
drawSpeed (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2009-07-15 09:40:22 -04:00
|
|
|
drawLap (info, player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2009-07-15 23:24:17 -04:00
|
|
|
drawAllMessages (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2009-07-12 07:54:21 -04:00
|
|
|
|
|
|
|
if(player_kart->hasViewBlockedByPlunger())
|
|
|
|
{
|
|
|
|
const int screen_width = (num_players > 2) ? UserConfigParams::m_width/2 : UserConfigParams::m_width;
|
|
|
|
const int plunger_size = (num_players > 1) ? UserConfigParams::m_height/2 : UserConfigParams::m_height;
|
|
|
|
int plunger_x = offset_x + screen_width/2 - plunger_size/2;
|
|
|
|
|
|
|
|
if (num_players == 3 && pla > 1)
|
|
|
|
plunger_x = offset_x + UserConfigParams::m_width/2 - plunger_size/2;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-15 23:24:17 -04:00
|
|
|
video::ITexture *t=m_plunger_face->getTexture();
|
|
|
|
core::rect<s32> dest(plunger_x, offset_y,
|
|
|
|
plunger_x+plunger_size, offset_y+plunger_size);
|
|
|
|
const core::rect<s32> source(core::position2d<s32>(0,0), t->getOriginalSize());
|
|
|
|
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(t, dest, source);
|
2008-05-11 17:48:13 -04:00
|
|
|
}
|
2009-07-12 07:54:21 -04:00
|
|
|
} // next player
|
2008-10-04 14:50:45 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
drawTimer();
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
if(RaceManager::getWorld()->getPhase() == GO_PHASE ||
|
|
|
|
RaceManager::getWorld()->getPhase() == MUSIC_PHASE)
|
|
|
|
{
|
|
|
|
drawMusicDescription();
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
drawMiniMap();
|
2009-07-13 08:25:38 -04:00
|
|
|
drawPlayerIcons(info);
|
2009-07-12 07:54:21 -04:00
|
|
|
|
|
|
|
} // drawStatusText
|