SuperTuxKart
Loading...
Searching...
No Matches
server_selection.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2013-2015 Glenn De Jonghe
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#ifndef HEADER_SERVER_SELECTION_HPP
19#define HEADER_SERVER_SELECTION_HPP
20
21#include "guiengine/screen.hpp"
22#include "guiengine/widgets/list_widget.hpp"
23#include "guiengine/widgets/text_box_widget.hpp"
24
25#include <memory>
26
27namespace Online { class XMLRequest; }
28
29namespace GUIEngine
30{
31 class CheckBoxWidget;
32 class IconButtonWidget;
33 class LabelWidget;
34}
35
36namespace irr
37{
38 namespace gui
39 {
40 class STKModifiedSpriteBank;
41 }
42}
43
44class Server;
45struct ServerList;
46
52 public GUIEngine::ScreenSingleton<ServerSelection>,
55{
57
58private:
61
62 std::vector<std::shared_ptr<Server> > m_servers;
63
64 GUIEngine::CheckBoxWidget* m_private_server;
66 GUIEngine::IconButtonWidget* m_reload_widget;
67 GUIEngine::IconButtonWidget* m_bookmark_widget;
68 video::ITexture* m_bookmark_icon;
69 video::ITexture* m_global_icon;
70 GUIEngine::LabelWidget* m_update_status;
71 GUIEngine::ListWidget* m_server_list_widget;
72 GUIEngine::TextBoxWidget* m_searcher;
73 irr::gui::STKModifiedSpriteBank* m_icon_bank;
74
77
78 int m_current_column;
79
80 bool m_refreshing_server;
81
82 float m_refresh_timer;
83
85 void loadList();
86
87 void updateHeader();
88
89 void refresh();
90
91 bool m_ipv6_only_without_nat64;
92 bool m_ip_warning_shown;
93 int64_t m_last_load_time;
94 std::shared_ptr<ServerList> m_server_list;
95public:
97 virtual void loadedFromFile() OVERRIDE;
98
100 virtual void eventCallback(GUIEngine::Widget* widget,
101 const std::string& name,
102 const int playerID) OVERRIDE;
103
105 virtual void beforeAddingWidget() OVERRIDE;
106
107 virtual void onColumnClicked(int column_id, bool sort_desc,
108 bool sort_default) OVERRIDE;
109
110 virtual void init() OVERRIDE;
111
112 virtual void tearDown() OVERRIDE;
113
114 virtual void unloaded() OVERRIDE;
115
117 virtual void onUpdate(float dt) OVERRIDE;
118
119 virtual void onTextUpdated() OVERRIDE { copyFromServerList(); }
120
121 virtual bool onEnterPressed(const irr::core::stringw& text) OVERRIDE
122 { return false; }
123
124 void copyFromServerList();
125
126 GUIEngine::ListWidget* getServerList() const
127 { return m_server_list_widget; }
128}; // ServerSelection
129
130#endif
A checkbox widget.
Definition: check_box_widget.hpp:34
Definition: list_widget.hpp:37
Definition: text_box_widget.hpp:42
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
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:97
A text field widget.
Definition: text_box_widget.hpp:53
ServerSelection.
Definition: server_selection.hpp:55
virtual void init() OVERRIDE
Triggers a refresh of the server list.
Definition: server_selection.cpp:152
bool m_sort_desc
To check (and set) if sort order is descending.
Definition: server_selection.hpp:76
void refresh()
Requests the servers manager to update its list of servers, and disables the 'refresh' button (till t...
Definition: server_selection.cpp:80
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:353
virtual void unloaded() OVERRIDE
Callback invoked when this screen is being unloaded.
Definition: server_selection.cpp:556
ServerSelection()
Constructor, which loads the stkgui file.
Definition: server_selection.cpp:49
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:101
void loadList()
Load the servers into the main list.
Definition: server_selection.cpp:220
virtual void onColumnClicked(int column_id, bool sort_desc, bool sort_default) OVERRIDE
Change the sort order if a column was clicked.
Definition: server_selection.cpp:336
~ServerSelection()
Destructor.
Definition: server_selection.cpp:60
virtual void tearDown() OVERRIDE
Clean up.
Definition: server_selection.cpp:67
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:128
virtual void onUpdate(float dt) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:416
Definition: server.hpp:44
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Definition: servers_manager.hpp:40