SuperTuxKart
Loading...
Searching...
No Matches
skill_level_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_SKILL_LEVEL_HPP
21#define HEADER_SKILL_LEVEL_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/icon_button_widget.hpp"
30#include "guiengine/widgets/progress_bar_widget.hpp"
31
32
33namespace GUIEngine
34{
39 class SkillLevelWidget : public Widget
40 {
43 virtual int getWidthNeededAroundLabel() const { return 35; }
44
47 virtual int getHeightNeededAroundLabel() const { return 4; }
48
50 int m_bar_x, m_bar_y, m_bar_h, m_bar_w;
51 int m_iconbutton_x, m_iconbutton_y, m_iconbutton_h, m_iconbutton_w;
52
53 int m_player_id;
54 //shall icon be display left of the skill bar?
55 bool m_display_icon;
56
57 public:
58
59 LEAK_CHECK()
60
61 IconButtonWidget* m_iconbutton;
62 ProgressBarWidget* m_bar;
63
64 SkillLevelWidget(core::recti area, const int player_id,
65 bool multiplayer, bool display_text,
66 const float value = 0);
67
68 virtual ~SkillLevelWidget() {};
69
70 // ------------------------------------------------------------------------
72 virtual void add();
73
74 // -------------------------------------------------------------------------
75
76 virtual void move(const int x, const int y, const int w, const int h);
77
78 // -------------------------------------------------------------------------
79
82 void setSize(const int x, const int y, const int w, const int h);
83
85 void setValue(const float value);
86
88 float getValue() {return m_bar->getValue(); };
89
91 void setLabel(const irr::core::stringw& label);
92
94 void setIcon(const irr::core::stringc& filepath);
95
97 const irr::core::stringw getLabel()
98 {
99 return m_iconbutton->getText();
100 }
101
103 void setDisplayIcon(bool display_icon);
104 };
105}
106
107#endif
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A progress bar widget.
Definition: progress_bar_widget.hpp:36
float getValue()
Get the current value of the widget.
Definition: progress_bar_widget.hpp:72
A skill level widget.
Definition: skill_level_widget.hpp:40
void setLabel(const irr::core::stringw &label)
Change the label of the widget.
virtual void add()
Add the widgets to the current screen.
Definition: skill_level_widget.cpp:83
const irr::core::stringw getLabel()
Get the current label of the widget.
Definition: skill_level_widget.hpp:97
void setIcon(const irr::core::stringc &filepath)
Change the image for the icon.
Definition: skill_level_widget.cpp:149
int m_bar_x
widget coordinates
Definition: skill_level_widget.hpp:50
virtual int getWidthNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: skill_level_widget.hpp:43
void setDisplayIcon(bool display_icon)
If the label should be displayed.
Definition: skill_level_widget.cpp:156
virtual int getHeightNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: skill_level_widget.hpp:47
float getValue()
Get the current values of the widget.
Definition: skill_level_widget.hpp:88
void setSize(const int x, const int y, const int w, const int h)
Sets the size of the widget as a whole, and placed children widgets inside itself.
Definition: skill_level_widget.cpp:116
virtual void move(const int x, const int y, const int w, const int h)
Call to resize/move the widget.
Definition: skill_level_widget.cpp:93
void setValue(const float value)
Change the value of the widget, it must be a percent.
Definition: skill_level_widget.cpp:142
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
const irr::core::stringw & getText() const
Returns the text of a widget.
Definition: widget.hpp:500
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33