Update networking lobbdy for better display info

This commit is contained in:
Benau 2018-02-25 02:09:07 +08:00
parent 2a117d8e44
commit 34caab24fe
3 changed files with 71 additions and 81 deletions

View File

@ -3,58 +3,30 @@
<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"/>
<spacer height="15" width="10"/>
<div proportion="1" x="2%" width="96%" layout="vertical-row">
<div proportion="3" x="2%" width="96%" layout="vertical-row">
<div width="100%" proportion="2" layout="horizontal-row">
<box id="info" proportion="2" height="100%" layout="vertical-row">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the networking lobby" text="Server name:"/>
<label proportion="2" text_align="left" id="server_name" text=""/>
</div>
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the networking lobby" text="Difficulty:"/>
<label proportion="2" text_align="left" id="server_difficulty" text=""/>
</div>
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the networking lobby" text="Game mode:"/>
<label proportion="2" text_align="left" id="server_game_mode" text=""/>
</div>
</box>
<bubble id="text" proportion="3" height="100%"/>
<spacer width="20" height="20"/>
<box proportion="1" height="100%" layout="vertical-row">
<list id="players" width="100%" height="100%"/>
</box>
</div>
<spacer width="20" height="20"/>
<div width="100%" proportion="1" layout="horizontal-row">
<box proportion="2" height="100%" layout="vertical-row">
<list id="chat" width="100%" height="100%"/>
</box>
<spacer width="20" height="20"/>
<box id="actions" proportion="1" height="100%" layout="vertical-row">
<!-- <label I18N="In networking lobby" word_wrap="true" text="actions" align="center" text-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"/>
</box>
</div>
</div>
<spacer width="10" height="7%"/>
<bottombar x="2%" width="96%" height="10%" layout="horizontal-row">
<label text_align="left" align="center" height="100%" id="online_status" proportion="1" text=""/>
<spacer width="10" height="10" />
<buttonbar id="menu_bottomrow" x="0" y="0" width="20%" height="100%" align="center">
<icon-button id="exit" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
I18N="In the networking lobby" text="Exit" label_location="hover"/>
<spacer height="10"/>
<div width="100%" proportion="1" layout="horizontal-row">
<spacer width="20" height="20"/>
<box proportion="2" height="100%" layout="horizontal-row">
<textbox id="chat" width="100%" height="25%"/>
</box>
<spacer width="20"/>
<buttonbar id="actions" proportion="1" width="75%" height="75%">
<icon-button id="start" width="64" height="64" icon="gui/green_check.png" align="center"
I18N="In the network lobby" text="Start Race"/>
<icon-button id="exit" width="64" height="64" icon="gui/main_quit.png" align="center"
I18N="In the network lobby" text="Exit"/>
</buttonbar>
</bottombar>
</div>
<spacer height="10"/>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -24,12 +24,11 @@
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/bubble_widget.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 "guiengine/widgets/text_box_widget.hpp"
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
@ -61,7 +60,6 @@ DEFINE_SCREEN_SINGLETON( NetworkingLobby );
// ----------------------------------------------------------------------------
NetworkingLobby::NetworkingLobby() : Screen("online/networking_lobby.stkgui")
{
m_server = NULL;
m_player_list = NULL;
} // NetworkingLobby
@ -75,26 +73,16 @@ void NetworkingLobby::loadedFromFile()
m_start_button= getWidget<IconButtonWidget>("start");
assert(m_start_button!= NULL);
m_server_name_widget = getWidget<LabelWidget>("server_name");
assert(m_server_name_widget != NULL);
m_text_bubble = getWidget<BubbleWidget>("text");
assert(m_text_bubble != NULL);
m_server_difficulty = getWidget<LabelWidget>("server_difficulty");
assert(m_server_difficulty != NULL);
m_server_game_mode = getWidget<LabelWidget>("server_game_mode");
assert(m_server_game_mode != NULL);
m_online_status_widget = getWidget<LabelWidget>("online_status");
assert(m_online_status_widget != NULL);
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
assert(m_bottom_menu_widget != NULL);
m_chat_box = getWidget<TextBoxWidget>("chat");
assert(m_chat_box != NULL);
m_player_list = getWidget<ListWidget>("players");
assert(m_player_list!= NULL);
m_exit_widget = (IconButtonWidget *) m_bottom_menu_widget
->findWidgetNamed("exit");
m_exit_widget = getWidget<IconButtonWidget>("exit");;
assert(m_exit_widget != NULL);
} // loadedFromFile
@ -112,18 +100,25 @@ void NetworkingLobby::beforeAddingWidget()
*/
void NetworkingLobby::init()
{
m_server_info.clear();
Screen::init();
setInitialFocus();
m_server = ServersManager::get()->getJoinedServer();
if (m_server)
Server* server = ServersManager::get()->getJoinedServer();
if (server)
{
m_server_name_widget->setText(m_server->getName(), false);
m_server_name = server->getName();
core::stringw each_line;
each_line = _("Server name: %s", m_server_name);
m_server_info.push_back(each_line);
core::stringw difficulty = race_manager->getDifficultyName(m_server->getDifficulty());
m_server_difficulty->setText(difficulty, false);
const core::stringw& difficulty_name =
race_manager->getDifficultyName(race_manager->getDifficulty());
each_line = _("Difficulty: %s", difficulty_name);
m_server_info.push_back(each_line);
core::stringw mode = RaceManager::getNameOf(m_server->getRaceMinorMode());
m_server_game_mode->setText(mode, false);
core::stringw mode = RaceManager::getNameOf(server->getRaceMinorMode());
each_line = _("Game mode: %s", mode);
m_server_info.push_back(each_line);
}
if(!NetworkConfig::get()->isServer())
@ -136,15 +131,37 @@ void NetworkingLobby::init()
StateManager::get()->createActivePlayer(profile, device);
} // init
// ----------------------------------------------------------------------------
void NetworkingLobby::addMoreServerInfo(const core::stringw& info)
{
} // addMoreServerInfo
// ----------------------------------------------------------------------------
void NetworkingLobby::onUpdate(float delta)
{
// FIXME Network looby should be closed when stkhost is shut down
auto lp = LobbyProtocol::get<LobbyProtocol>();
if (!lp)
{
const core::stringw connect_msg = StringUtils::loadingDots(
_("Connecting to server %s", m_server_name));
m_text_bubble->setText(connect_msg);
}
else
{
core::stringw total_msg;
for (auto& string : m_server_info)
{
total_msg += string;
total_msg += L"\n";
}
m_text_bubble->setText(total_msg);
}
if(NetworkConfig::get()->isClient())
{
m_start_button->setVisible(STKHost::existHost() &&
STKHost::get()->isAuthorisedToControl());
}
} // onUpdate
// ----------------------------------------------------------------------------

