Added some default settings for race mode and send them to the server.

Changed major and minor mode in protocols from 1-byte to int, since 1-byte
is too small to store the actual values.
This commit is contained in:
hiker 2015-12-03 07:53:56 +11:00
parent 03d857db3e
commit ee7097af35
10 changed files with 226 additions and 200 deletions

View File

@ -68,12 +68,12 @@ void ClientLobbyRoomProtocol::requestKartSelection(const std::string &kart_name)
//-----------------------------------------------------------------------------
void ClientLobbyRoomProtocol::voteMajor(uint8_t major)
void ClientLobbyRoomProtocol::voteMajor(uint32_t major)
{
NetworkString request(8);
// size_token (4), token, size major(1),major
request.ai8(LE_VOTE_MAJOR).ai8(4)
.ai32(m_server->getClientServerToken()).ai8(1).ai8(major);
.ai32(m_server->getClientServerToken()).ai8(4).addUInt32(major);
sendMessage(request, true);
} // voteMajor
@ -90,12 +90,12 @@ void ClientLobbyRoomProtocol::voteRaceCount(uint8_t count)
//-----------------------------------------------------------------------------
void ClientLobbyRoomProtocol::voteMinor(uint8_t minor)
void ClientLobbyRoomProtocol::voteMinor(uint32_t minor)
{
NetworkString request(8);
// size_token (4), token, size minor(1),minor
request.ai8(LE_VOTE_MINOR).ai8(4).ai32(m_server->getClientServerToken())
.ai8(1).ai8(minor);
.ai8(4).addUInt32(minor);
sendMessage(request, true);
} // voteMinor
@ -723,7 +723,7 @@ void ClientLobbyRoomProtocol::playerMajorVote(Event* event)
return;
if (!isByteCorrect(event, 5, 1))
return;
if (!isByteCorrect(event, 7, 1))
if (!isByteCorrect(event, 7, 4))
return;
m_setup->getRaceConfig()->setPlayerMajorVote(data[6], data[8]);
} // playerMajorVote
@ -758,8 +758,8 @@ void ClientLobbyRoomProtocol::playerRaceCountVote(Event* event)
* Format of the data :
* Byte 0 1 5 6 7 8 9
* --------------------------------------------------------
* Size | 1 | 4 | 1 | 1 | 1 | 1 |
* Data | 4 | priv token | 1 | player id | 1 | minor mode vote |
* Size | 1 | 4 | 1 | 1 | 1 | 4 |
* Data | 4 | priv token | 1 | player id | 4 | minor mode vote |
* --------------------------------------------------------
*/
void ClientLobbyRoomProtocol::playerMinorVote(Event* event)
@ -769,7 +769,7 @@ void ClientLobbyRoomProtocol::playerMinorVote(Event* event)
return;
if (!isByteCorrect(event, 5, 1))
return;
if (!isByteCorrect(event, 7, 1))
if (!isByteCorrect(event, 7, 4))
return;
m_setup->getRaceConfig()->setPlayerMinorVote(data[6], data[8]);
} // playerMinorVote

View File

@ -13,9 +13,9 @@ class ClientLobbyRoomProtocol : public LobbyRoomProtocol
virtual ~ClientLobbyRoomProtocol();
void requestKartSelection(const std::string &kart_name);
void voteMajor(uint8_t major);
void voteMajor(uint32_t major);
void voteRaceCount(uint8_t count);
void voteMinor(uint8_t minor);
void voteMinor(uint32_t minor);
void voteTrack(const std::string &track, uint8_t track_nb = 0);
void voteReversed(bool reversed, uint8_t track_nb = 0);
void voteLaps(uint8_t laps, uint8_t track_nb = 0);

View File

