2010-07-15 18:41:41 -04:00
|
|
|
// $Id: race_result_gui.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_RESULT_GUI_HPP
|
|
|
|
#define HEADER_RACE_RESULT_GUI_HPP
|
|
|
|
|
2010-07-20 20:01:22 -04:00
|
|
|
#include "states_screens/race_gui_base.hpp"
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
#include "guiengine/screen.hpp"
|
|
|
|
|
2010-07-20 20:01:22 -04:00
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
class ScalableFont;
|
|
|
|
}
|
|
|
|
}
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Displays the results (while the end animation is shown).
|
|
|
|
* \ingroup states_screens
|
|
|
|
*/
|
2010-08-24 19:19:14 -04:00
|
|
|
class RaceResultGUI : public RaceGUIBase,
|
|
|
|
public GUIEngine::Screen,
|
|
|
|
public GUIEngine::ScreenSingleton<RaceResultGUI>
|
2010-07-15 18:41:41 -04:00
|
|
|
{
|
|
|
|
private:
|
2010-07-20 19:01:47 -04:00
|
|
|
/** Timer variable for animations. */
|
2010-07-15 18:41:41 -04:00
|
|
|
float m_timer;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
|
|
|
/** Finite state machine for the animations:
|
2010-07-29 19:03:20 -04:00
|
|
|
INIT: Set up data structures.
|
|
|
|
RACE_RESULT: The rows scroll into place.
|
|
|
|
OLD_GP_TABLE: Scroll new table into place, sorted by previous
|
|
|
|
GP ranks
|
|
|
|
INCREASE_POINTS: The overall points are added up
|
|
|
|
RESORT_TABLE: Resort the table so that it is now sorted by
|
|
|
|
GP points.
|
|
|
|
WAIT_TILL_END Some delay to wait for end, after a period it
|
|
|
|
wii automatically end. */
|
|
|
|
enum {RR_INIT,
|
|
|
|
RR_RACE_RESULT,
|
|
|
|
RR_OLD_GP_RESULTS,
|
2010-07-20 19:01:47 -04:00
|
|
|
RR_INCREASE_POINTS,
|
|
|
|
RR_RESORT_TABLE,
|
|
|
|
RR_WAIT_TILL_END}
|
|
|
|
m_animation_state;
|
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
class RowInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Start time for each line of the animation. */
|
|
|
|
float m_start_at;
|
|
|
|
/** Currenct X position. */
|
|
|
|
float m_x_pos;
|
|
|
|
/** Currenct Y position. */
|
|
|
|
float m_y_pos;
|
|
|
|
/** True if kart is a player kart. */
|
|
|
|
bool m_is_player_kart;
|
|
|
|
/** The radius to use when sorting the entries. Positive values
|
|
|
|
will rotate downwards, negatives are upwards. */
|
|
|
|
float m_radius;
|
|
|
|
/** The center point when sorting the entries. */
|
|
|
|
float m_centre_point;
|
|
|
|
/** The names of all karts in the right order. */
|
|
|
|
core::stringw m_kart_name;
|
|
|
|
/** Points earned in this race. */
|
|
|
|
float m_new_points;
|
|
|
|
/** New overall points after this race. */
|
|
|
|
int m_new_overall_points;
|
|
|
|
/** When updating the number of points in the display, this is the
|
|
|
|
currently displayed number of points. This is a floating point number
|
|
|
|
since it stores the increments during increasing the points. */
|
|
|
|
float m_current_displayed_points;
|
|
|
|
/** The kart icons. */
|
|
|
|
video::ITexture *m_kart_icon;
|
|
|
|
/** The times of all karts in the right order. */
|
|
|
|
core::stringw m_finish_time_string;
|
|
|
|
}; // Rowinfo
|
|
|
|
|
|
|
|
std::vector<RowInfo> m_all_row_infos;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
/** Time to wait till the next row starts to be animated. */
|
|
|
|
float m_time_between_rows;
|
|
|
|
|
2010-07-20 19:01:47 -04:00
|
|
|
/** The time a single line scrolls into place. */
|
|
|
|
float m_time_single_scroll;
|
|
|
|
|
2010-07-25 18:37:11 -04:00
|
|
|
/** Time to rotate the GP entries. */
|
|
|
|
float m_time_rotation;
|
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
/** The time for inreasing the points by one during the
|
|
|
|
point update phase. */
|
|
|
|
float m_time_for_points;
|
|
|
|
|
2010-07-20 19:01:47 -04:00
|
|
|
/** The overall time the first phase (scrolling) is displayed.
|
|
|
|
This includes a small waiting time at the end. */
|
|
|
|
float m_time_overall_scroll;
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
/** Distance between each row of the race results */
|
|
|
|
unsigned int m_distance_between_rows;
|
|
|
|
|
|
|
|
/** The size of the kart icons. */
|
2010-07-22 18:51:14 -04:00
|
|
|
unsigned int m_width_icon;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-07-20 19:01:47 -04:00
|
|
|
/** Width of the kart name column. */
|
2010-07-22 18:51:14 -04:00
|
|
|
unsigned int m_width_kart_name;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
/** Width of the finish time column. */
|
|
|
|
unsigned int m_width_finish_time;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
/** Width of the new points columns. */
|
|
|
|
unsigned int m_width_new_points;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
/** Position of left end of table (so that the whole
|
|
|
|
table is aligned. */
|
|
|
|
unsigned int m_leftmost_column;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-07-29 19:03:20 -04:00
|
|
|
/** Top-most pixel for first row. */
|
|
|
|
unsigned int m_top;
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
/** Size of space between columns. */
|
2010-07-22 18:51:14 -04:00
|
|
|
unsigned int m_width_column_space;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
/** The font to use. */
|
2010-07-22 18:51:14 -04:00
|
|
|
gui::ScalableFont *m_font;
|
|
|
|
|
2010-08-25 18:55:58 -04:00
|
|
|
/** True if a GP position was changed. If not, the point increase
|
|
|
|
* animation can be skipped. */
|
|
|
|
bool m_gp_position_was_changed;
|
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
/** The previous monospace state of the font. */
|
|
|
|
bool m_was_monospace;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
void displayOneEntry(unsigned int x, unsigned int y,
|
|
|
|
unsigned int n, bool display_points);
|
2010-07-29 19:03:20 -04:00
|
|
|
void determineTableLayout();
|
|
|
|
void determineGPLayout();
|
2010-08-24 19:19:14 -04:00
|
|
|
void enableAllButtons();
|
2010-07-22 18:51:14 -04:00
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
public:
|
|
|
|
|
|
|
|
RaceResultGUI();
|
|
|
|
virtual void renderGlobal(float dt);
|
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
/** \brief Implement callback from parent class GUIEngine::Screen */
|
2010-08-25 09:54:28 -04:00
|
|
|
virtual void loadedFromFile() {};
|
2010-08-24 19:19:14 -04:00
|
|
|
|
2010-08-25 09:54:28 -04:00
|
|
|
virtual void init();
|
|
|
|
virtual void tearDown();
|
|
|
|
virtual bool onEscapePressed();
|
2010-08-26 06:16:58 -04:00
|
|
|
virtual GUIEngine::EventPropagation
|
|
|
|
filterActions(PlayerAction action, const unsigned int value,
|
|
|
|
Input::InputType type, int playerId);
|
2010-08-24 19:19:14 -04:00
|
|
|
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
|
|
|
const int playerID);
|
|
|
|
|
2010-08-26 06:16:58 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
friend class GUIEngine::ScreenSingleton<RaceResultGUI>;
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
/** Should not be called anymore. */
|
|
|
|
const core::dimension2du getMiniMapSize() const
|
|
|
|
{ assert(false); return core::dimension2du(0, 0); }
|
|
|
|
|
|
|
|
/** No kart specific view needs to be rendered in the result gui. */
|
|
|
|
virtual void renderPlayerView(const Kart *kart) {}
|
2010-08-24 19:19:14 -04:00
|
|
|
|
|
|
|
virtual void onUpdate(float dt, irr::video::IVideoDriver*);
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
/** No more messages need to be displayed, so this function shouldn't
|
|
|
|
* be called at all. */
|
|
|
|
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) { assert(false); }
|
|
|
|
|
|
|
|
/** Should not be called anymore. */
|
|
|
|
virtual void clearAllMessages() {assert(false); }
|
|
|
|
|
|
|
|
void nextPhase();
|
|
|
|
}; // RaceResultGUI
|
|
|
|
|
|
|
|
#endif
|