Use icon to identify server owner, online and offline players
Also hide the friend request button for offline players
This commit is contained in:
parent
95208967cf
commit
d527c0eee2
@ -20,7 +20,7 @@
|
|||||||
<box proportion="2" height="100%" layout="vertical-row">
|
<box proportion="2" height="100%" layout="vertical-row">
|
||||||
<textbox id="chat" width="100%" height="30%"/>
|
<textbox id="chat" width="100%" height="30%"/>
|
||||||
<spacer height="20"/>
|
<spacer height="20"/>
|
||||||
<button id="send_text" height="30%" width="fit" I18N="In the network lobby" text="Send text" />
|
<button id="send_text" height="30%" width="fit" I18N="In the network lobby" text="Send" />
|
||||||
</box>
|
</box>
|
||||||
<spacer width="40"/>
|
<spacer width="40"/>
|
||||||
<buttonbar id="actions" proportion="1" width="75%" height="75%">
|
<buttonbar id="actions" proportion="1" width="75%" height="75%">
|
||||||
|
@ -118,11 +118,9 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
uint32_t getOnlineID() const { return m_online_id; }
|
uint32_t getOnlineID() const { return m_online_id; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
std::shared_ptr<STKPeer> getPeer() const { return m_peer.lock(); }
|
bool isOfflineAccount() const { return m_online_id == 0; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the minimun info for networking lobby screen. */
|
std::shared_ptr<STKPeer> getPeer() const { return m_peer.lock(); }
|
||||||
std::tuple<uint32_t, uint32_t, irr::core::stringw> toTuple() const
|
|
||||||
{ return std::make_tuple(m_host_id, m_online_id, m_player_name); }
|
|
||||||
|
|
||||||
}; // class NetworkPlayerProfile
|
}; // class NetworkPlayerProfile
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ bool ClientLobby::notifyEventAsynchronous(Event* event)
|
|||||||
case LE_VOTE_TRACK: playerTrackVote(event); break;
|
case LE_VOTE_TRACK: playerTrackVote(event); break;
|
||||||
case LE_VOTE_REVERSE: playerReversedVote(event); break;
|
case LE_VOTE_REVERSE: playerReversedVote(event); break;
|
||||||
case LE_VOTE_LAPS: playerLapsVote(event); break;
|
case LE_VOTE_LAPS: playerLapsVote(event); break;
|
||||||
case LE_AUTHORISED: becomingServerOwner(); break;
|
case LE_SERVER_OWNERSHIP: becomingServerOwner(); break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -456,16 +456,19 @@ void ClientLobby::updatePlayerList(Event* event)
|
|||||||
if (!checkDataSize(event, 1)) return;
|
if (!checkDataSize(event, 1)) return;
|
||||||
NetworkString& data = event->data();
|
NetworkString& data = event->data();
|
||||||
unsigned player_count = data.getUInt8();
|
unsigned player_count = data.getUInt8();
|
||||||
NetworkingLobby::getInstance()->cleanPlayers();
|
std::vector<std::tuple<uint32_t, uint32_t, core::stringw, int> > players;
|
||||||
for (unsigned i = 0; i < player_count; i++)
|
for (unsigned i = 0; i < player_count; i++)
|
||||||
{
|
{
|
||||||
std::tuple<uint32_t, uint32_t, core::stringw, bool> pl;
|
std::tuple<uint32_t, uint32_t, core::stringw, int> pl;
|
||||||
std::get<0>(pl) = data.getUInt32();
|
std::get<0>(pl) = data.getUInt32();
|
||||||
std::get<1>(pl) = data.getUInt32();
|
std::get<1>(pl) = data.getUInt32();
|
||||||
data.decodeStringW(&std::get<2>(pl));
|
data.decodeStringW(&std::get<2>(pl));
|
||||||
std::get<3>(pl) = data.getUInt8() == 1;
|
// icon to be used, see NetworkingLobby::loadedFromFile
|
||||||
NetworkingLobby::getInstance()->addPlayer(pl);
|
std::get<3>(pl) = data.getUInt8() == 1 /*if server owner*/ ? 0 :
|
||||||
|
std::get<1>(pl) != 0 /*if online account*/ ? 1 : 2;
|
||||||
|
players.push_back(pl);
|
||||||
}
|
}
|
||||||
|
NetworkingLobby::getInstance()->updatePlayers(players);
|
||||||
} // updatePlayerList
|
} // updatePlayerList
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
LE_VOTE_LAPS, // vote number of laps
|
LE_VOTE_LAPS, // vote number of laps
|
||||||
LE_CHAT,
|
LE_CHAT,
|
||||||
LE_FINAL_PLAYER_LIST,
|
LE_FINAL_PLAYER_LIST,
|
||||||
LE_AUTHORISED,
|
LE_SERVER_OWNERSHIP,
|
||||||
LE_KICK_HOST
|
LE_KICK_HOST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ void ServerLobby::kickHost(Event* event)
|
|||||||
if (m_server_owner.lock() != event->getPeerSP())
|
if (m_server_owner.lock() != event->getPeerSP())
|
||||||
return;
|
return;
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
if (!checkDataSize(event, 4)) return;
|
||||||
NetworkString& data = event->data();
|
NetworkString& data = event->data();
|
||||||
uint32_t host_id = data.getUInt32();
|
uint32_t host_id = data.getUInt32();
|
||||||
std::shared_ptr<STKPeer> peer = STKHost::get()->findPeerByHostId(host_id);
|
std::shared_ptr<STKPeer> peer = STKHost::get()->findPeerByHostId(host_id);
|
||||||
@ -872,7 +873,7 @@ void ServerLobby::updateServerOwner()
|
|||||||
if (owner)
|
if (owner)
|
||||||
{
|
{
|
||||||
NetworkString* ns = getNetworkString();
|
NetworkString* ns = getNetworkString();
|
||||||
ns->addUInt8(LE_AUTHORISED);
|
ns->addUInt8(LE_SERVER_OWNERSHIP);
|
||||||
owner->sendPacket(ns);
|
owner->sendPacket(ns);
|
||||||
delete ns;
|
delete ns;
|
||||||
m_server_owner = owner;
|
m_server_owner = owner;
|
||||||
|
@ -47,6 +47,7 @@ void NetworkUserDialog::beforeAddingWidgets()
|
|||||||
|
|
||||||
m_friend_widget = getWidget<IconButtonWidget>("friend");
|
m_friend_widget = getWidget<IconButtonWidget>("friend");
|
||||||
assert(m_friend_widget != NULL);
|
assert(m_friend_widget != NULL);
|
||||||
|
m_friend_widget->setVisible(m_online_id != 0);
|
||||||
m_kick_widget = getWidget<IconButtonWidget>("decline");
|
m_kick_widget = getWidget<IconButtonWidget>("decline");
|
||||||
assert(m_kick_widget != NULL);
|
assert(m_kick_widget != NULL);
|
||||||
|
|
||||||
|
@ -15,16 +15,12 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#define DEBUG_MENU_ITEM 0
|
|
||||||
|
|
||||||
#include "states_screens/networking_lobby.hpp"
|
#include "states_screens/networking_lobby.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "challenges/unlock_manager.hpp"
|
|
||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "guiengine/widgets/bubble_widget.hpp"
|
#include "guiengine/CGUISpriteBank.hpp"
|
||||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "guiengine/widgets/list_widget.hpp"
|
#include "guiengine/widgets/list_widget.hpp"
|
||||||
@ -86,6 +82,18 @@ void NetworkingLobby::loadedFromFile()
|
|||||||
m_exit_widget = getWidget<IconButtonWidget>("exit");
|
m_exit_widget = getWidget<IconButtonWidget>("exit");
|
||||||
assert(m_exit_widget != NULL);
|
assert(m_exit_widget != NULL);
|
||||||
|
|
||||||
|
m_icon_bank = new irr::gui::STKModifiedSpriteBank(GUIEngine::getGUIEnv());
|
||||||
|
video::ITexture* icon_1 = irr_driver->getTexture
|
||||||
|
(file_manager->getAsset(FileManager::GUI, "cup_gold.png"));
|
||||||
|
video::ITexture* icon_2 = irr_driver->getTexture
|
||||||
|
(file_manager->getAsset(FileManager::GUI, "difficulty_medium.png"));
|
||||||
|
video::ITexture* icon_3 = irr_driver->getTexture
|
||||||
|
(file_manager->getAsset(FileManager::GUI, "main_help.png"));
|
||||||
|
m_icon_bank->addTextureAsSprite(icon_1);
|
||||||
|
m_icon_bank->addTextureAsSprite(icon_2);
|
||||||
|
m_icon_bank->addTextureAsSprite(icon_3);
|
||||||
|
const int screen_width = irr_driver->getFrameSize().Width;
|
||||||
|
m_icon_bank->setScale(screen_width > 1280 ? 0.4f : 0.25f);
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -105,7 +113,8 @@ void NetworkingLobby::init()
|
|||||||
|
|
||||||
// For now create the active player and bind it to the right
|
// For now create the active player and bind it to the right
|
||||||
// input device.
|
// input device.
|
||||||
InputDevice *device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
InputDevice* device =
|
||||||
|
input_manager->getDeviceManager()->getLatestUsedDevice();
|
||||||
PlayerProfile* profile = PlayerManager::getCurrentPlayer();
|
PlayerProfile* profile = PlayerManager::getCurrentPlayer();
|
||||||
StateManager::get()->createActivePlayer(profile, device);
|
StateManager::get()->createActivePlayer(profile, device);
|
||||||
} // init
|
} // init
|
||||||
@ -241,6 +250,13 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
|
|||||||
|
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void NetworkingLobby::unloaded()
|
||||||
|
{
|
||||||
|
delete m_icon_bank;
|
||||||
|
m_icon_bank = NULL;
|
||||||
|
} // unloaded
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void NetworkingLobby::tearDown()
|
void NetworkingLobby::tearDown()
|
||||||
@ -248,7 +264,6 @@ void NetworkingLobby::tearDown()
|
|||||||
} // tearDown
|
} // tearDown
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool NetworkingLobby::onEscapePressed()
|
bool NetworkingLobby::onEscapePressed()
|
||||||
{
|
{
|
||||||
STKHost::get()->shutdown();
|
STKHost::get()->shutdown();
|
||||||
@ -256,25 +271,29 @@ bool NetworkingLobby::onEscapePressed()
|
|||||||
} // onEscapePressed
|
} // onEscapePressed
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void NetworkingLobby::addPlayer(const std::tuple<uint32_t, uint32_t,
|
void NetworkingLobby::updatePlayers(const std::vector<std::tuple<uint32_t,
|
||||||
core::stringw, bool>& p)
|
uint32_t, core::stringw, int> >& p)
|
||||||
{
|
{
|
||||||
// In GUI-less server this function will be called without proper
|
// In GUI-less server this function will be called without proper
|
||||||
// initialisation
|
// initialisation
|
||||||
if (m_player_list)
|
if (!m_player_list)
|
||||||
{
|
return;
|
||||||
const std::string internal_name =
|
|
||||||
StringUtils::toString(std::get<0>(p)) + "_" +
|
|
||||||
StringUtils::toString(std::get<1>(p));
|
|
||||||
m_player_list->addItem(internal_name, std::get<2>(p));
|
|
||||||
if (std::get<3>(p))
|
|
||||||
m_player_list->markItemBlue(internal_name, true);
|
|
||||||
}
|
|
||||||
} // addPlayer
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
void NetworkingLobby::cleanPlayers()
|
|
||||||
{
|
|
||||||
if (m_player_list)
|
|
||||||
m_player_list->clear();
|
m_player_list->clear();
|
||||||
} // cleanPlayers
|
|
||||||
|
if (p.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
irr::gui::STKModifiedSpriteBank* icon_bank = m_icon_bank;
|
||||||
|
for (auto& q : p)
|
||||||
|
{
|
||||||
|
if (icon_bank)
|
||||||
|
{
|
||||||
|
m_player_list->setIcons(icon_bank);
|
||||||
|
icon_bank = NULL;
|
||||||
|
}
|
||||||
|
const std::string internal_name =
|
||||||
|
StringUtils::toString(std::get<0>(q)) + "_" +
|
||||||
|
StringUtils::toString(std::get<1>(q));
|
||||||
|
m_player_list->addItem(internal_name, std::get<2>(q), std::get<3>(q));
|
||||||
|
}
|
||||||
|
} // updatePlayers
|
||||||
|
@ -33,6 +33,14 @@ namespace GUIEngine
|
|||||||
class TextBoxWidget;
|
class TextBoxWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace irr
|
||||||
|
{
|
||||||
|
namespace gui
|
||||||
|
{
|
||||||
|
class STKModifiedSpriteBank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Handles the networking lobby
|
* \brief Handles the networking lobby
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
@ -55,6 +63,11 @@ private:
|
|||||||
GUIEngine::ListWidget *m_player_list;
|
GUIEngine::ListWidget *m_player_list;
|
||||||
GUIEngine::TextBoxWidget* m_chat_box;
|
GUIEngine::TextBoxWidget* m_chat_box;
|
||||||
|
|
||||||
|
irr::gui::STKModifiedSpriteBank* m_icon_bank;
|
||||||
|
|
||||||
|
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
||||||
|
virtual void unloaded();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void onUpdate(float delta) OVERRIDE;
|
virtual void onUpdate(float delta) OVERRIDE;
|
||||||
@ -81,9 +94,9 @@ public:
|
|||||||
/** Used to insert each client chat message (reserved). */
|
/** Used to insert each client chat message (reserved). */
|
||||||
void addMoreServerInfo(const core::stringw& info);
|
void addMoreServerInfo(const core::stringw& info);
|
||||||
void setJoinedServer(std::shared_ptr<Server> server);
|
void setJoinedServer(std::shared_ptr<Server> server);
|
||||||
void addPlayer(const std::tuple<uint32_t/*host id*/, uint32_t/*online id*/,
|
void updatePlayers(const std::vector<std::tuple<uint32_t/*host id*/,
|
||||||
core::stringw/*player name*/, bool/*is server owner*/>& p);
|
uint32_t/*online id*/, core::stringw/*player name*/,
|
||||||
void cleanPlayers();
|
int/*icon id*/> >& p);
|
||||||
}; // class NetworkingLobby
|
}; // class NetworkingLobby
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user