Move some code from GUI screens to RaceManager, where it makes more sense to find the said code, and correcting 2 FIXMEs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7235 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d22ec956b6
commit
9c3f46521e
@ -535,4 +535,36 @@ void RaceManager::rerunRace()
|
||||
World::getWorld()->restartRace();
|
||||
} // rerunRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RaceManager::startGP(const GrandPrixData* gp)
|
||||
{
|
||||
assert(gp != NULL);
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
setGrandPrix(*gp);
|
||||
setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
network_manager->setupPlayerKartInfo();
|
||||
|
||||
setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
|
||||
startNew();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RaceManager::startSingleRace(const std::string trackIdent, const int num_laps)
|
||||
{
|
||||
StateManager::get()->enterGameState();
|
||||
setTrack(trackIdent.c_str());
|
||||
|
||||
if (num_laps != -1) setNumLaps( num_laps );
|
||||
|
||||
setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
||||
setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
network_manager->setupPlayerKartInfo();
|
||||
|
||||
startNew();
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@ -335,6 +335,19 @@ public:
|
||||
void rerunRace(); // Rerun the same race again
|
||||
void exitRace(); // exit a race (and don't start the next one)
|
||||
|
||||
/**
|
||||
* \brief Higher-level method to start a GP without having to care about the exact startup sequence
|
||||
*/
|
||||
void startGP(const GrandPrixData* gp);
|
||||
|
||||
/**
|
||||
* \brief Higher-level method to start a GP without having to care about the exact startup sequence
|
||||
* \param trackIdent Internal name of the track to race on
|
||||
* \param num_laps Number of laps to race, or -1 if number of laps is not relevant in current mode
|
||||
*/
|
||||
void startSingleRace(const std::string trackIdent, const int num_laps);
|
||||
|
||||
|
||||
/** get information about given mode (returns true if 'mode' is of linear races type)
|
||||
* info is stored in its ID for conveniance, see the macros LINEAR_RACE and
|
||||
* BATTLE_ARENA above for exact meaning.
|
||||
|
@ -178,34 +178,12 @@ GPInfoDialog::~GPInfoDialog()
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
// FIXME : this probably doesn't belong here
|
||||
void startGPGame(const GrandPrixData* gp)
|
||||
{
|
||||
assert(gp != NULL);
|
||||
ModalDialog::dismiss();
|
||||
|
||||
//FIXME: simplify and centralize race start sequence!!
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setGrandPrix(*gp);
|
||||
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
//race_manager->setNumKarts( 1 );
|
||||
network_manager->setupPlayerKartInfo();
|
||||
//race_manager->getKartType(1) = KT_PLAYER;
|
||||
|
||||
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
|
||||
race_manager->startNew();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void GPInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
startGPGame(grand_prix_manager->getGrandPrix(m_gp_ident));
|
||||
ModalDialog::dismiss();
|
||||
race_manager->startGP(grand_prix_manager->getGrandPrix(m_gp_ident));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
@ -214,7 +192,8 @@ GUIEngine::EventPropagation GPInfoDialog::processEvent(const std::string& eventS
|
||||
{
|
||||
if (eventSource == "start")
|
||||
{
|
||||
startGPGame(grand_prix_manager->getGrandPrix(m_gp_ident));
|
||||
ModalDialog::dismiss();
|
||||
race_manager->startGP(grand_prix_manager->getGrandPrix(m_gp_ident));
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "cannot_start")
|
||||
|
@ -275,40 +275,12 @@ 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)
|
||||
{
|
||||
//FIXME: simplify and centralize race start sequence!!
|
||||
|
||||
ModalDialog::dismiss();
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
//race_manager->setDifficulty(RaceManager::RD_HARD);
|
||||
race_manager->setTrack(trackIdent.c_str());
|
||||
|
||||
if (num_laps != -1) race_manager->setNumLaps( num_laps );
|
||||
|
||||
race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
|
||||
|
||||
race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge
|
||||
network_manager->setupPlayerKartInfo();
|
||||
|
||||
race_manager->startNew();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void TrackInfoDialog::onEnterPressedInternal()
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
|
||||
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
|
||||
startGame(m_track_ident, num_laps);
|
||||
race_manager->startSingleRace(m_track_ident, num_laps);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
@ -317,8 +289,10 @@ GUIEngine::EventPropagation TrackInfoDialog::processEvent(const std::string& eve
|
||||
{
|
||||
if (eventSource == "start" )
|
||||
{
|
||||
ModalDialog::dismiss();
|
||||
|
||||
const int num_laps = (m_spinner == NULL ? -1 : m_spinner->getValue());
|
||||
startGame(m_track_ident, num_laps);
|
||||
race_manager->startSingleRace(m_track_ident, num_laps);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "lapcountspinner")
|
||||
|
Loading…
Reference in New Issue
Block a user