Improve challenge selection screen
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10768 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c7083edba3
commit
6cc19c39d0
@ -6,19 +6,31 @@
|
||||
|
||||
<spacer height="2%" width="1"/>
|
||||
|
||||
<icon-button id="novice" icon="gui/difficulty_easy.png"
|
||||
I18N="Difficulty" text="Novice" proportion="1"/>
|
||||
|
||||
<div width="100%" proportion="1" layout="horizontal-row">
|
||||
<icon-button id="novice" icon="gui/difficulty_easy.png"
|
||||
I18N="Difficulty" text="Novice" height="100%"/>
|
||||
<spacer width="5%" height="1"/>
|
||||
<label id="novice_label" proportion="1" height="100%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="8%" width="1"/>
|
||||
|
||||
<icon-button id="intermediate" icon="gui/difficulty_medium.png"
|
||||
I18N="Difficulty" text="Intermediate" proportion="1"/>
|
||||
|
||||
<div width="100%" proportion="1" layout="horizontal-row">
|
||||
<icon-button id="intermediate" icon="gui/difficulty_medium.png"
|
||||
I18N="Difficulty" text="Intermediate" height="100%"/>
|
||||
<spacer width="5%" height="1"/>
|
||||
<label id="intermediate_label" proportion="1" height="100%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="8%" width="1"/>
|
||||
|
||||
<icon-button id="expert" icon="gui/difficulty_hard.png"
|
||||
I18N="Difficulty" text="Expert" proportion="1"/>
|
||||
|
||||
<div width="100%" proportion="1" layout="horizontal-row">
|
||||
<icon-button id="expert" icon="gui/difficulty_hard.png"
|
||||
I18N="Difficulty" text="Expert" height="100%"/>
|
||||
<spacer width="5%" height="1"/>
|
||||
<label id="difficult_label" proportion="1" height="100%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="8%" width="1"/>
|
||||
|
||||
</div>
|
||||
|
@ -414,6 +414,10 @@ namespace GUIEngine
|
||||
is not what you're looking for; instead, add a stretching spacer before
|
||||
and after the widget(s) you want to center.
|
||||
|
||||
\note When applied to a label widget, this property will center the text
|
||||
widget within its parent. To align the text inside the label widget,
|
||||
see \ref prop4
|
||||
|
||||
\n
|
||||
\subsection prop13 PROP_PROPORTION
|
||||
<em> Name in XML files: </em> \c "proportion"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
@ -25,6 +26,37 @@
|
||||
#include "race/race_manager.hpp"
|
||||
#include "states_screens/dialogs/select_challenge.hpp"
|
||||
|
||||
using namespace GUIEngine;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
core::stringw getLabel(RaceManager::Difficulty difficulty, const ChallengeData* c)
|
||||
{
|
||||
core::stringw label = _("Number of AI Karts : %i",
|
||||
c->getNumKarts(difficulty) - 1);
|
||||
|
||||
if (c->getPosition(difficulty) != -1)
|
||||
{
|
||||
label.append(L"\n");
|
||||
label.append( _("Required Rank : %i", c->getPosition(difficulty)) );
|
||||
}
|
||||
if (c->getTime(difficulty) > 0)
|
||||
{
|
||||
label.append(L"\n");
|
||||
label.append( _("Required Time : %i",
|
||||
StringUtils::timeToString(c->getTime(difficulty)).c_str()) );
|
||||
}
|
||||
if (c->getEnergy(difficulty) > 0)
|
||||
{
|
||||
label.append(L"\n");
|
||||
label.append( _("Required Nitro Points : %i", c->getEnergy(difficulty)) );
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
const float percentHeight,
|
||||
@ -35,14 +67,39 @@ SelectChallengeDialog::SelectChallengeDialog(const float percentWidth,
|
||||
m_challenge_id = challenge_id;
|
||||
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
|
||||
|
||||
// TODO: select the previously selected difficulty
|
||||
switch (UserConfigParams::m_difficulty)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const ChallengeData* c = unlock_manager->getChallenge(challenge_id);
|
||||
|
||||
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::RD_EASY, c), false );
|
||||
medium_label->setText( getLabel(RaceManager::RD_MEDIUM, c), false );
|
||||
expert_label->setText( getLabel(RaceManager::RD_HARD, c), false );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
SelectChallengeDialog::~SelectChallengeDialog()
|
||||
{
|
||||
World::getWorld()->scheduleUnpause();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::string& eventSourceParam)
|
||||
{
|
||||
std::string eventSource = eventSourceParam;
|
||||
@ -94,14 +151,17 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
||||
if (eventSource == "novice")
|
||||
{
|
||||
challenge->setRace(RaceManager::RD_EASY);
|
||||
UserConfigParams::m_difficulty = 0;
|
||||
}
|
||||
else if (eventSource == "intermediate")
|
||||
{
|
||||
challenge->setRace(RaceManager::RD_MEDIUM);
|
||||
UserConfigParams::m_difficulty = 1;
|
||||
}
|
||||
else if (eventSource == "expert")
|
||||
{
|
||||
challenge->setRace(RaceManager::RD_HARD);
|
||||
UserConfigParams::m_difficulty = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,3 +179,5 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user