Several improvements to the server selection screen

This commit is contained in:
Alayan 2018-12-15 08:05:37 +01:00
parent 830c85a262
commit 19b0c1a465
2 changed files with 22 additions and 21 deletions

View File

@ -9,7 +9,8 @@
</div> </div>
<box proportion="1" width="98%" align="center" layout="vertical-row" padding="6"> <box proportion="1" width="98%" align="center" layout="vertical-row" padding="6">
<list id="server_list" x="0" y="0" width="100%" height="93%"/> <list id="server_list" x="0" y="0" width="100%" height="93%" word_wrap="true"
alternate_bg="true" line_height="small"/>
<textbox id="searcher" width="100%" height="7%"/> <textbox id="searcher" width="100%" height="7%"/>
</box> </box>
<div width="99%" align="center" layout="vertical-row" height="fit"> <div width="99%" align="center" layout="vertical-row" height="fit">

View File

@ -115,19 +115,18 @@ void ServerSelection::loadedFromFile()
*/ */
void ServerSelection::beforeAddingWidget() void ServerSelection::beforeAddingWidget()
{ {
m_server_list_widget->setAlternatingDarkness(true);
m_server_list_widget->clearColumns(); m_server_list_widget->clearColumns();
m_server_list_widget->addColumn( _C("column_name", "Name"), 3); m_server_list_widget->addColumn( _C("column_name", "Name"), 7);
m_server_list_widget->addColumn( _C("column_name", "Players"), 1); m_server_list_widget->addColumn(_C("column_name", "Game mode"), 3);
m_server_list_widget->addColumn(_C("column_name", "Difficulty"), 1); m_server_list_widget->addColumn( _C("column_name", "Players"), 2);
m_server_list_widget->addColumn(_C("column_name", "Game mode"), 2); m_server_list_widget->addColumn(_C("column_name", "Difficulty"), 3);
if (NetworkConfig::get()->isWAN()) if (NetworkConfig::get()->isWAN())
{ {
// I18N: In server selection screen, owner of server, only displayed // I18N: In server selection screen, owner of server, only displayed
// if it's localhost or friends' // if it's localhost or friends'
m_server_list_widget->addColumn(_C("column_name", "Owner"), 1); m_server_list_widget->addColumn(_C("column_name", "Owner"), 3);
// I18N: In server selection screen, distance to server // I18N: In server selection screen, distance to server
m_server_list_widget->addColumn(_C("column_name", "Distance (km)"), 1); m_server_list_widget->addColumn(_C("column_name", "Distance (km)"), 3);
} }
} // beforeAddingWidget } // beforeAddingWidget
@ -142,7 +141,7 @@ void ServerSelection::init()
m_searcher->addListener(this); m_searcher->addListener(this);
m_icon_bank->setScale((float)getHeight() / 15.0f / 128.0f); m_icon_bank->setScale((float)getHeight() / 15.0f / 128.0f);
m_server_list_widget->setIcons(m_icon_bank, m_server_list_widget->setIcons(m_icon_bank,
int(getHeight() / 12.0f)); int(getHeight() / 15.0f));
m_sort_desc = false; m_sort_desc = false;
/** Triggers the loading of the server list in the servers manager. */ /** Triggers the loading of the server list in the servers manager. */
refresh(true); refresh(true);
@ -167,13 +166,13 @@ void ServerSelection::loadList()
return c->getLowerCaseName() > d->getLowerCaseName(); return c->getLowerCaseName() > d->getLowerCaseName();
break; break;
case 1: case 1:
return c->getCurrentPlayers() > d->getCurrentPlayers(); return c->getServerMode() > d->getServerMode();
break; break;
case 2: case 2:
return c->getDifficulty() > d->getDifficulty(); return c->getCurrentPlayers() > d->getCurrentPlayers();
break; break;
case 3: case 3:
return c->getServerMode() > d->getServerMode(); return c->getDifficulty() > d->getDifficulty();
break; break;
case 4: case 4:
return c->getServerOwnerLowerCaseName() > return c->getServerOwnerLowerCaseName() >
@ -195,28 +194,29 @@ void ServerSelection::loadList()
num_players.append(StringUtils::toWString(server->getMaxPlayers())); num_players.append(StringUtils::toWString(server->getMaxPlayers()));
std::vector<GUIEngine::ListWidget::ListCell> row; std::vector<GUIEngine::ListWidget::ListCell> row;
row.push_back(GUIEngine::ListWidget::ListCell(server->getName(), icon, row.push_back(GUIEngine::ListWidget::ListCell(server->getName(), icon,
3)); 7));
row.push_back(GUIEngine::ListWidget::ListCell(num_players, -1, 1,
core::stringw mode =
ServerConfig::getModeName(server->getServerMode());
row.push_back(GUIEngine::ListWidget::ListCell(mode, -1, 3, true));
row.push_back(GUIEngine::ListWidget::ListCell(num_players, -1, 2,
true)); true));
core::stringw difficulty = core::stringw difficulty =
race_manager->getDifficultyName(server->getDifficulty()); race_manager->getDifficultyName(server->getDifficulty());
row.push_back(GUIEngine::ListWidget::ListCell(difficulty, -1, 1, row.push_back(GUIEngine::ListWidget::ListCell(difficulty, -1, 3,
true)); true));
core::stringw mode =
ServerConfig::getModeName(server->getServerMode());
row.push_back(GUIEngine::ListWidget::ListCell(mode, -1, 2, true));
if (NetworkConfig::get()->isWAN()) if (NetworkConfig::get()->isWAN())
{ {
row.push_back(GUIEngine::ListWidget::ListCell( row.push_back(GUIEngine::ListWidget::ListCell(
server->getServerOwnerName(), -1, 1, true)); server->getServerOwnerName(), -1, 3, true));
// I18N: In server selection screen, unknown distance to server // I18N: In server selection screen, unknown distance to server
core::stringw distance = _("Unknown"); core::stringw distance = _("Unknown");
if (!(server->getDistance() < 0.0f)) if (!(server->getDistance() < 0.0f))
distance = StringUtils::toWString(server->getDistance()); distance = StringUtils::toWString(server->getDistance());
row.push_back(GUIEngine::ListWidget::ListCell(distance, -1, 1, row.push_back(GUIEngine::ListWidget::ListCell(distance, -1, 3,
true)); true));
} }
m_server_list_widget->addItem("server", row); m_server_list_widget->addItem("server", row);