Show the connected players in the player list of the gui.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "online/online_profile.hpp"
|
||||
#include "states_screens/networking_lobby.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@@ -328,6 +329,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
// FIXME: memory leak??
|
||||
profile->setOnlineProfile(new Online::OnlineProfile(global_id, ""));
|
||||
m_setup->addPlayer(profile);
|
||||
NetworkingLobby::getInstance()->addPlayer(profile);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,6 +422,8 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
// connection token
|
||||
uint32_t token = data.gui32(3);
|
||||
peer->setClientServerToken(token);
|
||||
NetworkingLobby::getInstance()->addPlayer(profile);
|
||||
|
||||
|
||||
// Add all players
|
||||
// ===============
|
||||
@@ -444,6 +448,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
profile2->setOnlineProfile(new_user);
|
||||
m_setup->addPlayer(profile2);
|
||||
n += bytes_read+7;
|
||||
NetworkingLobby::getInstance()->addPlayer(profile2);
|
||||
}
|
||||
|
||||
// add self
|
||||
|
||||
@@ -27,10 +27,12 @@
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/list_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
@@ -71,6 +73,9 @@ void NetworkingLobby::loadedFromFile()
|
||||
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
|
||||
assert(m_bottom_menu_widget != NULL);
|
||||
|
||||
m_player_list = getWidget<ListWidget>("players");
|
||||
assert(m_player_list!= NULL);
|
||||
|
||||
m_exit_widget = (IconButtonWidget *) m_bottom_menu_widget
|
||||
->findWidgetNamed("exit");
|
||||
assert(m_exit_widget != NULL);
|
||||
@@ -169,3 +174,15 @@ void NetworkingLobby::onDialogClose()
|
||||
{
|
||||
setInitialFocus();
|
||||
} // onDialogClose()
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkingLobby::addPlayer(NetworkPlayerProfile *profile)
|
||||
{
|
||||
m_player_list->addItem(StringUtils::toString(profile->getPlayerID()),
|
||||
profile->getName());
|
||||
} // addPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkingLobby::removePlayer(NetworkPlayerProfile *profile)
|
||||
{
|
||||
} // removePlayer
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace GUIEngine {
|
||||
class RibbonWidget;
|
||||
}
|
||||
|
||||
class NetworkPlayerProfile;
|
||||
|
||||
/**
|
||||
* \brief Handles the main menu
|
||||
* \ingroup states_screens
|
||||
@@ -50,6 +52,7 @@ private:
|
||||
GUIEngine::RibbonWidget * m_bottom_menu_widget;
|
||||
GUIEngine::IconButtonWidget * m_exit_widget;
|
||||
GUIEngine::IconButtonWidget *m_start_button;
|
||||
GUIEngine::ListWidget *m_player_list;
|
||||
|
||||
/** \brief Sets which widget has to be focused. Depends on the user state. */
|
||||
void setInitialFocus();
|
||||
@@ -82,6 +85,9 @@ public:
|
||||
|
||||
/** \brief Implements the callback when a dialog gets closed. */
|
||||
virtual void onDialogClose() OVERRIDE;
|
||||
};
|
||||
|
||||
void addPlayer(NetworkPlayerProfile *profile);
|
||||
void removePlayer(NetworkPlayerProfile *profile);
|
||||
}; // class NetworkingLobby
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user