SuperTuxKart
Loading...
Searching...
No Matches
kart_stats_widget.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2009-2015 Marianne Gagnon
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19
20#ifndef HEADER_KART_STATS_HPP
21#define HEADER_KART_STATS_HPP
22
23#include <irrString.h>
24
25#include "guiengine/widget.hpp"
26#include "utils/leak_check.hpp"
27#include "utils/ptr_vector.hpp"
28
29#include "guiengine/widgets/label_widget.hpp"
30#include "guiengine/widgets/progress_bar_widget.hpp"
31#include "guiengine/widgets/skill_level_widget.hpp"
32
33class KartProperties;
34enum HandicapLevel : uint8_t;
35
36namespace GUIEngine
37{
42 class KartStatsWidget : public Widget
43 {
44 public:
45
46 enum Stats
47 {
48 SKILL_MASS,
49 SKILL_SPEED,
50 SKILL_ACCELERATION,
51 SKILL_NITRO_EFFICIENCY,
52 SKILL_COUNT
53 };
54
55 private:
58 virtual int getWidthNeededAroundLabel() const { return 35; }
59
62 virtual int getHeightNeededAroundLabel() const { return 4; }
63
67 int m_skill_bar_x, m_skill_bar_y, m_skill_bar_h, m_skill_bar_w;
68
69 int m_player_id;
70
71 std::vector<SkillLevelWidget*> m_skills;
72
73 void setSkillValues(Stats skill_type, float value, const std::string icon_name,
74 const std::string skillbar_propID, const irr::core::stringw icon_tooltip);
75
76
77 public:
78
79 LEAK_CHECK()
80
81 KartStatsWidget(core::recti area, const int player_id,
82 std::string kart_group, bool multiplayer,
83 bool display_icons);
84 virtual ~KartStatsWidget() {};
85
86 // ------------------------------------------------------------------------
88 virtual void add();
89
91 virtual void move(const int x, const int y, const int w, const int h);
92
93 // -------------------------------------------------------------------------
95 void onUpdate(float delta);
96
97 // -------------------------------------------------------------------------
100 // -------------------------------------------------------------------------
103 void setSize(const int x, const int y, const int w, const int h);
104
105 void setValues(const KartProperties* props, HandicapLevel h);
106
107 void hideAll();
108
110 void setValue(Stats type, float value);
111
113 float getValue(Stats type);
114
116 void setDisplayIcons(bool display_icons);
117 };
118}
119
120#endif
A progress bar widget.
Definition: kart_stats_widget.hpp:43
void onUpdate(float delta)
Updates the animation (moving/shrinking/etc.)
int m_skill_bar_x
widget coordinates These are not the actual coordinates of any of the skill bars but only (badly name...
Definition: kart_stats_widget.hpp:67
virtual void move(const int x, const int y, const int w, const int h)
Move the widget and its children.
Definition: kart_stats_widget.cpp:156
void setDisplayIcons(bool display_icons)
If the icons should be displayed.
Definition: kart_stats_widget.cpp:205
virtual int getWidthNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: kart_stats_widget.hpp:58
virtual int getHeightNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: kart_stats_widget.hpp:62
void setSize(const int x, const int y, const int w, const int h)
Event callback.
Definition: kart_stats_widget.cpp:190
virtual void add()
Add the widgets to the current screen.
Definition: kart_stats_widget.cpp:147
float getValue(Stats type)
Get the current values of the widget.
Definition: kart_stats_widget.cpp:182
void setValue(Stats type, float value)
Change the value of the widget, it must be a percent.
Definition: kart_stats_widget.cpp:174
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
This class stores the properties of a kart.
Definition: kart_properties.hpp:60
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:42