@ -566,10 +566,10 @@ void ServerLobbyRoomProtocol::kartSelectionRequested(Event* event)
* \param event : Event providing the information.
*
* Format of the data :
* Byte 0 1 5 6 7
* Byte 0 1 5 6 10
* ----------------------------------------
* Size | 1 | 4 | 1 | 1 |
* Data | 4 | priv token | 1 | major mode vote |
* Size | 1 | 4 | 1 | 4 |
* Data | 4 | priv token | 4 | major mode vote |
* ----------------------------------------
*/
void ServerLobbyRoomProtocol::playerMajorVote(Event* event)
@ -578,13 +578,14 @@ void ServerLobbyRoomProtocol::playerMajorVote(Event* event)
STKPeer* peer = event->getPeer();
if (!checkDataSizeAndToken(event, 7))
return;
if (!isByteCorrect(event, 5, 1))
if (!isByteCorrect(event, 5, 4))
return;
uint8_t player_id = peer->getPlayerProfile()->getPlayerID();
m_setup->getRaceConfig()->setPlayerMajorVote(player_id, data[6]);
uint32_t major = data.getUInt32(6);
m_setup->getRaceConfig()->setPlayerMajorVote(player_id, major);
// Send the vote to everybody (including the sender)
data.removeFront(5); // remove the token
NetworkString other(2+data.size());
NetworkString other(5+data.size());
other.ai8(1).ai8(player_id); // add the player id
other += data; // add the data
NetworkString prefix(1);
@ -630,10 +631,10 @@ void ServerLobbyRoomProtocol::playerRaceCountVote(Event* event)
* \param event : Event providing the information.
*
* Format of the data :
* Byte 0 1 5 6 7
* Byte 0 1 5 6 10
* ----------------------------------------
* Size | 1 | 4 | 1 | 1 |
* Data | 4 | priv token | 1 | minor mode vote |
* Size | 1 | 4 | 1 | 4 |
* Data | 4 | priv token | 4 | minor mode vote |
* ----------------------------------------
*/
void ServerLobbyRoomProtocol::playerMinorVote(Event* event)
@ -642,10 +643,11 @@ void ServerLobbyRoomProtocol::playerMinorVote(Event* event)
STKPeer* peer = event->getPeer();
if (!checkDataSizeAndToken(event, 7))
return;
if (!isByteCorrect(event, 5, 1))
if (!isByteCorrect(event, 5, 4))
return;
uint8_t player_id = peer->getPlayerProfile()->getPlayerID();
m_setup->getRaceConfig()->setPlayerMinorVote(player_id, data[6]);
uint32_t minor = data.getUInt32(6);
m_setup->getRaceConfig()->setPlayerMinorVote(player_id, minor);
// Send the vote to everybody (including the sender)
data.removeFront(5); // remove the token
NetworkString other(2+data.size());

View File

