SuperTuxKart
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 
27 namespace Online { class XMLRequest; }
28 
29 namespace GUIEngine
30 {
31  class CheckBoxWidget;
32  class IconButtonWidget;
33  class LabelWidget;
34 }
35 
36 namespace irr
37 {
38  namespace gui
39  {
40  class STKModifiedSpriteBank;
41  }
42 }
43 
44 class Server;
45 struct ServerList;
46 
52  public GUIEngine::ScreenSingleton<ServerSelection>,
55 {
56  friend class GUIEngine::ScreenSingleton<ServerSelection>;
57 
58 private:
59  ServerSelection();
60  ~ServerSelection();
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;
95 public:
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
Definition: server.hpp:43
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
A text field widget.
Definition: text_box_widget.hpp:52
Definition: three_d_animation.hpp:32
A checkbox widget.
Definition: check_box_widget.hpp:33
ServerSelection.
Definition: server_selection.hpp:51
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:43
Definition: servers_manager.hpp:39
Definition: list_widget.hpp:36
A vertical list widget with text entries.
Definition: list_widget.hpp:49
A simple label widget.
Definition: label_widget.hpp:35
Represents a single GUI screen.
Definition: screen.hpp:96
Definition: text_box_widget.hpp:41
Declares a class to be a singleton.
Definition: screen.hpp:58
Definition: player_manager.hpp:35
bool m_sort_desc
To check (and set) if sort order is descending.
Definition: server_selection.hpp:76