New interface of challenge selection (#3957)
* New interface * New interface * New interface * Replace tabs into 4 spaces && fix a bug * Change the solution * Fix a bug
This commit is contained in:
@@ -2,69 +2,33 @@
|
||||
<stkgui>
|
||||
<div x="5%" y="5%" width="90%" height="90%" layout="vertical-row" >
|
||||
|
||||
<div width="100%" layout="horizontal-row" height="12%">
|
||||
<div width="8%" layout="vertical-row" height="100%">
|
||||
|
||||
<spacer height="5%" width="1"/>
|
||||
<icon-button id="back" width="100%" height="60%" align="left" icon="gui/icons/back.png"/>
|
||||
|
||||
</div>
|
||||
|
||||
<header id="title" width="80%" text="Race Setup" align="center" text_align="center" />
|
||||
<header id="title" height="10%" width="100%" text="Race Setup" align="center" text_align="center" />
|
||||
|
||||
<spacer height="1" width="12%"/>
|
||||
</div>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
<spacer height="2%" width="1"/>
|
||||
|
||||
<div width="100%" layout="horizontal-row" height="fit">
|
||||
<label id="race_type" text="Type:" I18N="Type of race, in a challenge"/>
|
||||
<spacer width="5" height="1"/>
|
||||
<label id="race_type_val"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4%" width="1"/>
|
||||
|
||||
<div width="100%" height="16%" layout="horizontal-row">
|
||||
<buttonbar id="icon_novice" height="100%" width="8%" align="center">
|
||||
<icon-button id="novice" icon="gui/icons/difficulty_easy.png"
|
||||
<ribbon id="difficulty" height="25%" width="80%" align="center">
|
||||
<icon-button id="novice" icon="gui/icons/difficulty_easy.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Novice"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="novice_label" height="100%"/>
|
||||
</div>
|
||||
<icon-button id="intermediate" icon="gui/icons/difficulty_medium.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Intermediate"/>
|
||||
<icon-button id="expert" icon="gui/icons/difficulty_hard.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Expert"/>
|
||||
<icon-button id="supertux" icon="gui/icons/difficulty_best.png"
|
||||
width="128" height="128" I18N="Difficulty" text="SuperTux"/>
|
||||
</ribbon>
|
||||
|
||||
<spacer height="4%" width="1"/>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
<div width="100%" height="16%" layout="horizontal-row">
|
||||
<buttonbar id="icon_intermediate" height="100%" width="8%" align="center">
|
||||
<icon-button id="intermediate" icon="gui/icons/difficulty_medium.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Intermediate"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="intermediate_label" height="100%"/>
|
||||
</div>
|
||||
<label id="challenge_info" height="35%" width="100%" text_align="center"/>
|
||||
|
||||
<spacer height="4%" width="1"/>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
<div width="100%" height="16%" layout="horizontal-row">
|
||||
<buttonbar id="icon_expert" height="100%" width="8%" align="center">
|
||||
<icon-button id="expert" icon="gui/icons/difficulty_hard.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Expert"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="difficult_label" height="100%"/>
|
||||
</div>
|
||||
<buttonbar id="actions" height="20%" width="30%" align="center">
|
||||
<icon-button id="back" icon="gui/icons/back.png"
|
||||
width="128" height="128" text="Back"/>
|
||||
<icon-button id="start" icon="gui/icons/green_check.png"
|
||||
width="128" height="128" text="Start Race"/>
|
||||
</buttonbar>
|
||||
|
||||
<spacer height="4%" width="1"/>
|
||||
|
||||
<div width="100%" height="16%" layout="horizontal-row">
|
||||
<buttonbar id="icon_supertux" height="100%" width="8%" align="center">
|
||||
<icon-button id="supertux" icon="gui/icons/difficulty_best.png"
|
||||
width="128" height="128" I18N="Difficulty" text="SuperTux"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="supertux_label" height="100%"/>
|
||||
</div>
|
||||
</div>
|
||||
</stkgui>
|
||||
|
||||
@@ -2,58 +2,31 @@
|
||||
<stkgui>
|
||||
<div x="5%" y="5%" width="90%" height="90%" layout="vertical-row" >
|
||||
|
||||
<div width="100%" layout="horizontal-row" height="12%">
|
||||
<div width="8%" layout="vertical-row" height="100%">
|
||||
<header id="title" height="10%" width="100%" text="Race Setup" align="center" text_align="center" />
|
||||
|
||||
<spacer height="5%" width="1"/>
|
||||
<icon-button id="back" width="100%" height="60%" align="left" icon="gui/icons/back.png"/>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
</div>
|
||||
|
||||
<header id="title" width="80%" text="Race Setup" align="center" text_align="center" />
|
||||
|
||||
<spacer height="1" width="12%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="2%" width="1"/>
|
||||
|
||||
<div width="100%" layout="horizontal-row" height="fit">
|
||||
<label id="race_type" text="Type:" I18N="Type of race, in a challenge"/>
|
||||
<spacer width="5" height="1"/>
|
||||
<label id="race_type_val" proportion="1"/>
|
||||
</div>
|
||||
|
||||
<spacer height="6%" width="1"/>
|
||||
|
||||
<div width="100%" height="20%" layout="horizontal-row">
|
||||
<buttonbar id="icon_novice" height="100%" width="10%" align="center">
|
||||
<icon-button id="novice" icon="gui/icons/difficulty_easy.png"
|
||||
<ribbon id="difficulty" height="25%" width="80%" align="center">
|
||||
<icon-button id="novice" icon="gui/icons/difficulty_easy.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Novice"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="novice_label" height="100%"/>
|
||||
</div>
|
||||
<icon-button id="intermediate" icon="gui/icons/difficulty_medium.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Intermediate"/>
|
||||
<icon-button id="expert" icon="gui/icons/difficulty_hard.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Expert"/>
|
||||
</ribbon>
|
||||
|
||||
<spacer height="6%" width="1"/>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
<div width="100%" height="20%" layout="horizontal-row">
|
||||
<buttonbar id="icon_intermediate" height="100%" width="10%" align="center">
|
||||
<icon-button id="intermediate" icon="gui/icons/difficulty_medium.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Intermediate"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="intermediate_label" height="100%"/>
|
||||
</div>
|
||||
<label id="challenge_info" height="35%" width="100%" text_align="center"/>
|
||||
|
||||
<spacer height="6%" width="1"/>
|
||||
<spacer height="3%" width="1"/>
|
||||
|
||||
<buttonbar id="actions" height="20%" width="30%" align="center">
|
||||
<icon-button id="back" icon="gui/icons/back.png"
|
||||
width="128" height="128" text="Back"/>
|
||||
<icon-button id="start" icon="gui/icons/green_check.png"
|
||||
width="128" height="128" text="Start Race"/>
|
||||
</buttonbar>
|
||||
|
||||
<div width="100%" height="20%" layout="horizontal-row">
|
||||
<buttonbar id="icon_expert" height="100%" width="10%" align="center">
|
||||
<icon-button id="expert" icon="gui/icons/difficulty_hard.png"
|
||||
width="128" height="128" I18N="Difficulty" text="Expert"/>
|
||||
</buttonbar>
|
||||
<spacer width="1f" height="1"/>
|
||||
<label id="difficult_label" height="100%"/>
|
||||
</div>
|
||||
</div>
|
||||
</stkgui>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
@@ -39,34 +40,60 @@ using namespace GUIEngine;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
core::stringw getLabel(RaceManager::Difficulty difficulty, const ChallengeData* c)
|
||||
core::stringw getLabel(RaceManager::Difficulty difficulty, const ChallengeData* c_data)
|
||||
{
|
||||
core::stringw label;
|
||||
core::stringw label, description;
|
||||
|
||||
if (c_data->isGrandPrix())
|
||||
{
|
||||
// Doesn't work for RTL
|
||||
description += _("Grand Prix");
|
||||
description += L" - ";
|
||||
description += RaceManager::getNameOf(c_data->getMinorMode());
|
||||
} // if isGrandPrix
|
||||
else
|
||||
{
|
||||
if (c_data->getEnergy(RaceManager::DIFFICULTY_EASY) > 0)
|
||||
description += _("Nitro challenge");
|
||||
else if (c_data->isGhostReplay())
|
||||
description += _("Ghost replay race");
|
||||
else
|
||||
description += RaceManager::getNameOf(c_data->getMinorMode());
|
||||
|
||||
if (c->getMaxPosition(difficulty) != -1)
|
||||
{
|
||||
int r = c->getMaxPosition(difficulty);
|
||||
if (c->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) r--;
|
||||
description += L" - ";
|
||||
description += _("Laps: %i", c_data->getNumLaps());
|
||||
|
||||
if (label.size() > 0) label.append(L"\n");
|
||||
label.append( _("Required Rank: %i", r) );
|
||||
}
|
||||
if (c->getTimeRequirement(difficulty) > 0)
|
||||
if (c_data->getReverse())
|
||||
{
|
||||
description += L" - ";
|
||||
description += _("Mode: Reverse");
|
||||
}
|
||||
} // if !isGrandPrix
|
||||
|
||||
label = _("Type: %s", description);
|
||||
|
||||
if (c_data->getMaxPosition(difficulty) != -1)
|
||||
{
|
||||
if (label.size() > 0) label.append(L"\n");
|
||||
label.append( _("Required Time: %i",
|
||||
StringUtils::timeToString(c->getTimeRequirement(difficulty)).c_str()) );
|
||||
int r = c_data->getMaxPosition(difficulty);
|
||||
if (c_data->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) r--;
|
||||
label += L"\n";
|
||||
label += _("Required Rank: %i", r);
|
||||
}
|
||||
if (c->getEnergy(difficulty) > 0)
|
||||
if (c_data->getTimeRequirement(difficulty) > 0)
|
||||
{
|
||||
if (label.size() > 0) label.append(L"\n");
|
||||
label.append( _("Required Nitro Points: %i", c->getEnergy(difficulty)) );
|
||||
label += L"\n";
|
||||
label += _("Required Time: %i",
|
||||
StringUtils::timeToString(c_data->getTimeRequirement(difficulty)).c_str());
|
||||
}
|
||||
|
||||
if (!c->isGhostReplay())
|
||||
if (c_data->getEnergy(difficulty) > 0)
|
||||
{
|
||||
if (label.size() > 0) label.append(L"\n");
|
||||
label.append(_("Number of AI Karts: %i", c->getNumKarts(difficulty) - 1));
|
||||
label += L"\n";
|
||||
label += _("Required Nitro Points: %i", c_data->getEnergy(difficulty));
|
||||
}
|
||||
if (!c_data->isGhostReplay())
|
||||
{
|
||||
label += L"\n";
|
||||
label += _("Number of AI Karts: %i", c_data->getNumKarts(difficulty) - 1);
|
||||
}
|
||||
|
||||
return label;
|
||||
@@ -84,52 +111,56 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
loadFromFile("select_challenge_nobest.stkgui");
|
||||
else
|
||||
loadFromFile("select_challenge.stkgui");
|
||||
|
||||
m_challenge_id = challenge_id;
|
||||
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
|
||||
|
||||
switch (UserConfigParams::m_difficulty)
|
||||
|
||||
GUIEngine::RibbonWidget* difficulty =
|
||||
getWidget<GUIEngine::RibbonWidget>("difficulty");
|
||||
|
||||
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
|
||||
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
case 0:
|
||||
getWidget("novice")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
break;
|
||||
case 1:
|
||||
getWidget("intermediate")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
break;
|
||||
case 2:
|
||||
getWidget("expert")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
if(PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
getWidget("expert")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
else
|
||||
getWidget("supertux")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
break;
|
||||
}
|
||||
difficulty->setSelection(RaceManager::DIFFICULTY_HARD, PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
else
|
||||
{
|
||||
difficulty->setSelection( UserConfigParams::m_difficulty, PLAYER_ID_GAME_MASTER );
|
||||
}
|
||||
|
||||
const ChallengeStatus* c = PlayerManager::getCurrentPlayer()
|
||||
->getChallengeStatus(challenge_id);
|
||||
|
||||
LabelWidget* challenge_info = getWidget<LabelWidget>("challenge_info");
|
||||
|
||||
switch (UserConfigParams::m_difficulty)
|
||||
{
|
||||
case 0:
|
||||
challenge_info->setText(getLabel(RaceManager::DIFFICULTY_EASY, c->getData()), false );
|
||||
break;
|
||||
case 1:
|
||||
challenge_info->setText(getLabel(RaceManager::DIFFICULTY_MEDIUM, c->getData()), false );
|
||||
break;
|
||||
case 2:
|
||||
challenge_info->setText(getLabel(RaceManager::DIFFICULTY_HARD, c->getData()), false );
|
||||
break;
|
||||
case 3:
|
||||
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
|
||||
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
challenge_info->setText(getLabel(RaceManager::DIFFICULTY_HARD, c->getData()), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
challenge_info->setText(getLabel(RaceManager::DIFFICULTY_BEST, c->getData()), false );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
updateSolvedIcon(c, RaceManager::DIFFICULTY_EASY, "novice", "cup_bronze.png");
|
||||
updateSolvedIcon(c, RaceManager::DIFFICULTY_MEDIUM, "intermediate", "cup_silver.png");
|
||||
updateSolvedIcon(c, RaceManager::DIFFICULTY_HARD, "expert", "cup_gold.png");
|
||||
updateSolvedIcon(c, RaceManager::DIFFICULTY_BEST, "supertux", "cup_platinum.png");
|
||||
|
||||
LabelWidget* novice_label = getWidget<LabelWidget>("novice_label");
|
||||
LabelWidget* medium_label = getWidget<LabelWidget>("intermediate_label");
|
||||
LabelWidget* expert_label = getWidget<LabelWidget>("difficult_label");
|
||||
|
||||
novice_label->setText( getLabel(RaceManager::DIFFICULTY_EASY, c->getData()), false );
|
||||
medium_label->setText( getLabel(RaceManager::DIFFICULTY_MEDIUM, c->getData()), false );
|
||||
expert_label->setText( getLabel(RaceManager::DIFFICULTY_HARD, c->getData()), false );
|
||||
|
||||
if (!PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
LabelWidget* supertux_label = getWidget<LabelWidget>("supertux_label");
|
||||
supertux_label->setText( getLabel(RaceManager::DIFFICULTY_BEST, c->getData()), false );
|
||||
}
|
||||
|
||||
|
||||
if (c->getData()->isGrandPrix())
|
||||
{
|
||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(c->getData()->getGPId());
|
||||
@@ -141,36 +172,6 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
track_manager->getTrack(c->getData()->getTrackId())->getName();
|
||||
getWidget<LabelWidget>("title")->setText(translations->fribidize(track_name), true);
|
||||
}
|
||||
|
||||
LabelWidget* typeLbl = getWidget<LabelWidget>("race_type_val");
|
||||
core::stringw description;
|
||||
|
||||
if (c->getData()->isGrandPrix())
|
||||
{
|
||||
// Doesn't work for RTL
|
||||
description = _("Grand Prix");
|
||||
description += L" - ";
|
||||
description += RaceManager::getNameOf(c->getData()->getMinorMode());
|
||||
} // if isGrandPrix
|
||||
else
|
||||
{
|
||||
if (c->getData()->getEnergy(RaceManager::DIFFICULTY_EASY) > 0)
|
||||
description = _("Nitro challenge");
|
||||
else if (c->getData()->isGhostReplay())
|
||||
description = _("Ghost replay race");
|
||||
else
|
||||
description = RaceManager::getNameOf(c->getData()->getMinorMode());
|
||||
|
||||
description += L" - ";
|
||||
description += _("Laps: %i", c->getData()->getNumLaps());
|
||||
|
||||
if (c->getData()->getReverse())
|
||||
{
|
||||
description += L" - ";
|
||||
description += _("Mode: Reverse");
|
||||
}
|
||||
} // if !isGrandPrix
|
||||
typeLbl->setText(description, false );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -209,95 +210,149 @@ void SelectChallengeDialog::onUpdate(float dt)
|
||||
GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::string& eventSourceParam)
|
||||
{
|
||||
std::string eventSource = eventSourceParam;
|
||||
if (eventSource == "back")
|
||||
|
||||
GUIEngine::RibbonWidget* actions =
|
||||
getWidget<GUIEngine::RibbonWidget>("actions");
|
||||
GUIEngine::RibbonWidget* difficulty =
|
||||
getWidget<GUIEngine::RibbonWidget>("difficulty");
|
||||
|
||||
LabelWidget* challenge_info = getWidget<LabelWidget>("challenge_info");
|
||||
|
||||
const ChallengeData* c_data = unlock_manager->getChallengeData(m_challenge_id);
|
||||
|
||||
const ChallengeStatus* c_stat = PlayerManager::getCurrentPlayer()
|
||||
->getChallengeStatus(m_challenge_id);
|
||||
|
||||
if (eventSource == "actions")
|
||||
{
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
if (eventSource == "icon_novice" || eventSource == "icon_intermediate" ||
|
||||
eventSource == "icon_expert" || eventSource == "icon_supertux")
|
||||
{
|
||||
const ChallengeData* challenge = unlock_manager->getChallengeData(m_challenge_id);
|
||||
|
||||
if (challenge == NULL)
|
||||
const std::string& action =
|
||||
actions->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if(action == "back")
|
||||
{
|
||||
Log::error("SelectChallenge", "Cannot find challenge <%s>\n",
|
||||
m_challenge_id.c_str());
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if(action == "start")
|
||||
{
|
||||
if (c_data == NULL)
|
||||
{
|
||||
Log::error("SelectChallenge", "Cannot find challenge <%s>\n",
|
||||
m_challenge_id.c_str());
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge(m_challenge_id);
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
core::rect<s32> pos(15,
|
||||
10,
|
||||
15 + UserConfigParams::m_width/2,
|
||||
10 + GUIEngine::getTitleFontHeight());
|
||||
|
||||
race_manager->exitRace();
|
||||
//StateManager::get()->resetActivePlayers();
|
||||
|
||||
// Use latest used device
|
||||
#ifdef DEBUG
|
||||
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
||||
assert(device != NULL);
|
||||
#endif
|
||||
// Set up race manager appropriately
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||
|
||||
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
||||
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||
|
||||
// ASSIGN should make sure that only input from assigned devices is read.
|
||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
||||
|
||||
// Go straight to the race
|
||||
StateManager::get()->enterGameState();
|
||||
|
||||
// Initialise global data - necessary even in local games to avoid
|
||||
// many if tests in other places (e.g. if network_game call
|
||||
// network_manager else call race_manager).
|
||||
// network_manager->initCharacterDataStructures();
|
||||
switch (UserConfigParams::m_difficulty)
|
||||
{
|
||||
case 0:
|
||||
c_data->setRace(RaceManager::DIFFICULTY_EASY);
|
||||
break;
|
||||
case 1:
|
||||
c_data->setRace(RaceManager::DIFFICULTY_MEDIUM);
|
||||
break;
|
||||
case 2:
|
||||
c_data->setRace(RaceManager::DIFFICULTY_HARD);
|
||||
break;
|
||||
case 3:
|
||||
if (UserConfigParams::m_difficulty == RaceManager::DIFFICULTY_BEST &&
|
||||
PlayerManager::getCurrentPlayer()->isLocked("difficulty_best"))
|
||||
{
|
||||
c_data->setRace(RaceManager::DIFFICULTY_HARD);
|
||||
}
|
||||
else
|
||||
{
|
||||
c_data->setRace(RaceManager::DIFFICULTY_BEST);
|
||||
}
|
||||
break;
|
||||
}
|
||||
race_manager->setupPlayerKartInfo();
|
||||
race_manager->startNew(true);
|
||||
|
||||
irr_driver->hidePointer();
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("SelectChallenge", "Unknown widget <%s>\n",
|
||||
action.c_str());
|
||||
//assert(false);
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge(m_challenge_id);
|
||||
if (eventSource == "difficulty")
|
||||
{
|
||||
const std::string& selected =
|
||||
difficulty->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
core::stringw description;
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
core::rect<s32> pos(15,
|
||||
10,
|
||||
15 + UserConfigParams::m_width/2,
|
||||
10 + GUIEngine::getTitleFontHeight());
|
||||
|
||||
race_manager->exitRace();
|
||||
//StateManager::get()->resetActivePlayers();
|
||||
|
||||
// Use latest used device
|
||||
#ifdef DEBUG
|
||||
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice();
|
||||
assert(device != NULL);
|
||||
#endif
|
||||
// Set up race manager appropriately
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||
|
||||
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
||||
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
||||
|
||||
// ASSIGN should make sure that only input from assigned devices is read.
|
||||
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
||||
|
||||
// Go straight to the race
|
||||
StateManager::get()->enterGameState();
|
||||
|
||||
// Initialise global data - necessary even in local games to avoid
|
||||
// many if tests in other places (e.g. if network_game call
|
||||
// network_manager else call race_manager).
|
||||
// network_manager->initCharacterDataStructures();
|
||||
|
||||
// Launch challenge
|
||||
if (eventSource == "icon_novice")
|
||||
// Select difficulty
|
||||
if (selected == "novice")
|
||||
{
|
||||
challenge->setRace(RaceManager::DIFFICULTY_EASY);
|
||||
description = getLabel(RaceManager::DIFFICULTY_EASY, c_stat->getData());
|
||||
UserConfigParams::m_difficulty = 0;
|
||||
}
|
||||
else if (eventSource == "icon_intermediate")
|
||||
else if (selected == "intermediate")
|
||||
{
|
||||
challenge->setRace(RaceManager::DIFFICULTY_MEDIUM);
|
||||
description = getLabel(RaceManager::DIFFICULTY_MEDIUM, c_stat->getData());
|
||||
UserConfigParams::m_difficulty = 1;
|
||||
}
|
||||
else if (eventSource == "icon_expert")
|
||||
else if (selected == "expert")
|
||||
{
|
||||
challenge->setRace(RaceManager::DIFFICULTY_HARD);
|
||||
description = getLabel(RaceManager::DIFFICULTY_HARD, c_stat->getData());
|
||||
UserConfigParams::m_difficulty = 2;
|
||||
}
|
||||
else if (eventSource == "icon_supertux")
|
||||
else if (selected == "supertux")
|
||||
{
|
||||
challenge->setRace(RaceManager::DIFFICULTY_BEST);
|
||||
description = getLabel(RaceManager::DIFFICULTY_BEST, c_stat->getData());
|
||||
UserConfigParams::m_difficulty = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("SelectChallenge", "Unknown widget <%s>\n",
|
||||
eventSource.c_str());
|
||||
selected.c_str());
|
||||
//assert(false);
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
challenge_info->setText(description, false );
|
||||
// Sets up kart info, including random list of kart for AI
|
||||
race_manager->setupPlayerKartInfo();
|
||||
race_manager->startNew(true);
|
||||
|
||||
irr_driver->hidePointer();
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
return GUIEngine::EVENT_LET;
|
||||
|
||||
Reference in New Issue
Block a user