+
+
+
diff --git a/src/states_screens/soccer_setup_screen.cpp b/src/states_screens/soccer_setup_screen.cpp
index 6f9f0956e..f09559aaa 100644
--- a/src/states_screens/soccer_setup_screen.cpp
+++ b/src/states_screens/soccer_setup_screen.cpp
@@ -87,14 +87,6 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
{
StateManager::get()->escapePressed();
}
- else if(name == "time_enabled")
- {
- SpinnerWidget* timeEnabled = dynamic_cast(widget);
- bool timed = timeEnabled->getValue() == 0;
- UserConfigParams::m_soccer_use_time_limit = timed;
- getWidget("goalamount")->setActive(!timed);
- getWidget("timeamount")->setActive(timed);
- }
else if (name == "red_team")
{
if (m_kart_view_info.size() == 1)
@@ -211,26 +203,6 @@ void SoccerSetupScreen::init()
Screen::init();
- if (UserConfigParams::m_num_goals <= 0)
- UserConfigParams::m_num_goals = 3;
-
- if (UserConfigParams::m_soccer_time_limit <= 0)
- UserConfigParams::m_soccer_time_limit = 3;
-
- SpinnerWidget* goalamount = getWidget("goalamount");
- goalamount->setValue(UserConfigParams::m_num_goals);
- goalamount->setActive(!UserConfigParams::m_soccer_use_time_limit);
-
- SpinnerWidget* timeAmount = getWidget("timeamount");
- timeAmount->setValue(UserConfigParams::m_soccer_time_limit);
- timeAmount->setActive(UserConfigParams::m_soccer_use_time_limit);
-
- SpinnerWidget* timeEnabled = getWidget("time_enabled");
- timeEnabled->clearLabels();
- timeEnabled->addLabel(_("Time limit"));
- timeEnabled->addLabel(_("Goals limit"));
- timeEnabled->setValue(UserConfigParams::m_soccer_use_time_limit ? 0 : 1);
-
// Set focus on "continue"
ButtonWidget* bt_continue = getWidget("continue");
bt_continue->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
@@ -252,9 +224,6 @@ void SoccerSetupScreen::tearDown()
// Reset the 'map fire to select' option of the device manager
input_manager->getDeviceManager()->mapFireToSelect(false);
- UserConfigParams::m_num_goals = getWidget("goalamount")->getValue();
- UserConfigParams::m_soccer_time_limit = getWidget("timeamount")->getValue();
-
// Remove all ModelViewWidgets we created manually
PtrVector& children = central_div->getChildren();
for(int i = children.size()-1 ; i >= 0 ; i--)
@@ -520,10 +489,5 @@ bool SoccerSetupScreen::onEscapePressed()
// -----------------------------------------------------------------------------
void SoccerSetupScreen::prepareGame()
{
- if (getWidget("goalamount")->isActivated())
- race_manager->setMaxGoal(getWidget("goalamount")->getValue());
- else
- race_manager->setTimeTarget((float)getWidget("timeamount")->getValue() * 60);
-
input_manager->setMasterPlayerOnly(true);
} // prepareGame
diff --git a/src/states_screens/track_info_screen.cpp b/src/states_screens/track_info_screen.cpp
index 940a9edff..54939d4e1 100644
--- a/src/states_screens/track_info_screen.cpp
+++ b/src/states_screens/track_info_screen.cpp
@@ -62,10 +62,14 @@ TrackInfoScreen::TrackInfoScreen()
/* Saves some often used pointers. */
void TrackInfoScreen::loadedFromFile()
{
- m_lap_spinner = getWidget("lap-spinner");
- m_ai_kart_spinner = getWidget("ai-spinner");
- m_option = getWidget("option");
- m_record_race = getWidget("record");
+ m_target_type_spinner = getWidget("target-type-spinner");
+ m_target_type_label = getWidget ("target-type-text");
+ m_target_type_div = getWidget("target-type-div");
+ m_target_value_spinner = getWidget("target-value-spinner");
+ m_target_value_label = getWidget("target-value-text");
+ m_ai_kart_spinner = getWidget("ai-spinner");
+ m_option = getWidget("option");
+ m_record_race = getWidget("record");
m_option->setState(false);
m_record_race->setState(false);
@@ -82,6 +86,13 @@ void TrackInfoScreen::loadedFromFile()
screenshot->m_tab_stop = false;
} // loadedFromFile
+void TrackInfoScreen::beforeAddingWidget()
+{
+ const bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
+ m_target_type_div->setCollapsed(!is_soccer, this);
+} // beforeAddingWidget
+
+
// ----------------------------------------------------------------------------
void TrackInfoScreen::setTrack(Track *track)
{
@@ -134,18 +145,55 @@ void TrackInfoScreen::init()
if (image != NULL)
screenshot->setImage(image);
+ m_target_value_spinner->setVisible(false);
+ m_target_value_label->setVisible(false);
+
+ // Soccer options
+ // -------------
+ const bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
+ if (is_soccer)
+ {
+ m_target_value_spinner->setVisible(true);
+ m_target_value_label->setVisible(true);
+
+ if (UserConfigParams::m_num_goals <= 0)
+ UserConfigParams::m_num_goals = UserConfigParams::m_num_goals.getDefaultValue();
+
+ if (UserConfigParams::m_soccer_time_limit <= 0)
+ UserConfigParams::m_soccer_time_limit = UserConfigParams::m_soccer_time_limit.getDefaultValue();
+
+ m_target_type_spinner->clearLabels();
+ m_target_type_spinner->addLabel(_("Time limit"));
+ m_target_type_spinner->addLabel(_("Goals limit"));
+ m_target_type_spinner->setValue(UserConfigParams::m_soccer_use_time_limit ? 0 : 1);
+
+ if (UserConfigParams::m_soccer_use_time_limit)
+ {
+ m_target_value_label->setText(_("Maximum time (min.)"), false);
+ m_target_value_spinner->setValue(UserConfigParams::m_soccer_time_limit);
+ }
+ else
+ {
+ m_target_value_label->setText(_("Number of goals to win"), false);
+ m_target_value_spinner->setValue(UserConfigParams::m_num_goals);
+ }
+ }
+
// Lap count m_lap_spinner
// -----------------------
- m_lap_spinner->setVisible(has_laps);
- getWidget("lap-text")->setVisible(has_laps);
if (has_laps)
{
+ m_target_value_spinner->setVisible(true);
+ m_target_value_label->setVisible(true);
+
if (UserConfigParams::m_artist_debug_mode)
- m_lap_spinner->setMin(0);
+ m_target_value_spinner->setMin(0);
else
- m_lap_spinner->setMin(1);
- m_lap_spinner->setValue(m_track->getActualNumberOfLap());
- race_manager->setNumLaps(m_lap_spinner->getValue());
+ m_target_value_spinner->setMin(1);
+ m_target_value_spinner->setValue(m_track->getActualNumberOfLap());
+ race_manager->setNumLaps(m_target_value_spinner->getValue());
+
+ m_target_value_label->setText(_("Number of laps"), false);
}
// Number of AIs
@@ -346,7 +394,7 @@ void TrackInfoScreen::onEnterPressedInternal()
race_manager->setRecordRace(m_record_this_race);
// Create a copy of member variables we still need, since they will
// not be accessible after dismiss:
- const int num_laps = race_manager->modeHasLaps() ? m_lap_spinner->getValue()
+ const int num_laps = race_manager->modeHasLaps() ? m_target_value_spinner->getValue()
: -1;
const bool option_state = m_option == NULL ? false
: m_option->getState();
@@ -380,6 +428,13 @@ void TrackInfoScreen::onEnterPressedInternal()
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = local_players + num_ai;
}
+ const int selected_target_type = m_target_type_spinner->getValue();
+ const int selected_target_value = m_target_value_spinner->getValue();
+ if (selected_target_type == 0)
+ race_manager->setTimeTarget(static_cast(selected_target_value) * 60);
+ else
+ race_manager->setMaxGoal(selected_target_value);
+
// Disable accidentally unlocking of a challenge
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
@@ -403,6 +458,43 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
{
StateManager::get()->escapePressed();
}
+ else if (name == "target-type-spinner")
+ {
+ const bool timed = m_target_type_spinner->getValue() == 0;
+ UserConfigParams::m_soccer_use_time_limit = timed;
+
+ if (timed)
+ {
+ m_target_value_label->setText(_("Maximum time (min.)"), false);
+ m_target_value_spinner->setValue(UserConfigParams::m_soccer_time_limit);
+ }
+ else
+ {
+ m_target_value_label->setText(_("Number of goals to win"), false);
+ m_target_value_spinner->setValue(UserConfigParams::m_num_goals);
+
+ }
+ }
+ else if (name == "target-value-spinner")
+ {
+ const bool is_soccer = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
+ if (is_soccer)
+ {
+ const bool timed = m_target_type_spinner->getValue() == 0;
+ if (timed)
+ UserConfigParams::m_soccer_time_limit = m_target_value_spinner->getValue();
+ else
+ UserConfigParams::m_num_goals = m_target_value_spinner->getValue();
+ }
+ else
+ {
+ assert(race_manager->modeHasLaps());
+ const int num_laps = m_target_value_spinner->getValue();
+ race_manager->setNumLaps(num_laps);
+ UserConfigParams::m_num_laps = num_laps;
+ updateHighScores();
+ }
+ }
else if (name == "option")
{
if (m_track->hasNavMesh())
@@ -434,14 +526,6 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
m_ai_kart_spinner->setActive(true);
}
}
- else if (name == "lap-spinner")
- {
- assert(race_manager->modeHasLaps());
- const int num_laps = m_lap_spinner->getValue();
- race_manager->setNumLaps(num_laps);
- UserConfigParams::m_num_laps = num_laps;
- updateHighScores();
- }
else if (name=="ai-spinner")
{
const int num_ai = m_ai_kart_spinner->getValue();
diff --git a/src/states_screens/track_info_screen.hpp b/src/states_screens/track_info_screen.hpp
index 3d3f03770..f9ff3515f 100644
--- a/src/states_screens/track_info_screen.hpp
+++ b/src/states_screens/track_info_screen.hpp
@@ -48,8 +48,21 @@ class TrackInfoScreen : public GUIEngine::Screen,
// When there is no need to tab through / click on images/labels, we can add directly
// irrlicht labels (more complicated uses require the use of our widget set)
- /** Spinner for number of laps. */
- GUIEngine::SpinnerWidget* m_lap_spinner;
+
+ /** Spinner for target types. */
+ GUIEngine::SpinnerWidget* m_target_type_spinner;
+
+ /** The label besides the target types spinner. */
+ GUIEngine::LabelWidget* m_target_type_label;
+
+ /* The div that contains the target type spinner and label */
+ GUIEngine::Widget* m_target_type_div;
+
+ /** Spinner for target value e.g. number of laps or goals to score. */
+ GUIEngine::SpinnerWidget* m_target_value_spinner;
+
+ /** The label besides the target value spinner. */
+ GUIEngine::LabelWidget* m_target_value_label;
/** Spinner for number of AI karts. */
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
@@ -76,6 +89,7 @@ public:
virtual ~TrackInfoScreen();
virtual void init();
+ virtual void beforeAddingWidget() OVERRIDE;
virtual void loadedFromFile();
virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,
const int player_id);