Allow auto recreation of ghost replay file lists after recording.

This commit is contained in:
Benau 2016-03-25 16:11:32 +08:00
parent 151cc72e22
commit dff5f8d459
4 changed files with 14 additions and 12 deletions

View File

@ -280,7 +280,7 @@ void World::reset()
race_manager->reset();
// Make sure to overwrite the data from the previous race.
if(!history->replayHistory()) history->initRecording();
if(race_manager->willRecordRace())
if(race_manager->isRecordingRace())
{
Log::info("World", "Start Recording race.");
ReplayRecorder::get()->init();
@ -436,16 +436,18 @@ World::~World()
delete m_karts[i];
}
if(race_manager->hasGhostKarts())
if(race_manager->hasGhostKarts() || race_manager->isRecordingRace())
{
// Destroy the old replay object, which also stored the ghost
// karts, and create a new one (which means that in further
// races the usage of ghosts will still be enabled).
// It can allow auto recreation of ghost replay file lists
// when next time visit the ghost replay selection screen.
ReplayPlay::destroy();
ReplayPlay::create();
}
m_karts.clear();
if(race_manager->willRecordRace())
if(race_manager->isRecordingRace())
ReplayRecorder::get()->reset();
race_manager->setRaceGhostKarts(false);
race_manager->setRecordRace(false);
@ -982,7 +984,7 @@ void World::update(float dt)
PROFILER_PUSH_CPU_MARKER("World::update (sub-updates)", 0x20, 0x7F, 0x00);
history->update(dt);
if(race_manager->willRecordRace()) ReplayRecorder::get()->update(dt);
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(dt);
if(history->replayHistory()) dt=history->getNextDelta();
WorldStatus::update(dt);
if (m_script_engine) m_script_engine->update(dt);

View File

@ -948,7 +948,7 @@ void RaceManager::setupPlayerKartInfo()
void RaceManager::startWatchingReplay(const std::string &track_ident,
const int num_laps)
{
assert(m_watching_replay && m_has_ghost_karts && !m_will_record_race);
assert(m_watching_replay && m_has_ghost_karts && !m_is_recording_race);
StateManager::get()->enterGameState();
setTrack(track_ident);
setNumLaps(num_laps);

View File

@ -351,7 +351,7 @@ private:
/** Determines if saved GP should be continued or not*/
bool m_continue_saved_gp;
bool m_will_record_race;
bool m_is_recording_race;
bool m_has_ghost_karts;
@ -722,7 +722,7 @@ public:
// ------------------------------------------------------------------------
void setRecordRace(bool record)
{
m_will_record_race = record;
m_is_recording_race = record;
} // setRecordRace
// ------------------------------------------------------------------------
void setRaceGhostKarts(bool ghost)
@ -735,10 +735,10 @@ public:
m_watching_replay = watch;
} // setWatchingReplay
// ------------------------------------------------------------------------
bool willRecordRace() const
bool isRecordingRace() const
{
return m_will_record_race;
} // willRecordRace
return m_is_recording_race;
} // isRecordingRace
// ------------------------------------------------------------------------
bool hasGhostKarts() const
{

View File

@ -231,9 +231,9 @@ void TrackInfoScreen::init()
const bool record_available = race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL;
m_record_race->setVisible(record_available);
getWidget<LabelWidget>("record-race-text")->setVisible(record_available);
if (race_manager->willRecordRace())
if (race_manager->isRecordingRace())
{
// willRecordRace() is true when it's pre-set by ghost replay selection
// isRecordingRace() is true when it's pre-set by ghost replay selection
// which force record this race
m_record_this_race = true;
m_record_race->setState(true);