View File

@ -22,12 +22,13 @@
class Server;
namespace GUIEngine {
namespace GUIEngine
{
class Widget;
class ListWidget;
class IconButtonWidget;
class LabelWidget;
class RibbonWidget;
class BubbleWidget;
class TextBoxWidget;
}
class NetworkPlayerProfile;
@ -42,19 +43,17 @@ class NetworkingLobby : public GUIEngine::Screen,
private:
friend class GUIEngine::ScreenSingleton<NetworkingLobby>;
Server * m_server;
NetworkingLobby();
core::stringw m_server_name;
std::vector<core::stringw> m_server_info;
GUIEngine::IconButtonWidget * m_back_widget;
GUIEngine::LabelWidget * m_server_name_widget;
GUIEngine::LabelWidget * m_online_status_widget;
GUIEngine::RibbonWidget * m_bottom_menu_widget;
GUIEngine::BubbleWidget * m_text_bubble;
GUIEngine::IconButtonWidget * m_exit_widget;
GUIEngine::IconButtonWidget *m_start_button;
GUIEngine::ListWidget *m_player_list;
GUIEngine::LabelWidget* m_server_difficulty;
GUIEngine::LabelWidget* m_server_game_mode;
GUIEngine::TextBoxWidget* m_chat_box;
/** \brief Sets which widget has to be focused. Depends on the user state. */
void setInitialFocus();
@ -88,6 +87,8 @@ public:
/** \brief Implements the callback when a dialog gets closed. */
virtual void onDialogClose() OVERRIDE;
/** Used to insert each client chat message (reserved). */
void addMoreServerInfo(const core::stringw& info);
void addPlayer(NetworkPlayerProfile *profile);
void removePlayer(NetworkPlayerProfile *profile);
}; // class NetworkingLobby