Changed: #1469 Base implementation of the function that plays steps

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent 64b1ba3752
commit e61d13566e

@ -17,6 +17,7 @@
#include "camera_animation_manager/camera_animation_player.h" #include "camera_animation_manager/camera_animation_player.h"
#include "camera_animation_manager/camera_animation_step_player_factory.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -28,25 +29,59 @@ CCameraAnimationPlayer* CCameraAnimationPlayer::_Instance = NULL;
CCameraAnimationPlayer::CCameraAnimationPlayer() CCameraAnimationPlayer::CCameraAnimationPlayer()
{ {
_IsPlaying = false;
} }
CCameraAnimationPlayer::~CCameraAnimationPlayer() CCameraAnimationPlayer::~CCameraAnimationPlayer()
{ {
stop();
} }
void CCameraAnimationPlayer::start() void CCameraAnimationPlayer::start()
{ {
if (isPlaying())
stop();
_IsPlaying = true;
} }
void CCameraAnimationPlayer::stop() void CCameraAnimationPlayer::stop()
{ {
_IsPlaying = false;
// We release the steps and modifiers
for (std::vector<ICameraAnimationStepPlayer*>::iterator it = _Steps.begin(); it != _Steps.end(); ++it)
{
ICameraAnimationStepPlayer* step = *it;
delete step;
}
_Steps.clear();
} }
void CCameraAnimationPlayer::playStep( const std::string& stepName, NLMISC::CBitMemStream& impulse ) void CCameraAnimationPlayer::playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse)
{ {
// We check if we are playing an animation
if (!isPlaying())
{
nlwarning("CameraAnimationPlayer: animation not playing, cannot play step %s", stepName.c_str());
return;
}
// We initialize the step with the factory
ICameraAnimationStepPlayer* step = ICameraAnimationStepPlayerFactory::initStep(stepName, impulse);
if (step == NULL)
{
nlwarning("CameraAnimationPlayer: cannot create step player %s", stepName.c_str());
return;
}
// We add the step to our list
_Steps.push_back(step);
// We start playing the step
step->playStep();
}
bool CCameraAnimationPlayer::isPlaying()
{
return _IsPlaying;
} }

@ -20,6 +20,7 @@
#include <string> #include <string>
#include "nel\misc\bit_mem_stream.h" #include "nel\misc\bit_mem_stream.h"
#include "camera_animation_manager/camera_animation_step_player_factory.h"
/************************************************************************/ /************************************************************************/
@ -59,14 +60,22 @@ public:
/// Loads and play the specified step /// Loads and play the specified step
void playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse); void playStep(const std::string& stepName, NLMISC::CBitMemStream& impulse);
/// Checks if an animation is being played
bool isPlaying();
private: private:
/// Constructor /// Constructor
CCameraAnimationPlayer(); CCameraAnimationPlayer();
/// Destructor /// Destructor
~CCameraAnimationPlayer(); ~CCameraAnimationPlayer();
/// Instance of the manager /// Instance of the manager
static CCameraAnimationPlayer* _Instance; static CCameraAnimationPlayer* _Instance;
bool _IsPlaying;
std::vector<ICameraAnimationStepPlayer*> _Steps;
}; };

Loading…
Cancel
Save