More work on networking UI

This commit is contained in:
Marianne Gagnon 2016-03-10 18:48:40 -05:00
parent 35451515a2
commit 90f0c12393
9 changed files with 98 additions and 4 deletions

View File

@ -10,6 +10,14 @@
<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>
<spacer width="20" height="20"/>
<box proportion="1" height="100%" layout="vertical-row">
@ -27,7 +35,7 @@
<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"
<icon-button id="start" width="64" height="64" icon="gui/green_check.png" align="center"
I18N="In the network lobby" text="Start Race"/>
</box>

View File

@ -8,10 +8,24 @@
<spacer height="20" width="50"/>
<div width="80%" align="center" layout="vertical-row" height="fit" >
<!--
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the server info dialog" text="Name"/>
<label id="name" proportion="2" text_align="left" text=""/>
</div>
-->
<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>
</div>
<spacer height="20" width="50"/>

View File

@ -39,6 +39,12 @@ Server::Server(const XMLNode & xml, bool is_lan)
m_max_players = 0;
m_is_lan = is_lan;
// TODO: get minor mode and difficulty from network protocol
// See STKHost::handleLANRequests
// and this is unpacked in ServersManager operation(
m_minor_mode = RaceManager::MINOR_MODE_NORMAL_RACE;
m_difficulty = RaceManager::DIFFICULTY_HARD;
xml.get("name", &m_lower_case_name);
m_name = StringUtils::xmlDecode(m_lower_case_name);
m_lower_case_name = StringUtils::toLowerCase(m_lower_case_name);
@ -71,6 +77,13 @@ Server::Server(const core::stringw &name, bool is_lan, int max_players,
m_address.copy(address);
// In case of LAN server, public and private port are the same.
m_private_port = m_address.getPort();
// TODO: get minor mode and difficulty from network protocol
// See STKHost::handleLANRequests
// and this is unpacked in ServersManager operation(
m_minor_mode = RaceManager::MINOR_MODE_NORMAL_RACE;
m_difficulty = RaceManager::DIFFICULTY_HARD;
} // server(name, ...)
// ----------------------------------------------------------------------------

View File

@ -25,6 +25,7 @@
*/
#include "network/transport_address.hpp"
#include "race/race_manager.hpp"
#include "utils/types.hpp"
#include <irrString.h>
@ -78,6 +79,10 @@ protected:
* connection using the private port is possible. */
uint16_t m_private_port;
RaceManager::MinorRaceModeType m_minor_mode;
RaceManager::Difficulty m_difficulty;
/** The sort order to be used in the comparison. */
static SortOrder m_sort_order;
@ -112,6 +117,10 @@ public:
/** Returns the number of currently connected players. */
const int getCurrentPlayers() const { return m_current_players; }
// ------------------------------------------------------------------------
RaceManager::MinorRaceModeType getRaceMinorMode() const { return m_minor_mode; }
// ------------------------------------------------------------------------
RaceManager::Difficulty getDifficulty() const { return m_difficulty; }
// ------------------------------------------------------------------------
/** Compares two servers according to the sort order currently defined.
* \param a The addon to compare this addon to.
*/

View File

@ -529,6 +529,21 @@ public:
}
return "";
} // getDifficultyAsString
// ------------------------------------------------------------------------
/** Returns the specified difficulty as a string. */
core::stringw getDifficultyName(Difficulty diff) const
{
switch (diff)
{
case RaceManager::DIFFICULTY_EASY: return _("Novice"); break;
case RaceManager::DIFFICULTY_MEDIUM: return _("Intermediate"); break;
case RaceManager::DIFFICULTY_HARD: return _("Expert"); break;
case RaceManager::DIFFICULTY_BEST: return _("SuperTux"); break;
default: assert(false);
}
return "";
} // getDifficultyName
// ------------------------------------------------------------------------
const std::string& getTrackName() const { return m_tracks[m_track_number];}
// ------------------------------------------------------------------------

View File

@ -56,10 +56,19 @@ ServerInfoDialog::ServerInfoDialog(uint32_t server_id, uint32_t host_id,
loadFromFile("online/server_info_dialog.stkgui");
GUIEngine::LabelWidget *name = getWidget<LabelWidget>("name");
GUIEngine::LabelWidget *name = getWidget<LabelWidget>("server_name");
assert(name);
const Server * server = ServersManager::get()->getServerByID(m_server_id);
name->setText(server->getName(),false);
core::stringw difficulty = race_manager->getDifficultyName(server->getDifficulty());
GUIEngine::LabelWidget *lbldifficulty = getWidget<LabelWidget>("server_difficulty");
lbldifficulty->setText(difficulty, false);
core::stringw mode = RaceManager::getNameOf(server->getRaceMinorMode());
GUIEngine::LabelWidget *gamemode = getWidget<LabelWidget>("server_game_mode");
gamemode->setText(mode, false);
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL);
if (m_from_server_creation)

View File

@ -77,6 +77,12 @@ void NetworkingLobby::loadedFromFile()
m_server_name_widget = getWidget<LabelWidget>("server_name");
assert(m_server_name_widget != 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);
@ -108,8 +114,17 @@ void NetworkingLobby::init()
Screen::init();
setInitialFocus();
m_server = ServersManager::get()->getJoinedServer();
if(m_server)
if (m_server)
{
m_server_name_widget->setText(m_server->getName(), false);
core::stringw difficulty = race_manager->getDifficultyName(m_server->getDifficulty());
m_server_difficulty->setText(difficulty, false);
core::stringw mode = RaceManager::getNameOf(m_server->getRaceMinorMode());
m_server_game_mode->setText(mode, false);
}
m_start_button->setVisible(STKHost::get()->isAuthorisedToControl());
// For now create the active player and bind it to the right

View File

@ -53,6 +53,8 @@ private:
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;
/** \brief Sets which widget has to be focused. Depends on the user state. */
void setInitialFocus();

View File

@ -99,8 +99,10 @@ void ServerSelection::loadedFromFile()
void ServerSelection::beforeAddingWidget()
{
m_server_list_widget->clearColumns();
m_server_list_widget->addColumn( _("Name"), 3 );
m_server_list_widget->addColumn( _("Name"), 2 );
m_server_list_widget->addColumn( _("Players"), 1);
m_server_list_widget->addColumn(_("Difficulty"), 1);
m_server_list_widget->addColumn(_("Game mode"), 1);
} // beforeAddingWidget
// ----------------------------------------------------------------------------
@ -138,6 +140,13 @@ void ServerSelection::loadList()
std::vector<GUIEngine::ListWidget::ListCell> row;
row.push_back(GUIEngine::ListWidget::ListCell(server->getName(),-1,3));
row.push_back(GUIEngine::ListWidget::ListCell(num_players,-1,1,true));
core::stringw difficulty = race_manager->getDifficultyName(server->getDifficulty());
row.push_back(GUIEngine::ListWidget::ListCell(difficulty, -1, 1, true));
core::stringw mode = RaceManager::getNameOf(server->getRaceMinorMode());
row.push_back(GUIEngine::ListWidget::ListCell(mode, -1, 1, true));
m_server_list_widget->addItem("server", row);
}
} // loadList