Added time limited-match instead of only goal-limited ones.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14472 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -14,7 +14,20 @@
|
||||
<spacer width="50" height="25"/>
|
||||
<spinner id="goalamount" proportion="1" height="100%" min_value="1" max_value="10" wrap_around="true"/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="50" align="center">
|
||||
|
||||
<bright proportion="1" height="100%"
|
||||
I18N="In soccer setup menu" text="Maximum time(minutes)" text_align="right" />
|
||||
<checkbox id="time_enabled" height="40"/>
|
||||
<spacer width="50" height="25"/>
|
||||
|
||||
<spinner id="timeamount" proportion="1" height="100%" min_value="1" max_value="45" wrap_around="true"/>
|
||||
</div>
|
||||
|
||||
|
||||
<spacer height="25" width="25"/>
|
||||
|
||||
<bright height="15" width="25" I18N="In soccer setup menu" text="Use left/right to choose your team" text_align="center" align="center" />
|
||||
|
||||
@@ -161,6 +161,8 @@ namespace GUIEngine
|
||||
/** Override method from base class Widget */
|
||||
virtual void setDeactivated();
|
||||
|
||||
bool isActivated() { return !m_deactivated; }
|
||||
|
||||
/** Display custom text in spinner */
|
||||
void setCustomText(const core::stringw& text);
|
||||
};
|
||||
|
||||
@@ -41,7 +41,11 @@
|
||||
*/
|
||||
SoccerWorld::SoccerWorld() : WorldWithRank()
|
||||
{
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
if(race_manager->hasTimeTarget()){
|
||||
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN, race_manager->getTimeTarget());
|
||||
countDownReachedZero = false;
|
||||
}
|
||||
else WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
m_use_highscores = false;
|
||||
} // SoccerWorld
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -63,7 +67,7 @@ void SoccerWorld::init()
|
||||
m_display_rank = false;
|
||||
m_goal_timer = 0.f;
|
||||
m_lastKartToHitBall = -1;
|
||||
|
||||
|
||||
// check for possible problems if AI karts were incorrectly added
|
||||
if(getNumKarts() > race_manager->getNumPlayers())
|
||||
{
|
||||
@@ -81,6 +85,11 @@ void SoccerWorld::init()
|
||||
void SoccerWorld::reset()
|
||||
{
|
||||
WorldWithRank::reset();
|
||||
if(race_manager->hasTimeTarget()){
|
||||
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN, race_manager->getTimeTarget());
|
||||
countDownReachedZero = false;
|
||||
}
|
||||
else WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
|
||||
m_can_score_points = true;
|
||||
memset(m_team_goals, 0, sizeof(m_team_goals));
|
||||
@@ -165,11 +174,17 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||
{
|
||||
if(first_goal){
|
||||
m_redScorers.push_back(m_lastKartToHitBall);
|
||||
m_redScoreTimes.push_back(world->getTime());
|
||||
if(race_manager->hasTimeTarget())
|
||||
m_redScoreTimes.push_back(race_manager->getTimeTarget() - world->getTime());
|
||||
else
|
||||
m_redScoreTimes.push_back(world->getTime());
|
||||
}
|
||||
else{
|
||||
m_blueScorers.push_back(m_lastKartToHitBall);
|
||||
m_blueScoreTimes.push_back(world->getTime());
|
||||
if(race_manager->hasTimeTarget())
|
||||
m_blueScoreTimes.push_back(race_manager->getTimeTarget() - world->getTime());
|
||||
else
|
||||
m_blueScoreTimes.push_back(world->getTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,7 +239,11 @@ bool SoccerWorld::isRaceOver()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// One team scored the target goals ...
|
||||
|
||||
else if(race_manager->hasTimeTarget()){
|
||||
return countDownReachedZero;
|
||||
}
|
||||
// One team scored the target goals ...
|
||||
else if(getScore(0) >= m_goal_target ||
|
||||
getScore(1) >= m_goal_target )
|
||||
{
|
||||
@@ -244,6 +263,12 @@ void SoccerWorld::terminateRace()
|
||||
m_can_score_points = false;
|
||||
WorldWithRank::terminateRace();
|
||||
} // terminateRace
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when the match time ends.
|
||||
*/
|
||||
void SoccerWorld::countdownReachedZero(){
|
||||
countDownReachedZero = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the data to display in the race gui.
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
int m_team_goals[NB_SOCCER_TEAMS];
|
||||
/** Number of goals needed to win */
|
||||
int m_goal_target;
|
||||
bool countDownReachedZero;
|
||||
/** Whether or not goals can be scored (they are disabled when a point is scored
|
||||
and re-enabled when the next game can be played)*/
|
||||
bool m_can_score_points;
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
// clock events
|
||||
virtual bool isRaceOver();
|
||||
virtual void terminateRace();
|
||||
virtual void countdownReachedZero() OVERRIDE;
|
||||
|
||||
// overriding World methods
|
||||
virtual void reset();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "states_screens/arenas_screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/model_view_widget.hpp"
|
||||
#include "guiengine/scalable_font.hpp"
|
||||
@@ -56,13 +57,31 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name, c
|
||||
if(name == "continue")
|
||||
{
|
||||
StateManager::get()->pushScreen( ArenasScreen::getInstance() );
|
||||
race_manager->setMaxGoal(getWidget<SpinnerWidget>("goalamount")->getValue());
|
||||
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);
|
||||
}
|
||||
else if (name == "back")
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
else if(name == "time_enabled")
|
||||
{
|
||||
CheckBoxWidget* timeEnabled = dynamic_cast<CheckBoxWidget*>(widget);
|
||||
if(timeEnabled->getState())
|
||||
{
|
||||
getWidget<SpinnerWidget>("goalamount")->setDeactivated();
|
||||
getWidget<SpinnerWidget>("timeamount")->setActivated();
|
||||
}
|
||||
else
|
||||
{
|
||||
getWidget<SpinnerWidget>("timeamount")->setDeactivated();
|
||||
getWidget<SpinnerWidget>("goalamount")->setActivated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -143,6 +162,12 @@ void SoccerSetupScreen::init()
|
||||
|
||||
SpinnerWidget* goalamount = getWidget<SpinnerWidget>("goalamount");
|
||||
goalamount->setValue(UserConfigParams::m_num_goals);
|
||||
goalamount->setDeactivated();
|
||||
|
||||
SpinnerWidget* timeAmount = getWidget<SpinnerWidget>("timeamount");
|
||||
timeAmount->setValue(timeAmount->getMin());
|
||||
|
||||
CheckBoxWidget* timeEnabled = getWidget<CheckBoxWidget>("time_enabled");
|
||||
|
||||
// Set focus on "continue"
|
||||
ButtonWidget* bt_continue = getWidget<ButtonWidget>("continue");
|
||||
|
||||
Reference in New Issue
Block a user