Update lobby for new gui engine code
This commit is contained in:
parent
7b903a09ba
commit
571a524f59
@ -3,9 +3,11 @@
|
|||||||
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
|
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
|
||||||
<header text_align="center" width="80%" align="center" I18N="In networking lobby" text="Lobby"/>
|
<header text_align="center" width="80%" align="center" I18N="In networking lobby" text="Lobby"/>
|
||||||
<spacer height="15" width="10"/>
|
<spacer height="15" width="10"/>
|
||||||
<div proportion="3" x="2%" width="96%" layout="vertical-row">
|
<div proportion="4" x="2%" width="96%" layout="vertical-row">
|
||||||
<div width="100%" proportion="2" layout="horizontal-row">
|
<div width="100%" proportion="2" layout="horizontal-row">
|
||||||
<bubble id="text" proportion="3" height="100%"/>
|
<box id="info" proportion="2" height="100%" layout="vertical-row">
|
||||||
|
<label word_wrap="true" id="text" proportion="3" width="100%" height="100%" text_valign="top"/>
|
||||||
|
</box>
|
||||||
<spacer width="20" height="20"/>
|
<spacer width="20" height="20"/>
|
||||||
<box proportion="1" height="100%" layout="vertical-row">
|
<box proportion="1" height="100%" layout="vertical-row">
|
||||||
<list id="players" width="100%" height="100%"/>
|
<list id="players" width="100%" height="100%"/>
|
||||||
@ -15,13 +17,15 @@
|
|||||||
<spacer height="10"/>
|
<spacer height="10"/>
|
||||||
<div width="100%" proportion="1" layout="horizontal-row">
|
<div width="100%" proportion="1" layout="horizontal-row">
|
||||||
<spacer width="20" height="20"/>
|
<spacer width="20" height="20"/>
|
||||||
<box proportion="2" height="100%" layout="horizontal-row">
|
<box proportion="2" height="100%" layout="vertical-row">
|
||||||
<textbox id="chat" width="100%" height="25%"/>
|
<textbox id="chat" width="100%" height="30%"/>
|
||||||
|
<spacer height="20"/>
|
||||||
|
<button id="send_text" height="30%" width="fit" I18N="In the network lobby" text="Send text" />
|
||||||
</box>
|
</box>
|
||||||
<spacer width="20"/>
|
<spacer width="40"/>
|
||||||
<buttonbar id="actions" proportion="1" width="75%" height="75%">
|
<buttonbar id="actions" proportion="1" width="75%" height="75%">
|
||||||
<icon-button id="start" width="64" height="64" icon="gui/green_check.png" align="center"
|
<icon-button id="start" width="64" height="64" icon="gui/green_check.png" align="center"
|
||||||
I18N="In the network lobby" text="Start Race"/>
|
I18N="In the network lobby" text="Start race"/>
|
||||||
<icon-button id="exit" width="64" height="64" icon="gui/main_quit.png" align="center"
|
<icon-button id="exit" width="64" height="64" icon="gui/main_quit.png" align="center"
|
||||||
I18N="In the network lobby" text="Exit"/>
|
I18N="In the network lobby" text="Exit"/>
|
||||||
</buttonbar>
|
</buttonbar>
|
||||||
|
@ -56,8 +56,8 @@ ConnectToServer::ConnectToServer(uint32_t server_id, uint32_t host_id)
|
|||||||
m_server_id = server_id;
|
m_server_id = server_id;
|
||||||
m_host_id = host_id;
|
m_host_id = host_id;
|
||||||
m_quick_join = false;
|
m_quick_join = false;
|
||||||
const Server *server = ServersManager::get()->getServerByID(server_id);
|
m_server = ServersManager::get()->getServerByID(m_server_id);
|
||||||
m_server_address.copy(server->getAddress());
|
m_server_address.copy(m_server->getAddress());
|
||||||
setHandleConnections(true);
|
setHandleConnections(true);
|
||||||
} // ConnectToServer(server, host)
|
} // ConnectToServer(server, host)
|
||||||
|
|
||||||
@ -239,8 +239,7 @@ void ConnectToServer::update(float dt)
|
|||||||
{
|
{
|
||||||
// Shutdown STKHost (go back to online menu too)
|
// Shutdown STKHost (go back to online menu too)
|
||||||
STKHost::get()->setErrorMessage(
|
STKHost::get()->setErrorMessage(
|
||||||
_("Cannot connect to server with address: %s.",
|
_("Cannot connect to server %s.", m_server->getName()));
|
||||||
m_server_address.toString().c_str()));
|
|
||||||
STKHost::get()->requestShutdown();
|
STKHost::get()->requestShutdown();
|
||||||
}
|
}
|
||||||
requestTerminate();
|
requestTerminate();
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class Server;
|
||||||
|
|
||||||
class ConnectToServer : public Protocol
|
class ConnectToServer : public Protocol
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -34,6 +36,7 @@ private:
|
|||||||
uint32_t m_host_id;
|
uint32_t m_host_id;
|
||||||
unsigned m_tried_connection = 0;
|
unsigned m_tried_connection = 0;
|
||||||
|
|
||||||
|
const Server* m_server = NULL;
|
||||||
/** Protocol currently being monitored. */
|
/** Protocol currently being monitored. */
|
||||||
std::weak_ptr<Protocol> m_current_protocol;
|
std::weak_ptr<Protocol> m_current_protocol;
|
||||||
bool m_quick_join;
|
bool m_quick_join;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "guiengine/widgets/bubble_widget.hpp"
|
#include "guiengine/widgets/bubble_widget.hpp"
|
||||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||||
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "guiengine/widgets/list_widget.hpp"
|
#include "guiengine/widgets/list_widget.hpp"
|
||||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||||
#include "guiengine/widgets/text_box_widget.hpp"
|
#include "guiengine/widgets/text_box_widget.hpp"
|
||||||
@ -70,10 +71,10 @@ void NetworkingLobby::loadedFromFile()
|
|||||||
m_back_widget = getWidget<IconButtonWidget>("back");
|
m_back_widget = getWidget<IconButtonWidget>("back");
|
||||||
assert(m_back_widget != NULL);
|
assert(m_back_widget != NULL);
|
||||||
|
|
||||||
m_start_button= getWidget<IconButtonWidget>("start");
|
m_start_button = getWidget<IconButtonWidget>("start");
|
||||||
assert(m_start_button!= NULL);
|
assert(m_start_button!= NULL);
|
||||||
|
|
||||||
m_text_bubble = getWidget<BubbleWidget>("text");
|
m_text_bubble = getWidget<LabelWidget>("text");
|
||||||
assert(m_text_bubble != NULL);
|
assert(m_text_bubble != NULL);
|
||||||
|
|
||||||
m_chat_box = getWidget<TextBoxWidget>("chat");
|
m_chat_box = getWidget<TextBoxWidget>("chat");
|
||||||
@ -82,7 +83,7 @@ void NetworkingLobby::loadedFromFile()
|
|||||||
m_player_list = getWidget<ListWidget>("players");
|
m_player_list = getWidget<ListWidget>("players");
|
||||||
assert(m_player_list!= NULL);
|
assert(m_player_list!= NULL);
|
||||||
|
|
||||||
m_exit_widget = getWidget<IconButtonWidget>("exit");;
|
m_exit_widget = getWidget<IconButtonWidget>("exit");
|
||||||
assert(m_exit_widget != NULL);
|
assert(m_exit_widget != NULL);
|
||||||
|
|
||||||
} // loadedFromFile
|
} // loadedFromFile
|
||||||
@ -90,7 +91,6 @@ void NetworkingLobby::loadedFromFile()
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void NetworkingLobby::beforeAddingWidget()
|
void NetworkingLobby::beforeAddingWidget()
|
||||||
{
|
{
|
||||||
|
|
||||||
} // beforeAddingWidget
|
} // beforeAddingWidget
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -121,8 +121,7 @@ void NetworkingLobby::init()
|
|||||||
m_server_info.push_back(each_line);
|
m_server_info.push_back(each_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NetworkConfig::get()->isServer())
|
m_start_button->setVisible(false);
|
||||||
m_start_button->setVisible(STKHost::get()->isAuthorisedToControl());
|
|
||||||
|
|
||||||
// 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.
|
||||||
@ -144,7 +143,8 @@ void NetworkingLobby::onUpdate(float delta)
|
|||||||
{
|
{
|
||||||
const core::stringw connect_msg = StringUtils::loadingDots(
|
const core::stringw connect_msg = StringUtils::loadingDots(
|
||||||
_("Connecting to server %s", m_server_name));
|
_("Connecting to server %s", m_server_name));
|
||||||
m_text_bubble->setText(connect_msg);
|
m_text_bubble->setText(connect_msg, true);
|
||||||
|
m_start_button->setVisible(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -154,12 +154,12 @@ void NetworkingLobby::onUpdate(float delta)
|
|||||||
total_msg += string;
|
total_msg += string;
|
||||||
total_msg += L"\n";
|
total_msg += L"\n";
|
||||||
}
|
}
|
||||||
m_text_bubble->setText(total_msg);
|
m_text_bubble->setText(total_msg, true);
|
||||||
}
|
}
|
||||||
if(NetworkConfig::get()->isClient())
|
if (NetworkConfig::get()->isClient() &&
|
||||||
|
STKHost::get()->isAuthorisedToControl())
|
||||||
{
|
{
|
||||||
m_start_button->setVisible(STKHost::existHost() &&
|
m_start_button->setVisible(true);
|
||||||
STKHost::get()->isAuthorisedToControl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // onUpdate
|
} // onUpdate
|
||||||
@ -175,14 +175,23 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name==m_start_button->m_properties[PROP_ID])
|
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
||||||
|
if (ribbon == NULL) return;
|
||||||
|
const std::string &selection =
|
||||||
|
ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||||
|
|
||||||
|
if (selection == m_exit_widget->m_properties[PROP_ID])
|
||||||
{
|
{
|
||||||
if(NetworkConfig::get()->isServer())
|
StateManager::get()->escapePressed();
|
||||||
|
}
|
||||||
|
else if (selection == m_start_button->m_properties[PROP_ID])
|
||||||
|
{
|
||||||
|
if (NetworkConfig::get()->isServer())
|
||||||
{
|
{
|
||||||
auto slrp = LobbyProtocol::get<ServerLobby>();
|
auto slrp = LobbyProtocol::get<ServerLobby>();
|
||||||
slrp->startSelection();
|
slrp->startSelection();
|
||||||
}
|
}
|
||||||
else // client
|
else
|
||||||
{
|
{
|
||||||
// Send a message to the server to start
|
// Send a message to the server to start
|
||||||
NetworkString start(PROTOCOL_LOBBY_ROOM);
|
NetworkString start(PROTOCOL_LOBBY_ROOM);
|
||||||
@ -191,16 +200,6 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
|
|||||||
STKHost::get()->sendToServer(&start, true);
|
STKHost::get()->sendToServer(&start, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
|
|
||||||
if (ribbon == NULL) return;
|
|
||||||
const std::string &selection =
|
|
||||||
ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
|
||||||
|
|
||||||
if (selection == m_exit_widget->m_properties[PROP_ID])
|
|
||||||
{
|
|
||||||
StateManager::get()->escapePressed();
|
|
||||||
}
|
|
||||||
} // eventCallback
|
} // eventCallback
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -25,9 +25,9 @@ class Server;
|
|||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
class Widget;
|
class Widget;
|
||||||
class ListWidget;
|
class LabelWidget;
|
||||||
|
class ListWidget;
|
||||||
class IconButtonWidget;
|
class IconButtonWidget;
|
||||||
class BubbleWidget;
|
|
||||||
class TextBoxWidget;
|
class TextBoxWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ private:
|
|||||||
std::vector<core::stringw> m_server_info;
|
std::vector<core::stringw> m_server_info;
|
||||||
|
|
||||||
GUIEngine::IconButtonWidget * m_back_widget;
|
GUIEngine::IconButtonWidget * m_back_widget;
|
||||||
GUIEngine::BubbleWidget * m_text_bubble;
|
GUIEngine::LabelWidget * m_text_bubble;
|
||||||
GUIEngine::IconButtonWidget * m_exit_widget;
|
GUIEngine::IconButtonWidget * m_exit_widget;
|
||||||
GUIEngine::IconButtonWidget *m_start_button;
|
GUIEngine::IconButtonWidget *m_start_button;
|
||||||
GUIEngine::ListWidget *m_player_list;
|
GUIEngine::ListWidget *m_player_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user