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 
51  public GUIEngine::ScreenSingleton<ServerSelection>,
54 {
56 
57 private:
60 
61  std::vector<std::shared_ptr<Server> > m_servers;
62 
63  GUIEngine::CheckBoxWidget* m_private_server;
65  GUIEngine::IconButtonWidget* m_reload_widget;
66  GUIEngine::LabelWidget* m_update_status;
67  GUIEngine::ListWidget* m_server_list_widget;
68  GUIEngine::TextBoxWidget* m_searcher;
69  irr::gui::STKModifiedSpriteBank* m_icon_bank;
70 
73 
74  int m_current_column;
75 
76  bool m_refreshing_server;
77 
78  float m_refresh_timer;
79 
81  void loadList();
82 
83  void copyFromServersManager();
84 
85  void refresh(bool full_refresh);
86 
87 public:
89  virtual void loadedFromFile() OVERRIDE;
90 
92  virtual void eventCallback(GUIEngine::Widget* widget,
93  const std::string& name,
94  const int playerID) OVERRIDE;
95 
97  virtual void beforeAddingWidget() OVERRIDE;
98 
99  virtual void onColumnClicked(int column_id, bool sort_desc,
100  bool sort_default) OVERRIDE;
101 
102  virtual void init() OVERRIDE;
103 
104  virtual void tearDown() OVERRIDE;
105 
106  virtual void unloaded() OVERRIDE;
107 
109  virtual void onUpdate(float dt) OVERRIDE;
110 
111  virtual void onTextUpdated() OVERRIDE { copyFromServersManager(); }
112 
113  virtual bool onEnterPressed(const irr::core::stringw& text) OVERRIDE
114  { return false; }
115 
116 }; // ServerSelection
117 
118 #endif
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:91
Definition: server.hpp:43
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
virtual void tearDown() OVERRIDE
Clean up.
Definition: server_selection.cpp:64
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:301
A text field widget.
Definition: text_box_widget.hpp:52
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:112
A checkbox widget.
Definition: check_box_widget.hpp:33
ServerSelection.
Definition: server_selection.hpp:50
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:43
void refresh(bool full_refresh)
Requests the servers manager to update its list of servers, and disables the 'refresh' button (till t...
Definition: server_selection.cpp:75
void loadList()
Load the servers into the main list.
Definition: server_selection.cpp:198
virtual void init() OVERRIDE
Triggers a refresh of the server list.
Definition: server_selection.cpp:133
virtual void onUpdate(float dt) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: server_selection.cpp:340
Definition: list_widget.hpp:36
~ServerSelection()
Destructor.
Definition: server_selection.cpp:57
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:94
Definition: text_box_widget.hpp:41
Declares a class to be a singleton.
Definition: screen.hpp:57
virtual void unloaded() OVERRIDE
Callback invoked when this screen is being unloaded.
Definition: server_selection.cpp:430
bool m_sort_desc
To check (and set) if sort order is descending.
Definition: server_selection.hpp:72
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:284
ServerSelection()
Constructor, which loads the stkgui file.
Definition: server_selection.cpp:48