diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp new file mode 100644 index 000000000..0221a88c3 --- /dev/null +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.cpp @@ -0,0 +1,54 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +#include "camera_animation_manager/camera_animation_modifier_player_factory.h" + +std::vector >* ICameraAnimationModifierPlayerFactory::Entries; + +ICameraAnimationModifierPlayer* ICameraAnimationModifierPlayerFactory::initModifier(const std::string& name, NLMISC::CBitMemStream& impulse) +{ + // We search the correct modifier type in our entries + for (uint i = 0; i < Entries->size(); i++) + { + if (name == (*Entries)[i].first) + { + ICameraAnimationModifierPlayer* ret = (*Entries)[i].second->instanciate(); + if (!ret) + { + nlwarning("BUG IN CAMERA ANIMATION MODIFIER PLAYER FACTORY : BAD INIT CODE %s", name.c_str()); + return NULL; + } + // We init the modifier + if (!ret->initModifier(impulse)) + { + nlwarning("building camera animation modifier player failed %s", name.c_str()); + delete ret; + return NULL; + } + + return ret; + } + } + return NULL; +} + +void ICameraAnimationModifierPlayerFactory::init() +{ + if (!Entries) + Entries = new std::vector >; +} + diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h new file mode 100644 index 000000000..006d71c0d --- /dev/null +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_modifier_player_factory.h @@ -0,0 +1,84 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef RY_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H +#define RY_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H + +#include +#include +#include "nel\misc\bit_mem_stream.h" + +/************************************************************************/ +/* Interface for camera animation modifiers. + * It has to be able to parse the modifier from an impulse and to play it + */ +/************************************************************************/ +class ICameraAnimationModifierPlayer +{ +public: + /// This function is called when it's time to init the modifier from an impulse + virtual bool initModifier(NLMISC::CBitMemStream& impulse) = 0; + + /// Function that plays the modifier + virtual void playModifier() = 0; + +protected: +}; + +/************************************************************************/ +/* Factory class that can instanciate the correct camera animation modifier player. + * + * \author Fabien Henon + * \date 2012 + */ +/************************************************************************/ +class ICameraAnimationModifierPlayerFactory +{ +public: + /// Function that will instanciate the correct camera animation modifier player in function of the modifier name + static ICameraAnimationModifierPlayer* initModifier(const std::string& name, NLMISC::CBitMemStream& impulse); +protected: + + /// Functions used to be able to create the camera animation modifiers players + static void init(); + virtual ICameraAnimationModifierPlayer* instanciate() = 0; + static std::vector >* Entries; +}; + +// Define used to register the different types of camera animation modifiers players +#define CAMERA_ANIMATION_REGISTER_MODIFIER_PLAYER(_class_,_name_) \ +class _class_##CameraAnimationModifierPlayerFactory : public ICameraAnimationModifierPlayerFactory \ +{\ +public:\ + _class_##CameraAnimationModifierPlayerFactory()\ +{\ + init();\ + std::string str = std::string(_name_); \ + for (uint i = 0; i < (*Entries).size(); i++ ) \ +{\ + if ( (*Entries)[i].first == str || (*Entries)[i].second == this )nlstop;\ +}\ + (*Entries).push_back( std::make_pair( str, this ) );\ +}\ + ICameraAnimationModifierPlayer* instanciate()\ +{ \ + return new _class_;\ +} \ +};\ + static _class_##CameraAnimationModifierPlayerFactory* _class_##CameraAnimationModifierPlayerFactoryInstance = new _class_##CameraAnimationModifierPlayerFactory; + + +#endif /* RY_CAMERAANIMATIONMODIFIERPLAYERFACTORY_H */ diff --git a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp index 720c40cef..9089728fb 100644 --- a/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp +++ b/code/ryzom/client/src/camera_animation_manager/camera_animation_step_player_factory.cpp @@ -29,13 +29,13 @@ ICameraAnimationStepPlayer* ICameraAnimationStepPlayerFactory::initStep(const st ICameraAnimationStepPlayer* ret = (*Entries)[i].second->instanciate(); if (!ret) { - nlerror("BUG IN CAMERA ANIMATION STEP PLAYER FACTORY : BAD INIT CODE"); + nlwarning("BUG IN CAMERA ANIMATION STEP PLAYER FACTORY : BAD INIT CODE %s", name.c_str()); return NULL; } // We init the step if (!ret->initStep(impulse)) { - nlerror("building camera animation step player failed"); + nlwarning("building camera animation step player failed %s", name.c_str()); delete ret; return NULL; }