From 78b32332d3ae2bb40bfacc7823d6fec8b9879949 Mon Sep 17 00:00:00 2001 From: pipu Date: Mon, 12 Jan 2015 10:55:15 +0800 Subject: [PATCH] Parse InnerActionFrame, AlphaFrame, modify cocostudio editor version number. --- .../ActionTimeline/CCActionTimeline.cpp | 44 +- .../ActionTimeline/CCActionTimeline.h | 21 +- .../ActionTimeline/CCActionTimelineCache.cpp | 328 ++++---- .../ActionTimeline/CCActionTimelineCache.h | 38 +- .../cocostudio/ActionTimeline/CCFrame.cpp | 118 ++- .../cocostudio/ActionTimeline/CCFrame.h | 35 +- .../cocostudio/ActionTimeline/CSLoader.cpp | 44 +- .../cocostudio/ActionTimeline/CSLoader.h | 2 + .../cocostudio/CSParseBinary_generated.h | 482 +++++++----- .../cocostudio/FlatBuffersSerialize.cpp | 706 +++++++++++------- .../cocostudio/FlatBuffersSerialize.h | 37 +- .../ProjectNodeReader/ProjectNodeReader.cpp | 34 +- .../ActionTimelineTestScene.cpp | 24 +- 13 files changed, 1186 insertions(+), 727 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index 6ab3e3cf69..f112b125a1 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -93,14 +93,14 @@ bool ActionTimeline::init() void ActionTimeline::play(std::string name, bool loop) { - if(_indexes.find(name) == _indexes.end()) + if (_animationInfos.find(name) == _animationInfos.end()) { - CCLOG("Cann't find action indexes for %s.", name.c_str()); - return; + CCLOG("Can't find animation info for %s", name.c_str()); + return; } - - ActionIndexes& indexes = _indexes[name]; - gotoFrameAndPlay(indexes.startIndex, indexes.endIndex, loop); + + AnimationInfo& index = _animationInfos[name]; + gotoFrameAndPlay(index.startIndex, index.endIndex, loop); } void ActionTimeline::gotoFrameAndPlay(int startIndex) @@ -278,26 +278,37 @@ void ActionTimeline::removeTimeline(Timeline* timeline) } } -void ActionTimeline::addIndexes(const ActionIndexes& indexes) + +void ActionTimeline::addAnimationInfo(const AnimationInfo& animationInfo) { - if(_indexes.find(indexes.name) != _indexes.end()) + if (_animationInfos.find(animationInfo.name) != _animationInfos.end()) { - CCLOG("ActionIndexes (%s) already exsists.", indexes.name.c_str()); + CCLOG("Animation (%s) already exists.", animationInfo.name.c_str()); return; } - - _indexes[indexes.name] = indexes; + + _animationInfos[animationInfo.name] = animationInfo; } -void ActionTimeline::removeIndexes(std::string name) +void ActionTimeline::removeAnimationInfo(std::string animationName) { - if(_indexes.find(name) == _indexes.end()) + if (_animationInfos.find(animationName) == _animationInfos.end()) { - CCLOG("ActionIndexes %s don't exsists.", name.c_str()); + CCLOG("AnimationInfo (%s) not exists.", animationName.c_str()); return; } - - _indexes.erase(name); + + _animationInfos.erase(animationName); +} + +bool ActionTimeline::IsAnimationInfoExists(const std::string& animationName) +{ + return _animationInfos.find(animationName) != _animationInfos.end(); +} + +AnimationInfo ActionTimeline::getAnimationInfo(const std::string &animationName) +{ + return _animationInfos.find(animationName)->second; } void ActionTimeline::setFrameEventCallFunc(std::function listener) @@ -348,5 +359,4 @@ void ActionTimeline::stepToFrame(int frameIndex) _timelineList.at(i)->stepToFrame(frameIndex); } } - NS_TIMELINE_END diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h index 567188dec2..35dd7ae9cd 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h @@ -31,7 +31,7 @@ THE SOFTWARE. NS_TIMELINE_BEGIN -struct ActionIndexes +struct AnimationInfo { std::string name; int startIndex; @@ -63,9 +63,9 @@ public: ActionTimeline(); virtual ~ActionTimeline(); + virtual void play(std::string animationName, bool loop); + virtual bool init(); - - virtual void play(std::string name, bool loop); /** Goto the specified frame index, and start playing from this index. * @param startIndex The animation will play from this index. @@ -97,7 +97,6 @@ public: * @param startIndex The animation will pause at this index. */ virtual void gotoFrameAndPause(int startIndex); - /** Pause the animation. */ virtual void pause(); @@ -132,12 +131,14 @@ public: /** add Timeline to ActionTimeline */ virtual void addTimeline(Timeline* timeline); virtual void removeTimeline(Timeline* timeline); - - /** add ActionIndexes */ - virtual void addIndexes(const ActionIndexes& indexes); - virtual void removeIndexes(std::string name); - + virtual const cocos2d::Vector& getTimelines() const { return _timelineList; } + + /** add ActionIndexes*/ + virtual void addAnimationInfo(const AnimationInfo& animationInfo); + virtual void removeAnimationInfo(std::string animationName); + virtual bool IsAnimationInfoExists(const std::string& animationName); + virtual AnimationInfo getAnimationInfo(const std::string& animationName); /** Set ActionTimeline's frame event callback function */ void setFrameEventCallFunc(std::function listener); @@ -182,7 +183,7 @@ protected: std::function _frameEventListener; std::function _lastFrameListener; - std::map _indexes; + std::map _animationInfos; }; NS_TIMELINE_END diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp index f6db2f1ae1..be329dc430 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp @@ -47,18 +47,16 @@ using namespace flatbuffers; namespace cocostudio { namespace timeline{ -static const char* FrameType_VisibleFrame = "VisibleFrame"; -static const char* FrameType_PositionFrame = "PositionFrame"; -static const char* FrameType_ScaleFrame = "ScaleFrame"; -static const char* FrameType_RotationFrame = "RotationFrame"; -static const char* FrameType_SkewFrame = "SkewFrame"; -static const char* FrameType_RotationSkewFrame = "RotationSkewFrame"; -static const char* FrameType_AnchorFrame = "AnchorPointFrame"; -static const char* FrameType_InnerActionFrame = "InnerActionFrame"; -static const char* FrameType_ColorFrame = "ColorFrame"; -static const char* FrameType_TextureFrame = "TextureFrame"; -static const char* FrameType_EventFrame = "EventFrame"; -static const char* FrameType_ZOrderFrame = "ZOrderFrame"; +static const char* Property_VisibleForFrame = "VisibleForFrame"; +static const char* Property_Position = "Position"; +static const char* Property_Scale = "Scale"; +static const char* Property_RotationSkew = "RotationSkew"; +static const char* Property_CColor = "CColor"; +static const char* Property_FileData = "FileData"; +static const char* Property_FrameEvent = "FrameEvent"; +static const char* Property_Alpha = "Alpha"; +static const char* Property_ZOrder = "ZOrder"; +static const char* Property_ActionValue = "ActionValue"; static const char* ACTION = "action"; static const char* DURATION = "duration"; @@ -108,6 +106,7 @@ void ActionTimelineCache::purge() void ActionTimelineCache::init() { using namespace std::placeholders; + /* _funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&ActionTimelineCache::loadVisibleFrame, this, _1))); _funcs.insert(Pair(FrameType_PositionFrame, std::bind(&ActionTimelineCache::loadPositionFrame, this, _1))); _funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&ActionTimelineCache::loadScaleFrame, this, _1))); @@ -120,6 +119,7 @@ void ActionTimelineCache::init() _funcs.insert(Pair(FrameType_TextureFrame, std::bind(&ActionTimelineCache::loadTextureFrame, this, _1))); _funcs.insert(Pair(FrameType_EventFrame, std::bind(&ActionTimelineCache::loadEventFrame, this, _1))); _funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&ActionTimelineCache::loadZOrderFrame, this, _1))); + */ } @@ -439,7 +439,18 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(cons float speed = nodeAction->speed(); action->setTimeSpeed(speed); - + auto animationlist = csparsebinary->animationList(); + int animationcount = animationlist->size(); + for (int i = 0; i < animationcount; i++) + { + auto animationdata = animationlist->Get(i); + AnimationInfo info; + info.name = animationdata->name()->c_str(); + info.startIndex = animationdata->startIndex(); + info.endIndex = animationdata->endIndex(); + action->addAnimationInfo(info); + } + auto timelines = nodeAction->timeLines(); int timelineLength = timelines->size(); for (int i = 0; i < timelineLength; i++) @@ -460,14 +471,14 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti { Timeline* timeline = nullptr; - // get frame type - std::string frameType = flatbuffers->frameType()->c_str(); - if(frameType == "") + // property + std::string property = flatbuffers->property()->c_str(); + if(property == "") return nullptr; - CCLOG("frameType = %s", frameType.c_str()); + CCLOG("property = %s", property.c_str()); - if(frameType != "") + if(property != "") { timeline = Timeline::create(); @@ -482,68 +493,77 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti auto frameFlatbuf = framesFlatbuf->Get(i); Frame* frame = nullptr; - if (frameType == FrameType_VisibleFrame) + if (property == Property_VisibleForFrame) { - auto visibleFrame = frameFlatbuf->visibleFrame(); - frame = loadVisibleFrameWithFlatBuffers(visibleFrame); + auto boolFrame = frameFlatbuf->boolFrame(); + frame = loadVisibleFrameWithFlatBuffers(boolFrame); } - else if (frameType == FrameType_ZOrderFrame) + else if (property == Property_Position) { - auto zOrderFrame = frameFlatbuf->zOrderFrame(); - frame = loadZOrderFrameWithFlatBuffers(zOrderFrame); - } - else if (frameType == FrameType_RotationSkewFrame) - { - auto rotationSkewFrame = frameFlatbuf->rotationSkewFrame(); - frame = loadRotationSkewFrameWithFlatBuffers(rotationSkewFrame); - } - else if (frameType == FrameType_EventFrame) - { - auto eventFrame = frameFlatbuf->eventFrame(); - frame = loadEventFrameWithFlatBuffers(eventFrame); - } - else if (frameType == FrameType_AnchorFrame) - { - auto anchorPointFrame = frameFlatbuf->anchorPointFrame(); - frame = loadAnchorPointFrameWithFlatBuffers(anchorPointFrame); - } - else if (frameType == FrameType_PositionFrame) - { - auto potisionFrame = frameFlatbuf->positionFrame(); + auto potisionFrame = frameFlatbuf->pointFrame(); frame = loadPositionFrameWithFlatBuffers(potisionFrame); } - else if (frameType == FrameType_ScaleFrame) + else if (property == Property_Scale) { auto scaleFrame = frameFlatbuf->scaleFrame(); frame = loadScaleFrameWithFlatBuffers(scaleFrame); } - else if (frameType == FrameType_ColorFrame) + else if (property == Property_RotationSkew) + { + auto scaleFrame = frameFlatbuf->scaleFrame(); + frame = loadRotationSkewFrameWithFlatBuffers(scaleFrame); + } + else if (property == Property_CColor) { auto colorFrame = frameFlatbuf->colorFrame(); frame = loadColorFrameWithFlatBuffers(colorFrame); } - else if (frameType == FrameType_TextureFrame) + else if (property == Property_FrameEvent) + { + auto eventFrame = frameFlatbuf->eventFrame(); + frame = loadEventFrameWithFlatBuffers(eventFrame); + } + else if (property == Property_FileData) { auto textureFrame = frameFlatbuf->textureFrame(); frame = loadTextureFrameWithFlatBuffers(textureFrame); } + else if (property == Property_Alpha) + { + auto intFrame = frameFlatbuf->intFrame(); + frame = loadAlphaFrameWithFlatBuffers(intFrame); + } + else if (property == Property_ZOrder) + { + auto intFrame = frameFlatbuf->intFrame(); + frame = loadZOrderFrameWithFlatBuffers(intFrame); + } + else if (property == Property_ActionValue) + { + auto innerActionFrame = frameFlatbuf->innerActionFrame(); + frame = loadInnerActionFrameWithFlatBuffers(innerActionFrame); + } + if (!frame) + { + CCLOG("frame is invalid."); + continue; + } timeline->addFrame(frame); } } return timeline; } - -Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::TimeLineBoolFrame *flatbuffers) + +Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::BoolFrame *flatbuffers) { VisibleFrame* frame = VisibleFrame::create(); bool visible = flatbuffers->value(); + frame->setVisible(visible); - CCLOG("visible = %d", visible); - int frameIndex = flatbuffers->frameIndex(); frame->setFrameIndex(frameIndex); @@ -552,81 +572,8 @@ Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::T return frame; } - -Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::TimeLineIntFrame *flatbuffers) -{ - ZOrderFrame* frame = ZOrderFrame::create(); - int zorder = flatbuffers->value(); - frame->setZOrder(zorder); - - CCLOG("zorder = %d", zorder); - - int frameIndex = flatbuffers->frameIndex(); - frame->setFrameIndex(frameIndex); - - bool tween = flatbuffers->tween(); - frame->setTween(tween); - - return frame; -} - -Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers) -{ - RotationSkewFrame* frame = RotationSkewFrame::create(); - - auto f_rotationSkew = flatbuffers->postion(); - Vec2 rotationSkew(f_rotationSkew->x(), f_rotationSkew->y()); - frame->setSkewX(rotationSkew.x); - frame->setSkewY(rotationSkew.y); - - int frameIndex = flatbuffers->frameIndex(); - frame->setFrameIndex(frameIndex); - - bool tween = flatbuffers->tween(); - frame->setTween(tween); - - return frame; -} - -Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::TimeLineStringFrame *flatbuffers) -{ - EventFrame* frame = EventFrame::create(); - - std::string event = flatbuffers->value()->c_str(); - - if (event != "") - frame->setEvent(event); - - CCLOG("event = %s", event.c_str()); - - int frameIndex = flatbuffers->frameIndex(); - frame->setFrameIndex(frameIndex); - - bool tween = flatbuffers->tween(); - frame->setTween(tween); - - return frame; -} - -Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers) -{ - AnchorPointFrame* frame = AnchorPointFrame::create(); - - auto f_anchorPoint = flatbuffers->postion(); - Vec2 anchorPoint(f_anchorPoint->x(), f_anchorPoint->y()); - frame->setAnchorPoint(anchorPoint); - - int frameIndex = flatbuffers->frameIndex(); - frame->setFrameIndex(frameIndex); - - bool tween = flatbuffers->tween(); - frame->setTween(tween); - - return frame; -} - -Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers) +Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::PointFrame *flatbuffers) { PositionFrame* frame = PositionFrame::create(); @@ -643,12 +590,12 @@ Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers:: return frame; } -Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers) +Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers) { ScaleFrame* frame = ScaleFrame::create(); - auto f_scale = flatbuffers->postion(); - Vec2 scale(f_scale->x(), f_scale->y()); + auto f_scale = flatbuffers->scale(); + Vec2 scale(f_scale->scaleX(), f_scale->scaleY()); frame->setScaleX(scale.x); frame->setScaleY(scale.y); @@ -661,16 +608,14 @@ Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::Tim return frame; } -Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::TimeLineColorFrame *flatbuffers) +Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers) { - ColorFrame* frame = ColorFrame::create(); + RotationSkewFrame* frame = RotationSkewFrame::create(); - auto f_color = flatbuffers->color(); - Color3B color(f_color->r(), f_color->g(), f_color->b()); - frame->setColor(color); - - int alpha = f_color->a(); - frame->setAlpha(alpha); + auto f_scale = flatbuffers->scale(); + Vec2 rotationSkew(f_scale->scaleX(), f_scale->scaleY()); + frame->setSkewX(rotationSkew.x); + frame->setSkewY(rotationSkew.y); int frameIndex = flatbuffers->frameIndex(); frame->setFrameIndex(frameIndex); @@ -681,7 +626,24 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Tim return frame; } -Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TimeLineTextureFrame *flatbuffers) +Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::ColorFrame *flatbuffers) +{ + ColorFrame* frame = ColorFrame::create(); + + auto f_color = flatbuffers->color(); + Color3B color(f_color->r(), f_color->g(), f_color->b()); + frame->setColor(color); + + int frameIndex = flatbuffers->frameIndex(); + frame->setFrameIndex(frameIndex); + + bool tween = flatbuffers->tween(); + frame->setTween(tween); + + return frame; +} + +Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TextureFrame *flatbuffers) { std::string path = ""; int resourceType = 0; @@ -689,7 +651,7 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T TextureFrame* frame = TextureFrame::create(); - auto fileNameData = flatbuffers->fileNameData(); + auto fileNameData = flatbuffers->textureFile(); resourceType = fileNameData->resourceType(); switch (resourceType) @@ -727,7 +689,6 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T break; } - frame->setTextureName(path); int frameIndex = flatbuffers->frameIndex(); @@ -739,6 +700,85 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T return frame; } +Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::EventFrame *flatbuffers) +{ + EventFrame* frame = EventFrame::create(); + + std::string event = flatbuffers->value()->c_str(); + + if (event != "") + frame->setEvent(event); + + CCLOG("event = %s", event.c_str()); + + int frameIndex = flatbuffers->frameIndex(); + frame->setFrameIndex(frameIndex); + + bool tween = flatbuffers->tween(); + frame->setTween(tween); + + return frame; +} + +Frame* ActionTimelineCache::loadAlphaFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers) +{ + AlphaFrame* frame = AlphaFrame::create(); + + int alpha = flatbuffers->value(); + + frame->setAlpha(alpha); + + int frameIndex = flatbuffers->frameIndex(); + frame->setFrameIndex(frameIndex); + + bool tween = flatbuffers->tween(); + frame->setTween(tween); + + return frame; +} + +Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers) +{ + ZOrderFrame* frame = ZOrderFrame::create(); + + int zorder = flatbuffers->value(); + + frame->setZOrder(zorder); + + int frameIndex = flatbuffers->frameIndex(); + frame->setFrameIndex(frameIndex); + + bool tween = flatbuffers->tween(); + frame->setTween(tween); + + return frame; +} + +Frame* ActionTimelineCache::loadInnerActionFrameWithFlatBuffers(const flatbuffers::InnerActionFrame *flatbuffers) +{ + InnerActionFrame* frame = InnerActionFrame::create(); + + InnerActionType innerActionType = (InnerActionType)flatbuffers->innerActionType(); + + std::string currentAnimationFrame = flatbuffers->currentAniamtionName()->c_str(); + + int singleFrameIndex = flatbuffers->singleFrameIndex(); + + int frameIndex = flatbuffers->frameIndex(); + frame->setFrameIndex(frameIndex); + + bool tween = flatbuffers->tween(); + frame->setTween(tween); + + frame->setInnerActionType(innerActionType); + frame->setSingleFrameIndex(singleFrameIndex); + + frame->setEnterWithName(true); + frame->setAnimationName(currentAnimationFrame); + + return frame; +} + ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName) { FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance(); @@ -758,6 +798,18 @@ ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(con float speed = nodeAction->speed(); action->setTimeSpeed(speed); + auto animationlist = csparsebinary->animationList(); + int animationcount = animationlist->size(); + for (int i = 0; i < animationcount; i++) + { + auto animationdata = animationlist->Get(i); + AnimationInfo info; + info.name = animationdata->name()->c_str(); + info.startIndex = animationdata->startIndex(); + info.endIndex = animationdata->endIndex(); + action->addAnimationInfo(info); + } + auto timeLines = nodeAction->timeLines(); int timelineLength = timeLines->size(); for (int i = 0; i < timelineLength; i++) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h index 08612740db..700a5feacd 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h @@ -38,12 +38,14 @@ namespace flatbuffers struct NodeAction; struct TimeLine; - struct TimeLineBoolFrame; - struct TimeLineIntFrame; - struct TimeLineStringFrame; - struct TimeLinePointFrame; - struct TimeLineColorFrame; - struct TimeLineTextureFrame; + struct PointFrame; + struct ScaleFrame; + struct ColorFrame; + struct TextureFrame; + struct EventFrame; + struct IntFrame; + struct BoolFrame; + struct InnerActionFrame; } NS_TIMELINE_BEGIN @@ -54,7 +56,8 @@ class Frame; class CC_STUDIO_DLL ActionTimelineCache { -public: +public: + /** Gets the singleton */ static ActionTimelineCache* getInstance(); @@ -100,16 +103,17 @@ protected: Timeline* loadTimelineWithFlatBuffers(const flatbuffers::TimeLine* flatbuffers); - - Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::TimeLineBoolFrame* flatbuffers); - Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::TimeLineIntFrame* flatbuffers); - Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers); - Frame* loadEventFrameWithFlatBuffers (const flatbuffers::TimeLineStringFrame* flatbuffers); - Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers); - Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers); - Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers); - Frame* loadColorFrameWithFlatBuffers (const flatbuffers::TimeLineColorFrame* flatbuffers); - Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TimeLineTextureFrame* flatbuffers); + + 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); + Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers); + Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers); protected: diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index dc0595fbf0..b5ed343624 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -27,6 +27,8 @@ THE SOFTWARE. #include "CCActionTimeline.h" #include "2d/CCSpriteFrameCache.h" #include "2d/CCSpriteFrame.h" +#include +#include USING_NS_CC; @@ -466,20 +468,89 @@ InnerActionFrame* InnerActionFrame::create() InnerActionFrame::InnerActionFrame() : _innerActionType(LoopAction) , _startFrameIndex(0) + , _endFrameIndex(0) { + } void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { + int start = _startFrameIndex; + int end = _endFrameIndex; + auto actiontimeline = static_cast(_node->getActionByTag(_node->getTag())); + if (InnerActionType::SingleFrame == _innerActionType) + { + actiontimeline->gotoFrameAndPause(_singleFrameIndex); + return; + } + + if (_enterWithName) + { + if (_animationName == "-- ALL --") + { + start = 0; + end = actiontimeline->getDuration(); + } + else if(actiontimeline->IsAnimationInfoExists(_animationName)) + { + AnimationInfo info = actiontimeline->getAnimationInfo(_animationName); + start = info.startIndex; + end = info.endIndex; + } + else + { + CCLOG("Animation %s not exists!", _animationName.c_str()); + } + } + + if (InnerActionType::NoLoopAction == _innerActionType) + { + actiontimeline->gotoFrameAndPlay(start, end, false); + } + else if (InnerActionType::LoopAction == _innerActionType) + { + actiontimeline->gotoFrameAndPlay(start, end, true); + } } +void InnerActionFrame::setStartFrameIndex(int frameIndex) throw() +{ + if(_enterWithName) + { + CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!"); + throw std::exception(); + } + _startFrameIndex = frameIndex; +} + + +void InnerActionFrame::setEndFrameIndex(int frameIndex) throw() +{ + if(_enterWithName) + { + CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!"); + throw std::exception(); + } + _endFrameIndex = frameIndex; +} + +void InnerActionFrame::setAnimationName(const std::string& animationName) throw() +{ + if(!_enterWithName) + { + CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); + throw std::exception(); + } + _animationName = animationName; + +} Frame* InnerActionFrame::clone() { InnerActionFrame* frame = InnerActionFrame::create(); frame->setInnerActionType(_innerActionType); frame->setStartFrameIndex(_startFrameIndex); - + frame->setEndFrameIndex(_endFrameIndex); frame->cloneProperty(this); return frame; @@ -548,6 +619,51 @@ Frame* ColorFrame::clone() return frame; } +// AlphaFrame +AlphaFrame* AlphaFrame::create() +{ + AlphaFrame* frame = new (std::nothrow) AlphaFrame(); + if (frame) + { + frame->autorelease(); + return frame; + } + CC_SAFE_DELETE(frame); + return nullptr; +} + +AlphaFrame::AlphaFrame() + : _alpha(255) +{ +} + +void AlphaFrame::onEnter(Frame *nextFrame, int currentFrameIndex) +{ + _node->setOpacity(_alpha); + + if (_tween) + { + _betweenAlpha = static_cast(nextFrame)->_alpha - _alpha; + } +} + +void AlphaFrame::apply(float percent) +{ + if (_tween) + { + GLubyte alpha = _alpha + _betweenAlpha * percent; + _node->setOpacity(alpha); + } +} + +Frame* AlphaFrame::clone() +{ + AlphaFrame* frame = AlphaFrame::create(); + frame->setAlpha(_alpha); + frame->cloneProperty(this); + + return frame; +} // EventFrame EventFrame* EventFrame::create() diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h index e5d411f159..1e2b6df5ef 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h @@ -263,13 +263,27 @@ public: inline void setInnerActionType(InnerActionType type) { _innerActionType = type; } inline InnerActionType getInnerActionType() const { return _innerActionType; } - - inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; } + + inline void setEnterWithName(bool isEnterWithName) { _enterWithName = isEnterWithName;} + + void setStartFrameIndex(int frameIndex) throw(); inline int getStartFrameIndex() const { return _startFrameIndex; } + void setEndFrameIndex(int frameIndex) throw(); + inline int getEndFrameIndex() const { return _endFrameIndex; } + + void setAnimationName(const std::string& animationNamed) throw(); + + inline void setSingleFrameIndex(int frameIndex) { _singleFrameIndex = frameIndex;} + inline int getSingleFrameIndex() const { return _singleFrameIndex;} + protected: InnerActionType _innerActionType; int _startFrameIndex; + int _endFrameIndex; + int _singleFrameIndex; + std::string _animationName; + bool _enterWithName; }; @@ -299,6 +313,23 @@ protected: int _betweenBlue; }; +class CC_STUDIO_DLL AlphaFrame : public Frame +{ +public: + static AlphaFrame* create(); + AlphaFrame(); + + virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override; + virtual void apply(float percent) override; + virtual Frame* clone() override; + + inline void setAlpha(GLubyte alpha) { _alpha = alpha; } + inline GLubyte getAlpha() const { return _alpha; } + +protected: + GLubyte _alpha; + int _betweenAlpha; +}; class CC_STUDIO_DLL EventFrame : public Frame { diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index a43591bccf..ed9af698af 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -181,7 +181,7 @@ CSLoader::CSLoader() , _jsonPath("") , _monoCocos2dxVersion("") , _rootNode(nullptr) -, _csBuildID("2.0.8.0") +, _csBuildID("2.1.0.0") { CREATE_CLASS_NODE_READER_INFO(NodeReader); CREATE_CLASS_NODE_READER_INFO(SingleNodeReader); @@ -285,6 +285,7 @@ ActionTimeline* CSLoader::createTimeline(const std::string &filename) return nullptr; } +/* ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filename) { Node* root = createNode(filename); @@ -308,6 +309,7 @@ ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filena return node; } + */ @@ -833,29 +835,16 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree) CCLOG("filePath = %s", filePath.c_str()); if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath)) { - - Node* root = createNodeWithFlatBuffersFile(filePath); - reader->setPropsWithFlatBuffers(root, options->data()); - - bool isloop = projectNodeOptions->isLoop(); - bool isautoplay = projectNodeOptions->isAutoPlay(); - + + node = createNodeWithFlatBuffersFile(filePath); + reader->setPropsWithFlatBuffers(node, options->data()); + cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); if (action) { - root->runAction(action); - if (isautoplay) - { - action->gotoFrameAndPlay(0, isloop); - } - else - { - action->gotoFrameAndPause(0); - } + node->runAction(action); } - - node = ActionTimelineNode::create(root, action); - node->setName(root->getName()); + } } else if (classname == "SimpleAudio") @@ -1182,22 +1171,11 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod { node = createNodeWithFlatBuffersForSimulator(filePath); reader->setPropsWithFlatBuffers(node, options->data()); - - bool isloop = projectNodeOptions->isLoop(); - bool isautoplay = projectNodeOptions->isAutoPlay(); - cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath); + + cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath); if (action) { node->runAction(action); - action->gotoFrameAndPlay(0); - if (isautoplay) - { - action->gotoFrameAndPlay(0, isloop); - } - else - { - action->gotoFrameAndPause(0); - } } } } diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h index 505645e5fc..a3fc4cab41 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h @@ -77,8 +77,10 @@ public: static cocos2d::Node* createNode(const std::string& filename); static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename); + /* static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename); static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename, int startIndex, int endIndex, bool loop); + */ cocos2d::Node* createNodeFromJson(const std::string& filename); cocos2d::Node* loadNodeWithFile(const std::string& fileName); diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index d4ebff7371..2f2d5b0220 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -33,15 +33,18 @@ struct ListViewOptions; struct ProjectNodeOptions; struct ComponentOptions; struct ComAudioOptions; +struct AnimationInfo; struct NodeAction; struct TimeLine; struct Frame; -struct TimeLineBoolFrame; -struct TimeLineIntFrame; -struct TimeLineStringFrame; -struct TimeLinePointFrame; -struct TimeLineColorFrame; -struct TimeLineTextureFrame; +struct PointFrame; +struct ScaleFrame; +struct ColorFrame; +struct TextureFrame; +struct EventFrame; +struct IntFrame; +struct BoolFrame; +struct InnerActionFrame; struct RotationSkew; struct Position; struct Scale; @@ -177,7 +180,8 @@ struct CSParseBinary : private flatbuffers::Table { const flatbuffers::Vector> *texturePngs() const { return GetPointer> *>(6); } const NodeTree *nodeTree() const { return GetPointer(8); } const NodeAction *action() const { return GetPointer(10); } - const flatbuffers::String *version() const { return GetPointer(12); } + const flatbuffers::Vector> *animationList() const { return GetPointer> *>(12); } + const flatbuffers::String *version() const { return GetPointer(14); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* textures */) && @@ -190,7 +194,10 @@ struct CSParseBinary : private flatbuffers::Table { verifier.VerifyTable(nodeTree()) && VerifyField(verifier, 10 /* action */) && verifier.VerifyTable(action()) && - VerifyField(verifier, 12 /* version */) && + VerifyField(verifier, 12 /* animationList */) && + verifier.Verify(animationList()) && + verifier.VerifyVectorOfTables(animationList()) && + VerifyField(verifier, 14 /* version */) && verifier.Verify(version()) && verifier.EndTable(); } @@ -203,11 +210,12 @@ struct CSParseBinaryBuilder { void add_texturePngs(flatbuffers::Offset>> texturePngs) { fbb_.AddOffset(6, texturePngs); } void add_nodeTree(flatbuffers::Offset nodeTree) { fbb_.AddOffset(8, nodeTree); } void add_action(flatbuffers::Offset action) { fbb_.AddOffset(10, action); } - void add_version(flatbuffers::Offset version) { fbb_.AddOffset(12, version); } + void add_animationList(flatbuffers::Offset>> animationList) { fbb_.AddOffset(12, animationList); } + void add_version(flatbuffers::Offset version) { fbb_.AddOffset(14, version); } CSParseBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } CSParseBinaryBuilder &operator=(const CSParseBinaryBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 5)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 6)); return o; } }; @@ -217,9 +225,11 @@ inline flatbuffers::Offset CreateCSParseBinary(flatbuffers::FlatB flatbuffers::Offset>> texturePngs = 0, flatbuffers::Offset nodeTree = 0, flatbuffers::Offset action = 0, + flatbuffers::Offset>> animationList = 0, flatbuffers::Offset version = 0) { CSParseBinaryBuilder builder_(_fbb); builder_.add_version(version); + builder_.add_animationList(animationList); builder_.add_action(action); builder_.add_nodeTree(nodeTree); builder_.add_texturePngs(texturePngs); @@ -1675,16 +1685,12 @@ inline flatbuffers::Offset CreateListViewOptions(flatbuffers::F struct ProjectNodeOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const flatbuffers::String *fileName() const { return GetPointer(6); } - uint8_t isLoop() const { return GetField(8, 1); } - uint8_t isAutoPlay() const { return GetField(10, 1); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && verifier.VerifyTable(nodeOptions()) && VerifyField(verifier, 6 /* fileName */) && verifier.Verify(fileName()) && - VerifyField(verifier, 8 /* isLoop */) && - VerifyField(verifier, 10 /* isAutoPlay */) && verifier.EndTable(); } }; @@ -1694,26 +1700,20 @@ struct ProjectNodeOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileName(flatbuffers::Offset fileName) { fbb_.AddOffset(6, fileName); } - void add_isLoop(uint8_t isLoop) { fbb_.AddElement(8, isLoop, 1); } - void add_isAutoPlay(uint8_t isAutoPlay) { fbb_.AddElement(10, isAutoPlay, 1); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 4)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); return o; } }; inline flatbuffers::Offset CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileName = 0, - uint8_t isLoop = 1, - uint8_t isAutoPlay = 1) { + flatbuffers::Offset fileName = 0) { ProjectNodeOptionsBuilder builder_(_fbb); builder_.add_fileName(fileName); builder_.add_nodeOptions(nodeOptions); - builder_.add_isAutoPlay(isAutoPlay); - builder_.add_isLoop(isLoop); return builder_.Finish(); } @@ -1814,10 +1814,50 @@ inline flatbuffers::Offset CreateComAudioOptions(flatbuffers::F return builder_.Finish(); } +struct AnimationInfo : private flatbuffers::Table { + const flatbuffers::String *name() const { return GetPointer(4); } + int32_t startIndex() const { return GetField(6, 0); } + int32_t endIndex() const { return GetField(8, 0); } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, 4 /* name */) && + verifier.Verify(name()) && + VerifyField(verifier, 6 /* startIndex */) && + VerifyField(verifier, 8 /* endIndex */) && + verifier.EndTable(); + } +}; + +struct AnimationInfoBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_name(flatbuffers::Offset name) { fbb_.AddOffset(4, name); } + void add_startIndex(int32_t startIndex) { fbb_.AddElement(6, startIndex, 0); } + void add_endIndex(int32_t endIndex) { fbb_.AddElement(8, endIndex, 0); } + AnimationInfoBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + AnimationInfoBuilder &operator=(const AnimationInfoBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + return o; + } +}; + +inline flatbuffers::Offset CreateAnimationInfo(flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset name = 0, + int32_t startIndex = 0, + int32_t endIndex = 0) { + AnimationInfoBuilder builder_(_fbb); + builder_.add_endIndex(endIndex); + builder_.add_startIndex(startIndex); + builder_.add_name(name); + return builder_.Finish(); +} + struct NodeAction : private flatbuffers::Table { int32_t duration() const { return GetField(4, 0); } float speed() const { return GetField(6, 0); } const flatbuffers::Vector> *timeLines() const { return GetPointer> *>(8); } + const flatbuffers::String *currentAnimationName() const { return GetPointer(10); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* duration */) && @@ -1825,6 +1865,8 @@ struct NodeAction : private flatbuffers::Table { VerifyField(verifier, 8 /* timeLines */) && verifier.Verify(timeLines()) && verifier.VerifyVectorOfTables(timeLines()) && + VerifyField(verifier, 10 /* currentAnimationName */) && + verifier.Verify(currentAnimationName()) && verifier.EndTable(); } }; @@ -1835,10 +1877,11 @@ struct NodeActionBuilder { void add_duration(int32_t duration) { fbb_.AddElement(4, duration, 0); } void add_speed(float speed) { fbb_.AddElement(6, speed, 0); } void add_timeLines(flatbuffers::Offset>> timeLines) { fbb_.AddOffset(8, timeLines); } + void add_currentAnimationName(flatbuffers::Offset currentAnimationName) { fbb_.AddOffset(10, currentAnimationName); } NodeActionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } NodeActionBuilder &operator=(const NodeActionBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 4)); return o; } }; @@ -1846,8 +1889,10 @@ struct NodeActionBuilder { inline flatbuffers::Offset CreateNodeAction(flatbuffers::FlatBufferBuilder &_fbb, int32_t duration = 0, float speed = 0, - flatbuffers::Offset>> timeLines = 0) { + flatbuffers::Offset>> timeLines = 0, + flatbuffers::Offset currentAnimationName = 0) { NodeActionBuilder builder_(_fbb); + builder_.add_currentAnimationName(currentAnimationName); builder_.add_timeLines(timeLines); builder_.add_speed(speed); builder_.add_duration(duration); @@ -1855,13 +1900,13 @@ inline flatbuffers::Offset CreateNodeAction(flatbuffers::FlatBufferB } struct TimeLine : private flatbuffers::Table { - const flatbuffers::String *frameType() const { return GetPointer(4); } + const flatbuffers::String *property() const { return GetPointer(4); } int32_t actionTag() const { return GetField(6, 0); } const flatbuffers::Vector> *frames() const { return GetPointer> *>(8); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, 4 /* frameType */) && - verifier.Verify(frameType()) && + VerifyField(verifier, 4 /* property */) && + verifier.Verify(property()) && VerifyField(verifier, 6 /* actionTag */) && VerifyField(verifier, 8 /* frames */) && verifier.Verify(frames()) && @@ -1873,7 +1918,7 @@ struct TimeLine : private flatbuffers::Table { struct TimeLineBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_frameType(flatbuffers::Offset frameType) { fbb_.AddOffset(4, frameType); } + void add_property(flatbuffers::Offset property) { fbb_.AddOffset(4, property); } void add_actionTag(int32_t actionTag) { fbb_.AddElement(6, actionTag, 0); } void add_frames(flatbuffers::Offset>> frames) { fbb_.AddOffset(8, frames); } TimeLineBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } @@ -1885,46 +1930,43 @@ struct TimeLineBuilder { }; inline flatbuffers::Offset CreateTimeLine(flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset frameType = 0, + flatbuffers::Offset property = 0, int32_t actionTag = 0, flatbuffers::Offset>> frames = 0) { TimeLineBuilder builder_(_fbb); builder_.add_frames(frames); builder_.add_actionTag(actionTag); - builder_.add_frameType(frameType); + builder_.add_property(property); return builder_.Finish(); } struct Frame : private flatbuffers::Table { - const TimeLineBoolFrame *visibleFrame() const { return GetPointer(4); } - const TimeLineIntFrame *zOrderFrame() const { return GetPointer(6); } - const TimeLinePointFrame *rotationSkewFrame() const { return GetPointer(8); } - const TimeLineStringFrame *eventFrame() const { return GetPointer(10); } - const TimeLinePointFrame *anchorPointFrame() const { return GetPointer(12); } - const TimeLinePointFrame *positionFrame() const { return GetPointer(14); } - const TimeLinePointFrame *scaleFrame() const { return GetPointer(16); } - const TimeLineColorFrame *colorFrame() const { return GetPointer(18); } - const TimeLineTextureFrame *textureFrame() const { return GetPointer(20); } + const PointFrame *pointFrame() const { return GetPointer(4); } + const ScaleFrame *scaleFrame() const { return GetPointer(6); } + const ColorFrame *colorFrame() const { return GetPointer(8); } + const TextureFrame *textureFrame() const { return GetPointer(10); } + const EventFrame *eventFrame() const { return GetPointer(12); } + const IntFrame *intFrame() const { return GetPointer(14); } + const BoolFrame *boolFrame() const { return GetPointer(16); } + const InnerActionFrame *innerActionFrame() const { return GetPointer(18); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyField(verifier, 4 /* visibleFrame */) && - verifier.VerifyTable(visibleFrame()) && - VerifyField(verifier, 6 /* zOrderFrame */) && - verifier.VerifyTable(zOrderFrame()) && - VerifyField(verifier, 8 /* rotationSkewFrame */) && - verifier.VerifyTable(rotationSkewFrame()) && - VerifyField(verifier, 10 /* eventFrame */) && - verifier.VerifyTable(eventFrame()) && - VerifyField(verifier, 12 /* anchorPointFrame */) && - verifier.VerifyTable(anchorPointFrame()) && - VerifyField(verifier, 14 /* positionFrame */) && - verifier.VerifyTable(positionFrame()) && - VerifyField(verifier, 16 /* scaleFrame */) && + VerifyField(verifier, 4 /* pointFrame */) && + verifier.VerifyTable(pointFrame()) && + VerifyField(verifier, 6 /* scaleFrame */) && verifier.VerifyTable(scaleFrame()) && - VerifyField(verifier, 18 /* colorFrame */) && + VerifyField(verifier, 8 /* colorFrame */) && verifier.VerifyTable(colorFrame()) && - VerifyField(verifier, 20 /* textureFrame */) && + VerifyField(verifier, 10 /* textureFrame */) && verifier.VerifyTable(textureFrame()) && + VerifyField(verifier, 12 /* eventFrame */) && + verifier.VerifyTable(eventFrame()) && + VerifyField(verifier, 14 /* intFrame */) && + verifier.VerifyTable(intFrame()) && + VerifyField(verifier, 16 /* boolFrame */) && + verifier.VerifyTable(boolFrame()) && + VerifyField(verifier, 18 /* innerActionFrame */) && + verifier.VerifyTable(innerActionFrame()) && verifier.EndTable(); } }; @@ -1932,123 +1974,197 @@ struct Frame : private flatbuffers::Table { struct FrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_visibleFrame(flatbuffers::Offset visibleFrame) { fbb_.AddOffset(4, visibleFrame); } - void add_zOrderFrame(flatbuffers::Offset zOrderFrame) { fbb_.AddOffset(6, zOrderFrame); } - void add_rotationSkewFrame(flatbuffers::Offset rotationSkewFrame) { fbb_.AddOffset(8, rotationSkewFrame); } - void add_eventFrame(flatbuffers::Offset eventFrame) { fbb_.AddOffset(10, eventFrame); } - void add_anchorPointFrame(flatbuffers::Offset anchorPointFrame) { fbb_.AddOffset(12, anchorPointFrame); } - void add_positionFrame(flatbuffers::Offset positionFrame) { fbb_.AddOffset(14, positionFrame); } - void add_scaleFrame(flatbuffers::Offset scaleFrame) { fbb_.AddOffset(16, scaleFrame); } - void add_colorFrame(flatbuffers::Offset colorFrame) { fbb_.AddOffset(18, colorFrame); } - void add_textureFrame(flatbuffers::Offset textureFrame) { fbb_.AddOffset(20, textureFrame); } + void add_pointFrame(flatbuffers::Offset pointFrame) { fbb_.AddOffset(4, pointFrame); } + void add_scaleFrame(flatbuffers::Offset scaleFrame) { fbb_.AddOffset(6, scaleFrame); } + void add_colorFrame(flatbuffers::Offset colorFrame) { fbb_.AddOffset(8, colorFrame); } + void add_textureFrame(flatbuffers::Offset textureFrame) { fbb_.AddOffset(10, textureFrame); } + void add_eventFrame(flatbuffers::Offset eventFrame) { fbb_.AddOffset(12, eventFrame); } + void add_intFrame(flatbuffers::Offset intFrame) { fbb_.AddOffset(14, intFrame); } + void add_boolFrame(flatbuffers::Offset boolFrame) { fbb_.AddOffset(16, boolFrame); } + void add_innerActionFrame(flatbuffers::Offset innerActionFrame) { fbb_.AddOffset(18, innerActionFrame); } FrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } FrameBuilder &operator=(const FrameBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 9)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 8)); return o; } }; inline flatbuffers::Offset CreateFrame(flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset visibleFrame = 0, - flatbuffers::Offset zOrderFrame = 0, - flatbuffers::Offset rotationSkewFrame = 0, - flatbuffers::Offset eventFrame = 0, - flatbuffers::Offset anchorPointFrame = 0, - flatbuffers::Offset positionFrame = 0, - flatbuffers::Offset scaleFrame = 0, - flatbuffers::Offset colorFrame = 0, - flatbuffers::Offset textureFrame = 0) { + flatbuffers::Offset pointFrame = 0, + flatbuffers::Offset scaleFrame = 0, + flatbuffers::Offset colorFrame = 0, + flatbuffers::Offset textureFrame = 0, + flatbuffers::Offset eventFrame = 0, + flatbuffers::Offset intFrame = 0, + flatbuffers::Offset boolFrame = 0, + flatbuffers::Offset innerActionFrame = 0) { FrameBuilder builder_(_fbb); + builder_.add_innerActionFrame(innerActionFrame); + builder_.add_boolFrame(boolFrame); + builder_.add_intFrame(intFrame); + builder_.add_eventFrame(eventFrame); builder_.add_textureFrame(textureFrame); builder_.add_colorFrame(colorFrame); builder_.add_scaleFrame(scaleFrame); - builder_.add_positionFrame(positionFrame); - builder_.add_anchorPointFrame(anchorPointFrame); - builder_.add_eventFrame(eventFrame); - builder_.add_rotationSkewFrame(rotationSkewFrame); - builder_.add_zOrderFrame(zOrderFrame); - builder_.add_visibleFrame(visibleFrame); + builder_.add_pointFrame(pointFrame); return builder_.Finish(); } -struct TimeLineBoolFrame : private flatbuffers::Table { +struct PointFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } - uint8_t value() const { return GetField(8, 0); } + const Position *postion() const { return GetStruct(8); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* frameIndex */) && VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* value */) && + VerifyField(verifier, 8 /* postion */) && verifier.EndTable(); } }; -struct TimeLineBoolFrameBuilder { +struct PointFrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_value(uint8_t value) { fbb_.AddElement(8, value, 0); } - TimeLineBoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineBoolFrameBuilder &operator=(const TimeLineBoolFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); } + PointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + PointFrameBuilder &operator=(const PointFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; -inline flatbuffers::Offset CreateTimeLineBoolFrame(flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset CreatePointFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, - uint8_t value = 0) { - TimeLineBoolFrameBuilder builder_(_fbb); - builder_.add_frameIndex(frameIndex); - builder_.add_value(value); - builder_.add_tween(tween); - return builder_.Finish(); -} - -struct TimeLineIntFrame : private flatbuffers::Table { - int32_t frameIndex() const { return GetField(4, 0); } - uint8_t tween() const { return GetField(6, 1); } - int32_t value() const { return GetField(8, 0); } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyField(verifier, 4 /* frameIndex */) && - VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* value */) && - verifier.EndTable(); - } -}; - -struct TimeLineIntFrameBuilder { - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } - void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_value(int32_t value) { fbb_.AddElement(8, value, 0); } - TimeLineIntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineIntFrameBuilder &operator=(const TimeLineIntFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); - return o; - } -}; - -inline flatbuffers::Offset CreateTimeLineIntFrame(flatbuffers::FlatBufferBuilder &_fbb, - int32_t frameIndex = 0, - uint8_t tween = 1, - int32_t value = 0) { - TimeLineIntFrameBuilder builder_(_fbb); - builder_.add_value(value); + const Position *postion = 0) { + PointFrameBuilder builder_(_fbb); + builder_.add_postion(postion); builder_.add_frameIndex(frameIndex); builder_.add_tween(tween); return builder_.Finish(); } -struct TimeLineStringFrame : private flatbuffers::Table { +struct ScaleFrame : private flatbuffers::Table { + int32_t frameIndex() const { return GetField(4, 0); } + uint8_t tween() const { return GetField(6, 1); } + const Scale *scale() const { return GetStruct(8); } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, 4 /* frameIndex */) && + VerifyField(verifier, 6 /* tween */) && + VerifyField(verifier, 8 /* scale */) && + verifier.EndTable(); + } +}; + +struct ScaleFrameBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } + void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } + void add_scale(const Scale *scale) { fbb_.AddStruct(8, scale); } + ScaleFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + ScaleFrameBuilder &operator=(const ScaleFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + return o; + } +}; + +inline flatbuffers::Offset CreateScaleFrame(flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + uint8_t tween = 1, + const Scale *scale = 0) { + ScaleFrameBuilder builder_(_fbb); + builder_.add_scale(scale); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); +} + +struct ColorFrame : private flatbuffers::Table { + int32_t frameIndex() const { return GetField(4, 0); } + uint8_t tween() const { return GetField(6, 1); } + const Color *color() const { return GetStruct(8); } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, 4 /* frameIndex */) && + VerifyField(verifier, 6 /* tween */) && + VerifyField(verifier, 8 /* color */) && + verifier.EndTable(); + } +}; + +struct ColorFrameBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } + void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } + void add_color(const Color *color) { fbb_.AddStruct(8, color); } + ColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + ColorFrameBuilder &operator=(const ColorFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + return o; + } +}; + +inline flatbuffers::Offset CreateColorFrame(flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + uint8_t tween = 1, + const Color *color = 0) { + ColorFrameBuilder builder_(_fbb); + builder_.add_color(color); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); +} + +struct TextureFrame : private flatbuffers::Table { + int32_t frameIndex() const { return GetField(4, 0); } + uint8_t tween() const { return GetField(6, 1); } + const ResourceData *textureFile() const { return GetPointer(8); } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, 4 /* frameIndex */) && + VerifyField(verifier, 6 /* tween */) && + VerifyField(verifier, 8 /* textureFile */) && + verifier.VerifyTable(textureFile()) && + verifier.EndTable(); + } +}; + +struct TextureFrameBuilder { + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } + void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } + void add_textureFile(flatbuffers::Offset textureFile) { fbb_.AddOffset(8, textureFile); } + TextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + TextureFrameBuilder &operator=(const TextureFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + return o; + } +}; + +inline flatbuffers::Offset CreateTextureFrame(flatbuffers::FlatBufferBuilder &_fbb, + int32_t frameIndex = 0, + uint8_t tween = 1, + flatbuffers::Offset textureFile = 0) { + TextureFrameBuilder builder_(_fbb); + builder_.add_textureFile(textureFile); + builder_.add_frameIndex(frameIndex); + builder_.add_tween(tween); + return builder_.Finish(); +} + +struct EventFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } const flatbuffers::String *value() const { return GetPointer(8); } @@ -2062,141 +2178,151 @@ struct TimeLineStringFrame : private flatbuffers::Table { } }; -struct TimeLineStringFrameBuilder { +struct EventFrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } void add_value(flatbuffers::Offset value) { fbb_.AddOffset(8, value); } - TimeLineStringFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineStringFrameBuilder &operator=(const TimeLineStringFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + EventFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + EventFrameBuilder &operator=(const EventFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; -inline flatbuffers::Offset CreateTimeLineStringFrame(flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset CreateEventFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, flatbuffers::Offset value = 0) { - TimeLineStringFrameBuilder builder_(_fbb); + EventFrameBuilder builder_(_fbb); builder_.add_value(value); builder_.add_frameIndex(frameIndex); builder_.add_tween(tween); return builder_.Finish(); } -struct TimeLinePointFrame : private flatbuffers::Table { +struct IntFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } - const Position *postion() const { return GetStruct(8); } + int32_t value() const { return GetField(8, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* frameIndex */) && VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* postion */) && + VerifyField(verifier, 8 /* value */) && verifier.EndTable(); } }; -struct TimeLinePointFrameBuilder { +struct IntFrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); } - TimeLinePointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLinePointFrameBuilder &operator=(const TimeLinePointFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + void add_value(int32_t value) { fbb_.AddElement(8, value, 0); } + IntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + IntFrameBuilder &operator=(const IntFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; -inline flatbuffers::Offset CreateTimeLinePointFrame(flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset CreateIntFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, - const Position *postion = 0) { - TimeLinePointFrameBuilder builder_(_fbb); - builder_.add_postion(postion); + int32_t value = 0) { + IntFrameBuilder builder_(_fbb); + builder_.add_value(value); builder_.add_frameIndex(frameIndex); builder_.add_tween(tween); return builder_.Finish(); } -struct TimeLineColorFrame : private flatbuffers::Table { +struct BoolFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } - const Color *color() const { return GetStruct(8); } + uint8_t value() const { return GetField(8, 1); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* frameIndex */) && VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* color */) && + VerifyField(verifier, 8 /* value */) && verifier.EndTable(); } }; -struct TimeLineColorFrameBuilder { +struct BoolFrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_color(const Color *color) { fbb_.AddStruct(8, color); } - TimeLineColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineColorFrameBuilder &operator=(const TimeLineColorFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + void add_value(uint8_t value) { fbb_.AddElement(8, value, 1); } + BoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + BoolFrameBuilder &operator=(const BoolFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; -inline flatbuffers::Offset CreateTimeLineColorFrame(flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset CreateBoolFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, - const Color *color = 0) { - TimeLineColorFrameBuilder builder_(_fbb); - builder_.add_color(color); + uint8_t value = 1) { + BoolFrameBuilder builder_(_fbb); builder_.add_frameIndex(frameIndex); + builder_.add_value(value); builder_.add_tween(tween); return builder_.Finish(); } -struct TimeLineTextureFrame : private flatbuffers::Table { +struct InnerActionFrame : private flatbuffers::Table { int32_t frameIndex() const { return GetField(4, 0); } uint8_t tween() const { return GetField(6, 1); } - const ResourceData *fileNameData() const { return GetPointer(8); } + int32_t innerActionType() const { return GetField(8, 0); } + const flatbuffers::String *currentAniamtionName() const { return GetPointer(10); } + int32_t singleFrameIndex() const { return GetField(12, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* frameIndex */) && VerifyField(verifier, 6 /* tween */) && - VerifyField(verifier, 8 /* fileNameData */) && - verifier.VerifyTable(fileNameData()) && + VerifyField(verifier, 8 /* innerActionType */) && + VerifyField(verifier, 10 /* currentAniamtionName */) && + verifier.Verify(currentAniamtionName()) && + VerifyField(verifier, 12 /* singleFrameIndex */) && verifier.EndTable(); } }; -struct TimeLineTextureFrameBuilder { +struct InnerActionFrameBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_frameIndex(int32_t frameIndex) { fbb_.AddElement(4, frameIndex, 0); } void add_tween(uint8_t tween) { fbb_.AddElement(6, tween, 1); } - void add_fileNameData(flatbuffers::Offset fileNameData) { fbb_.AddOffset(8, fileNameData); } - TimeLineTextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TimeLineTextureFrameBuilder &operator=(const TimeLineTextureFrameBuilder &); - flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); + void add_innerActionType(int32_t innerActionType) { fbb_.AddElement(8, innerActionType, 0); } + void add_currentAniamtionName(flatbuffers::Offset currentAniamtionName) { fbb_.AddOffset(10, currentAniamtionName); } + void add_singleFrameIndex(int32_t singleFrameIndex) { fbb_.AddElement(12, singleFrameIndex, 0); } + InnerActionFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } + InnerActionFrameBuilder &operator=(const InnerActionFrameBuilder &); + flatbuffers::Offset Finish() { + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 5)); return o; } }; -inline flatbuffers::Offset CreateTimeLineTextureFrame(flatbuffers::FlatBufferBuilder &_fbb, +inline flatbuffers::Offset CreateInnerActionFrame(flatbuffers::FlatBufferBuilder &_fbb, int32_t frameIndex = 0, uint8_t tween = 1, - flatbuffers::Offset fileNameData = 0) { - TimeLineTextureFrameBuilder builder_(_fbb); - builder_.add_fileNameData(fileNameData); + int32_t innerActionType = 0, + flatbuffers::Offset currentAniamtionName = 0, + int32_t singleFrameIndex = 0) { + InnerActionFrameBuilder builder_(_fbb); + builder_.add_singleFrameIndex(singleFrameIndex); + builder_.add_currentAniamtionName(currentAniamtionName); + builder_.add_innerActionType(innerActionType); builder_.add_frameIndex(frameIndex); builder_.add_tween(tween); return builder_.Finish(); diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp index a780c70bf4..b75d0a671b 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp @@ -68,15 +68,16 @@ using namespace flatbuffers; namespace cocostudio { -static const char* FrameType_VisibleFrame = "VisibleFrame"; -static const char* FrameType_PositionFrame = "PositionFrame"; -static const char* FrameType_ScaleFrame = "ScaleFrame"; -static const char* FrameType_RotationSkewFrame = "RotationSkewFrame"; -static const char* FrameType_AnchorFrame = "AnchorPointFrame"; -static const char* FrameType_ColorFrame = "ColorFrame"; -static const char* FrameType_TextureFrame = "TextureFrame"; -static const char* FrameType_EventFrame = "EventFrame"; -static const char* FrameType_ZOrderFrame = "ZOrderFrame"; +static const char* Property_VisibleForFrame = "VisibleForFrame"; +static const char* Property_Position = "Position"; +static const char* Property_Scale = "Scale"; +static const char* Property_RotationSkew = "RotationSkew"; +static const char* Property_CColor = "CColor"; +static const char* Property_FileData = "FileData"; +static const char* Property_FrameEvent = "FrameEvent"; +static const char* Property_Alpha = "Alpha"; +static const char* Property_ZOrder = "ZOrder"; +static const char* Property_ActionValue = "ActionValue"; static FlatBuffersSerialize* _instanceFlatBuffersSerialize = nullptr; @@ -232,7 +233,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str Offset nodeTree; Offset aciton; - + std::vector> animationInfos; const tinyxml2::XMLElement* child = element->FirstChildElement(); @@ -250,15 +251,26 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str const tinyxml2::XMLElement* objectData = child; nodeTree = createNodeTree(objectData, rootType); } - + else if (name == "AnimationList") // animation list + { + const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement(); + while (animationinfoElement) + { + auto animationinfo = createAnimationInfo(animationinfoElement); + animationInfos.push_back(animationinfo); + animationinfoElement = animationinfoElement->NextSiblingElement(); + } + } child = child->NextSiblingElement(); } + auto csparsebinary = CreateCSParseBinary(*_builder, _builder->CreateVector(_textures), _builder->CreateVector(_texturePngs), nodeTree, aciton, + _builder->CreateVector(animationInfos), _builder->CreateString(_csdVersion)); _builder->Finish(csparsebinary); @@ -514,6 +526,7 @@ Offset FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle { int duration = 0; float speed = 0.0f; + std::string currentAnimationName = ""; // CCLOG("animation name = %s", objectData->Name()); @@ -534,6 +547,10 @@ Offset FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle { speed = atof(value.c_str()); } + else if (name == "ActivedAnimationName") + { + currentAnimationName = value.c_str(); + } attribute = attribute->Next(); } @@ -552,13 +569,43 @@ Offset FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle return CreateNodeAction(*_builder, duration, speed, - _builder->CreateVector(timelines)); + _builder->CreateVector(timelines), + _builder->CreateString(currentAnimationName)); } + +Offset FlatBuffersSerialize::createAnimationInfo(const tinyxml2::XMLElement *objectData) + { + std::string infoName = ""; + int startIndex = 0; + int endIndex = 0; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string attriname = attribute->Name(); + std::string attrivalue = attribute->Value(); + if (attriname == "Name") + { + infoName = attrivalue; + } + else if (attriname == "StartIndex") + { + startIndex = atoi(attrivalue.c_str()); + } + else if (attriname == "EndIndex") + { + endIndex = atoi(attrivalue.c_str()); + } + attribute = attribute->Next(); + } + return CreateAnimationInfo(*_builder, _builder->CreateString(infoName), startIndex, endIndex); + } + Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement *objectData) { int actionTag = 0; - std::string frameType = ""; + std::string property = ""; // TimelineData attrsibutes const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); @@ -571,9 +618,9 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement { actionTag = atoi(value.c_str()); } - else if (name == "FrameType") + else if (name == "Property") { - frameType = value; + property = value; } attribute = attribute->Next(); @@ -587,210 +634,113 @@ Offset FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement { Offset frame; - if (frameType == FrameType_VisibleFrame) + if (property == Property_VisibleForFrame) { - auto visibleFrame = createTimeLineBoolFrame(frameElement); + auto boolFrame = createBoolFrame(frameElement); frame = CreateFrame(*_builder, - visibleFrame); - } - else if (frameType == FrameType_ZOrderFrame) - { - auto zOrderFrame = createTimeLineIntFrame(frameElement); - frame = CreateFrame(*_builder, - 0, // VisibleFrame - zOrderFrame); - } - else if (frameType == FrameType_RotationSkewFrame) - { - auto rotationSkewFrame = createTimeLinePointFrame(frameElement); - frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - rotationSkewFrame); - } - else if (frameType == FrameType_EventFrame) - { - auto eventFrame = createTimeLineStringFrame(frameElement); - frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame - eventFrame); - } - else if (frameType == FrameType_AnchorFrame) - { - auto anchorPointFrame = createTimeLinePointFrame(frameElement); - frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame + 0, // PointFrame + 0, // ScaleFrame + 0, // ColorFrame + 0, // TextureFrame 0, // EventFrame - anchorPointFrame); + 0, // IntFrame + boolFrame); } - else if (frameType == FrameType_PositionFrame) + else if (property == Property_Position) { - auto positionFrame = createTimeLinePointFrame(frameElement); + auto pointFrame = createPointFrame(frameElement); frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame - 0, // EventFrame - 0, // AnchorPointFrame - positionFrame); + pointFrame); } - else if (frameType == FrameType_ScaleFrame) + else if (property == Property_Scale) { - auto scaleFrame = createTimeLinePointFrame(frameElement); + auto scaleFrame = createScaleFrame(frameElement); frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame - 0, // EventFrame - 0, // AnchorPointFrame - 0, // PositionFrame + 0, // PointFrame scaleFrame); } - else if (frameType == FrameType_ColorFrame) + else if (property == Property_RotationSkew) { - auto colorFrame = createTimeLineColorFrame(frameElement); + auto scaleFrame = createScaleFrame(frameElement); frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame - 0, // EventFrame - 0, // AnchorPointFrame - 0, // PositionFrame + 0, // PointFrame + scaleFrame); + } + else if (property == Property_CColor) + { + auto colorFrame = createColorFrame(frameElement); + frame = CreateFrame(*_builder, + 0, // PointFrame 0, // ScaleFrame colorFrame); } - else if (frameType == FrameType_TextureFrame) + else if (property == Property_FileData) { - auto textureFrame = createTimeLineTextureFrame(frameElement); + auto textureFrame = createTextureFrame(frameElement); frame = CreateFrame(*_builder, - 0, // VisibleFrame - 0, // ZOrderFrame - 0, // RotationSkewFrame - 0, // EventFrame - 0, // AnchorPointFrame - 0, // PositionFrame + 0, // PointFrame 0, // ScaleFrame 0, // ColorFrame textureFrame); } + else if (property == Property_FrameEvent) + { + auto eventFrame = createEventFrame(frameElement); + frame = CreateFrame(*_builder, + 0, // PointFrame + 0, // ScaleFrame + 0, // ColorFrame + 0, // TextureFrame + eventFrame); + } + else if (property == Property_Alpha) + { + auto intFrame = createIntFrame(frameElement); + frame = CreateFrame(*_builder, + 0, // PointFrame + 0, // ScaleFrame + 0, // ColorFrame + 0, // TextureFrame + 0, // EventFrame + intFrame); + } + else if (property == Property_ZOrder) + { + auto intFrame = createIntFrame(frameElement); + frame = CreateFrame(*_builder, + 0, // PointFrame + 0, // ScaleFrame + 0, // ColorFrame + 0, // TextureFrame + 0, // EventFrame + intFrame); + } + else if (property == Property_ActionValue) + { + auto innerActionFrame = createInnerActionFrame(frameElement); + frame = CreateFrame(*_builder, + 0, // PointFrame + 0, // ScaleFrame + 0, // ColorFrame + 0, // TextureFrame + 0, // EventFrame + 0, // IntFrame + 0, // BoolFrame + innerActionFrame); + } + frames.push_back(frame); frameElement = frameElement->NextSiblingElement(); } return CreateTimeLine(*_builder, - _builder->CreateString(frameType), + _builder->CreateString(property), actionTag, _builder->CreateVector(frames)); } - -Offset FlatBuffersSerialize::createTimeLineBoolFrame(const tinyxml2::XMLElement *objectData) -{ - int frameIndex = 0; - bool tween = true; - bool value = false; - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string name = attribute->Name(); - std::string attrivalue = attribute->Value(); - - if (name == "Value") - { - value = (attrivalue == "True") ? true : false; - } - else if (name == "FrameIndex") - { - frameIndex = atoi(attrivalue.c_str()); - } - else if (name == "Tween") - { - tween = atoi(attrivalue.c_str()); - } - - attribute = attribute->Next(); - } - - return CreateTimeLineBoolFrame(*_builder, - frameIndex, - tween, - value); -} - -Offset FlatBuffersSerialize::createTimeLineIntFrame(const tinyxml2::XMLElement *objectData) -{ - int frameIndex = 0; - bool tween = true; - int value = 0; - - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string name = attribute->Name(); - std::string attrivalue = attribute->Value(); - - if (name == "Value") // to be gonna modify - { - value = atoi(attrivalue.c_str()); - } - else if (name == "FrameIndex") - { - frameIndex = atoi(attrivalue.c_str()); - } - else if (name == "Tween") - { - tween = (attrivalue == "True") ? true : false; - } - - attribute = attribute->Next(); - } - - return CreateTimeLineIntFrame(*_builder, - frameIndex, - tween, - value); -} - -Offset FlatBuffersSerialize::createTimeLineStringFrame(const tinyxml2::XMLElement *objectData) -{ - int frameIndex = 0; - bool tween = true; - std::string value = ""; - - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string name = attribute->Name(); - std::string attrivalue = attribute->Value(); - - if (name == "Value") // to be gonna modify - { - value = attrivalue; - } - else if (name == "FrameIndex") - { - frameIndex = atoi(attrivalue.c_str()); - } - else if (name == "Tween") - { - tween = (attrivalue == "True") ? true : false; - } - - attribute = attribute->Next(); - } - - return CreateTimeLineStringFrame(*_builder, - frameIndex, - tween, - _builder->CreateString(value)); -} - -Offset FlatBuffersSerialize::createTimeLinePointFrame(const tinyxml2::XMLElement *objectData) +Offset FlatBuffersSerialize::createPointFrame(const tinyxml2::XMLElement *objectData) { int frameIndex = 0; bool tween = true; @@ -824,17 +774,57 @@ Offset FlatBuffersSerialize::createTimeLinePointFrame(const Position f_position(position.x, position.y); - return CreateTimeLinePointFrame(*_builder, - frameIndex, - tween, - &f_position); + return CreatePointFrame(*_builder, + frameIndex, + tween, + &f_position); } -Offset FlatBuffersSerialize::createTimeLineColorFrame(const tinyxml2::XMLElement *objectData) +Offset FlatBuffersSerialize::createScaleFrame(const tinyxml2::XMLElement *objectData) { int frameIndex = 0; bool tween = true; - Color4B color; + Vec2 scale; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "X") + { + scale.x = atof(value.c_str()); + } + else if (name == "Y") + { + scale.y = atof(value.c_str()); + } + else if (name == "FrameIndex") + { + frameIndex = atoi(value.c_str()); + } + else if (name == "Tween") + { + tween = (value == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + Scale f_scale(scale.x, scale.y); + + return CreateScaleFrame(*_builder, + frameIndex, + tween, + &f_scale); +} + +Offset FlatBuffersSerialize::createColorFrame(const tinyxml2::XMLElement *objectData) +{ + int frameIndex = 0; + bool tween = true; + Color3B color; const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); while (attribute) @@ -846,10 +836,6 @@ Offset FlatBuffersSerialize::createTimeLineColorFrame(const { frameIndex = atoi(value.c_str()); } - else if (name == "Alpha") - { - color.a = atoi(value.c_str()); - } else if (name == "Tween") { tween = (value == "True") ? true : false; @@ -879,7 +865,7 @@ Offset FlatBuffersSerialize::createTimeLineColorFrame(const else if (name == "B") { color.b = atoi(value.c_str()); - } + } attribute = attribute->Next(); } @@ -887,85 +873,244 @@ Offset FlatBuffersSerialize::createTimeLineColorFrame(const child = child->NextSiblingElement(); } - Color f_color(color.a, color.r, color.g, color.b); + Color f_color(255, color.r, color.g, color.b); - return CreateTimeLineColorFrame(*_builder, - frameIndex, - tween, - &f_color); + return CreateColorFrame(*_builder, + frameIndex, + tween, + &f_color); } - Offset FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData) +Offset FlatBuffersSerialize::createTextureFrame(const tinyxml2::XMLElement *objectData) +{ + int frameIndex = 0; + bool tween = true; + + std::string path = ""; + std::string plistFile = ""; + int resourceType = 0; + + std::string texture = ""; + std::string texturePng = ""; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) { - int frameIndex = 0; - bool tween = true; + std::string attriname = attribute->Name(); + std::string value = attribute->Value(); - std::string path = ""; - std::string plistFile = ""; - int resourceType = 0; + if (attriname == "FrameIndex") + { + frameIndex = atoi(value.c_str()); + } + else if (attriname == "Tween") + { + tween = (value == "True") ? true : false; + } - std::string texture = ""; - std::string texturePng = ""; - - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + attribute = attribute->Next(); + } + + const tinyxml2::XMLElement* child = objectData->FirstChildElement(); + while (child) + { + attribute = child->FirstAttribute(); while (attribute) { std::string attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "FrameIndex") + if (attriname == "Path") { - frameIndex = atoi(value.c_str()); + path = value; } - else if (attriname == "Tween") + else if (attriname == "Type") { - tween = (value == "True") ? true : false; + resourceType = getResourceType(value); + } + else if (attriname == "Plist") + { + plistFile = value; + texture = value; } attribute = attribute->Next(); } - const tinyxml2::XMLElement* child = objectData->FirstChildElement(); - while (child) + if (resourceType == 1) { - attribute = child->FirstAttribute(); - while (attribute) - { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); - - if (attriname == "Path") - { - path = value; - } - else if (attriname == "Type") - { - resourceType = getResourceType(value); - } - else if (attriname == "Plist") - { - plistFile = value; - texture = value; - } - - attribute = attribute->Next(); - } - - if (resourceType == 1) - { - _textures.push_back(_builder->CreateString(texture)); - } - - child = child->NextSiblingElement(); + _textures.push_back(_builder->CreateString(texture)); } - return CreateTimeLineTextureFrame(*_builder, - frameIndex, - tween, - CreateResourceData(*_builder, - _builder->CreateString(path), - _builder->CreateString(plistFile), - resourceType)); + child = child->NextSiblingElement(); + } + + return CreateTextureFrame(*_builder, + frameIndex, + tween, + CreateResourceData(*_builder, + _builder->CreateString(path), + _builder->CreateString(plistFile), + resourceType)); +} + +Offset FlatBuffersSerialize::createEventFrame(const tinyxml2::XMLElement *objectData) +{ + int frameIndex = 0; + bool tween = true; + std::string value = ""; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string name = attribute->Name(); + std::string attrivalue = attribute->Value(); + + if (name == "Value") // to be gonna modify + { + value = attrivalue; + } + else if (name == "FrameIndex") + { + frameIndex = atoi(attrivalue.c_str()); + } + else if (name == "Tween") + { + tween = (attrivalue == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + return CreateEventFrame(*_builder, + frameIndex, + tween, + _builder->CreateString(value)); +} + +Offset FlatBuffersSerialize::createIntFrame(const tinyxml2::XMLElement *objectData) +{ + int frameIndex = 0; + bool tween = true; + int value = 0; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string name = attribute->Name(); + std::string attrivalue = attribute->Value(); + + if (name == "Value") // to be gonna modify + { + value = atoi(attrivalue.c_str()); + } + else if (name == "FrameIndex") + { + frameIndex = atoi(attrivalue.c_str()); + } + else if (name == "Tween") + { + tween = (attrivalue == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + return CreateIntFrame(*_builder, + frameIndex, + tween, + value); +} + +Offset FlatBuffersSerialize::createBoolFrame(const tinyxml2::XMLElement *objectData) +{ + int frameIndex = 0; + bool tween = true; + bool value = true; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string name = attribute->Name(); + std::string attrivalue = attribute->Value(); + + if (name == "Value") + { + value = (attrivalue == "True") ? true : false; + } + else if (name == "FrameIndex") + { + frameIndex = atoi(attrivalue.c_str()); + } + else if (name == "Tween") + { + tween = (attrivalue == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + return CreateBoolFrame(*_builder, + frameIndex, + tween, + value); +} + + Offset FlatBuffersSerialize::createInnerActionFrame(const tinyxml2::XMLElement *objectData) + { + int frameIndex = 0; + bool tween = true; + int innerActionType = 0; + std::string currentAniamtionName = ""; + int singleFrameIndex = 0; + + const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); + while (attribute) + { + std::string name = attribute->Name(); + std::string attrivalue = attribute->Value(); + + if (name == "InnerActionType") + { + if (attrivalue == "LoopAction") + { + innerActionType = 0; + } + else if (attrivalue == "NoLoopAction") + { + innerActionType = 1; + } + else if (attrivalue == "SingleFrame") + { + innerActionType = 2; + } + } + else if (name == "CurrentAniamtionName") + { + currentAniamtionName = attrivalue; + } + else if (name == "SingleFrameIndex") + { + singleFrameIndex = atoi(attrivalue.c_str()); + } + else if (name == "FrameIndex") + { + frameIndex = atoi(attrivalue.c_str()); + } + else if (name == "Tween") + { + tween = (attrivalue == "True") ? true : false; + } + + attribute = attribute->Next(); + } + + return CreateInnerActionFrame(*_builder, + frameIndex, + tween, + innerActionType, + _builder->CreateString(currentAniamtionName), + singleFrameIndex); } /* create flat buffers with XML */ @@ -1005,7 +1150,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato if (attribute) _csdVersion = attribute->Value(); } - + if (strcmp("Content", element->Name()) == 0) { const tinyxml2::XMLAttribute* attribute = element->FirstAttribute(); @@ -1040,7 +1185,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato Offset nodeTree; Offset aciton; - + std::vector > animationInfos; const tinyxml2::XMLElement* child = element->FirstChildElement(); @@ -1058,6 +1203,16 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato const tinyxml2::XMLElement* objectData = child; nodeTree = createNodeTreeForSimulator(objectData, rootType); } + else if (name == "AnimationList") // animation list + { + const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement(); + while (animationinfoElement) + { + auto animationinfo = createAnimationInfo(animationinfoElement); + animationInfos.push_back(animationinfo); + animationinfoElement = animationinfoElement->NextSiblingElement(); + } + } child = child->NextSiblingElement(); } @@ -1067,8 +1222,9 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato _builder->CreateVector(_texturePngs), nodeTree, aciton, + _builder->CreateVector(animationInfos), _builder->CreateString(_csdVersion)); - _builder->Finish(csparsebinary); + _builder->Finish(csparsebinary); _textures.clear(); _texturePngs.clear(); @@ -1190,26 +1346,6 @@ Offset FlatBuffersSerialize::createProjectNodeOptionsForSimu std::string filename = ""; - - bool isloop = true; - bool isAutoPlay = true; - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); - if (attriname == "IsLoop") - { - isloop = (value == "True") ? true : false; - - } - else if (attriname == "IsAutoPlay") - { - isAutoPlay = (value == "True") ? true : false; - } - attribute = attribute->Next(); - } - // FileData const tinyxml2::XMLElement* child = objectData->FirstChildElement(); while (child) @@ -1218,19 +1354,19 @@ Offset FlatBuffersSerialize::createProjectNodeOptionsForSimu if (name == "FileData") { - const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute(); + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); - while (attributeFileData) + while (attribute) { - name = attributeFileData->Name(); - std::string value = attributeFileData->Value(); + name = attribute->Name(); + std::string value = attribute->Value(); if (name == "Path") { filename = value; } - attributeFileData = attributeFileData->Next(); + attribute = attribute->Next(); } } @@ -1239,9 +1375,7 @@ Offset FlatBuffersSerialize::createProjectNodeOptionsForSimu return CreateProjectNodeOptions(*_builder, nodeOptions, - _builder->CreateString(filename), - isloop, - isAutoPlay); + _builder->CreateString(filename)); } } diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h index bdaea811ea..9cd0d804f2 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h @@ -65,16 +65,18 @@ namespace flatbuffers struct TextAtlasOptions; - struct NodeAction; + struct AnimationInfo; struct TimeLine; struct Frame; - struct TimeLineBoolFrame; - struct TimeLineIntFrame; - struct TimeLineStringFrame; - struct TimeLinePointFrame; - struct TimeLineColorFrame; - struct TimeLineTextureFrame; + struct PointFrame; + struct ScaleFrame; + struct ColorFrame; + struct TextureFrame; + struct EventFrame; + struct IntFrame; + struct BoolFrame; + struct InnerActionFrame; } namespace tinyxml2 @@ -109,13 +111,18 @@ public: // NodeAction flatbuffers::Offset createNodeAction(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLine(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLineBoolFrame(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLineIntFrame(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLineStringFrame(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLinePointFrame(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLineColorFrame(const tinyxml2::XMLElement* objectData); - flatbuffers::Offset createTimeLineTextureFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createTimeLine(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createPointFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createScaleFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createColorFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createTextureFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createEventFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createIntFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createBoolFrame(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createInnerActionFrame(const tinyxml2::XMLElement* objectData); + + //Animation Info + flatbuffers::Offset createAnimationInfo(const tinyxml2::XMLElement* objectData); /**/ int getResourceType(std::string key); @@ -126,7 +133,7 @@ public: flatbuffers::FlatBufferBuilder* createFlatBuffersWithXMLFileForSimulator(const std::string& xmlFileName); flatbuffers::Offset createNodeTreeForSimulator(const tinyxml2::XMLElement* objectData, std::string classType); - flatbuffers::Offset createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData); + flatbuffers::Offset createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData); /**/ std::string getCsdVersion() { return _csdVersion; } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp index 810f4d1f26..090b5185ce 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp @@ -69,26 +69,6 @@ namespace cocostudio auto nodeOptions = *(Offset*)(&temp); std::string filename = ""; - bool isloop = true; - bool isAutoPlay = true; - - const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute(); - while (attribute) - { - std::string attriname = attribute->Name(); - std::string value = attribute->Value(); - - if (attriname == "IsLoop") - { - isloop = (value == "True") ? true : false; - } - else if (attriname == "IsAutoPlay") - { - isAutoPlay = (value == "True") ? true : false; - } - - attribute = attribute->Next(); - } // FileData const tinyxml2::XMLElement* child = objectData->FirstChildElement(); @@ -98,12 +78,12 @@ namespace cocostudio if (name == "FileData") { - const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute(); + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); - while (attributeFileData) + while (attribute) { - name = attributeFileData->Name(); - std::string value = attributeFileData->Value(); + name = attribute->Name(); + std::string value = attribute->Value(); if (name == "Path") { @@ -112,7 +92,7 @@ namespace cocostudio filename = convert; } - attributeFileData = attributeFileData->Next(); + attribute = attribute->Next(); } } @@ -121,9 +101,7 @@ namespace cocostudio auto options = CreateProjectNodeOptions(*builder, nodeOptions, - builder->CreateString(filename), - isloop, - isAutoPlay); + builder->CreateString(filename)); return *(Offset*)(&options); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 70ac3c14b9..14921367a6 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -197,7 +197,11 @@ void TestActionTimeline::onEnter() { ActionTimelineTestLayer::onEnter(); - ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true); + Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + node->runAction(action); + action->gotoFrameAndPlay(0); +// ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true); node->setScale(0.2f); node->setPosition(VisibleRect::center()); @@ -217,8 +221,14 @@ void TestChangePlaySection::onEnter() { ActionTimelineTestLayer::onEnter(); + Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); + action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + node->runAction(action); + action->gotoFrameAndPlay(41); + /* ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true); action = node->getActionTimeline(); + */ node->setScale(0.2f); node->setPosition(VisibleRect::center()); @@ -250,8 +260,14 @@ void TestTimelineFrameEvent::onEnter() { ActionTimelineTestLayer::onEnter(); + Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + node->runAction(action); + action->gotoFrameAndPlay(0); + /* ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true); ActionTimeline* action = node->getActionTimeline(); + */ node->setScale(0.2f); node->setPosition(150,100); @@ -291,7 +307,11 @@ void TestTimelinePerformance::onEnter() for (int i = 0; i< 100; i++) { - ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true); + Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb"); + ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb"); + node->runAction(action); + action->gotoFrameAndPlay(41); +// ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true); node->setScale(0.1f); node->setPosition(i*2,100);