SuperTuxKart
online_screen.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2009-2015 Marianne Gagnon
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_SCREEN_HPP
19 #define HEADER_ONLINE_SCREEN_HPP
20 
21 #include "guiengine/screen.hpp"
22 #include "guiengine/widgets/list_widget.hpp"
23 
24 #include <memory>
25 #include <unordered_map>
26 
27 class Server;
28 class SocketAddress;
29 
30 namespace GUIEngine { class CheckBoxWidget; class ButtonWidget;
31  class IconButtonWidget; class STKModifiedSpriteBank; }
32 
38  public GUIEngine::ScreenSingleton<OnlineScreen>,
40 {
41 private:
43 
44  core::stringw m_online_string;
45 
46  core::stringw m_login_string;
47 
50 
53 
54  GUIEngine::CheckBoxWidget* m_enable_splitscreen;
55 
56  GUIEngine::ListWidget* m_news_list;
57 
58  std::shared_ptr<Server> m_entered_server;
59 
61  core::stringw m_entered_server_name;
62 
69 
70  irr::gui::STKModifiedSpriteBank
71  *m_icon_bank;
72 
73  std::unordered_map<std::string, std::string> m_news_links;
74 
75  OnlineScreen();
76 
77 public:
78 
79  virtual void onUpdate(float delta) OVERRIDE;
80 
82  virtual void loadedFromFile() OVERRIDE;
83 
84  virtual void unloaded() OVERRIDE;
85 
87  virtual void beforeAddingWidget() OVERRIDE;
88 
90  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
91  const int playerID) OVERRIDE;
92 
94  virtual void init() OVERRIDE;
95 
96  void loadList();
97 
98  virtual void onColumnClicked(int column_id, bool sort_desc, bool sort_default) OVERRIDE;
99 
101  virtual bool onEscapePressed() OVERRIDE;
102 
103  void setEnteredServerName(const core::stringw& name)
104  { m_entered_server_name = name; }
105 };
106 
107 #endif
A text button widget.
Definition: button_widget.hpp:41
A checkbox widget.
Definition: check_box_widget.hpp:34
Definition: list_widget.hpp:37
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
Handles the networking main menu.
Definition: online_screen.hpp:40
GUIEngine::IconButtonWidget * m_online
Keep the widget to avoid looking it up every frame.
Definition: online_screen.hpp:52
GUIEngine::ButtonWidget * m_user_id
Keep the widget to to the user name.
Definition: online_screen.hpp:49
virtual void onUpdate(float delta) OVERRIDE
optional callback you can override to be notified at every frame.
Definition: online_screen.cpp:213
int m_icon_news_headline
Icon for headline news.
Definition: online_screen.hpp:66
int m_icon_red_dot
Icon for unread news.
Definition: online_screen.hpp:64
virtual bool onEscapePressed() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_screen.cpp:360
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_screen.cpp:115
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_screen.cpp:74
int m_icon_news
Icon for normal news.
Definition: online_screen.hpp:68
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: online_screen.cpp:106
core::stringw m_entered_server_name
Save the previous successfully connected server name.
Definition: online_screen.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_screen.cpp:254
virtual void unloaded() OVERRIDE
Callback invoked when this screen is being unloaded.
Definition: online_screen.cpp:98
Definition: server.hpp:44
Describes a IPv4 or IPv6 address in sockaddr_in(6) format, suitable in using with sendto.
Definition: socket_address.hpp:47
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33