Work on "Create server" screen to include more options

This commit is contained in:
Marianne Gagnon 2016-03-09 19:47:45 -05:00
parent 193aabe393
commit 35451515a2
2 changed files with 61 additions and 3 deletions

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

@ -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);
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();