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-03-11 01:10:56 -04:00
|
|
|
#ifndef HEADER_RACEGUI_HPP
|
|
|
|
#define HEADER_RACEGUI_HPP
|
|
|
|
|
2009-06-11 06:00:43 -04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2009-03-11 01:10:56 -04:00
|
|
|
#include "irrlicht.h"
|
|
|
|
using namespace irr;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2007-09-10 10:11:08 -04:00
|
|
|
|
2009-06-11 06:00:43 -04:00
|
|
|
#include "config/player.hpp"
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2007-10-03 07:23:07 -04:00
|
|
|
class InputMap;
|
2009-08-20 20:32:24 -04:00
|
|
|
class Kart;
|
|
|
|
class Material;
|
2007-05-27 12:01:53 -04:00
|
|
|
class RaceSetup;
|
|
|
|
|
2009-03-13 09:50:24 -04:00
|
|
|
class RaceGUI
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-08-20 20:32:24 -04:00
|
|
|
public:
|
|
|
|
/**
|
2010-03-31 19:49:42 -04:00
|
|
|
* Used to display the list of karts and their times or
|
|
|
|
* whatever other info is relevant to the current mode.
|
|
|
|
*/
|
2009-08-20 20:32:24 -04:00
|
|
|
struct KartIconDisplayInfo
|
|
|
|
{
|
2010-03-31 19:49:42 -04:00
|
|
|
/** text to display next to icon, if any */
|
|
|
|
irr::core::stringw m_text;
|
|
|
|
|
|
|
|
/** text color, if any text */
|
2009-08-20 20:32:24 -04:00
|
|
|
float r, g, b;
|
2010-03-31 19:49:42 -04:00
|
|
|
|
|
|
|
/** if this kart has a special title, e.g. "leader" in follow-the-leader */
|
2009-08-30 14:21:59 -04:00
|
|
|
irr::core::stringw special_title;
|
2010-03-31 19:49:42 -04:00
|
|
|
|
|
|
|
/** Current lap of this kart, or -1 if irrelevant */
|
2009-08-20 20:32:24 -04:00
|
|
|
int lap;
|
|
|
|
}; // KartIconDisplayInfo
|
|
|
|
|
2009-03-11 01:10:56 -04:00
|
|
|
private:
|
2007-05-27 12:01:53 -04:00
|
|
|
class TimedMessage
|
|
|
|
{
|
|
|
|
public:
|
2010-02-24 20:48:32 -05:00
|
|
|
irr::core::stringw m_message; //!< message to display
|
|
|
|
float m_remaining_time; //!< time remaining before removing this message from screen
|
|
|
|
video::SColor m_color; //!< color of message
|
|
|
|
int m_font_size; //!< size
|
2009-08-30 14:21:59 -04:00
|
|
|
const Kart *m_kart;
|
2010-03-06 20:35:57 -05:00
|
|
|
bool m_important; //!< Important msgs are displayed in the middle of the screen
|
2009-08-20 20:32:24 -04:00
|
|
|
// -----------------------------------------------------
|
2007-09-10 10:11:08 -04:00
|
|
|
// std::vector needs standard copy-ctor and std-assignment op.
|
|
|
|
// let compiler create defaults .. they'll do the job, no
|
|
|
|
// deep copies here ..
|
2009-08-30 14:21:59 -04:00
|
|
|
TimedMessage(const irr::core::stringw &message,
|
2008-12-15 18:35:15 -05:00
|
|
|
const Kart *kart, float time, int size,
|
2010-03-06 20:35:57 -05:00
|
|
|
const video::SColor &color, const bool important)
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2009-07-15 23:24:17 -04:00
|
|
|
m_message = message;
|
|
|
|
m_font_size = size;
|
|
|
|
m_kart = kart;
|
|
|
|
m_remaining_time = ( time < 0.0f ) ? -1.0f : time;
|
|
|
|
m_color = color;
|
2010-03-06 20:35:57 -05:00
|
|
|
m_important = important;
|
2009-08-20 20:32:24 -04:00
|
|
|
} // TimedMessage
|
|
|
|
// -----------------------------------------------------
|
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
|
|
|
// in follow leader the clock counts backwards
|
2008-10-04 14:50:45 -04:00
|
|
|
bool done(const float dt)
|
|
|
|
{
|
|
|
|
m_remaining_time -= dt;
|
|
|
|
return m_remaining_time < 0;
|
2009-08-20 20:32:24 -04:00
|
|
|
} // done
|
|
|
|
}; // TimedMessage
|
|
|
|
// ---------------------------------------------------------
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
Material *m_speed_meter_icon;
|
|
|
|
Material *m_speed_bar_icon;
|
|
|
|
Material *m_plunger_face;
|
|
|
|
typedef std::vector<TimedMessage> AllMessageType;
|
|
|
|
AllMessageType m_messages;
|
2010-03-06 20:35:57 -05:00
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
/** A texture with all mini dots to be displayed in the minimap for all karts. */
|
2009-07-27 07:56:09 -04:00
|
|
|
video::ITexture *m_marker;
|
|
|
|
|
2009-08-16 18:52:41 -04:00
|
|
|
/** Musical notes icon (for music description and credits) */
|
|
|
|
Material *m_music_icon;
|
2010-01-11 17:08:33 -05:00
|
|
|
|
|
|
|
/** Translated string of 'finished' message. */
|
|
|
|
core::stringw m_string_finished;
|
|
|
|
|
|
|
|
/** Translated string 'lap' displayed every frame. */
|
|
|
|
core::stringw m_string_lap;
|
|
|
|
|
|
|
|
/** Translated strings 'ready', 'set', 'go'. */
|
|
|
|
core::stringw m_string_ready, m_string_set, m_string_go;
|
2009-08-16 18:52:41 -04:00
|
|
|
|
2009-08-20 20:32:24 -04:00
|
|
|
// Minimap related variables
|
|
|
|
// -------------------------
|
2009-07-29 22:40:30 -04:00
|
|
|
/** The mini map of the track. */
|
|
|
|
video::ITexture *m_mini_map;
|
2009-08-20 20:32:24 -04:00
|
|
|
/** The size of a single marker in pixels, must be a power of 2. */
|
2009-07-29 22:40:30 -04:00
|
|
|
int m_marker_rendered_size;
|
|
|
|
|
|
|
|
/** The size of a single marker on the screen for AI karts,
|
|
|
|
* need not be a power of 2. */
|
|
|
|
int m_marker_ai_size;
|
|
|
|
|
|
|
|
/** The size of a single marker on the screen or player karts,
|
|
|
|
* need not be a power of 2. */
|
|
|
|
int m_marker_player_size;
|
|
|
|
|
|
|
|
/** The width of the rendered mini map in pixels, must be a power of 2. */
|
|
|
|
int m_map_rendered_width;
|
|
|
|
|
|
|
|
/** The height of the rendered mini map in pixels, must be a power of 2. */
|
|
|
|
int m_map_rendered_height;
|
|
|
|
|
|
|
|
/** Width of the map in pixels on the screen, need not be a power of 2. */
|
|
|
|
int m_map_width;
|
|
|
|
|
|
|
|
/** Height of the map in pixels on the screen, need not be a power of 2. */
|
|
|
|
int m_map_height;
|
|
|
|
|
|
|
|
/** Distance of map from left side of screen. */
|
|
|
|
int m_map_left;
|
|
|
|
|
|
|
|
/** Distance of map from bottom of screen. */
|
|
|
|
int m_map_bottom;
|
|
|
|
|
2010-03-04 20:58:27 -05:00
|
|
|
/** Used to display messages without overlapping */
|
|
|
|
int m_max_font_height;
|
2010-03-06 21:03:39 -05:00
|
|
|
int m_small_font_max_height;
|
2010-03-04 20:58:27 -05:00
|
|
|
|
2009-07-27 07:56:09 -04:00
|
|
|
void createMarkerTexture();
|
|
|
|
void createRegularPolygon(unsigned int n, float radius,
|
|
|
|
const core::vector2df ¢er,
|
2009-10-15 19:51:41 -04:00
|
|
|
const video::SColor &color,
|
|
|
|
video::S3DVertex *v, unsigned short int *index);
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2009-11-23 00:20:05 -05:00
|
|
|
/* Display informat for one player on the screen. */
|
2010-02-10 06:40:33 -05:00
|
|
|
void drawEnergyMeter (const Kart *kart,
|
2009-11-23 00:20:05 -05:00
|
|
|
const core::recti &viewport,
|
|
|
|
const core::vector2df &scaling);
|
2010-02-10 06:40:33 -05:00
|
|
|
void drawPowerupIcons (const Kart* kart,
|
2009-11-23 00:20:05 -05:00
|
|
|
const core::recti &viewport,
|
|
|
|
const core::vector2df &scaling);
|
2010-02-10 06:40:33 -05:00
|
|
|
void drawAllMessages (const Kart* kart,
|
2009-11-23 00:20:05 -05:00
|
|
|
const core::recti &viewport,
|
|
|
|
const core::vector2df &scaling);
|
2010-02-10 06:40:33 -05:00
|
|
|
void drawSpeed (const Kart* kart, const core::recti &viewport,
|
2009-11-23 00:20:05 -05:00
|
|
|
const core::vector2df &scaling);
|
2010-02-10 06:40:33 -05:00
|
|
|
void drawLap (const KartIconDisplayInfo* info, const Kart* kart,
|
2009-11-23 00:20:05 -05:00
|
|
|
const core::recti &viewport,
|
|
|
|
const core::vector2df &scaling);
|
|
|
|
void drawGlobalPlayerIcons (const KartIconDisplayInfo* info);
|
|
|
|
/** Display items that are shown once only (for all karts). */
|
|
|
|
void drawGlobalMiniMap ();
|
|
|
|
void drawGlobalTimer ();
|
|
|
|
void drawGlobalMusicDescription();
|
2008-10-04 14:50:45 -04:00
|
|
|
void cleanupMessages (const float dt);
|
2009-11-23 00:20:05 -05:00
|
|
|
void drawGlobalReadySetGo ();
|
2010-03-04 20:58:27 -05:00
|
|
|
|
2009-03-11 01:10:56 -04:00
|
|
|
public:
|
|
|
|
|
2009-07-12 07:54:21 -04:00
|
|
|
RaceGUI();
|
|
|
|
~RaceGUI();
|
2009-11-23 00:20:05 -05:00
|
|
|
void renderGlobal(float dt);
|
2010-02-10 06:40:33 -05:00
|
|
|
void renderPlayerView(const Kart *kart);
|
2009-11-23 00:20:05 -05:00
|
|
|
|
2009-08-30 14:21:59 -04:00
|
|
|
void addMessage(const irr::core::stringw &m, const Kart *kart, float time,
|
2009-07-15 23:24:17 -04:00
|
|
|
int fonst_size,
|
2010-03-06 20:35:57 -05:00
|
|
|
const video::SColor &color=video::SColor(255, 255, 0, 255),
|
|
|
|
bool important=true);
|
2009-07-29 22:40:30 -04:00
|
|
|
|
2010-02-26 14:09:05 -05:00
|
|
|
void clearAllMessages() { m_messages.clear(); }
|
|
|
|
|
2009-07-29 22:40:30 -04:00
|
|
|
/** Returns the size of the texture on which to render the minimap to. */
|
2009-08-05 08:45:11 -04:00
|
|
|
const core::dimension2du getMiniMapSize() const
|
|
|
|
{ return core::dimension2du(m_map_width, m_map_height); }
|
2007-05-27 12:01:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|