Allow watch replay only
This commit is contained in:
parent
07afd444a8
commit
da70d305a9
@ -19,7 +19,7 @@
|
|||||||
<div width="100%" height="fit" layout="horizontal-row" >
|
<div width="100%" height="fit" layout="horizontal-row" >
|
||||||
<checkbox width="fit" id="watch-only" I18N="Ghost replay info action" text_align="left"/>
|
<checkbox width="fit" id="watch-only" I18N="Ghost replay info action" text_align="left"/>
|
||||||
<spacer width="10"/>
|
<spacer width="10"/>
|
||||||
<label proportion="1" height="100%" text_align="left" I18N="Ghost replay info action" text="Watch the race"/>
|
<label proportion="1" height="100%" text_align="left" I18N="Ghost replay info action" text="Watch replay only"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -710,7 +710,8 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
|
|||||||
|
|
||||||
// ... when in-game
|
// ... when in-game
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::GAME &&
|
if (StateManager::get()->getGameState() == GUIEngine::GAME &&
|
||||||
!GUIEngine::ModalDialog::isADialogActive() )
|
!GUIEngine::ModalDialog::isADialogActive() &&
|
||||||
|
!race_manager->isWatchingReplay() )
|
||||||
{
|
{
|
||||||
if (player == NULL)
|
if (player == NULL)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +83,8 @@ void GhostKart::update(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int idx = gc->getCurrentReplayIndex();
|
const unsigned int idx = gc->getCurrentReplayIndex();
|
||||||
|
if (!race_manager->isWatchingReplay())
|
||||||
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
{
|
{
|
||||||
m_node->setVisible(false);
|
m_node->setVisible(false);
|
||||||
@ -92,6 +94,7 @@ void GhostKart::update(float dt)
|
|||||||
// Start showing the ghost when it start racing
|
// Start showing the ghost when it start racing
|
||||||
m_node->setVisible(true);
|
m_node->setVisible(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const float rd = gc->getReplayDelta();
|
const float rd = gc->getReplayDelta();
|
||||||
assert(idx < m_all_transform.size());
|
assert(idx < m_all_transform.size());
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "items/powerup_manager.hpp"
|
#include "items/powerup_manager.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/controller/controller.hpp"
|
#include "karts/controller/controller.hpp"
|
||||||
|
#include "karts/controller/ghost_controller.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -34,6 +35,11 @@ StandardRace::StandardRace() : LinearWorld()
|
|||||||
*/
|
*/
|
||||||
bool StandardRace::isRaceOver()
|
bool StandardRace::isRaceOver()
|
||||||
{
|
{
|
||||||
|
if (race_manager->isWatchingReplay())
|
||||||
|
{
|
||||||
|
return dynamic_cast<GhostController*>
|
||||||
|
(m_karts[0]->getController())->isReplayEnd();
|
||||||
|
}
|
||||||
// The race is over if all players have finished the race. Remaining
|
// The race is over if all players have finished the race. Remaining
|
||||||
// times for AI opponents will be estimated in enterRaceOverState
|
// times for AI opponents will be estimated in enterRaceOverState
|
||||||
return race_manager->allPlayerFinished();
|
return race_manager->allPlayerFinished();
|
||||||
|
@ -285,10 +285,11 @@ void World::reset()
|
|||||||
Log::info("World", "Start Recording race.");
|
Log::info("World", "Start Recording race.");
|
||||||
ReplayRecorder::get()->init();
|
ReplayRecorder::get()->init();
|
||||||
}
|
}
|
||||||
if(NetworkConfig::get()->isServer() && !ProfileWorld::isNoGraphics())
|
if((NetworkConfig::get()->isServer() && !ProfileWorld::isNoGraphics()) ||
|
||||||
|
race_manager->isWatchingReplay())
|
||||||
{
|
{
|
||||||
// In case that the server is running with gui, create a camera and
|
// In case that the server is running with gui or watching replay,
|
||||||
// attach it to the first kart.
|
// create a camera and attach it to the first kart.
|
||||||
Camera::createCamera(World::getWorld()->getKart(0));
|
Camera::createCamera(World::getWorld()->getKart(0));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -448,6 +449,7 @@ World::~World()
|
|||||||
ReplayRecorder::get()->reset();
|
ReplayRecorder::get()->reset();
|
||||||
race_manager->setRaceGhostKarts(false);
|
race_manager->setRaceGhostKarts(false);
|
||||||
race_manager->setRecordRace(false);
|
race_manager->setRecordRace(false);
|
||||||
|
race_manager->setWatchingReplay(false);
|
||||||
|
|
||||||
Camera::removeAllCameras();
|
Camera::removeAllCameras();
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ RaceManager::RaceManager()
|
|||||||
setReverseTrack(false);
|
setReverseTrack(false);
|
||||||
setRecordRace(false);
|
setRecordRace(false);
|
||||||
setRaceGhostKarts(false);
|
setRaceGhostKarts(false);
|
||||||
|
setWatchingReplay(false);
|
||||||
setTrack("jungle");
|
setTrack("jungle");
|
||||||
m_default_ai_list.clear();
|
m_default_ai_list.clear();
|
||||||
setNumPlayers(0);
|
setNumPlayers(0);
|
||||||
@ -913,6 +914,7 @@ void RaceManager::startSingleRace(const std::string &track_ident,
|
|||||||
const int num_laps,
|
const int num_laps,
|
||||||
bool from_overworld)
|
bool from_overworld)
|
||||||
{
|
{
|
||||||
|
assert(!m_watching_replay);
|
||||||
StateManager::get()->enterGameState();
|
StateManager::get()->enterGameState();
|
||||||
setTrack(track_ident);
|
setTrack(track_ident);
|
||||||
|
|
||||||
@ -931,10 +933,44 @@ void RaceManager::startSingleRace(const std::string &track_ident,
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Fills up the remaining kart slots with AI karts.
|
/** Fills up the remaining kart slots with AI karts.
|
||||||
v*/
|
*/
|
||||||
void RaceManager::setupPlayerKartInfo()
|
void RaceManager::setupPlayerKartInfo()
|
||||||
{
|
{
|
||||||
computeRandomKartList();
|
computeRandomKartList();
|
||||||
} // setupPlayerKartInfo
|
} // setupPlayerKartInfo
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
/** \brief Function to start the race with only ghost kart(s) and watch.
|
||||||
|
* \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 RaceManager::startWatchingReplay(const std::string &track_ident,
|
||||||
|
const int num_laps)
|
||||||
|
{
|
||||||
|
assert(m_watching_replay && m_has_ghost_karts && !m_will_record_race);
|
||||||
|
StateManager::get()->enterGameState();
|
||||||
|
setTrack(track_ident);
|
||||||
|
setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
|
||||||
|
setCoinTarget(0);
|
||||||
|
m_num_karts = ReplayPlay::get()->getNumGhostKart();
|
||||||
|
|
||||||
|
Log::verbose("RaceManager", "%u ghost kart(s) for watching replay only\n",
|
||||||
|
(unsigned int)m_num_karts);
|
||||||
|
|
||||||
|
int init_gp_rank = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < m_num_karts; i++)
|
||||||
|
{
|
||||||
|
m_kart_status.push_back(KartStatus(ReplayPlay::get()->getGhostKartName(i),
|
||||||
|
i, -1, -1, init_gp_rank, KT_GHOST, PLAYER_DIFFICULTY_NORMAL));
|
||||||
|
init_gp_rank ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_track_number = 0;
|
||||||
|
startNextRace();
|
||||||
|
} // startSingleRace
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
@ -354,6 +354,8 @@ private:
|
|||||||
bool m_will_record_race;
|
bool m_will_record_race;
|
||||||
|
|
||||||
bool m_has_ghost_karts;
|
bool m_has_ghost_karts;
|
||||||
|
|
||||||
|
bool m_watching_replay;
|
||||||
public:
|
public:
|
||||||
RaceManager();
|
RaceManager();
|
||||||
~RaceManager();
|
~RaceManager();
|
||||||
@ -407,6 +409,7 @@ public:
|
|||||||
void saveGP();
|
void saveGP();
|
||||||
void startSingleRace(const std::string &track_ident, const int num_laps,
|
void startSingleRace(const std::string &track_ident, const int num_laps,
|
||||||
bool from_overworld);
|
bool from_overworld);
|
||||||
|
void startWatchingReplay(const std::string &track_ident, const int num_laps);
|
||||||
void setupPlayerKartInfo();
|
void setupPlayerKartInfo();
|
||||||
void kartFinishedRace(const AbstractKart* kart, float time);
|
void kartFinishedRace(const AbstractKart* kart, float time);
|
||||||
void setNumPlayers(int players, int local_players=-1);
|
void setNumPlayers(int players, int local_players=-1);
|
||||||
@ -727,6 +730,11 @@ public:
|
|||||||
m_has_ghost_karts = ghost;
|
m_has_ghost_karts = ghost;
|
||||||
} // setRaceGhostKarts
|
} // setRaceGhostKarts
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void setWatchingReplay(bool watch)
|
||||||
|
{
|
||||||
|
m_watching_replay = watch;
|
||||||
|
} // setWatchingReplay
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
bool willRecordRace() const
|
bool willRecordRace() const
|
||||||
{
|
{
|
||||||
return m_will_record_race;
|
return m_will_record_race;
|
||||||
@ -736,6 +744,11 @@ public:
|
|||||||
{
|
{
|
||||||
return m_has_ghost_karts;
|
return m_has_ghost_karts;
|
||||||
} // hasGhostKarts
|
} // hasGhostKarts
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
bool isWatchingReplay() const
|
||||||
|
{
|
||||||
|
return m_watching_replay;
|
||||||
|
} // isWatchingReplay
|
||||||
|
|
||||||
}; // RaceManager
|
}; // RaceManager
|
||||||
|
|
||||||
|
@ -73,19 +73,26 @@ GUIEngine::EventPropagation
|
|||||||
std::string track_name = m_rd.m_track_name;
|
std::string track_name = m_rd.m_track_name;
|
||||||
int laps = m_rd.m_laps;
|
int laps = m_rd.m_laps;
|
||||||
int replay_id = m_replay_id;
|
int replay_id = m_replay_id;
|
||||||
bool record = m_record_race;
|
|
||||||
|
race_manager->setRecordRace(m_record_race);
|
||||||
|
race_manager->setWatchingReplay(m_watch_only);
|
||||||
|
|
||||||
ModalDialog::dismiss();
|
ModalDialog::dismiss();
|
||||||
ReplayPlay::get()->setReplayFile(replay_id);
|
ReplayPlay::get()->setReplayFile(replay_id);
|
||||||
race_manager->setRaceGhostKarts(true);
|
race_manager->setRaceGhostKarts(true);
|
||||||
race_manager->setRecordRace(record);
|
|
||||||
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
|
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
|
||||||
|
|
||||||
// Disable accidentally unlocking of a challenge
|
// Disable accidentally unlocking of a challenge
|
||||||
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
PlayerManager::getCurrentPlayer()->setCurrentChallenge("");
|
||||||
|
|
||||||
race_manager->setReverseTrack(reverse);
|
race_manager->setReverseTrack(reverse);
|
||||||
|
|
||||||
|
if (race_manager->isWatchingReplay())
|
||||||
|
race_manager->startWatchingReplay(track_name, laps);
|
||||||
|
else
|
||||||
race_manager->startSingleRace(track_name, laps, false);
|
race_manager->startSingleRace(track_name, laps, false);
|
||||||
|
|
||||||
return GUIEngine::EVENT_BLOCK;
|
return GUIEngine::EVENT_BLOCK;
|
||||||
}
|
}
|
||||||
else if(selection == "remove")
|
else if(selection == "remove")
|
||||||
|
@ -497,7 +497,7 @@ void RaceResultGUI::backToLobby()
|
|||||||
const int rm_id = kart->getWorldKartId() -
|
const int rm_id = kart->getWorldKartId() -
|
||||||
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
|
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
|
||||||
|
|
||||||
if (rm_id >= 0)
|
if (rm_id >= 0 && !race_manager->isWatchingReplay())
|
||||||
ri->m_kart_name = race_manager->getKartInfo(rm_id).getPlayerName();
|
ri->m_kart_name = race_manager->getKartInfo(rm_id).getPlayerName();
|
||||||
else
|
else
|
||||||
ri->m_kart_name = translations->fribidize(kart->getName());
|
ri->m_kart_name = translations->fribidize(kart->getName());
|
||||||
@ -869,7 +869,7 @@ void RaceResultGUI::backToLobby()
|
|||||||
const int rm_id = kart_id -
|
const int rm_id = kart_id -
|
||||||
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
|
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
|
||||||
|
|
||||||
if (rm_id >= 0)
|
if (rm_id >= 0 && !race_manager->isWatchingReplay())
|
||||||
ri->m_kart_name = race_manager->getKartInfo(rm_id).getPlayerName();
|
ri->m_kart_name = race_manager->getKartInfo(rm_id).getPlayerName();
|
||||||
else
|
else
|
||||||
ri->m_kart_name = translations->fribidize(kart->getName());
|
ri->m_kart_name = translations->fribidize(kart->getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user