Make connect to server message stay longer if needed in lobby

This commit is contained in:
Benau 2018-06-03 15:24:36 +08:00
parent 490b865ddd
commit 2fe50ba0c4

View File

@ -34,9 +34,8 @@
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
#include "network/network_config.hpp"
#include "network/protocols/client_lobby.hpp"
#include "network/protocols/connect_to_server.hpp"
#include "network/protocols/server_lobby.hpp"
#include "network/protocols/lobby_protocol.hpp"
#include "network/server.hpp"
#include "network/stk_host.hpp"
#include "network/stk_peer.hpp"
@ -198,7 +197,9 @@ void NetworkingLobby::addMoreServerInfo(core::stringw info)
// ----------------------------------------------------------------------------
void NetworkingLobby::onUpdate(float delta)
{
if (m_state == LS_ADD_PLAYERS && NetworkConfig::get()->isClient())
if (NetworkConfig::get()->isServer())
return;
if (m_state == LS_ADD_PLAYERS)
{
m_text_bubble->setText(_("Everyone:\nPress the 'Select' button to "
"join the game"), true);
@ -215,7 +216,7 @@ void NetworkingLobby::onUpdate(float delta)
m_start_button->setVisible(false);
m_exit_widget->setVisible(true);
auto lp = LobbyProtocol::get<LobbyProtocol>();
if (!lp)
if (!lp || !lp->waitingForPlayers())
{
core::stringw connect_msg;
if (m_joined_server)
@ -223,7 +224,7 @@ void NetworkingLobby::onUpdate(float delta)
connect_msg = StringUtils::loadingDots(
_("Connecting to server %s", m_joined_server->getName()));
}
else if (NetworkConfig::get()->isClient())
else
{
connect_msg =
StringUtils::loadingDots(_("Finding a quick play server"));
@ -233,8 +234,7 @@ void NetworkingLobby::onUpdate(float delta)
}
else
{
if (m_server_peer.expired() && NetworkConfig::get()->isClient()
&& STKHost::existHost())
if (m_server_peer.expired() && STKHost::existHost())
m_server_peer = STKHost::get()->getServerPeerForClient();
core::stringw total_msg;
for (auto& string : m_server_info)
@ -244,8 +244,7 @@ void NetworkingLobby::onUpdate(float delta)
}
m_text_bubble->setText(total_msg, true);
}
if (NetworkConfig::get()->isClient())
{
if (STKHost::get()->isAuthorisedToControl())
{
m_start_button->setVisible(true);
@ -254,7 +253,7 @@ void NetworkingLobby::onUpdate(float delta)
const uint32_t ping = getServerPing();
if (ping != 0)
m_header->setText(_("Lobby (ping: %dms)", ping), false);
}
} // onUpdate
// ----------------------------------------------------------------------------