This commit is contained in:
hiker
2016-03-11 16:46:20 +11:00
16 changed files with 168 additions and 14 deletions

View File

@@ -10,10 +10,10 @@
</hard>
<medium>
<karts number="4"/>
<requirements time="225"/>
<requirements time="258"/>
</medium>
<easy>
<karts number="4"/>
<requirements time="290"/>
<requirements time="330"/>
</easy>
</challenge>

Binary file not shown.

Binary file not shown.

View File

@@ -17,6 +17,42 @@
<label proportion="1" text_align="left" I18N="In the server creation screen" text="Max. number of players"/>
<gauge id="max_players" proportion="1" min_value="2" max_value="12"/>
</div>
<spacer height="20" width="20"/>
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the server creation screen" text="Password (optional)"/>
<textbox proportion="1" id="password" I18N="In the server creation screen"/>
</div>
<spacer height="20" width="20"/>
<label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Difficulty"/>
<!--<gauge id="difficulty" proportion="1" min_value="1" max_value="4"/>-->
<ribbon id="difficulty" height="135" width="90%" align="center">
<icon-button id="novice" width="128" height="128" icon="gui/difficulty_easy.png"
I18N="Difficulty" text="Novice"/>
<icon-button id="intermediate" width="128" height="128" icon="gui/difficulty_medium.png"
I18N="Difficulty" text="Intermediate"/>
<icon-button id="expert" width="128" height="128" icon="gui/difficulty_hard.png"
I18N="Difficulty" text="Expert"/>
<icon-button id="best" width="128" height="128" icon="gui/difficulty_best.png"
I18N="Difficulty" text="SuperTux"/>
</ribbon>
<spacer height="20" width="20"/>
<label width="100%" height="fit" text_align="left" I18N="In the server creation screen" text="Game mode"/>
<ribbon id="gamemode" height="135" width="50%" align="center">
<icon-button id="normal" width="128" height="128" icon="gui/mode_normal.png"
I18N="Multiplayer game mode" text="Normal Race"/>
<icon-button id="timetrial" width="128" height="128" icon="gui/mode_tt.png"
I18N="Multiplayer game mode" text="Time Trial"/>
</ribbon>
<!--
<scrollable_toolbar id="gamemode" height="135" width="90%" label_location="bottom" align="center"
child_width="135" child_height="135" />
-->
</div>
<label id="info" proportion="1" width="100%" align="center" text_align="center" word_wrap="true" text=""/>

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

@@ -38,6 +38,8 @@ Server::Server(const XMLNode & xml, bool is_lan)
m_current_players = 0;
m_max_players = 0;
m_is_lan = is_lan;
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);
@@ -71,6 +73,9 @@ 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();
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,14 @@ public:
/** Returns the number of currently connected players. */
const int getCurrentPlayers() const { return m_current_players; }
// ------------------------------------------------------------------------
RaceManager::MinorRaceModeType getRaceMinorMode() const { return m_minor_mode; }
// ------------------------------------------------------------------------
void setRaceMinorMode(RaceManager::MinorRaceModeType m) { m_minor_mode = m; }
// ------------------------------------------------------------------------
RaceManager::Difficulty getDifficulty() const { return m_difficulty; }
// ------------------------------------------------------------------------
void setDifficulty(RaceManager::Difficulty d) { m_difficulty = d; }
// ------------------------------------------------------------------------
/** Compares two servers according to the sort order currently defined.
* \param a The addon to compare this addon to.
*/

View File

@@ -178,10 +178,14 @@ Online::XMLRequest* ServersManager::getLANRefreshRequest() const
uint8_t players = s.getUInt8(bytes_read+1);
uint32_t my_ip = s.getUInt32(bytes_read+2);
uint32_t my_port = s.getUInt16(bytes_read+6);
ServersManager::get()
->addServer(new Server(name, /*lan*/true,
max_players, players,
sender) );
uint16_t mode = s.getUInt16(bytes_read+8);
uint8_t difficulty = s.getUInt8(bytes_read+10);
Server* server = new Server(name, /*lan*/true,
max_players, players, sender);
server->setDifficulty((RaceManager::Difficulty)difficulty);
server->setRaceMinorMode((RaceManager::MinorRaceModeType)mode);
ServersManager::get()->addServer(server);
TransportAddress me(my_ip, my_port);
NetworkConfig::get()->setMyAddress(me);
m_success = true;

View File

@@ -586,12 +586,14 @@ void STKHost::handleLANRequests()
// current players, and the client's ip address and port
// number (which solves the problem which network interface
// might be the right one if there is more than one).
BareNetworkString s(name.size()+1+8);
BareNetworkString s(name.size()+1+11);
s.encodeString(name);
s.addUInt8(NetworkConfig::get()->getMaxPlayers());
s.addUInt8(0); // FIXME: current number of connected players
s.addUInt32(sender.getIP());
s.addUInt16(sender.getPort());
s.addUInt16((uint16_t)race_manager->getMinorMode());
s.addUInt8((uint8_t)race_manager->getDifficulty());
m_lan_network->sendRawPacket(s, sender);
} // if message is server-requested
else if (command == "connection-request")

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

@@ -22,6 +22,7 @@
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/user_config.hpp"
#include "modes/demo_world.hpp"
#include "network/network_config.hpp"
#include "network/servers_manager.hpp"
@@ -68,7 +69,6 @@ void CreateServerScreen::loadedFromFile()
assert(m_create_widget != NULL);
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
assert(m_cancel_widget != NULL);
} // loadedFromFile
// ----------------------------------------------------------------------------
@@ -90,6 +90,17 @@ void CreateServerScreen::init()
: PlayerManager::getCurrentOnlineUserName()
)
);
// -- Difficulty
RibbonWidget* difficulty = getWidget<RibbonWidget>("difficulty");
assert(difficulty != NULL);
difficulty->setSelection(UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER);
// -- Game modes
RibbonWidget* gamemode = getWidget<RibbonWidget>("gamemode");
assert(gamemode != NULL);
gamemode->setSelection(0, PLAYER_ID_GAME_MASTER);
} // init
// ----------------------------------------------------------------------------
@@ -160,6 +171,10 @@ void CreateServerScreen::createServer()
const irr::core::stringw name = m_name_widget->getText().trim();
const int max_players = m_max_players_widget->getValue();
m_info_widget->setErrorColor();
RibbonWidget* difficulty_widget = getWidget<RibbonWidget>("difficulty");
RibbonWidget* gamemode_widget = getWidget<RibbonWidget>("gamemode");
if (name.size() < 4 || name.size() > 30)
{
m_info_widget->setText(
@@ -195,9 +210,16 @@ void CreateServerScreen::createServer()
// FIXME: Add the following fields to the create server screen
// FIXME: Long term we might add a 'vote' option (e.g. GP vs single race,
// and normal vs FTL vs time trial could be voted about).
race_manager->setDifficulty(RaceManager::convertDifficulty("hard"));
std::string difficulty = difficulty_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
race_manager->setDifficulty(RaceManager::convertDifficulty(difficulty));
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
std::string game_mode = gamemode_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (game_mode == "timetrial")
race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
else
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setReverseTrack(false);
STKHost::create();

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