Move soccer options to track info screen (#3638)
* moved soccer race options to track info screen * using one spinner for both target mode values * merged pointamount-spinner with lap-spinner and renamed it to target-value-spinner * fixed identation * small fix in track_info screen * storing target value when value was changed * making sure tartet spinners are invisible when not needed; small adjustments * some test with solving space issues on small resolutions * Revert "some test with solving space issues on small resolutions" This reverts commit f6b6526681d22d2d2767f1448838179268f7bac4. * test with collapsing widgets * removed deleting childs of widgets in track_info_screen * readded deleted spacer * collapsing target type widgets is now working * made target type spinner wider to have enough space for text in it on small resolutions * re-added setting target value to invisible/visible * using new collapsing widget function in track info screen for target type widgets
This commit is contained in:
parent
e142f04487
commit
c959836e34
@ -11,27 +11,6 @@
|
|||||||
|
|
||||||
<spacer height="1%" width="25"/>
|
<spacer height="1%" width="25"/>
|
||||||
|
|
||||||
<div layout="horizontal-row" width="100%" height="fit" align="left">
|
|
||||||
<bright width="fit" height="100%"
|
|
||||||
I18N="In soccer setup screen" text="Soccer game type" text_align="left" />
|
|
||||||
<spacer width="2%" height="25"/>
|
|
||||||
<spinner id="time_enabled" width="30%" wrap_around="true"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div layout="horizontal-row" width="100%" height="fit" align="left">
|
|
||||||
<bright width="fit" height="100%"
|
|
||||||
I18N="In soccer setup screen" text="Number of goals to win" text_align="left" />
|
|
||||||
<spacer width="2%" height="25"/>
|
|
||||||
<spinner id="goalamount" width="15%" min_value="1" max_value="10"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div layout="horizontal-row" width="100%" height="fit" align="left">
|
|
||||||
<bright width="fit" height="100%"
|
|
||||||
I18N="In soccer setup screen" text="Maximum time (min.)" text_align="left" />
|
|
||||||
<spacer width="2%" height="25"/>
|
|
||||||
<spinner id="timeamount" width="15%" min_value="1" max_value="15"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<spacer height="1%" width="25"/>
|
<spacer height="1%" width="25"/>
|
||||||
|
|
||||||
<bubble height="fit" width="100%" id="lblLeftRight" I18N="In soccer setup screen" text="Use left/right to choose your team and press fire" word_wrap="true" text_align="center"/>
|
<bubble height="fit" width="100%" id="lblLeftRight" I18N="In soccer setup screen" text="Use left/right to choose your team and press fire" word_wrap="true" text_align="center"/>
|
||||||
|
@ -74,14 +74,23 @@
|
|||||||
|
|
||||||
<spacer width="1" height="2%"/>
|
<spacer width="1" height="2%"/>
|
||||||
<!-- Race options box -->
|
<!-- Race options box -->
|
||||||
<box width="100%" height="43%" layout="vertical-row">
|
<box width="100%" height="43%" layout="vertical-row" id="race-options-box">
|
||||||
<div width="100%" height="fit" layout="horizontal-row" >
|
<div width="100%" height="fit" layout="horizontal-row" id="target-type-div">
|
||||||
<div proportion="1" height="fit" layout="horizontal-row">
|
<div proportion="3" height="fit" layout="horizontal-row">
|
||||||
<spinner id="lap-spinner" width="100%" min_value="1" max_value="20" align="center"
|
<spinner id="target-type-spinner" width="100%" align="center"
|
||||||
wrap_around="true" />
|
wrap_around="true" />
|
||||||
</div>
|
</div>
|
||||||
<spacer width="3%"/>
|
<spacer width="3%"/>
|
||||||
<label id="lap-text" proportion="3" I18N="In the track info screen" text="Number of laps" text_align="left"/>
|
<label id="target-type-text" proportion="3" I18N="In the track info screen" text="Soccer game type" text_align="left" />
|
||||||
|
</div>
|
||||||
|
<spacer width="1" height="2%"/>
|
||||||
|
<div width="100%" height="fit" layout="horizontal-row" >
|
||||||
|
<div proportion="1" height="fit" layout="horizontal-row">
|
||||||
|
<spinner id="target-value-spinner" width="100%" min_value="1" max_value="20" align="center"
|
||||||
|
wrap_around="true" />
|
||||||
|
</div>
|
||||||
|
<spacer width="3%"/>
|
||||||
|
<label id="target-value-text" proportion="3" I18N="In the track info screen" text="Number of laps" text_align="left"/>
|
||||||
</div>
|
</div>
|
||||||
<spacer width="1" height="2%"/>
|
<spacer width="1" height="2%"/>
|
||||||
<div width="100%" height="fit" layout="horizontal-row" >
|
<div width="100%" height="fit" layout="horizontal-row" >
|
||||||
|
@ -87,14 +87,6 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
{
|
{
|
||||||
StateManager::get()->escapePressed();
|
StateManager::get()->escapePressed();
|
||||||
}
|
}
|
||||||
else if(name == "time_enabled")
|
|
||||||
{
|
|
||||||
SpinnerWidget* timeEnabled = dynamic_cast<SpinnerWidget*>(widget);
|
|
||||||
bool timed = timeEnabled->getValue() == 0;
|
|
||||||
UserConfigParams::m_soccer_use_time_limit = timed;
|
|
||||||
getWidget<SpinnerWidget>("goalamount")->setActive(!timed);
|
|
||||||
getWidget<SpinnerWidget>("timeamount")->setActive(timed);
|
|
||||||
}
|
|
||||||
else if (name == "red_team")
|
else if (name == "red_team")
|
||||||
{
|
{
|
||||||
if (m_kart_view_info.size() == 1)
|
if (m_kart_view_info.size() == 1)
|
||||||
@ -211,26 +203,6 @@ void SoccerSetupScreen::init()
|
|||||||
|
|
||||||
Screen::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<SpinnerWidget>("goalamount");
|
|
||||||
goalamount->setValue(UserConfigParams::m_num_goals);
|
|
||||||
goalamount->setActive(!UserConfigParams::m_soccer_use_time_limit);
|
|
||||||
|
|
||||||
SpinnerWidget* timeAmount = getWidget<SpinnerWidget>("timeamount");
|
|
||||||
timeAmount->setValue(UserConfigParams::m_soccer_time_limit);
|
|
||||||
timeAmount->setActive(UserConfigParams::m_soccer_use_time_limit);
|
|
||||||
|
|
||||||
SpinnerWidget* timeEnabled = getWidget<SpinnerWidget>("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"
|
// Set focus on "continue"
|
||||||
ButtonWidget* bt_continue = getWidget<ButtonWidget>("continue");
|
ButtonWidget* bt_continue = getWidget<ButtonWidget>("continue");
|
||||||
bt_continue->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
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
|
// Reset the 'map fire to select' option of the device manager
|
||||||
input_manager->getDeviceManager()->mapFireToSelect(false);
|
input_manager->getDeviceManager()->mapFireToSelect(false);
|
||||||
|
|
||||||
UserConfigParams::m_num_goals = getWidget<SpinnerWidget>("goalamount")->getValue();
|
|
||||||
UserConfigParams::m_soccer_time_limit = getWidget<SpinnerWidget>("timeamount")->getValue();
|
|
||||||
|
|
||||||
// Remove all ModelViewWidgets we created manually
|
// Remove all ModelViewWidgets we created manually
|
||||||
PtrVector<Widget>& children = central_div->getChildren();
|
PtrVector<Widget>& children = central_div->getChildren();
|
||||||
for(int i = children.size()-1 ; i >= 0 ; i--)
|
for(int i = children.size()-1 ; i >= 0 ; i--)
|
||||||
@ -520,10 +489,5 @@ bool SoccerSetupScreen::onEscapePressed()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void SoccerSetupScreen::prepareGame()
|
void SoccerSetupScreen::prepareGame()
|
||||||
{
|
{
|
||||||
if (getWidget<SpinnerWidget>("goalamount")->isActivated())
|
|
||||||
race_manager->setMaxGoal(getWidget<SpinnerWidget>("goalamount")->getValue());
|
|
||||||
else
|
|
||||||
race_manager->setTimeTarget((float)getWidget<SpinnerWidget>("timeamount")->getValue() * 60);
|
|
||||||
|
|
||||||
input_manager->setMasterPlayerOnly(true);
|
input_manager->setMasterPlayerOnly(true);
|
||||||
} // prepareGame
|
} // prepareGame
|
||||||
|
@ -62,7 +62,11 @@ TrackInfoScreen::TrackInfoScreen()
|
|||||||
/* Saves some often used pointers. */
|
/* Saves some often used pointers. */
|
||||||
void TrackInfoScreen::loadedFromFile()
|
void TrackInfoScreen::loadedFromFile()
|
||||||
{
|
{
|
||||||
m_lap_spinner = getWidget<SpinnerWidget>("lap-spinner");
|
m_target_type_spinner = getWidget<SpinnerWidget>("target-type-spinner");
|
||||||
|
m_target_type_label = getWidget <LabelWidget>("target-type-text");
|
||||||
|
m_target_type_div = getWidget<Widget>("target-type-div");
|
||||||
|
m_target_value_spinner = getWidget<SpinnerWidget>("target-value-spinner");
|
||||||
|
m_target_value_label = getWidget<LabelWidget>("target-value-text");
|
||||||
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
|
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
|
||||||
m_option = getWidget<CheckBoxWidget>("option");
|
m_option = getWidget<CheckBoxWidget>("option");
|
||||||
m_record_race = getWidget<CheckBoxWidget>("record");
|
m_record_race = getWidget<CheckBoxWidget>("record");
|
||||||
@ -82,6 +86,13 @@ void TrackInfoScreen::loadedFromFile()
|
|||||||
screenshot->m_tab_stop = false;
|
screenshot->m_tab_stop = false;
|
||||||
} // loadedFromFile
|
} // 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)
|
void TrackInfoScreen::setTrack(Track *track)
|
||||||
{
|
{
|
||||||
@ -134,18 +145,55 @@ void TrackInfoScreen::init()
|
|||||||
if (image != NULL)
|
if (image != NULL)
|
||||||
screenshot->setImage(image);
|
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
|
// Lap count m_lap_spinner
|
||||||
// -----------------------
|
// -----------------------
|
||||||
m_lap_spinner->setVisible(has_laps);
|
|
||||||
getWidget<LabelWidget>("lap-text")->setVisible(has_laps);
|
|
||||||
if (has_laps)
|
if (has_laps)
|
||||||
{
|
{
|
||||||
|
m_target_value_spinner->setVisible(true);
|
||||||
|
m_target_value_label->setVisible(true);
|
||||||
|
|
||||||
if (UserConfigParams::m_artist_debug_mode)
|
if (UserConfigParams::m_artist_debug_mode)
|
||||||
m_lap_spinner->setMin(0);
|
m_target_value_spinner->setMin(0);
|
||||||
else
|
else
|
||||||
m_lap_spinner->setMin(1);
|
m_target_value_spinner->setMin(1);
|
||||||
m_lap_spinner->setValue(m_track->getActualNumberOfLap());
|
m_target_value_spinner->setValue(m_track->getActualNumberOfLap());
|
||||||
race_manager->setNumLaps(m_lap_spinner->getValue());
|
race_manager->setNumLaps(m_target_value_spinner->getValue());
|
||||||
|
|
||||||
|
m_target_value_label->setText(_("Number of laps"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of AIs
|
// Number of AIs
|
||||||
@ -346,7 +394,7 @@ void TrackInfoScreen::onEnterPressedInternal()
|
|||||||
race_manager->setRecordRace(m_record_this_race);
|
race_manager->setRecordRace(m_record_this_race);
|
||||||
// Create a copy of member variables we still need, since they will
|
// Create a copy of member variables we still need, since they will
|
||||||
// not be accessible after dismiss:
|
// 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;
|
: -1;
|
||||||
const bool option_state = m_option == NULL ? false
|
const bool option_state = m_option == NULL ? false
|
||||||
: m_option->getState();
|
: m_option->getState();
|
||||||
@ -380,6 +428,13 @@ void TrackInfoScreen::onEnterPressedInternal()
|
|||||||
UserConfigParams::m_num_karts_per_gamemode[race_manager->getMinorMode()] = local_players + num_ai;
|
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<float>(selected_target_value) * 60);
|
||||||
|
else
|
||||||
|
race_manager->setMaxGoal(selected_target_value);
|
||||||
|
|
||||||
// Disable accidentally unlocking of a challenge
|
// Disable accidentally unlocking of a challenge
|
||||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
||||||
|
|
||||||
@ -403,6 +458,43 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
{
|
{
|
||||||
StateManager::get()->escapePressed();
|
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")
|
else if (name == "option")
|
||||||
{
|
{
|
||||||
if (m_track->hasNavMesh())
|
if (m_track->hasNavMesh())
|
||||||
@ -434,14 +526,6 @@ void TrackInfoScreen::eventCallback(Widget* widget, const std::string& name,
|
|||||||
m_ai_kart_spinner->setActive(true);
|
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")
|
else if (name=="ai-spinner")
|
||||||
{
|
{
|
||||||
const int num_ai = m_ai_kart_spinner->getValue();
|
const int num_ai = m_ai_kart_spinner->getValue();
|
||||||
|
@ -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
|
// 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)
|
// 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. */
|
/** Spinner for number of AI karts. */
|
||||||
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
|
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
|
||||||
@ -76,6 +89,7 @@ public:
|
|||||||
virtual ~TrackInfoScreen();
|
virtual ~TrackInfoScreen();
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
virtual void beforeAddingWidget() OVERRIDE;
|
||||||
virtual void loadedFromFile();
|
virtual void loadedFromFile();
|
||||||
virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,
|
virtual void eventCallback(GUIEngine::Widget *,const std::string &name ,
|
||||||
const int player_id);
|
const int player_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user