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-01-23 00:23:22 -05:00
|
|
|
#include "gui/race_gui.hpp"
|
2007-11-26 09:28:15 -05:00
|
|
|
|
|
|
|
#include "user_config.hpp"
|
2009-01-22 17:27:13 -05:00
|
|
|
#include "race_manager.hpp"
|
2008-09-17 23:24:19 -04:00
|
|
|
#include "audio/sound_manager.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"
|
2009-01-23 00:23:22 -05:00
|
|
|
#include "gui/font.hpp"
|
2009-06-02 08:37:29 -04:00
|
|
|
#include "input/input.hpp"
|
|
|
|
#include "input/input_manager.hpp"
|
2009-01-22 17:27:13 -05:00
|
|
|
#include "tracks/track.hpp"
|
|
|
|
#include "utils/constants.hpp"
|
2009-01-23 00:23:22 -05:00
|
|
|
#include "utils/translation.hpp"
|
2008-01-12 20:26:30 -05:00
|
|
|
|
2009-03-13 09:50:24 -04:00
|
|
|
RaceGUI* instance = NULL;
|
|
|
|
RaceGUI* getRaceGUI()
|
|
|
|
{
|
|
|
|
if(instance == NULL) instance = new RaceGUI();
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void timeToString(const double TIME, char *s)
|
|
|
|
{
|
|
|
|
int min = (int) floor ( TIME / 60.0 ) ;
|
|
|
|
int sec = (int) floor ( TIME - (double) ( 60 * min ) ) ;
|
|
|
|
int tenths = (int) floor ( 10.0f * (TIME - (double)(sec + 60* min)));
|
|
|
|
sprintf ( s, "%d:%02d:%d", min, sec, tenths ) ;
|
|
|
|
} // TimeToString
|
|
|
|
|
2007-12-24 22:23:32 -05:00
|
|
|
|
2008-02-10 18:17:25 -05:00
|
|
|
RaceGUI::RaceGUI()
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
// FIXME: translation problem
|
|
|
|
m_pos_string[0] = "?!?";
|
|
|
|
m_pos_string[1] = "1st";
|
|
|
|
m_pos_string[2] = "2nd";
|
|
|
|
m_pos_string[3] = "3rd";
|
|
|
|
m_pos_string[4] = "4th";
|
|
|
|
m_pos_string[5] = "5th";
|
|
|
|
m_pos_string[6] = "6th";
|
|
|
|
m_pos_string[7] = "7th";
|
|
|
|
m_pos_string[8] = "8th";
|
|
|
|
m_pos_string[9] = "9th";
|
|
|
|
m_pos_string[10] = "10th";
|
|
|
|
|
2009-03-11 01:10:56 -04:00
|
|
|
#ifdef HAVE_IRRLICHT
|
|
|
|
gui::IGUIEnvironment *gui_env = irr_driver->getGUI();
|
2009-03-13 09:50:24 -04:00
|
|
|
core::rect<s32> pos(user_config->m_width-60, 10,
|
|
|
|
user_config->m_width, 50);
|
2009-03-11 01:10:56 -04:00
|
|
|
m_time = gui_env->addStaticText(L"", pos);
|
|
|
|
m_time->setOverrideFont(irr_driver->getRaceFont());
|
|
|
|
|
|
|
|
int icon_width=40;
|
|
|
|
int icon_player_width=50;
|
|
|
|
if(user_config->m_height<600)
|
|
|
|
{
|
|
|
|
icon_width = 27;
|
|
|
|
icon_player_width = 35;
|
|
|
|
}
|
2009-03-11 20:57:00 -04:00
|
|
|
|
2009-03-11 01:10:56 -04:00
|
|
|
m_icons = new gui::IGUIImage*[race_manager->getNumKarts()];
|
|
|
|
for(unsigned int i=0; i<race_manager->getNumKarts(); i++)
|
|
|
|
{
|
|
|
|
core::position2d<s32> p(0, i*20);
|
|
|
|
Kart *kart = race_manager->getKart(i);
|
|
|
|
Material *m = kart->getKartProperties()->getIconMaterial();
|
2009-03-11 20:57:00 -04:00
|
|
|
// FIXME: The icons needs to be resized.
|
2009-03-11 01:10:56 -04:00
|
|
|
m_icons[i] = irr_driver->getGUI()->addImage(m->getTexture(), p);
|
|
|
|
}
|
2009-03-11 20:57:00 -04:00
|
|
|
core::rect<s32> p(user_config->m_width-10, 0,
|
|
|
|
user_config->m_width+10, 10);
|
|
|
|
m_attachment_icon = irr_driver->getGUI()->addImage(p);
|
2009-03-11 01:10:56 -04:00
|
|
|
#else
|
2007-05-27 12:01:53 -04:00
|
|
|
m_speed_back_icon = material_manager->getMaterial("speedback.rgb");
|
|
|
|
m_speed_back_icon->getState()->disable(GL_CULL_FACE);
|
|
|
|
m_speed_fore_icon = material_manager->getMaterial("speedfore.rgb");
|
|
|
|
m_speed_fore_icon->getState()->disable(GL_CULL_FACE);
|
2008-12-26 15:12:57 -05:00
|
|
|
|
|
|
|
m_plunger_face = material_manager->getMaterial("plungerface.rgb");
|
|
|
|
m_plunger_face->getState()->disable(GL_CULL_FACE);
|
2009-02-26 19:15:09 -05:00
|
|
|
#endif
|
2008-12-26 15:12:57 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
m_fps_counter = 0;
|
|
|
|
m_fps_string[0]=0;
|
2009-05-10 21:28:18 -04:00
|
|
|
//m_fps_timer.reset();
|
|
|
|
//m_fps_timer.update();
|
|
|
|
//m_fps_timer.setMaxDelta(1000);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
} // RaceGUI
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
RaceGUI::~RaceGUI()
|
|
|
|
{
|
|
|
|
//FIXME: does all that material stuff need freeing somehow?
|
|
|
|
} // ~Racegui
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-03-16 19:52:34 -04:00
|
|
|
void RaceGUI::resetFPSCounter()
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-05-10 21:28:18 -04:00
|
|
|
// TODO - FPS
|
|
|
|
//m_fps_timer.reset();
|
|
|
|
//m_fps_timer.setMaxDelta(1000);
|
2009-03-16 19:52:34 -04:00
|
|
|
m_fps_counter=0;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-03-16 19:52:34 -04:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
void RaceGUI::update(float dt)
|
|
|
|
{
|
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
|
|
|
drawStatusText(dt);
|
2008-10-04 14:50:45 -04:00
|
|
|
cleanupMessages(dt);
|
2007-12-24 22:23:32 -05:00
|
|
|
|
2009-03-13 09:50:24 -04:00
|
|
|
//BaseGUI::update( dt );
|
2007-05-27 12:01:53 -04:00
|
|
|
} // update
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceGUI::drawFPS ()
|
|
|
|
{
|
2009-05-10 21:28:18 -04:00
|
|
|
// TODO
|
|
|
|
/*
|
2007-05-27 12:01:53 -04:00
|
|
|
if (++m_fps_counter>=50)
|
|
|
|
{
|
|
|
|
m_fps_timer.update();
|
|
|
|
sprintf(m_fps_string, "%d",
|
|
|
|
(int)(m_fps_counter/m_fps_timer.getDeltaTime()));
|
|
|
|
m_fps_counter = 0;
|
|
|
|
m_fps_timer.setMaxDelta(1000);
|
|
|
|
}
|
2008-01-12 20:26:30 -05:00
|
|
|
font_race->PrintShadow(m_fps_string,48, 0, user_config->m_height-50);
|
2009-05-10 21:28:18 -04:00
|
|
|
*/
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawFPS
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-03-11 01:10:56 -04:00
|
|
|
/** Displays the racing time on the screen.
|
|
|
|
*/
|
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;
|
2007-05-27 12:01:53 -04:00
|
|
|
char str[256];
|
2008-09-21 12:07:56 -04:00
|
|
|
|
2009-03-13 09:50:24 -04:00
|
|
|
timeToString(RaceManager::getWorld()->getTime(), str);
|
2009-03-11 01:10:56 -04:00
|
|
|
#ifdef HAVE_IRRLICHT
|
|
|
|
m_time->setText(core::stringw(str).c_str());
|
2008-01-12 20:26:30 -05:00
|
|
|
#else
|
|
|
|
font_race->PrintShadow(str, 60, user_config->m_width-260,
|
2009-03-11 01:10:56 -04:00
|
|
|
user_config->m_height-64);
|
2008-01-12 20:26:30 -05:00
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawTimer
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#define TRACKVIEW_SIZE 100
|
|
|
|
|
|
|
|
void RaceGUI::drawMap ()
|
|
|
|
{
|
2008-10-14 16:20:54 -04:00
|
|
|
// arenas currently don't have a map.
|
|
|
|
if(RaceManager::getTrack()->isArena()) return;
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
glDisable ( GL_TEXTURE_2D ) ;
|
2008-09-21 12:07:56 -04:00
|
|
|
assert(RaceManager::getWorld() != NULL);
|
2007-05-27 12:01:53 -04:00
|
|
|
int xLeft = 10;
|
|
|
|
int yTop = 10;
|
|
|
|
|
2008-09-21 12:07:56 -04:00
|
|
|
RaceManager::getTrack() -> draw2Dview ( (float)xLeft, (float)yTop );
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
|
2008-04-15 09:57:18 -04:00
|
|
|
for ( unsigned int i = 0 ; i < race_manager->getNumKarts() ; 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; // don't draw eliminated kart
|
2008-05-25 12:02:26 -04:00
|
|
|
glColor3fv ( kart->getColor().toFloat());
|
2008-06-20 05:34:35 -04:00
|
|
|
const Vec3& xyz = kart->getXYZ();
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
/* If it's a player, draw a bigger sign */
|
2009-05-10 21:28:18 -04:00
|
|
|
// TODO
|
|
|
|
/*
|
2007-05-27 12:01:53 -04:00
|
|
|
if (kart -> isPlayerKart ())
|
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft+3, (float)yTop+3);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft-2, (float)yTop+3);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft-2, (float)yTop-2);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft+3, (float)yTop-2);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-21 12:07:56 -04:00
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft+2, (float)yTop+2);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft-1, (float)yTop+2);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft-1, (float)yTop-1);
|
|
|
|
RaceManager::getTrack() -> glVtx ( xyz.toFloat(), (float)xLeft+2, (float)yTop-1);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2009-05-10 21:28:18 -04:00
|
|
|
*/
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnd () ;
|
|
|
|
glEnable ( GL_TEXTURE_2D ) ;
|
|
|
|
} // drawMap
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Draw players position on the race
|
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;
|
|
|
|
if(user_config->m_height<600)
|
|
|
|
{
|
|
|
|
ICON_WIDTH = 27;
|
|
|
|
ICON_PLAYER_WIDTH = 35;
|
|
|
|
}
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
//glEnable(GL_TEXTURE_2D);
|
|
|
|
Material *last_players_gst = 0;
|
|
|
|
|
|
|
|
int bFirst = 1;
|
2008-09-30 20:46:00 -04:00
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
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-01-06 08:29:48 -05:00
|
|
|
y = user_config->m_height*7/8-20 - ( (position == -1 ? i : position-1)*(ICON_PLAYER_WIDTH+2));
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-09-27 15:43:57 -04:00
|
|
|
GLfloat COLOR[] = {info[i].r, info[i].g, info[i].b, 1.0f};
|
2009-01-06 08:29:48 -05:00
|
|
|
font_race->PrintShadow(info[i].time.c_str(), 30, ICON_PLAYER_WIDTH+x, y+5, COLOR);
|
2008-09-27 15:43:57 -04:00
|
|
|
|
|
|
|
if(info[i].special_title.length() >0)
|
2008-04-16 20:20:06 -04:00
|
|
|
{
|
2008-04-24 03:06:09 -04:00
|
|
|
GLfloat const RED[] = { 1.0f, 0, 0, 1.0f};
|
2009-01-06 08:29:48 -05:00
|
|
|
font_race->PrintShadow(info[i].special_title.c_str(), 30, ICON_PLAYER_WIDTH+x, y+5, RED );
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2008-09-27 15:43:57 -04:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
bFirst = 0;
|
|
|
|
// draw icon
|
|
|
|
Material* players_gst = kart->getKartProperties()->getIconMaterial();
|
|
|
|
// Hmm - if the same icon is displayed more than once in a row,
|
|
|
|
// plib does only do the first setTexture, therefore nothing is
|
|
|
|
// displayed for the remaining icons. So we have to call force() if
|
|
|
|
// the same icon is displayed more than once in a row.
|
|
|
|
if(last_players_gst==players_gst)
|
|
|
|
{
|
2009-02-26 19:15:09 -05:00
|
|
|
#ifndef HAVE_IRRLICHT
|
2007-05-27 12:01:53 -04:00
|
|
|
players_gst->getState()->force();
|
2009-02-26 19:15:09 -05:00
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
//The material of the icons should not have a non-zero alpha_ref value,
|
|
|
|
//because if so the next call can make the text look aliased.
|
2009-02-10 00:30:59 -05:00
|
|
|
#ifdef HAVE_IRRLICHT
|
|
|
|
#else
|
2007-05-27 12:01:53 -04:00
|
|
|
players_gst -> apply ();
|
2009-02-10 00:30:59 -05:00
|
|
|
#endif
|
2007-05-27 12:01:53 -04:00
|
|
|
last_players_gst = players_gst;
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor4f ( 1, 1, 1, 1 ) ;
|
|
|
|
if (kart -> isPlayerKart ())
|
|
|
|
{
|
|
|
|
glTexCoord2f ( 0, 0 ) ; glVertex2i ( x , y ) ;
|
2009-01-06 08:29:48 -05:00
|
|
|
glTexCoord2f ( 1, 0 ) ; glVertex2i ( x+ICON_PLAYER_WIDTH, y ) ;
|
|
|
|
glTexCoord2f ( 1, 1 ) ; glVertex2i ( x+ICON_PLAYER_WIDTH, y+ICON_PLAYER_WIDTH ) ;
|
|
|
|
glTexCoord2f ( 0, 1 ) ; glVertex2i ( x , y+ICON_PLAYER_WIDTH ) ;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glTexCoord2f ( 0, 0 ) ; glVertex2i ( x , y ) ;
|
|
|
|
glTexCoord2f ( 1, 0 ) ; glVertex2i ( x+ICON_WIDTH, y ) ;
|
|
|
|
glTexCoord2f ( 1, 1 ) ; glVertex2i ( x+ICON_WIDTH, y+ICON_WIDTH ) ;
|
|
|
|
glTexCoord2f ( 0, 1 ) ; glVertex2i ( x , y+ICON_WIDTH ) ;
|
|
|
|
}
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// draw position (1st, 2nd...)
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
char str[256];
|
|
|
|
|
2008-10-14 16:20:54 -04:00
|
|
|
if(position != -1)
|
|
|
|
{
|
|
|
|
sprintf(str, "%d", position);
|
|
|
|
font_race->PrintShadow(str, 33, x-7, y-4);
|
|
|
|
|
|
|
|
// FIXME: translation
|
|
|
|
if (kart->getPosition() == 1)
|
|
|
|
font_race->PrintShadow("st", 13, x-7+17, y-4+17);
|
|
|
|
else if (kart->getPosition() == 2)
|
|
|
|
font_race->PrintShadow("nd", 13, x-7+17, y-4+17);
|
|
|
|
else if (kart->getPosition() == 3)
|
|
|
|
font_race->PrintShadow("rd", 13, x-7+17, y-4+17);
|
|
|
|
else
|
|
|
|
font_race->PrintShadow("th", 13, x-7+17, y-4+17);
|
|
|
|
}
|
2008-09-30 20:46:00 -04:00
|
|
|
} // next kart
|
|
|
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
2007-05-27 12:01:53 -04:00
|
|
|
} // drawPlayerIcons
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-10-29 22:02:56 -04:00
|
|
|
void RaceGUI::drawPowerupIcons ( Kart* player_kart, int offset_x,
|
2007-05-27 12:01:53 -04:00
|
|
|
int offset_y, float ratio_x,
|
|
|
|
float ratio_y )
|
|
|
|
{
|
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;
|
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
|
|
|
|
int x1 = (int)((user_config->m_width/2-32) * ratio_x) + offset_x ;
|
|
|
|
int y1 = (int)(user_config->m_height*5/6 * ratio_y) + offset_y;
|
|
|
|
|
|
|
|
int nSize=(int)(64.0f*std::min(ratio_x, ratio_y));
|
2009-03-11 20:57:00 -04:00
|
|
|
#ifdef HAVE_IRRLICHT
|
|
|
|
m_attachment_icon->setImage(powerup->getIcon()->getTexture());
|
|
|
|
#else
|
2008-10-29 22:02:56 -04:00
|
|
|
powerup->getIcon()->apply();
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-10-29 22:02:56 -04:00
|
|
|
int n = player_kart->getNumPowerup() ;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
if ( n > 5 ) n = 5 ;
|
|
|
|
if ( n < 1 ) n = 1 ;
|
|
|
|
|
|
|
|
glBegin(GL_QUADS) ;
|
|
|
|
glColor4f(1, 1, 1, 1 );
|
|
|
|
|
|
|
|
for ( int i = 0 ; i < n ; i++ )
|
|
|
|
{
|
|
|
|
glTexCoord2f(0, 0); glVertex2i( i*30 + x1 , y1 );
|
|
|
|
glTexCoord2f(1, 0); glVertex2i( i*30 + x1+nSize, y1 );
|
|
|
|
glTexCoord2f(1, 1); glVertex2i( i*30 + x1+nSize, y1+nSize);
|
|
|
|
glTexCoord2f(0, 1); glVertex2i( i*30 + x1 , y1+nSize);
|
|
|
|
} // for i
|
|
|
|
glEnd () ;
|
2009-02-25 08:14:27 -05:00
|
|
|
#endif
|
2008-10-29 22:02:56 -04:00
|
|
|
} // drawPowerupIcons
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/* Energy meter that gets filled with coins */
|
|
|
|
|
|
|
|
// Meter fluid color (0 - 255)
|
|
|
|
#define METER_TOP_COLOR 240, 0, 0, 255
|
|
|
|
#define METER_BOTTOM_COLOR 240, 200, 0, 160
|
|
|
|
// Meter border color (0.0 - 1.0)
|
|
|
|
#define METER_BORDER_BLACK 0.0, 0.0, 0.0
|
|
|
|
#define METER_BORDER_WHITE 1.0, 1.0, 1.0
|
2008-05-11 13:32:41 -04:00
|
|
|
#define METER_TARGET_RED 1.0, 0.0, 0.0
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
|
|
|
|
float ratio_x, float ratio_y )
|
|
|
|
{
|
2008-11-24 18:19:47 -05:00
|
|
|
float state = (float)(player_kart->getEnergy()) /
|
2008-10-29 11:55:54 -04:00
|
|
|
MAX_ITEMS_COLLECTED;
|
2007-05-27 12:01:53 -04:00
|
|
|
int x = (int)((user_config->m_width-24) * ratio_x) + offset_x;
|
|
|
|
int y = (int)(250 * ratio_y) + offset_y;
|
|
|
|
int w = (int)(16 * ratio_x);
|
|
|
|
int h = (int)(user_config->m_height/4 * ratio_y);
|
|
|
|
int wl = (int)(ratio_x);
|
|
|
|
if(wl < 1)
|
|
|
|
wl = 1;
|
2008-10-29 11:55:54 -04:00
|
|
|
const int GRADS = (int)(MAX_ITEMS_COLLECTED/5); // each graduation equals 5 items
|
2008-05-10 09:30:55 -04:00
|
|
|
int gh = (int)(h/GRADS); //graduation height
|
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));
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
// Draw a Meter border
|
|
|
|
x-=1;
|
|
|
|
y-=1;
|
|
|
|
// left side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_BLACK ) ;
|
|
|
|
glVertex2i ( x-wl, y-wl ) ;
|
|
|
|
glVertex2i ( x, y-wl ) ;
|
|
|
|
glVertex2i ( x, y + h+1) ;
|
|
|
|
glVertex2i ( x-wl, y + h+1) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// right side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_BLACK ) ;
|
|
|
|
glVertex2i ( x+w, y-wl ) ;
|
|
|
|
glVertex2i ( x+w+wl, y-wl ) ;
|
|
|
|
glVertex2i ( x+w+wl, y + h+1) ;
|
|
|
|
glVertex2i ( x+w, y + h+1) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// down side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_BLACK ) ;
|
|
|
|
glVertex2i ( x, y-wl ) ;
|
|
|
|
glVertex2i ( x+w, y-wl ) ;
|
|
|
|
glVertex2i ( x+w, y ) ;
|
|
|
|
glVertex2i ( x, y ) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// up side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_BLACK ) ;
|
|
|
|
glVertex2i ( x, y+h ) ;
|
|
|
|
glVertex2i ( x+w, y+h ) ;
|
|
|
|
glVertex2i ( x+w, y+h+wl ) ;
|
|
|
|
glVertex2i ( x, y+h+wl ) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
x+=1;
|
|
|
|
y+=1;
|
|
|
|
|
|
|
|
// left side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_WHITE ) ;
|
|
|
|
glVertex2i ( x-wl, y-wl ) ;
|
|
|
|
glVertex2i ( x, y-wl ) ;
|
|
|
|
glVertex2i ( x, y + h+1) ;
|
|
|
|
glVertex2i ( x-wl, y + h+1) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// right side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_WHITE ) ;
|
|
|
|
glVertex2i ( x+w, y-wl ) ;
|
|
|
|
glVertex2i ( x+w+wl, y-wl ) ;
|
|
|
|
glVertex2i ( x+w+wl, y + h+1) ;
|
|
|
|
glVertex2i ( x+w, y + h+1) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// down side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_WHITE ) ;
|
|
|
|
glVertex2i ( x, y-wl ) ;
|
|
|
|
glVertex2i ( x+w, y-wl ) ;
|
|
|
|
glVertex2i ( x+w, y ) ;
|
|
|
|
glVertex2i ( x, y ) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
2008-05-10 09:30:55 -04:00
|
|
|
//Graduations
|
|
|
|
int gh_incr = gh;
|
|
|
|
for (int i=0; i<GRADS-1; i++)
|
|
|
|
{
|
|
|
|
glBegin( GL_QUADS );
|
|
|
|
glColor3f(METER_BORDER_WHITE);
|
|
|
|
glVertex2i(x, y+gh);
|
|
|
|
glVertex2i(x+w, y+gh);
|
|
|
|
glVertex2i(x+w, y+gh+wl);
|
|
|
|
glVertex2i(x, y+gh+wl);
|
|
|
|
glEnd();
|
|
|
|
gh+=gh_incr;
|
|
|
|
}
|
|
|
|
|
2008-05-11 13:32:41 -04:00
|
|
|
//Target line
|
|
|
|
if (coin_target > 0)
|
|
|
|
{
|
|
|
|
glBegin ( GL_QUADS );
|
|
|
|
glColor3f(METER_TARGET_RED);
|
|
|
|
glVertex2i(x, y+th);
|
|
|
|
glVertex2i(x+w, y+th);
|
|
|
|
glVertex2i(x+w, y+th+wl);
|
|
|
|
glVertex2i(x, y+th+wl);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
// up side
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor3f ( METER_BORDER_WHITE ) ;
|
|
|
|
glVertex2i ( x, y+h ) ;
|
|
|
|
glVertex2i ( x+w, y+h ) ;
|
|
|
|
glVertex2i ( x+w, y+h+wl ) ;
|
|
|
|
glVertex2i ( x, y+h+wl ) ;
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
// Draw the Meter fluid
|
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glColor4ub ( METER_BOTTOM_COLOR ) ;
|
|
|
|
glVertex2i ( x, y ) ;
|
|
|
|
glVertex2i ( x+w, y ) ;
|
|
|
|
|
|
|
|
glColor4ub ( METER_TOP_COLOR ) ;
|
|
|
|
glVertex2i ( x+w, y + (int)(state * h));
|
|
|
|
glVertex2i ( x, y + (int)(state * h) ) ;
|
|
|
|
glEnd () ;
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
} // drawEnergyMeter
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
|
|
|
float ratio_x, float ratio_y )
|
|
|
|
{
|
|
|
|
|
|
|
|
float minRatio = std::min(ratio_x, ratio_y);
|
|
|
|
#define SPEEDWIDTH 128
|
|
|
|
int width = (int)(SPEEDWIDTH*minRatio);
|
|
|
|
int height = (int)(SPEEDWIDTH*minRatio);
|
|
|
|
offset_x += (int)((user_config->m_width-10)*ratio_x) - width;
|
|
|
|
offset_y += (int)(10*ratio_y);
|
|
|
|
|
2009-02-10 00:30:59 -05:00
|
|
|
#ifdef HAVE_IRRLICHT
|
|
|
|
#else
|
2007-05-27 12:01:53 -04:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
m_speed_back_icon->getState()->force();
|
2008-12-02 16:11:50 -05:00
|
|
|
// If the colour isn't set, the speedometer is blended with the last
|
|
|
|
// used colour.
|
|
|
|
glColor4f(1,1,1,1);
|
2007-05-27 12:01:53 -04:00
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glTexCoord2f(0, 0);glVertex2i(offset_x , offset_y );
|
|
|
|
glTexCoord2f(1, 0);glVertex2i(offset_x+width, offset_y );
|
|
|
|
glTexCoord2f(1, 1);glVertex2i(offset_x+width, offset_y+height);
|
|
|
|
glTexCoord2f(0, 1);glVertex2i(offset_x , offset_y+height);
|
|
|
|
glEnd () ;
|
|
|
|
|
|
|
|
//convention taken from btRaycastVehicle::updateVehicle
|
|
|
|
const float speed = kart->getSpeed();
|
|
|
|
|
|
|
|
if ( !kart->isOnGround() )
|
|
|
|
font_race->PrintShadow("!", (int)(60*minRatio),
|
|
|
|
offset_x-(int)(30*minRatio),
|
|
|
|
offset_y-(int)(10*minRatio));
|
|
|
|
/* Show speed */
|
|
|
|
if ( speed < 0 )
|
|
|
|
font_race->PrintShadow(_("REV"), (int)(40*minRatio),
|
|
|
|
offset_x+(int)(40*minRatio),
|
|
|
|
offset_y+(int)(10*minRatio));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float speedRatio = speed/KILOMETERS_PER_HOUR/110.0f;
|
|
|
|
// The following does not work with wheelie or Zipper
|
|
|
|
//float speedRatio = kart->getVelocity()->xyz[1]/(kart->getMaxSpeed();
|
|
|
|
|
|
|
|
if ( speedRatio > 1 )
|
|
|
|
speedRatio = 1;
|
2008-12-26 15:12:57 -05:00
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
m_speed_fore_icon->getState()->force();
|
|
|
|
glBegin ( GL_POLYGON ) ;
|
|
|
|
glTexCoord2f(1, 0);glVertex2i(offset_x+width, offset_y);
|
|
|
|
glTexCoord2f(0, 0);glVertex2i(offset_x, offset_y);
|
|
|
|
if (speedRatio < 0.5)
|
|
|
|
{
|
|
|
|
glTexCoord2f(0, speedRatio*2);glVertex2i(offset_x, (int)(offset_y+width*speedRatio*2));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glTexCoord2f(0, 1);glVertex2i(offset_x, offset_y+width);
|
2007-12-08 08:04:56 -05:00
|
|
|
glTexCoord2f((speedRatio-0.5f)*2, 1);glVertex2i((int)(offset_x+height*(speedRatio-0.5f)*2), offset_y+height);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnd () ;
|
|
|
|
} // speed<0
|
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
|
|
|
char str[256];
|
|
|
|
offset_x += (int)(120*ratio_x);
|
2009-01-17 22:27:44 -05:00
|
|
|
offset_y += (int)(70*minRatio);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2008-05-19 23:33:48 -04:00
|
|
|
if(kart->hasFinishedRace())
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
|
|
|
sprintf(str, _("Finished"));
|
2009-01-17 22:27:44 -05:00
|
|
|
font_race->PrintShadow(str, (int)(48*minRatio), offset_x, offset_y);
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-17 22:27:44 -05:00
|
|
|
font_race->PrintShadow( _("Lap"), (int)(48*minRatio), offset_x, offset_y);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
offset_y -= (int)(50*ratio_y);
|
|
|
|
|
2008-09-27 15:43:57 -04:00
|
|
|
sprintf(str, "%d/%d", lap < 0 ? 0 : lap+1,
|
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
|
|
|
race_manager->getNumLaps());
|
2009-01-17 22:27:44 -05:00
|
|
|
font_race->PrintShadow(str, (int)(48*minRatio), offset_x, offset_y);
|
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
|
|
|
|
y = (int)(ratio_y*(user_config->m_height -164)+offset_y);
|
|
|
|
// 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
|
|
|
|
2008-04-24 03:06:09 -04:00
|
|
|
//FIXME: instead of the next line, in msg there should be a GLfloat that acts as the colors.
|
|
|
|
GLfloat const COLORS[] = {msg.m_red/255.0f, msg.m_green/255.0f, msg.m_blue/255.0f, 255.0f};
|
2007-09-10 10:11:08 -04:00
|
|
|
font_race->Print( msg.m_message.c_str(), msg.m_font_size,
|
2007-12-09 12:58:51 -05:00
|
|
|
Font::CENTER_OF_SCREEN, y,
|
2008-04-24 03:06:09 -04:00
|
|
|
COLORS,
|
2007-05-27 12:01:53 -04:00
|
|
|
ratio_x, ratio_y,
|
|
|
|
offset_x, offset_x+(int)(user_config->m_width*ratio_x));
|
|
|
|
// Add 20% of font size as space between the lines
|
2007-09-10 10:11:08 -04:00
|
|
|
y-=msg.m_font_size*12/10;
|
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,
|
2007-05-27 12:01:53 -04:00
|
|
|
int font_size, int red, int green, int blue)
|
|
|
|
{
|
2007-09-10 10:11:08 -04:00
|
|
|
m_messages.push_back(TimedMessage(msg, kart, time, font_size, red, green, blue));
|
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;
|
2008-02-10 18:17:25 -05:00
|
|
|
int y=0;
|
2008-03-14 05:49:17 -04:00
|
|
|
if(mi->getComposer()!="")
|
2008-02-10 18:17:25 -05:00
|
|
|
{
|
2008-03-14 05:49:17 -04:00
|
|
|
std::string s="by "+mi->getComposer();
|
2008-02-11 19:16:59 -05:00
|
|
|
font_race->Print( s.c_str(), 25,
|
2008-04-24 03:06:09 -04:00
|
|
|
Font::CENTER_OF_SCREEN, y );
|
2008-02-10 18:17:25 -05:00
|
|
|
y+=20;
|
2008-03-14 05:49:17 -04:00
|
|
|
}
|
|
|
|
std::string s="\""+mi->getTitle()+"\"";
|
|
|
|
font_race->Print( s.c_str(), 25,
|
2008-04-24 03:06:09 -04:00
|
|
|
Font::CENTER_OF_SCREEN, y );
|
2008-02-10 18:17:25 -05:00
|
|
|
} // drawMusicDescription
|
|
|
|
|
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
|
|
|
void RaceGUI::drawStatusText(const float dt)
|
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
|
|
|
|
|
|
|
glMatrixMode ( GL_MODELVIEW ) ;
|
|
|
|
glPushMatrix () ;
|
|
|
|
glLoadIdentity () ;
|
|
|
|
|
|
|
|
glMatrixMode ( GL_PROJECTION ) ;
|
|
|
|
glPushMatrix () ;
|
|
|
|
glLoadIdentity () ;
|
|
|
|
|
|
|
|
glPushAttrib ( GL_ENABLE_BIT | GL_LIGHTING_BIT ) ;
|
|
|
|
glDisable ( GL_DEPTH_TEST );
|
|
|
|
glDisable ( GL_LIGHTING );
|
|
|
|
glDisable ( GL_FOG );
|
|
|
|
glDisable ( GL_CULL_FACE );
|
|
|
|
glEnable ( GL_ALPHA_TEST );
|
|
|
|
glAlphaFunc ( GL_GREATER, 0.1f);
|
|
|
|
glEnable ( GL_BLEND );
|
|
|
|
|
|
|
|
glOrtho ( 0, user_config->m_width, 0, user_config->m_height, 0, 100 ) ;
|
2008-09-21 12:07:56 -04:00
|
|
|
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
|
|
|
{
|
|
|
|
GLfloat const COLORS[] = { 0.9f, 0.66f, 0.62f, 1.0f };
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2008-04-24 03:06:09 -04:00
|
|
|
font_race->PrintShadow( _("Ready!"), 90,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
COLORS );
|
|
|
|
}
|
|
|
|
break;
|
2008-09-20 19:45:22 -04:00
|
|
|
case SET_PHASE:
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
|
|
|
GLfloat const COLORS[] = { 0.9f, 0.9f, 0.62f, 1.0f };
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2008-04-24 03:06:09 -04:00
|
|
|
font_race->PrintShadow( _("Set!"), 90,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
COLORS );
|
|
|
|
}
|
|
|
|
break;
|
2008-09-20 19:45:22 -04:00
|
|
|
case GO_PHASE:
|
2008-04-24 03:06:09 -04:00
|
|
|
{
|
|
|
|
GLfloat const COLORS[] = { 0.39f, 0.82f, 0.39f, 1.0f };
|
2008-09-01 20:35:28 -04:00
|
|
|
//I18N: as in "ready, set, go", shown at the beginning of the race
|
2008-04-24 03:06:09 -04:00
|
|
|
font_race->PrintShadow( _("Go!"), 90,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
Font::CENTER_OF_SCREEN,
|
|
|
|
COLORS );
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
GLfloat const COLORS[] = { 0.39f, 0.82f, 0.39f, 1.0f };
|
2008-09-21 12:07:56 -04:00
|
|
|
font_race->Print( RaceManager::getWorld()->m_debug_text[i].c_str(),
|
2008-04-24 03:06:09 -04:00
|
|
|
20, 20, 200 -i*20, COLORS );
|
|
|
|
}
|
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
|
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
|
|
|
{
|
2008-09-07 09:33:12 -04:00
|
|
|
for(unsigned int i=0; i<race_manager->getNumLocalPlayers(); 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
|
|
|
{
|
2008-04-24 03:06:09 -04:00
|
|
|
GLfloat const COLORS[] = { 0.78f, 0.025f, 0.025f, 1.0f };
|
2009-01-19 23:26:24 -05:00
|
|
|
|
2008-04-24 03:06:09 -04:00
|
|
|
font_race->PrintShadow( _("Penalty time!!"), 80,
|
2007-12-09 12:58:51 -05:00
|
|
|
Font::CENTER_OF_SCREEN, 200,
|
2008-04-24 03:06:09 -04:00
|
|
|
COLORS );
|
2007-05-27 12:01:53 -04:00
|
|
|
} // if penalty
|
|
|
|
} // for i < getNumPlayers
|
|
|
|
} // if not RACE_PHASE
|
|
|
|
|
|
|
|
|
2008-10-04 13:32:40 -04:00
|
|
|
if ( RaceManager::getWorld()->isRacePhase() )
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-09-27 15:43:57 -04:00
|
|
|
KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo(this);
|
|
|
|
|
2008-09-07 09:33:12 -04:00
|
|
|
const int numPlayers = race_manager->getNumLocalPlayers();
|
2007-09-24 08:28:19 -04:00
|
|
|
|
|
|
|
for(int pla = 0; pla < numPlayers; pla++)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2008-12-26 15:12:57 -05:00
|
|
|
int offset_x = 0, offset_y = 0;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2007-09-24 08:28:19 -04:00
|
|
|
if(numPlayers == 2)
|
|
|
|
{
|
|
|
|
if(pla == 0) offset_y = user_config->m_height/2;
|
|
|
|
}
|
|
|
|
else if (numPlayers == 3)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2007-09-24 08:28:19 -04:00
|
|
|
if (pla == 0 || pla == 1)
|
|
|
|
offset_y = user_config->m_height/2;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Fixes width for player 3
|
|
|
|
split_screen_ratio_x = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pla == 1)
|
|
|
|
offset_x = user_config->m_width/2;
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
2007-09-24 08:28:19 -04:00
|
|
|
else if(numPlayers == 4)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2007-09-24 08:28:19 -04:00
|
|
|
if(pla == 0 || pla == 1)
|
|
|
|
offset_y = user_config->m_height/2;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2007-09-24 08:28:19 -04:00
|
|
|
if((pla == 1) || pla == 3)
|
|
|
|
offset_x = user_config->m_width/2;
|
2007-05-27 12:01:53 -04:00
|
|
|
}
|
|
|
|
|
2008-09-21 12:07:56 -04:00
|
|
|
Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(pla);
|
2008-10-29 22:02:56 -04:00
|
|
|
drawPowerupIcons(player_kart, offset_x, offset_y,
|
2007-05-27 12:01:53 -04:00
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
|
|
|
drawEnergyMeter (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
|
|
|
drawSpeed (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2008-09-27 15:43:57 -04:00
|
|
|
drawLap (info, player_kart, offset_x, offset_y,
|
2007-05-27 12:01:53 -04:00
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
|
|
|
drawAllMessages (player_kart, offset_x, offset_y,
|
|
|
|
split_screen_ratio_x, split_screen_ratio_y );
|
2008-12-26 15:12:57 -05:00
|
|
|
|
|
|
|
if(player_kart->hasViewBlockedByPlunger())
|
|
|
|
{
|
|
|
|
const int screen_width = (numPlayers > 2) ? user_config->m_width/2 : user_config->m_width;
|
|
|
|
const int plunger_size = (numPlayers > 1) ? user_config->m_height/2 : user_config->m_height;
|
|
|
|
int plunger_x = offset_x + screen_width/2 - plunger_size/2;
|
|
|
|
|
|
|
|
if (numPlayers == 3 && pla > 1)
|
|
|
|
plunger_x = offset_x + user_config->m_width/2 - plunger_size/2;
|
|
|
|
|
2009-02-26 19:15:09 -05:00
|
|
|
#ifndef HAVE_IRRLICHT
|
2008-12-26 15:12:57 -05:00
|
|
|
m_plunger_face->getState()->force();
|
2009-02-26 19:15:09 -05:00
|
|
|
#endif
|
2008-12-26 15:12:57 -05:00
|
|
|
glBegin ( GL_QUADS ) ;
|
|
|
|
glTexCoord2f(1, 0); glVertex2i(plunger_x+plunger_size, offset_y);
|
|
|
|
glTexCoord2f(0, 0); glVertex2i(plunger_x, offset_y);
|
|
|
|
glTexCoord2f(0, 1); glVertex2i(plunger_x, offset_y+plunger_size);
|
|
|
|
glTexCoord2f(1, 1); glVertex2i(plunger_x+plunger_size, offset_y+plunger_size);
|
|
|
|
glEnd () ;
|
|
|
|
}
|
2008-10-04 14:50:45 -04:00
|
|
|
} // next player
|
|
|
|
|
|
|
|
drawTimer();
|
|
|
|
|
|
|
|
if(RaceManager::getWorld()->getPhase() == GO_PHASE ||
|
|
|
|
RaceManager::getWorld()->getPhase() == MUSIC_PHASE)
|
2008-05-11 17:48:13 -04:00
|
|
|
{
|
|
|
|
drawMusicDescription();
|
|
|
|
}
|
2008-10-04 14:50:45 -04:00
|
|
|
|
2008-05-11 17:48:13 -04:00
|
|
|
|
2008-10-04 14:50:45 -04:00
|
|
|
drawMap();
|
|
|
|
if ( user_config->m_display_fps ) drawFPS();
|
|
|
|
|
|
|
|
drawPlayerIcons(info);
|
|
|
|
|
2007-05-27 12:01:53 -04:00
|
|
|
} // if RACE_PHASE
|
|
|
|
|
|
|
|
glPopAttrib () ;
|
|
|
|
glPopMatrix () ;
|
|
|
|
glMatrixMode ( GL_MODELVIEW ) ;
|
|
|
|
glPopMatrix () ;
|
|
|
|
} // drawStatusText
|
|
|
|
|
|
|
|
/* EOF */
|