Added new base class for race gui (in prepration for improved

result gui).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5680 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-07-11 23:03:54 +00:00
parent 87256f58e8
commit 626f83087a
21 changed files with 129 additions and 70 deletions

View File

@ -314,6 +314,7 @@ supertuxkart_SOURCES = \
states_screens/addons_screen.hpp \
states_screens/addons_update_screen.cpp \
states_screens/addons_update_screen.hpp \
states_screens/race_gui_base.hpp \
states_screens/race_gui.cpp \
states_screens/race_gui.hpp \
states_screens/race_setup_screen.cpp \

View File

@ -811,7 +811,7 @@ void IrrDriver::update(float dt)
if (inRace)
{
RaceGUI *rg = world->getRaceGUI();
RaceGUIBase *rg = world->getRaceGUI();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
Kart *kart=world->getKart(i);

View File

@ -1844,6 +1844,10 @@
RelativePath="..\..\states_screens\race_gui.hpp"
>
</File>
<File
RelativePath="..\..\states_screens\race_gui_base.hpp"
>
</File>
<File
RelativePath="..\..\states_screens\race_setup_screen.hpp"
>

View File

@ -392,7 +392,7 @@ void Flyable::hit(Kart *kart_hit, PhysicalObject* object)
if (kart_hit != NULL)
{
RaceGUI* gui = World::getWorld()->getRaceGUI();
RaceGUIBase* gui = World::getWorld()->getRaceGUI();
irr::core::stringw hit_message;
switch(m_type)
{

View File

@ -165,7 +165,7 @@ void Plunger::hit(Kart *kart, PhysicalObject *obj)
{
if(isOwnerImmunity(kart)) return;
RaceGUI* gui = World::getWorld()->getRaceGUI();
RaceGUIBase* gui = World::getWorld()->getRaceGUI();
irr::core::stringw hit_message;
// pulling back makes no sense in battle mode, since this mode is not a race.

View File

@ -205,7 +205,7 @@ void Powerup::use()
m_number--;
World *world = World::getWorld();
RaceGUI* gui = world->getRaceGUI();
RaceGUIBase* gui = world->getRaceGUI();
switch (m_type)
{
case PowerupManager::POWERUP_ZIPPER: m_owner->handleZipper();

View File

@ -234,7 +234,7 @@ void RubberBand::hit(Kart *kart_hit, const Vec3 *track_xyz)
m_hit_kart = kart_hit;
m_attached_state = RB_TO_KART;
RaceGUI* gui = World::getWorld()->getRaceGUI();
RaceGUIBase* gui = World::getWorld()->getRaceGUI();
irr::core::stringw hit_message;
hit_message += StringUtils::insertValues(getPlungerString(),
kart_hit->getName().c_str(),

View File

@ -29,7 +29,7 @@
#include "items/item.hpp"
#include "modes/world.hpp"
#include "race/history.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include "utils/constants.hpp"
#include "utils/translation.hpp"
@ -274,7 +274,7 @@ void PlayerController::update(float dt)
{
if (m_penalty_time == 0.0)//eliminates machine-gun-effect for SOUND_BZZT
{
RaceGUI* m=World::getWorld()->getRaceGUI();
RaceGUIBase* m=World::getWorld()->getRaceGUI();
if(m)
{
m->addMessage(_("Penalty time!!"), m_kart, 2.0f, 60);

View File

@ -492,7 +492,7 @@ void Kart::finishedRace(float time)
// Not all karts have a camera
if (m_camera) m_camera->setMode(Camera::CM_FINAL);
RaceGUI* m = World::getWorld()->getRaceGUI();
RaceGUIBase* m = World::getWorld()->getRaceGUI();
if(m)
{
m->addMessage((getPosition() == 1 ? _("You won the race!") : _("You finished the race!")) ,
@ -511,7 +511,7 @@ void Kart::finishedRace(float time)
// Not all karts have a camera
if (m_camera) m_camera->setMode(Camera::CM_REVERSE);
RaceGUI* m = World::getWorld()->getRaceGUI();
RaceGUIBase* m = World::getWorld()->getRaceGUI();
if(m)
{
m->addMessage((getPosition() == 2 ? _("You won the race!") : _("You finished the race!")) ,

View File

@ -21,7 +21,7 @@
#include "challenges/unlock_manager.hpp"
#include "config/user_config.hpp"
#include "items/powerup_manager.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
#include "utils/translation.hpp"
@ -134,7 +134,7 @@ std::string FollowTheLeaderRace::getIdent() const
return FTL_IDENT;
}
//-----------------------------------------------------------------------------
RaceGUI::KartIconDisplayInfo* FollowTheLeaderRace::getKartsDisplayInfo()
RaceGUIBase::KartIconDisplayInfo* FollowTheLeaderRace::getKartsDisplayInfo()
{
LinearWorld::getKartsDisplayInfo();
m_kart_display_info[0].special_title = _("Leader");

View File

@ -19,7 +19,7 @@
#define _follow_the_leader_hpp_
#include "modes/linear_world.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
/**
* \brief An implementation of World, based on LinearWorld, to provide the Follow-the-leader game mode
@ -42,7 +42,7 @@ public:
virtual void restartRace();
virtual std::string getIdent() const;
virtual bool useFastMusicNearEnd() const { return false; }
virtual RaceGUI::KartIconDisplayInfo* getKartsDisplayInfo();
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
virtual bool isRaceOver();
virtual bool raceHasLaps(){ return false; }

View File

@ -16,7 +16,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "modes/linear_world.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include <sstream>
@ -44,7 +44,7 @@ void LinearWorld::init()
World::init();
const unsigned int kart_amount = m_karts.size();
m_kart_display_info = new RaceGUI::KartIconDisplayInfo[kart_amount];
m_kart_display_info = new RaceGUIBase::KartIconDisplayInfo[kart_amount];
for(unsigned int n=0; n<kart_amount; n++)
{
@ -389,7 +389,7 @@ float LinearWorld::getTimeAtLapForKart(const int kart_id) const
} // getTimeAtLapForKart
//-----------------------------------------------------------------------------
RaceGUI::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
RaceGUIBase::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
{
int laps_of_leader = -1;
float time_of_leader = -1;
@ -399,7 +399,7 @@ RaceGUI::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
const unsigned int kart_amount = getNumKarts();
for(unsigned int i = 0; i < kart_amount ; i++)
{
RaceGUI::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
Kart* kart = m_karts[i];
// reset color
@ -428,7 +428,7 @@ RaceGUI::KartIconDisplayInfo* LinearWorld::getKartsDisplayInfo()
// we now know the best time of the lap. fill the remaining bits of info
for(unsigned int i = 0; i < kart_amount ; i++)
{
RaceGUI::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
KartInfo& kart_info = m_kart_info[i];
Kart* kart = m_karts[i];

View File

@ -62,7 +62,7 @@ private:
};
protected:
RaceGUI::KartIconDisplayInfo* m_kart_display_info;
RaceGUIBase::KartIconDisplayInfo* m_kart_display_info;
/** This vector contains an 'KartInfo' struct for every kart in the race.
* This member is not strictly private but try not to use it directly outside
@ -95,7 +95,7 @@ public:
void setTimeAtLapForKart(float t, const int kart_id);
float getTimeAtLapForKart(const int kart_id) const;
virtual RaceGUI::KartIconDisplayInfo*
virtual RaceGUIBase::KartIconDisplayInfo*
getKartsDisplayInfo();
virtual void moveKartAfterRescue(Kart* kart);

View File

@ -19,7 +19,7 @@
#include <string>
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include "audio/music_manager.hpp"
#include "tracks/track.hpp"
@ -45,7 +45,7 @@ void ThreeStrikesBattle::init()
}
const unsigned int kart_amount = m_karts.size();
m_kart_display_info = new RaceGUI::KartIconDisplayInfo[kart_amount];
m_kart_display_info = new RaceGUIBase::KartIconDisplayInfo[kart_amount];
for(unsigned int n=0; n<kart_amount; n++)
{
@ -213,12 +213,12 @@ void ThreeStrikesBattle::restartRace()
} // restartRace
//-----------------------------------------------------------------------------
RaceGUI::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
RaceGUIBase::KartIconDisplayInfo* ThreeStrikesBattle::getKartsDisplayInfo()
{
const unsigned int kart_amount = getNumKarts();
for(unsigned int i = 0; i < kart_amount ; i++)
{
RaceGUI::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
RaceGUIBase::KartIconDisplayInfo& rank_info = m_kart_display_info[i];
// reset color
rank_info.lap = -1;

View File

@ -23,7 +23,7 @@
#include <string>
#include "modes/world.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
/**
* \brief An implementation of World, to provide the 3 strikes battle game mode
@ -37,7 +37,7 @@ private:
int m_lives;
};
RaceGUI::KartIconDisplayInfo* m_kart_display_info;
RaceGUIBase::KartIconDisplayInfo* m_kart_display_info;
/** This vector contains an 'BattleInfo' struct for every kart in the race.
*/
@ -67,7 +67,7 @@ public:
//virtual void getDefaultCollectibles(int& collectible_type, int& amount);
virtual bool useFastMusicNearEnd() const { return false; }
virtual RaceGUI::KartIconDisplayInfo* getKartsDisplayInfo();
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo();
virtual bool raceHasLaps(){ return false; }
virtual void moveKartAfterRescue(Kart* kart);
@ -80,7 +80,7 @@ public:
virtual void raceResultOrder( int* order );
void updateKartRanks();
};
}; // ThreeStrikesBattles
#endif

View File

@ -32,6 +32,7 @@
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/race_gui_base.hpp"
#include "states_screens/race_gui.hpp"
#include "io/file_manager.hpp"
#include "items/projectile_manager.hpp"
@ -154,7 +155,7 @@ void World::init()
powerup_manager->updateWeightsForRace(num_karts);
// erase messages left over
RaceGUI* m = World::getWorld()->getRaceGUI();
RaceGUIBase* m = World::getWorld()->getRaceGUI();
if (m) m->clearAllMessages();
} // init
@ -293,7 +294,7 @@ void World::terminateRace()
updateHighscores();
unlock_manager->raceFinished();
RaceGUI* m = World::getWorld()->getRaceGUI();
RaceGUIBase* m = World::getWorld()->getRaceGUI();
if (m) m->clearAllMessages();
WorldStatus::terminateRace();

View File

@ -28,7 +28,7 @@
#include "network/network_kart.hpp"
#include "physics/physics.hpp"
#include "race/highscores.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include "utils/random_generator.hpp"
class btRigidBody;
@ -127,7 +127,7 @@ protected:
Track* m_track;
/** Pointer to the race GUI. The race GUI is handedl by world. */
RaceGUI *m_race_gui;
RaceGUIBase *m_race_gui;
bool m_clear_back_buffer;
@ -170,10 +170,10 @@ public:
/** Put race into limbo phase */
void disableRace();
/** Returns a pointer to the race gui. */
RaceGUI *getRaceGUI() const { return m_race_gui; }
Kart *getPlayerKart(unsigned int player) const;
Kart *getLocalPlayerKart(unsigned int n) const;
/** Returns a pointer to the race gui. */
RaceGUIBase *getRaceGUI() const { return m_race_gui; }
unsigned int getNumKarts() const { return m_karts.size(); }
Kart *getKart(int kartId) const { assert(kartId >= 0 &&
kartId < int(m_karts.size()));
@ -227,7 +227,7 @@ public:
/** Called by the code that draws the list of karts on the race GUI
* to know what needs to be drawn in the current mode
*/
virtual RaceGUI::KartIconDisplayInfo* getKartsDisplayInfo() = 0;
virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo() = 0;
/** Since each mode will have a different way of deciding where a rescued
* kart is dropped, this method will be called and each mode can implement it.

View File

@ -244,7 +244,7 @@ void RaceGUI::renderGlobal(float dt)
}
drawGlobalMiniMap();
RaceGUI::KartIconDisplayInfo* info = world->getKartsDisplayInfo();
KartIconDisplayInfo* info = world->getKartsDisplayInfo();
drawGlobalPlayerIcons(info);
} // renderGlobal

View File

@ -18,8 +18,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_RACEGUI_HPP
#define HEADER_RACEGUI_HPP
#ifndef HEADER_RACE_GUI_HPP
#define HEADER_RACE_GUI_HPP
#include <string>
#include <vector>
@ -27,8 +27,8 @@
#include "irrlicht.h"
using namespace irr;
#include "config/player.hpp"
#include "states_screens/race_gui_base.hpp"
class InputMap;
class Kart;
@ -39,28 +39,8 @@ class RaceSetup;
* \brief Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)
* \ingroup states_screens
*/
class RaceGUI
class RaceGUI : public RaceGUIBase
{
public:
/**
* Used to display the list of karts and their times or
* whatever other info is relevant to the current mode.
*/
struct KartIconDisplayInfo
{
/** text to display next to icon, if any */
irr::core::stringw m_text;
/** text color, if any text */
float r, g, b;
/** if this kart has a special title, e.g. "leader" in follow-the-leader */
irr::core::stringw special_title;
/** Current lap of this kart, or -1 if irrelevant */
int lap;
}; // KartIconDisplayInfo
private:
class TimedMessage
{
@ -191,19 +171,20 @@ public:
RaceGUI();
~RaceGUI();
void renderGlobal(float dt);
void renderPlayerView(const Kart *kart);
virtual void renderGlobal(float dt);
virtual void renderPlayerView(const Kart *kart);
void addMessage(const irr::core::stringw &m, const Kart *kart, float time,
int fonst_size,
const video::SColor &color=video::SColor(255, 255, 0, 255),
bool important=true);
virtual void addMessage(const irr::core::stringw &m, const Kart *kart,
float time, int fonst_size,
const video::SColor &color=
video::SColor(255, 255, 0, 255),
bool important=true);
void clearAllMessages() { m_messages.clear(); }
virtual void clearAllMessages() { m_messages.clear(); }
/** Returns the size of the texture on which to render the minimap to. */
const core::dimension2du getMiniMapSize() const
virtual const core::dimension2du getMiniMapSize() const
{ return core::dimension2du(m_map_width, m_map_height); }
};
}; // RaceGUI
#endif

View File

@ -0,0 +1,72 @@
// $Id: race_gui_base.hpp 5310 2010-04-28 18:26:23Z auria $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// 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.
#ifndef HEADER_RACE_GUI_BASE_HPP
#define HEADER_RACE_GUI_BASE_HPP
/**
* \brief An abstract base class for the two race guis (race_gui and
* race_result gui)
* \ingroup states_screens
*/
class Kart;
class RaceGUIBase
{
public:
/**
* Used to display the list of karts and their times or
* whatever other info is relevant to the current mode.
*/
struct KartIconDisplayInfo
{
/** text to display next to icon, if any */
irr::core::stringw m_text;
/** text color, if any text */
float r, g, b;
/** if this kart has a special title, e.g. "leader" in follow-the-leader */
irr::core::stringw special_title;
/** Current lap of this kart, or -1 if irrelevant */
int lap;
}; // KartIconDisplayInfo
public:
RaceGUIBase() {};
virtual ~RaceGUIBase() {};
virtual void renderGlobal(float dt) = 0;
virtual void renderPlayerView(const Kart *kart) = 0;
virtual void addMessage(const irr::core::stringw &m, const Kart *kart,
float time,
int fonst_size,
const video::SColor &color=
video::SColor(255, 255, 0, 255),
bool important=true) = 0;
virtual void clearAllMessages() = 0;
/** Returns the size of the texture on which to render the minimap to. */
virtual const core::dimension2du
getMiniMapSize() const = 0;
}; // RaceGUIBase
#endif

View File

@ -45,7 +45,7 @@ using namespace irr;
#include "physics/physical_object.hpp"
#include "physics/triangle_mesh.hpp"
#include "race/race_manager.hpp"
#include "states_screens/race_gui.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/bezier_curve.hpp"
#include "tracks/check_manager.hpp"
#include "tracks/quad_graph.hpp"