SuperTuxKart
Loading...
Searching...
No Matches
player_rankings_dialog.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
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#ifndef HEADER_PLAYER_RANKINGS_DIALOG_HPP
20#define HEADER_PLAYER_RANKINGS_DIALOG_HPP
21
22#include "guiengine/modaldialog.hpp"
23#include "utils/types.hpp"
24
25#include <irrString.h>
26#include <memory>
27#include <tuple>
28#include <vector>
29
30namespace GUIEngine
31{
32 class IconButtonWidget;
33 class LabelWidget;
34 class ListWidget;
35 class RibbonWidget;
36}
37
38class RankingCallback;
44{
45private:
46 const uint32_t m_online_id;
47
48 const core::stringw m_name;
49
50 bool m_self_destroy;
51
52 std::shared_ptr<RankingCallback> m_ranking_callback;
53
54 GUIEngine::RibbonWidget* m_options_widget;
55
56 GUIEngine::LabelWidget* m_ranking_info;
57
58 GUIEngine::ListWidget* m_top_ten;
59
60 GUIEngine::IconButtonWidget* m_refresh_widget;
61
62 GUIEngine::IconButtonWidget* m_ok_widget;
63
64 static std::vector<std::tuple</*rank*/int, /*user name*/core::stringw,
65 /*scores*/float> > m_rankings;
66
67 // ------------------------------------------------------------------------
68 void updateTopTenList();
69 // ------------------------------------------------------------------------
70 void fillTopTenList();
71
72public:
73 PlayerRankingsDialog(uint32_t online_id, const core::stringw& name);
74 // ------------------------------------------------------------------------
76 // ------------------------------------------------------------------------
77 virtual void beforeAddingWidgets();
78 // ------------------------------------------------------------------------
79 void onEnterPressedInternal() { m_self_destroy = true; }
80 // ------------------------------------------------------------------------
81 GUIEngine::EventPropagation processEvent(const std::string& source);
82 // ------------------------------------------------------------------------
83 virtual bool onEscapePressed()
84 {
85 m_self_destroy = true;
86 return false;
87 }
88 // ------------------------------------------------------------------------
89 virtual void onUpdate(float dt);
90};
91
92#endif
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A simple label widget.
Definition: label_widget.hpp:36
A vertical list widget with text entries.
Definition: list_widget.hpp:50
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
A static text/icons/tabs bar widget.
Definition: ribbon_widget.hpp:60
Dialog that handle user in network lobby.
Definition: player_rankings_dialog.hpp:44
virtual void onUpdate(float dt)
Override to be notified of updates.
Definition: player_rankings_dialog.cpp:137
GUIEngine::EventPropagation processEvent(const std::string &source)
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: player_rankings_dialog.cpp:160
virtual void beforeAddingWidgets()
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: player_rankings_dialog.cpp:59
virtual bool onEscapePressed()
Override to change what happens on escape pressed.
Definition: player_rankings_dialog.hpp:83
void updateTopTenList()
Definition: player_rankings_dialog.cpp:77
Definition: ranking_callback.hpp:31
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Declares the general types that are used by the network.