From fadac31868653b205377b4d9e235dc502b486d71 Mon Sep 17 00:00:00 2001 From: pipu Date: Thu, 5 Mar 2015 15:48:17 +0800 Subject: [PATCH] Serialize and parse attribute "inner speed" for ProjectNode. --- .../cocostudio/ActionTimeline/CSLoader.cpp | 2 ++ .../cocostudio/CSParseBinary_generated.h | 9 +++++++-- .../ProjectNodeReader/ProjectNodeReader.cpp | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 23a512ef06..4887a68623 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -854,6 +854,7 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree) reader->setPropsWithFlatBuffers(node, options->data()); if (action) { + action->setTimeSpeed(projectNodeOptions->innerActionSpeed()); node->runAction(action); action->gotoFrameAndPause(0); } @@ -1187,6 +1188,7 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod reader->setPropsWithFlatBuffers(node, options->data()); if (action) { + action->setTimeSpeed(projectNodeOptions->innerActionSpeed()); node->runAction(action); action->gotoFrameAndPause(0); } diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index a07e313ecb..b2485fbbef 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -1685,12 +1685,14 @@ 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); } + float innerActionSpeed() const { return GetField(8, 0); } 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 /* innerActionSpeed */) && verifier.EndTable(); } }; @@ -1700,18 +1702,21 @@ 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_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 0); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); flatbuffers::Offset Finish() { - auto o = flatbuffers::Offset(fbb_.EndTable(start_, 2)); + auto o = flatbuffers::Offset(fbb_.EndTable(start_, 3)); return o; } }; inline flatbuffers::Offset CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, - flatbuffers::Offset fileName = 0) { + flatbuffers::Offset fileName = 0, + float innerActionSpeed = 0) { ProjectNodeOptionsBuilder builder_(_fbb); + builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_fileName(fileName); builder_.add_nodeOptions(nodeOptions); return builder_.Finish(); diff --git a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp index 090b5185ce..6b0c73a53c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.cpp @@ -69,6 +69,21 @@ namespace cocostudio auto nodeOptions = *(Offset*)(&temp); std::string filename = ""; + float innerspeed = 1.0f; + + const tinyxml2::XMLAttribute* objattri = objectData->FirstAttribute(); + // inneraction speed + while (objattri) + { + std::string name = objattri->Name(); + std::string value = objattri->Value(); + if (name == "InnerActionSpeed") + { + innerspeed = atof(objattri->Value()); + break; + } + objattri = objattri->Next(); + } // FileData const tinyxml2::XMLElement* child = objectData->FirstChildElement(); @@ -101,7 +116,8 @@ namespace cocostudio auto options = CreateProjectNodeOptions(*builder, nodeOptions, - builder->CreateString(filename)); + builder->CreateString(filename), + innerspeed); return *(Offset*)(&options); }