@ -108,7 +108,7 @@ RaceVote::RaceVote()
//-----------------------------------------------------------------------------
/** Sets the selected major race vote.
*/
void RaceVote::voteMajor(uint8_t major)
void RaceVote::voteMajor(uint32_t major)
{
m_has_voted_major = true;
m_major_mode = major;
@ -126,7 +126,7 @@ void RaceVote::voteRaceCount(uint8_t count)
//-----------------------------------------------------------------------------
/** Sets vote for minor race mode.
*/
void RaceVote::voteMinor(uint8_t minor)
void RaceVote::voteMinor(uint32_t minor)
{
m_has_voted_minor = true;
m_minor_mode = minor;
@ -247,7 +247,7 @@ void RaceConfig::setMaxPlayerCount(uint8_t count)
} // setMaxPlayerCount
//-----------------------------------------------------------------------------
void RaceConfig::setPlayerMajorVote(uint8_t player_id, uint8_t major)
void RaceConfig::setPlayerMajorVote(uint8_t player_id, uint32_t major)
{
Log::info("RaceConfig", "Player %d voted for major %d", player_id, major);
m_votes[player_id].voteMajor(major);
@ -262,7 +262,7 @@ void RaceConfig::setPlayerRaceCountVote(uint8_t player_id, uint8_t count)
} // setPlayerRaceCountVote
//-----------------------------------------------------------------------------
void RaceConfig::setPlayerMinorVote(uint8_t player_id, uint8_t minor)
void RaceConfig::setPlayerMinorVote(uint8_t player_id, uint32_t minor)
{
Log::info("RaceConfig", "Player %d voted for minor %d", player_id, minor);
m_votes[player_id].voteMinor(minor);

View File

@ -59,9 +59,9 @@ class RaceVote
public:
RaceVote();
void voteMajor(uint8_t major);
void voteMajor(uint32_t major);
void voteRaceCount(uint8_t count);
void voteMinor(uint8_t minor);
void voteMinor(uint32_t minor);
void voteTrack(const std::string &track, uint8_t track_number = 0);
void voteReversed(bool reversed, uint8_t track_number = 0);
void voteLaps(uint8_t laps, uint8_t track_number = 0);
@ -81,8 +81,8 @@ class RaceVote
uint8_t getLapsVote(uint8_t track_number = 0) const;
private:
uint8_t m_major_mode;
uint8_t m_minor_mode;
uint32_t m_major_mode;
uint32_t m_minor_mode;
uint8_t m_races_count; //!< Stores the number of races that will be in a GP
bool m_has_voted_major;
bool m_has_voted_minor;
@ -97,9 +97,9 @@ class RaceConfig
RaceConfig();
void setMaxPlayerCount(uint8_t count);
void setPlayerMajorVote(uint8_t player_id, uint8_t major);
void setPlayerMajorVote(uint8_t player_id, uint32_t major);
void setPlayerRaceCountVote(uint8_t player_id, uint8_t count);
void setPlayerMinorVote(uint8_t player_id, uint8_t minor);
void setPlayerMinorVote(uint8_t player_id, uint32_t minor);
void setPlayerTrackVote(uint8_t player_id, const std::string &track,
uint8_t track_nb = 0);
void setPlayerReversedVote(uint8_t player_id, bool reversed,

View File

@ -222,6 +222,26 @@ void RaceManager::setNumPlayers(int num)
m_player_karts.resize(num);
} // setNumPlayers
// ----------------------------------------------------------------------------
/** Converst the difficulty given as a string into a Difficult enum. Defaults
* to HARD.
* \param difficulty The difficulty as string.
*/
RaceManager::Difficulty
RaceManager::convertDifficulty(const std::string &difficulty)
{
if (difficulty == "novice")
return DIFFICULTY_EASY;
else if (difficulty == "intermediate")
return DIFFICULTY_MEDIUM;
else if (difficulty == "expert")
return DIFFICULTY_HARD;
else if (difficulty == "best")
return DIFFICULTY_BEST;
else
return DIFFICULTY_HARD;
} // convertDifficulty
//-----------------------------------------------------------------------------
/** Sets the difficulty to use.
* \param diff The difficulty to use.

View File

@ -414,6 +414,7 @@ public:
* \param diff Difficulty.
*/
void setDifficulty(Difficulty diff);
static Difficulty convertDifficulty(const std::string &difficulty);
// ------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; }

View File

@ -192,6 +192,14 @@ void CreateServerScreen::createServer()
// request is finished.
NetworkConfig::get()->setMaxPlayers(max_players);
NetworkConfig::get()->setServerName(name);
// 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"));
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setReverseTrack(false);
STKHost::create();
} // createServer

View File

@ -32,6 +32,7 @@
#include "network/stk_host.hpp"
#include "states_screens/server_selection.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/tracks_screen.hpp"
static const char ID_LOCKED[] = "locked/";
@ -162,15 +163,15 @@ void NetworkKartSelectionScreen::playerConfirm(const int playerID)
} // playerConfirm
// ----------------------------------------------------------------------------
void NetworkKartSelectionScreen::playerSelected(uint8_t race_id,
void NetworkKartSelectionScreen::playerSelected(uint8_t player_id,
const std::string &kart_name)
{
uint8_t widget_id = -1;
for (unsigned int i = 0; i < m_id_mapping.size(); i++)
{
Log::info("NKSS", "Checking race id %d : mapped of %d is %d",
race_id, i, m_id_mapping[i]);
if (m_id_mapping[i] == race_id)
player_id, i, m_id_mapping[i]);
if (m_id_mapping[i] == player_id)
widget_id = i;
}
@ -181,6 +182,25 @@ void NetworkKartSelectionScreen::playerSelected(uint8_t race_id,
KartSelectionScreen::updateKartStats(widget_id, kart_name);
m_kart_widgets[widget_id].setKartInternalName(kart_name);
m_kart_widgets[widget_id].markAsReady(); // mark player ready
// If this is the authorised client, send the currently set race config
// to the server.
if(STKHost::get()->isAuthorisedToControl())
{
// FIXME: for now we submit a vote from the authorised user
// for the various modes based on the settings in the race manager.
// This needs more/better gui elements (and some should be set when
// defining the server).
Protocol* protocol = ProtocolManager::getInstance()
->getProtocol(PROTOCOL_LOBBY_ROOM);
ClientLobbyRoomProtocol* clrp =
static_cast<ClientLobbyRoomProtocol*>(protocol);
clrp->voteMajor(race_manager->getMajorMode());
clrp->voteMinor(race_manager->getMinorMode());
clrp->voteReversed(race_manager->getReverseTrack());
clrp->voteRaceCount(1);
}
TracksScreen::getInstance()->push();
} // playerSelected
// ----------------------------------------------------------------------------

View File

@ -59,7 +59,136 @@ void RaceSetupScreen::loadedFromFile()
// -----------------------------------------------------------------------------
void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
void RaceSetupScreen::init()
{
Screen::init();
input_manager->setMasterPlayerOnly(true);
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert( w != NULL );
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
w->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
}
else
{
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
}
DynamicRibbonWidget* w2 = getWidget<DynamicRibbonWidget>("gamemode");
assert( w2 != NULL );
w2->clearItems();
// ---- Add game modes
irr::core::stringw name1 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_NORMAL_RACE)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name1 += _("All blows allowed, so catch weapons and make clever use of them!");
w2->addItem( name1, IDENT_STD, RaceManager::getIconOf(RaceManager::MINOR_MODE_NORMAL_RACE));
irr::core::stringw name2 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_TIME_TRIAL)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name2 += _("Contains no powerups, so only your driving skills matter!");
w2->addItem( name2, IDENT_TTRIAL, RaceManager::getIconOf(RaceManager::MINOR_MODE_TIME_TRIAL));
if (PlayerManager::getCurrentPlayer()->isLocked(IDENT_FTL))
{
w2->addItem( _("Locked : solve active challenges to gain access to more!"),
"locked", RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), true);
}
else
{
irr::core::stringw name3 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_FOLLOW_LEADER)) + L"\n";
//I18N: short definition for follow-the-leader game mode
name3 += _("Keep up with the leader kart but don't overtake it!");
w2->addItem(name3, IDENT_FTL, RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), false);
}
if (race_manager->getNumLocalPlayers() > 1 || UserConfigParams::m_artist_debug_mode)
{
irr::core::stringw name4 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_3_STRIKES)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name4 += _("Hit others with weapons until they lose all their lives (only in multiplayer games).");
w2->addItem( name4, IDENT_STRIKES, RaceManager::getIconOf(RaceManager::MINOR_MODE_3_STRIKES));
}
#ifdef ENABLE_SOCCER_MODE
if (race_manager->getNumLocalPlayers() > 1 || UserConfigParams::m_artist_debug_mode)
{
irr::core::stringw name5 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_SOCCER)) + L"\n";
name5 += _("Push the ball to the opposite cage to score goals (only in multiplayer games).");
w2->addItem( name5, IDENT_SOCCER, RaceManager::getIconOf(RaceManager::MINOR_MODE_SOCCER));
}
#endif
#define ENABLE_EASTER_EGG_MODE
#ifdef ENABLE_EASTER_EGG_MODE
if(race_manager->getNumLocalPlayers() == 1)
{
irr::core::stringw name1 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_EASTER_EGG)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name1 += _("Explore tracks to find all hidden eggs");
w2->addItem( name1, IDENT_EASTER,
RaceManager::getIconOf(RaceManager::MINOR_MODE_EASTER_EGG));
}
#endif
w2->updateItemDisplay();
// restore saved game mode
switch (UserConfigParams::m_game_mode)
{
case CONFIG_CODE_NORMAL :
w2->setSelection(IDENT_STD, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_TIMETRIAL :
w2->setSelection(IDENT_TTRIAL, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_FTL :
w2->setSelection(IDENT_FTL, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_3STRIKES :
w2->setSelection(IDENT_STRIKES, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_EASTER :
w2->setSelection(IDENT_EASTER, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_SOCCER :
w2->setSelection(IDENT_SOCCER, PLAYER_ID_GAME_MASTER, true);
break;
}
{
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert(w != NULL);
int index = w->findItemNamed("best");
Widget* hardestWidget = &w->getChildren()[index];
if (PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
hardestWidget->setBadge(LOCKED_BADGE);
hardestWidget->setActive(false);
}
else
{
hardestWidget->unsetBadge(LOCKED_BADGE);
hardestWidget->setActive(true);
}
}
} // init
// -----------------------------------------------------------------------------
void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == "difficulty")
{
@ -132,173 +261,19 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
} // eventCallback
// -----------------------------------------------------------------------------
/** Converts the difficulty string into a RaceManager::Difficulty value
* and sets this difficulty in the user config and in the race manager.
*/
void RaceSetupScreen::assignDifficulty()
{
RibbonWidget* difficulty = getWidget<RibbonWidget>("difficulty");
assert(difficulty != NULL);
const std::string& difficultySelection = difficulty->getSelectionIDString(PLAYER_ID_GAME_MASTER);
RibbonWidget* difficulty_widget = getWidget<RibbonWidget>("difficulty");
assert(difficulty_widget != NULL);
const std::string& difficulty =
difficulty_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (difficultySelection == "novice")
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_EASY;
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
}
else if (difficultySelection == "intermediate")
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_MEDIUM;
race_manager->setDifficulty(RaceManager::DIFFICULTY_MEDIUM);
}
else if (difficultySelection == "expert")
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
}
else if (difficultySelection == "best")
{
if (PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
unlock_manager->playLockSound();
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_HARD;
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
difficulty->setSelection(2, PLAYER_ID_GAME_MASTER);
difficulty->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
else
{
UserConfigParams::m_difficulty = RaceManager::DIFFICULTY_BEST;
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
}
}
}
// -----------------------------------------------------------------------------
void RaceSetupScreen::init()
{
Screen::init();
input_manager->setMasterPlayerOnly(true);
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert( w != NULL );
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
w->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
}
else
{
w->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
}
DynamicRibbonWidget* w2 = getWidget<DynamicRibbonWidget>("gamemode");
assert( w2 != NULL );
w2->clearItems();
// ---- Add game modes
irr::core::stringw name1 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_NORMAL_RACE)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name1 += _("All blows allowed, so catch weapons and make clever use of them!");
w2->addItem( name1, IDENT_STD, RaceManager::getIconOf(RaceManager::MINOR_MODE_NORMAL_RACE));
irr::core::stringw name2 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_TIME_TRIAL)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name2 += _("Contains no powerups, so only your driving skills matter!");
w2->addItem( name2, IDENT_TTRIAL, RaceManager::getIconOf(RaceManager::MINOR_MODE_TIME_TRIAL));
if (PlayerManager::getCurrentPlayer()->isLocked(IDENT_FTL))
{
w2->addItem( _("Locked : solve active challenges to gain access to more!"),
"locked", RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), true);
}
else
{
irr::core::stringw name3 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_FOLLOW_LEADER)) + L"\n";
//I18N: short definition for follow-the-leader game mode
name3 += _("Keep up with the leader kart but don't overtake it!");
w2->addItem(name3, IDENT_FTL, RaceManager::getIconOf(RaceManager::MINOR_MODE_FOLLOW_LEADER), false);
}
if (race_manager->getNumLocalPlayers() > 1 || UserConfigParams::m_artist_debug_mode)
{
irr::core::stringw name4 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_3_STRIKES)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name4 += _("Hit others with weapons until they lose all their lives (only in multiplayer games).");
w2->addItem( name4, IDENT_STRIKES, RaceManager::getIconOf(RaceManager::MINOR_MODE_3_STRIKES));
}
#ifdef ENABLE_SOCCER_MODE
if (race_manager->getNumLocalPlayers() > 1 || UserConfigParams::m_artist_debug_mode)
{
irr::core::stringw name5 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_SOCCER)) + L"\n";
name5 += _("Push the ball to the opposite cage to score goals (only in multiplayer games).");
w2->addItem( name5, IDENT_SOCCER, RaceManager::getIconOf(RaceManager::MINOR_MODE_SOCCER));
}
#endif
#define ENABLE_EASTER_EGG_MODE
#ifdef ENABLE_EASTER_EGG_MODE
if(race_manager->getNumLocalPlayers() == 1)
{
irr::core::stringw name1 = irr::core::stringw(
RaceManager::getNameOf(RaceManager::MINOR_MODE_EASTER_EGG)) + L"\n";
//FIXME: avoid duplicating descriptions from the help menu!
name1 += _("Explore tracks to find all hidden eggs");
w2->addItem( name1, IDENT_EASTER,
RaceManager::getIconOf(RaceManager::MINOR_MODE_EASTER_EGG));
}
#endif
w2->updateItemDisplay();
// restore saved game mode
switch (UserConfigParams::m_game_mode)
{
case CONFIG_CODE_NORMAL :
w2->setSelection(IDENT_STD, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_TIMETRIAL :
w2->setSelection(IDENT_TTRIAL, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_FTL :
w2->setSelection(IDENT_FTL, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_3STRIKES :
w2->setSelection(IDENT_STRIKES, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_EASTER :
w2->setSelection(IDENT_EASTER, PLAYER_ID_GAME_MASTER, true);
break;
case CONFIG_CODE_SOCCER :
w2->setSelection(IDENT_SOCCER, PLAYER_ID_GAME_MASTER, true);
break;
}
{
RibbonWidget* w = getWidget<RibbonWidget>("difficulty");
assert(w != NULL);
int index = w->findItemNamed("best");
Widget* hardestWidget = &w->getChildren()[index];
if (PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
{
hardestWidget->setBadge(LOCKED_BADGE);
hardestWidget->setActive(false);
}
else
{
hardestWidget->unsetBadge(LOCKED_BADGE);
hardestWidget->setActive(true);
}
}
} // init
RaceManager::Difficulty diff = RaceManager::convertDifficulty(difficulty);
UserConfigParams::m_difficulty = diff;
race_manager->setDifficulty(diff);
} // assignDifficulty
// -----------------------------------------------------------------------------