SuperTuxKart
Loading...
Searching...
No Matches
networking_lobby.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_NETWORKING_LOBBY_HPP
19#define HEADER_NETWORKING_LOBBY_HPP
20
21#include "guiengine/screen.hpp"
22#include "guiengine/widgets/text_box_widget.hpp"
23#include "GlyphLayout.h"
24#include <map>
25#include <memory>
26#include <utility>
27
28class Addon;
29class InputDevice;
30class Server;
31enum KartTeam : int8_t;
32struct LobbyPlayer;
33
34namespace GUIEngine
35{
36 class ButtonWidget;
37 class LabelWidget;
38 class ListWidget;
39 class IconButtonWidget;
40 class TextBoxWidget;
41}
42
43namespace irr
44{
45 namespace gui
46 {
47 class STKModifiedSpriteBank;
48 }
49}
50
56 public GUIEngine::ScreenSingleton<NetworkingLobby>,
58{
59private:
60 enum LobbyState
61 {
62 LS_ADD_PLAYERS,
63 LS_CONNECTING
64 } m_state;
65
67
69
70 uint64_t m_ping_update_timer;
71 std::map<std::string, LobbyPlayer> m_player_names;
72 std::shared_ptr<Server> m_joined_server;
73
74 std::vector<gui::GlyphLayout> m_server_info;
75 int m_server_info_height, m_header_text_width;
76
77 core::stringw m_start_text, m_ready_text, m_live_join_text,
78 m_configuration_text, m_spectate_text, m_install_addon_text,
79 m_header_text;
80
81 float m_start_timeout;
82 int64_t m_cur_starting_timer;
83 unsigned m_min_start_game_players;
84
85 bool m_has_auto_start_in_server,
86 m_server_configurable, m_client_live_joinable,
87 m_reload_server_info, m_assigned_players;
88
89 Addon* m_addon_install;
90 video::ITexture* m_config_texture;
91 video::ITexture* m_spectate_texture;
92 video::ITexture* m_addon_texture;
93
94 GUIEngine::IconButtonWidget* m_back_widget;
95 GUIEngine::LabelWidget* m_header;
96 GUIEngine::LabelWidget* m_text_bubble;
97 GUIEngine::LabelWidget* m_timeout_message;
98 GUIEngine::IconButtonWidget* m_start_button;
99 GUIEngine::IconButtonWidget* m_config_button;
100 GUIEngine::ListWidget* m_player_list;
101 GUIEngine::TextBoxWidget* m_chat_box;
102 GUIEngine::ButtonWidget* m_send_button;
103 GUIEngine::ButtonWidget* m_emoji_button;
104
105 irr::gui::STKModifiedSpriteBank* m_icon_bank;
106
108 virtual void unloaded() OVERRIDE;
109
110 virtual void onTextUpdated() OVERRIDE {}
111 virtual bool onEnterPressed(const irr::core::stringw& text) OVERRIDE;
112 void updatePlayerPings();
113
114public:
115
116 virtual void onUpdate(float delta) OVERRIDE;
117
119 virtual void loadedFromFile() OVERRIDE;
120
122 virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
123 const int playerID) OVERRIDE;
124
126 virtual void beforeAddingWidget() OVERRIDE;
127
129 virtual void init() OVERRIDE;
130
132 virtual void tearDown() OVERRIDE;
133
135 virtual bool onEscapePressed() OVERRIDE;
136
137 void finishAddingPlayers();
138 void addMoreServerInfo(core::stringw info);
139 void setJoinedServer(std::shared_ptr<Server> server);
140 void updateServerInfos();
141 void updatePlayers();
142 void openSplitscreenDialog(InputDevice* device);
143 void addSplitscreenPlayer(irr::core::stringw name);
144 void cleanAddedPlayers();
145 void initAutoStartTimer(bool grand_prix_started, unsigned min_players,
146 float start_timeout, unsigned server_max_player);
147 void setStartingTimerTo(float t);
148 void toggleServerConfigButton(bool val) { m_server_configurable = val; }
149 void reloadServerInfos() { m_reload_server_info = true; }
150 void setHeader(const core::stringw& header) { m_header_text = header; }
151 void setAssignedPlayers(bool val) { m_assigned_players = val; }
152}; // class NetworkingLobby
153
154#endif
Definition: addon.hpp:40
A text button widget.
Definition: button_widget.hpp:41
Definition: text_box_widget.hpp:42
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A simple label widget.
Definition: label_widget.hpp:36
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:97
A text field widget.
Definition: text_box_widget.hpp:53
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
base class for input devices
Definition: input_device.hpp:48
Handles the networking lobby.
Definition: networking_lobby.hpp:58
NetworkingLobby()
This is the lobby screen that is shown on all clients, but not on the server.
Definition: networking_lobby.cpp:78
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:164
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:103
virtual bool onEscapePressed() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:894
virtual void onUpdate(float delta) OVERRIDE
optional callback you can override to be notified at every frame.
Definition: networking_lobby.cpp:439
virtual void tearDown() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:876
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:784
virtual void unloaded() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:869
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: networking_lobby.cpp:173
Definition: server.hpp:44
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Definition: client_lobby.hpp:46