Various fixes to get battle mode working again

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4753 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-02-17 16:48:12 +00:00
parent 85d077ff1d
commit 263b94c706
4 changed files with 48 additions and 24 deletions

View File

@@ -28,7 +28,9 @@ ThreeStrikesBattle::ThreeStrikesBattle() : World()
{
WorldStatus::setClockMode(CLOCK_CHRONO);
m_use_highscores = false;
}
void ThreeStrikesBattle::init()
{
World::init();
// check for possible problems if AI karts were incorrectly added

View File

@@ -45,6 +45,8 @@ public:
ThreeStrikesBattle();
virtual ~ThreeStrikesBattle();
virtual void init();
// clock events
virtual bool isRaceOver();
virtual void terminateRace();

View File

@@ -45,6 +45,8 @@ using namespace GUIEngine;
TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core::stringw& trackName,
ITexture* screenshot, const float w, const float h) : ModalDialog(w, h)
{
const bool has_laps = RaceManager::modeHasLaps(race_manager->getMinorMode());
const int y1 = m_area.getHeight()/7;
const int y2 = m_area.getHeight()*5/7;
const int y3 = m_area.getHeight()*6/7;
@@ -101,25 +103,32 @@ TrackInfoDialog::TrackInfoDialog(const std::string& trackIdent, const irr::core:
b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);
// ---- Lap count m_spinner
m_spinner = new SpinnerWidget();
m_spinner->x = m_area.getWidth()/2 - 200;
m_spinner->y = y2;
m_spinner->w = 400;
m_spinner->h = y3 - y2 - 15;
m_spinner->setParent(m_irrlicht_window);
m_spinner->m_properties[PROP_ID] = "lapcountspinner";
m_spinner->m_properties[PROP_MIN_VALUE] = "1";
m_spinner->m_properties[PROP_MAX_VALUE] = "99";
//I18N: In the track setup screen (number of laps choice, where %i is the number)
m_spinner->m_text = _("%i laps");
m_children.push_back(m_spinner);
m_spinner->add();
m_spinner->setValue(3);
m_spinner->getIrrlichtElement()->setTabStop(true);
m_spinner->getIrrlichtElement()->setTabGroup(false);
if (has_laps)
{
m_spinner = new SpinnerWidget();
m_spinner->x = m_area.getWidth()/2 - 200;
m_spinner->y = y2;
m_spinner->w = 400;
m_spinner->h = y3 - y2 - 15;
m_spinner->setParent(m_irrlicht_window);
m_spinner->m_properties[PROP_ID] = "lapcountspinner";
m_spinner->m_properties[PROP_MIN_VALUE] = "1";
m_spinner->m_properties[PROP_MAX_VALUE] = "99";
//I18N: In the track setup screen (number of laps choice, where %i is the number)
m_spinner->m_text = _("%i laps");
m_children.push_back(m_spinner);
m_spinner->add();
m_spinner->setValue(3);
m_spinner->getIrrlichtElement()->setTabStop(true);
m_spinner->getIrrlichtElement()->setTabGroup(false);
}
else
{
m_spinner = NULL;
}
// ---- Start button
ButtonWidget* okBtn = new ButtonWidget();
@@ -252,6 +261,13 @@ void TrackInfoDialog::updateHighScores()
// ------------------------------------------------------------------------------------------------------
// FIXME : this probably doesn't belong here
/**
* Start a race, using the settings set through previous menus, plus which track
* plus number of laps if relevant
*
* \param trackIdent Internal name of the track to race on
* \param num_laps Number of laps to do, or -1 if not relevant
*/
void startGame(const std::string trackIdent, const int num_laps)
{
ModalDialog::dismiss();
@@ -267,7 +283,9 @@ void startGame(const std::string trackIdent, const int num_laps)
StateManager::get()->enterGameState();
//race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setTrack(trackIdent.c_str());
race_manager->setNumLaps( num_laps );
if (num_laps != -1) race_manager->setNumLaps( num_laps );
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
//race_manager->setNumKarts( 1 );
network_manager->setupPlayerKartInfo();
@@ -280,7 +298,7 @@ void startGame(const std::string trackIdent, const int num_laps)
void TrackInfoDialog::onEnterPressedInternal()
{
const int num_laps = m_spinner->getValue();
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
startGame(m_track_ident, num_laps);
}
@@ -290,12 +308,13 @@ GUIEngine::EventPropagation TrackInfoDialog::processEvent(std::string& eventSour
{
if (eventSource == "start" )
{
const int num_laps = m_spinner->getValue();
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
startGame(m_track_ident, num_laps);
return GUIEngine::EVENT_BLOCK;
}
else if (eventSource == "lapcountspinner")
{
assert(m_spinner != NULL);
const int num_laps = m_spinner->getValue();
race_manager->setNumLaps(num_laps);
updateHighScores();

View File

@@ -86,11 +86,12 @@ void RaceSetupScreen::eventCallback(Widget* widget, const std::string& name, con
else if (selectedMode == "3strikes")
{
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
//FIXME: it's a little weird that the value from the 'AI karts' spinner is ignored
race_manager->setNumKarts( race_manager->getNumPlayers() ); // no AI karts;
StateManager::get()->pushScreen( ArenasScreen::getInstance() );
}
else if (selectedMode == "locked")
{
std::cout << "Requesting sound to be played\n";
unlock_manager->playLockSound();
}
}