SuperTuxKart
online_user_search.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_ONLINE_USER_SEARCH_HPP
19 #define HEADER_ONLINE_USER_SEARCH_HPP
20 
21 #include "guiengine/screen.hpp"
22 #include "online/online_profile.hpp"
23 #include "utils/ptr_vector.hpp"
24 
25 namespace GUIEngine
26 {
27  class ButtonWidget; class IconButtonWidget; class ListWidget;
28  class TextBoxWidget; class Widget;
29 }
30 
31 namespace Online { class XMLRequest; }
32 
38  public GUIEngine::ScreenSingleton<OnlineUserSearch>
39 {
41 
42 private:
45 
54 
56  irr::core::stringw m_search_string;
58  irr::core::stringw m_last_search_string;
59 
61  Online::OnlineProfile::IDList m_users;
62 
64  std::shared_ptr<Online::XMLRequest> m_search_request;
65 
66  void parseResult(const XMLNode * input);
67  void showList();
68  void search();
69 
70 
71 public:
72 
74  virtual void loadedFromFile() OVERRIDE;
75 
77  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
78  const int playerID) OVERRIDE;
79 
81  virtual void beforeAddingWidget() OVERRIDE;
82 
83  virtual void init() OVERRIDE;
84 
85  virtual void tearDown() OVERRIDE;
86 
88  virtual void onUpdate(float dt) OVERRIDE;
89 
91  void setSearchString(const irr::core::stringw & search_string)
92  {
93  m_search_string = search_string;
94  }
95 
96 };
97 
98 #endif
A text button widget.
Definition: button_widget.hpp:41
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
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:94
A text field widget.
Definition: text_box_widget.hpp:53
Definition: online_user_search.hpp:39
void search()
Called when a search is triggered.
Definition: online_user_search.cpp:173
GUIEngine::TextBoxWidget * m_search_box_widget
Pointer to the search box.
Definition: online_user_search.hpp:51
void showList()
Takes the list of user ids from a query and shows it in the list gui.
Definition: online_user_search.cpp:147
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_user_search.cpp:73
void parseResult(const XMLNode *input)
Adds the results of the query to the ProfileManager cache.
Definition: online_user_search.cpp:109
Online::OnlineProfile::IDList m_users
The list of all IDs found.
Definition: online_user_search.hpp:61
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_user_search.cpp:195
virtual void init() OVERRIDE
Called when entering this menu (before widgets are added).
Definition: online_user_search.cpp:81
virtual void tearDown() OVERRIDE
Callback before the screen is removed.
Definition: online_user_search.cpp:91
GUIEngine::IconButtonWidget * m_back_widget
Pointer to the back widget.
Definition: online_user_search.hpp:47
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_user_search.cpp:58
GUIEngine::ButtonWidget * m_search_button_widget
Pointer to the search button.
Definition: online_user_search.hpp:49
irr::core::stringw m_last_search_string
Last search string, used to avoid doing the same search again.
Definition: online_user_search.hpp:58
std::shared_ptr< Online::XMLRequest > m_search_request
The online request to search for users.
Definition: online_user_search.hpp:64
GUIEngine::ListWidget * m_user_list_widget
Pointer to the result list.
Definition: online_user_search.hpp:53
void setSearchString(const irr::core::stringw &search_string)
Sets the search string to an initial value.
Definition: online_user_search.hpp:91
virtual void onUpdate(float dt) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_user_search.cpp:222
irr::core::stringw m_search_string
Seach string entered in the search widget.
Definition: online_user_search.hpp:56
utility class used to parse XML files
Definition: xml_node.hpp:48
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33