2015-06-17 13:16:06 +08:00
|
|
|
|
/****************************************************************************
|
2014-06-11 11:10:07 +08:00
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __CCTIMELINE_ACTION_CACHE_H__
|
|
|
|
|
#define __CCTIMELINE_ACTION_CACHE_H__
|
|
|
|
|
|
2014-08-29 15:39:52 +08:00
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include "base/CCMap.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
|
#include "base/CCData.h"
|
2014-08-29 15:39:52 +08:00
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
|
#include "editor-support/cocostudio/DictionaryHelper.h"
|
|
|
|
|
#include "editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h"
|
|
|
|
|
#include "editor-support/cocostudio/CocosStudioExport.h"
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
|
namespace flatbuffers
|
|
|
|
|
{
|
2014-12-15 02:04:14 +08:00
|
|
|
|
class FlatBufferBuilder;
|
2014-11-21 15:15:38 +08:00
|
|
|
|
|
|
|
|
|
struct NodeAction;
|
|
|
|
|
struct TimeLine;
|
2015-01-12 10:55:15 +08:00
|
|
|
|
struct PointFrame;
|
|
|
|
|
struct ScaleFrame;
|
|
|
|
|
struct ColorFrame;
|
|
|
|
|
struct TextureFrame;
|
|
|
|
|
struct EventFrame;
|
|
|
|
|
struct IntFrame;
|
|
|
|
|
struct BoolFrame;
|
|
|
|
|
struct InnerActionFrame;
|
2015-04-09 16:55:15 +08:00
|
|
|
|
struct EasingData;
|
2015-08-17 13:05:29 +08:00
|
|
|
|
struct BlendFrame;
|
2014-11-21 15:15:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
NS_TIMELINE_BEGIN
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
class ActionTimeline;
|
|
|
|
|
class Timeline;
|
|
|
|
|
class Frame;
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
2014-07-21 17:45:56 +08:00
|
|
|
|
class CC_STUDIO_DLL ActionTimelineCache
|
2014-06-11 11:10:07 +08:00
|
|
|
|
{
|
2015-01-12 10:55:15 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2014-06-11 11:10:07 +08:00
|
|
|
|
/** Gets the singleton */
|
2014-06-13 16:03:03 +08:00
|
|
|
|
static ActionTimelineCache* getInstance();
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
|
|
/** Destroys the singleton */
|
|
|
|
|
static void destroyInstance();
|
|
|
|
|
|
|
|
|
|
void purge();
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
/** Remove action with filename, and also remove other resource relate with this file */
|
|
|
|
|
void removeAction(const std::string& fileName);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
|
|
static ActionTimeline* createAction(const std::string& fileName);
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
|
|
/** Clone a action with the specified name from the container. */
|
2014-10-09 18:28:09 +08:00
|
|
|
|
ActionTimeline* createActionFromJson(const std::string& fileName);
|
2016-01-14 16:16:37 +08:00
|
|
|
|
ActionTimeline* createActionFromContent(const std::string& fileName, const std::string& content);
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
ActionTimeline* loadAnimationActionWithFile(const std::string& fileName);
|
|
|
|
|
ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
|
ActionTimeline* createActionWithFlatBuffersFile(const std::string& fileName);
|
2016-01-14 16:16:37 +08:00
|
|
|
|
ActionTimeline* createActionWithDataBuffer(cocos2d::Data data, const std::string &fileName);
|
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
|
ActionTimeline* loadAnimationActionWithFlatBuffersFile(const std::string& fileName);
|
2016-01-15 00:49:48 +08:00
|
|
|
|
ActionTimeline* loadAnimationWithDataBuffer(const cocos2d::Data& data, const std::string& fileName);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
2014-12-08 14:32:33 +08:00
|
|
|
|
ActionTimeline* createActionWithFlatBuffersForSimulator(const std::string& fileName);
|
|
|
|
|
|
2014-06-11 11:10:07 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
Timeline* loadTimeline(const rapidjson::Value& json);
|
|
|
|
|
|
|
|
|
|
Frame* loadVisibleFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadPositionFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadScaleFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadSkewFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadRotationSkewFrame(const rapidjson::Value& json);
|
|
|
|
|
Frame* loadRotationFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadAnchorPointFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadInnerActionFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadColorFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadTextureFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadEventFrame (const rapidjson::Value& json);
|
|
|
|
|
Frame* loadZOrderFrame (const rapidjson::Value& json);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
|
Timeline* loadTimelineWithFlatBuffers(const flatbuffers::TimeLine* flatbuffers);
|
2015-01-12 10:55:15 +08:00
|
|
|
|
|
|
|
|
|
Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::BoolFrame* flatbuffers);
|
|
|
|
|
Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::PointFrame* flatbuffers);
|
|
|
|
|
Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
|
|
|
|
Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
|
|
|
|
Frame* loadColorFrameWithFlatBuffers (const flatbuffers::ColorFrame* flatbuffers);
|
|
|
|
|
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TextureFrame* flatbuffers);
|
|
|
|
|
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::EventFrame* flatbuffers);
|
|
|
|
|
Frame* loadAlphaFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
|
2015-01-22 11:20:01 +08:00
|
|
|
|
Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
2015-01-12 10:55:15 +08:00
|
|
|
|
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
|
|
|
|
|
Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers);
|
2015-08-17 13:05:29 +08:00
|
|
|
|
Frame* loadBlendFrameWithFlatBuffers (const flatbuffers::BlendFrame* flatbuffers);
|
2015-04-09 16:55:15 +08:00
|
|
|
|
void loadEasingDataWithFlatBuffers(Frame* frame, const flatbuffers::EasingData* flatbuffers);
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
2016-01-15 00:49:48 +08:00
|
|
|
|
inline ActionTimeline* createActionWithDataBuffer(const cocos2d::Data& data);
|
2014-06-11 11:10:07 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
typedef std::function<Frame*(const rapidjson::Value& json)> FrameCreateFunc;
|
2014-06-11 11:10:07 +08:00
|
|
|
|
typedef std::pair<std::string, FrameCreateFunc> Pair;
|
|
|
|
|
|
|
|
|
|
std::unordered_map<std::string, FrameCreateFunc> _funcs;
|
2014-06-13 18:51:32 +08:00
|
|
|
|
cocos2d::Map<std::string, ActionTimeline*> _animationActions;
|
2014-06-11 11:10:07 +08:00
|
|
|
|
};
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
|
NS_TIMELINE_END
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
|
|
#endif /*__CCTIMELINE_ACTION_CACHE_H__*/
|