Allow looking back when watching replay

This commit is contained in:
Benau
2016-04-04 09:02:04 +08:00
parent ae8fac6dcb
commit dca821d4e6
3 changed files with 32 additions and 1 deletions

View File

@@ -732,6 +732,12 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
Controller* controller = pk->getController();
if (controller != NULL) controller->action(action, abs(value));
}
else if (race_manager->isWatchingReplay())
{
// Get the first ghost kart
World::getWorld()->getKart(0)
->getController()->action(action, abs(value));
}
// ... when in menus
else
{

View File

@@ -16,7 +16,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/camera.hpp"
#include "karts/controller/ghost_controller.hpp"
#include "karts/controller/kart_control.hpp"
#include "modes/world.hpp"
GhostController::GhostController(AbstractKart *kart)
@@ -45,6 +47,21 @@ void GhostController::update(float dt)
}
}
// Watching replay use only
Camera *camera = Camera::getActiveCamera();
if (camera != NULL && camera->getMode() != Camera::CM_FINAL)
{
if (m_controls->m_look_back)
{
camera->setMode(Camera::CM_REVERSE);
}
else
{
if (camera->getMode() == Camera::CM_REVERSE)
camera->setMode(Camera::CM_NORMAL);
}
}
} // update
//-----------------------------------------------------------------------------
@@ -58,3 +75,11 @@ void GhostController::addReplayTime(float time)
m_all_times.push_back(time);
} // addReplayTime
//-----------------------------------------------------------------------------
void GhostController::action(PlayerAction action, int value)
{
// Watching replay use only
if (action == PA_LOOK_BACK)
m_controls->m_look_back = (value!=0);
} // action

View File

@@ -55,7 +55,7 @@ public:
virtual void setPosition(int p) {};
virtual bool isPlayerController() const { return false; }
virtual bool isLocalPlayerController() const { return false; }
virtual void action(PlayerAction action, int value) {};
virtual void action(PlayerAction action, int value) OVERRIDE;
virtual void skidBonusTriggered() {};
virtual void newLap(int lap) {};
void addReplayTime(float time);