Fix #3578
- If there is 2 or 3 karts in the GP, karts in 2nd and (if any) 3rd place display a sad animation - If there is 4 karts in the GP, the kart in 3rd displays a sad animation - If there is 5 karts or more in the GP, all karts on the podium display a happy animation The first kart in the GP always displays a happy animation even if alone.
This commit is contained in:
parent
bf88954e31
commit
a57ac415bb
@ -985,6 +985,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
|
||||
StateManager::get()->enterGameState();
|
||||
setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||
int num_gp_karts = m_num_karts;
|
||||
setNumKarts(0);
|
||||
setNumPlayers(0);
|
||||
|
||||
@ -995,6 +996,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
raceWasStartedFromOverworld());
|
||||
GrandPrixWin* scene = GrandPrixWin::getInstance();
|
||||
scene->push();
|
||||
scene->setNumGPKarts(num_gp_karts); // This must be set before we set karts
|
||||
scene->setKarts(winners);
|
||||
scene->setPlayerWon(some_human_player_won);
|
||||
std::set<std::string> karts;
|
||||
@ -1024,6 +1026,7 @@ void RaceManager::exitRace(bool delete_world)
|
||||
scene->setKarts(karts);
|
||||
}
|
||||
}
|
||||
|
||||
kart_properties_manager->onDemandLoadKartTextures(used_karts);
|
||||
}
|
||||
|
||||
@ -1118,6 +1121,7 @@ void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld,
|
||||
* \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
|
||||
* \param from_overworld If it was started from the Story Mode overworld
|
||||
*/
|
||||
void RaceManager::startSingleRace(const std::string &track_ident,
|
||||
const int num_laps,
|
||||
|
@ -119,6 +119,7 @@ GrandPrixWin::GrandPrixWin() : GrandPrixCutscene("grand_prix_win.stkgui")
|
||||
m_podium_steps[i] = NULL;
|
||||
}
|
||||
m_player_won = false;
|
||||
m_num_gp_karts = 0;
|
||||
} // GrandPrixWin
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
@ -329,6 +330,13 @@ void GrandPrixWin::onUpdate(float dt)
|
||||
} // onUpdate
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixWin::setNumGPKarts(int num_gp_karts)
|
||||
{
|
||||
m_num_gp_karts = num_gp_karts;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void GrandPrixWin::setKarts(const std::pair<std::string, float> idents_arg[3])
|
||||
@ -356,18 +364,41 @@ void GrandPrixWin::setKarts(const std::pair<std::string, float> idents_arg[3])
|
||||
// Lod node has to be animated
|
||||
auto* a_node = static_cast<scene::IAnimatedMeshSceneNode*>
|
||||
(lnode->getAllNodes()[0]);
|
||||
const unsigned start_frame =
|
||||
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) :
|
||||
kart_model->getFrame(KartModel::AF_WIN_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_START) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
const unsigned end_frame =
|
||||
kart_model->getFrame(KartModel::AF_WIN_END) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_END) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
a_node->setLoopMode(true);
|
||||
a_node->setFrameLoop(start_frame, end_frame);
|
||||
|
||||
// If the kart is not 1st (after the reorder, the id of the winner is 1, not 0)
|
||||
// and there are very few karts in the GP, display a sad animation rather than
|
||||
// a happy animation
|
||||
if ((i == 0 && m_num_gp_karts <= 3) ||
|
||||
(i == 2 && m_num_gp_karts <= 4))
|
||||
{
|
||||
const unsigned start_frame =
|
||||
kart_model->getFrame(KartModel::AF_LOSE_LOOP_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_LOSE_LOOP_START) :
|
||||
kart_model->getFrame(KartModel::AF_LOSE_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_LOSE_START) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
const unsigned end_frame =
|
||||
kart_model->getFrame(KartModel::AF_LOSE_END) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_LOSE_END) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
a_node->setLoopMode(true);
|
||||
a_node->setFrameLoop(start_frame, end_frame);
|
||||
}
|
||||
else // Standard happy animations
|
||||
{
|
||||
const unsigned start_frame =
|
||||
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) :
|
||||
kart_model->getFrame(KartModel::AF_WIN_START) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_START) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
const unsigned end_frame =
|
||||
kart_model->getFrame(KartModel::AF_WIN_END) > -1 ?
|
||||
kart_model->getFrame(KartModel::AF_WIN_END) :
|
||||
kart_model->getFrame(KartModel::AF_STRAIGHT);
|
||||
a_node->setLoopMode(true);
|
||||
a_node->setFrameLoop(start_frame, end_frame);
|
||||
}
|
||||
}
|
||||
|
||||
m_kart_x[i] = KARTS_INITIAL_X[i];
|
||||
|
@ -58,6 +58,9 @@ class GrandPrixWin :
|
||||
|
||||
int m_phase;
|
||||
|
||||
/** Used to pick the happy/sad animations of karts */
|
||||
int m_num_gp_karts;
|
||||
|
||||
float m_kart_x[3], m_kart_y[3], m_kart_z[3];
|
||||
float m_kart_rotation[3];
|
||||
|
||||
@ -75,6 +78,7 @@ public:
|
||||
MusicInformation* getInGameMenuMusic() const OVERRIDE;
|
||||
|
||||
/** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */
|
||||
void setNumGPKarts(int num_gp_karts);
|
||||
void setKarts(const std::pair<std::string, float> karts[3]);
|
||||
void setPlayerWon(bool some_player_won) { m_player_won = some_player_won; }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user