stk-code_catmod/src/states_screens/race_gui.hpp
Alayan-stk-2 7f84dd39a6 Numerous improvements related to ghost replays (#3244)
* Update GUI files for replay improvements

* Updated replay capabilities

* Improve timer formatting possibilities

Mainly, the ability to choose to display or not minutes, and to choose how many digits are shown after seconds (from 0 : second as smallest timestep - to 3 : ms as smallest timestep)

Also displays "mm:ss.ms" rather than "mm:ss:ms".

* Some new list widget possibilities

Like the ability to update the header while the list is displayed (useful to add or remove columns)

* Update ghost kart for the new replay data

* Also update the ghost controller

* Live differences with ghost replays in linear worlds

* Replay-related UI changes

Big changes to the replay selection screen, and small change to the race UI (add the live timer in ghost races) and the race result UI (add the option to directly race against a newly saved ghost).

* Improves the replay action modal dialog

* Fix time-to-ticks regression

* Several requested improvements

* Improved ghost icon

Also updates the license

* GUI changes and improvements to accomodate multi-mode support

* Additional recorded data

* More functions to get the current race state

* Update replay variables to match what is used

* Updated replay-related config values

* Add ghost kart support to easter egg hunt mode

* Transparent attachments for ghost karts

* Use new stored data (color, item type)

Also :
- Interpolate speed for smoother display in watch-only mode
- Coding style improvements

* Fix coding style issues and add UI support for modes

* Fix coding style issues & support for easter egg mode

* Remove leftover prints

* Use getDifficultyName to remove hardcoded values

* Fix attach_ticks and coding style fixes

* Make the position of the timers fully relative

Otherwise, they would tend to touch each other in some resolutions

Also add a comment about the 59.9995f

* Make the list filling code clearer

Also use getDifficultyName

Most of the line changes shown by git correspond to moving around some bits or adjusting indentation.

* Remove a TODO as requested

* Fix dialog being dismissed too soon

* Remove a fixme

* Small clean up

* Fix logging

* Partial #3249 fix
2018-05-13 20:51:52 -04:00

153 lines
5.4 KiB
C++

//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
// Copyright (C) 2006-2015 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
// 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_HPP
#define HEADER_RACE_GUI_HPP
#include <string>
#include <vector>
#include <irrString.h>
using namespace irr;
#include "states_screens/race_gui_base.hpp"
class AbstractKart;
class InputMap;
class Material;
class RaceSetup;
/**
* \brief Handles the in-race GUI (messages, mini-map, rankings, timer, etc...)
* \ingroup states_screens
*/
class RaceGUI : public RaceGUIBase
{
private:
Material *m_speed_meter_icon;
Material *m_speed_bar_icon;
// Minimap related variables
// -------------------------
/** The size of a single marker on the screen for AI karts,
* need not be a power of 2. */
int m_minimap_ai_size;
/** The size of a single marker on the screen or player karts,
* need not be a power of 2. */
int m_minimap_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;
/** Maximum lap display length (either 9/9 or 99/99). */
int m_lap_width;
/** Maximum string length for the timer */
int m_timer_width;
/** Maximum string length for a small precise timer
* (like the live difference timer under a minute) */
int m_small_precise_timer_width;
/** Maximum string length for a big precise timer
* (like the live difference timer over a minute) */
int m_big_precise_timer_width;
int m_negative_timer_additional_width;
/** Height of the digit font. */
int m_font_height;
/** Animation state: none, getting smaller (old value),
* getting bigger (new number). */
enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER};
std::vector<AnimationState> m_animation_states;
/** How long the rank animation has been shown. */
std::vector<float> m_rank_animation_duration;
/** Stores the previous rank for each kart. Used for the rank animation. */
std::vector<int> m_last_ranks;
bool m_is_tutorial;
/* Display informat for one player on the screen. */
void drawEnergyMeter (int x, int y, const AbstractKart *kart,
const core::recti &viewport,
const core::vector2df &scaling);
void drawSpeedEnergyRank (const AbstractKart* kart,
const core::recti &viewport,
const core::vector2df &scaling, float dt);
void drawLap (const AbstractKart* kart,
const core::recti &viewport,
const core::vector2df &scaling);
void drawRank (const AbstractKart *kart,
const core::vector2df &offset,
float min_ratio, int meter_width,
int meter_height, float dt);
/* Helper functions for drawing meters */
void drawMeterTexture(video::ITexture *meter_texture, video::S3DVertex vertices[], unsigned int count);
unsigned int computeVerticesForMeter(core::vector2df position[], float threshold[], video::S3DVertex vertices[],
unsigned int vertices_count, float measure, int gauge_width,
int gauge_height, core::vector2df offset);
/** Display items that are shown once only (for all karts). */
void drawGlobalMiniMap ();
void drawGlobalTimer ();
void drawLiveDifference ();
void drawScores();
public:
RaceGUI();
~RaceGUI();
virtual void init();
virtual void reset();
virtual void renderGlobal(float dt);
virtual void renderPlayerView(const Camera *camera, float dt);
/** Returns the size of the texture on which to render the minimap to. */
virtual const core::dimension2du getMiniMapSize() const
{ return core::dimension2du(m_map_width, m_map_height); }
}; // RaceGUI
#endif