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 
23 #include <memory>
24 
25 class Server;
26 class SocketAddress;
27 
28 namespace GUIEngine { class CheckBoxWidget; class ListWidget;
29                       class ButtonWidget; class IconButtonWidget; }
30 
31 /**
32   * \brief Handles the networking main menu
33   * \ingroup states_screens
34   */
35 class OnlineScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OnlineScreen>
36 {
37 private:
38     friend class GUIEngine::ScreenSingleton<OnlineScreen>;
39 
40     core::stringw m_online_string;
41 
42     core::stringw m_login_string;
43 
44     /** Keep the widget to to the user name. */
45     GUIEngine::ButtonWidget *m_user_id;
46 
47     /** Keep the widget to avoid looking it up every frame. */
48     GUIEngine::IconButtonWidget* m_online;
49 
50     GUIEngine::CheckBoxWidget* m_enable_splitscreen;
51 
52     std::shared_ptr<Server> m_entered_server;
53 
54     /** Save the previous successfully connected server name. */
55     core::stringw m_entered_server_name;
56 
57     OnlineScreen();
58 
59 public:
60 
61     virtual void onUpdate(float delta) OVERRIDE;
62 
63     /** \brief implement callback from parent class GUIEngine::Screen */
64     virtual void loadedFromFile() OVERRIDE;
65 
66     /** \brief implement callback from parent class GUIEngine::Screen */
67     virtual void beforeAddingWidget() OVERRIDE;
68 
69     /** \brief implement callback from parent class GUIEngine::Screen */
70     virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
71                                const int playerID) OVERRIDE;
72 
73     /** \brief implement callback from parent class GUIEngine::Screen */
74     virtual void init() OVERRIDE;
75 
76     /** \brief implement callback from parent class GUIEngine::Screen */
77     virtual bool onEscapePressed() OVERRIDE;
78 
setEnteredServerName(const core::stringw & name)79     void setEnteredServerName(const core::stringw& name)
80                                               { m_entered_server_name = name; }
81 };
82 
83 #endif
84