diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 7756c5c937..97f01b41c4 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1266,6 +1266,10 @@ 382384451A25915C002C4610 /* SpriteReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 382384421A25915C002C4610 /* SpriteReader.cpp */; }; 382384461A25915C002C4610 /* SpriteReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 382384431A25915C002C4610 /* SpriteReader.h */; }; 382384471A25915C002C4610 /* SpriteReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 382384431A25915C002C4610 /* SpriteReader.h */; }; + 382F7ADC1AB1292A002EBECF /* CCObjectExtensionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 382F7ADA1AB1292A002EBECF /* CCObjectExtensionData.cpp */; }; + 382F7ADD1AB1292A002EBECF /* CCObjectExtensionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 382F7ADA1AB1292A002EBECF /* CCObjectExtensionData.cpp */; }; + 382F7ADE1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 382F7ADB1AB1292A002EBECF /* CCObjectExtensionData.h */; }; + 382F7ADF1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 382F7ADB1AB1292A002EBECF /* CCObjectExtensionData.h */; }; 38ACD1FC1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38ACD1FA1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp */; }; 38ACD1FD1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38ACD1FA1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp */; }; 38ACD1FE1A27111900C3093D /* WidgetCallBackHandlerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 38ACD1FB1A27111900C3093D /* WidgetCallBackHandlerProtocol.h */; }; @@ -3089,6 +3093,8 @@ 3823843C1A259140002C4610 /* SingleNodeReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleNodeReader.h; sourceTree = ""; }; 382384421A25915C002C4610 /* SpriteReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteReader.cpp; sourceTree = ""; }; 382384431A25915C002C4610 /* SpriteReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteReader.h; sourceTree = ""; }; + 382F7ADA1AB1292A002EBECF /* CCObjectExtensionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCObjectExtensionData.cpp; sourceTree = ""; }; + 382F7ADB1AB1292A002EBECF /* CCObjectExtensionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCObjectExtensionData.h; sourceTree = ""; }; 38ACD1FA1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetCallBackHandlerProtocol.cpp; sourceTree = ""; }; 38ACD1FB1A27111900C3093D /* WidgetCallBackHandlerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetCallBackHandlerProtocol.h; sourceTree = ""; }; 38B8E2D319E66581002D7CE7 /* CSLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSLoader.cpp; sourceTree = ""; }; @@ -4772,6 +4778,8 @@ 382384061A25900F002C4610 /* FlatBuffersSerialize.h */, 38ACD1FA1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp */, 38ACD1FB1A27111900C3093D /* WidgetCallBackHandlerProtocol.h */, + 382F7ADA1AB1292A002EBECF /* CCObjectExtensionData.cpp */, + 382F7ADB1AB1292A002EBECF /* CCObjectExtensionData.h */, 29E99D1C1957BA7000046604 /* CocoLoader.cpp */, 29E99D1D1957BA7000046604 /* CocoLoader.h */, 0634A4C4194B19E400E608AF /* ActionTimeline */, @@ -7014,6 +7022,7 @@ 15AE1BA219AADFDF00C27E9E /* UILayoutParameter.h in Headers */, 50ABBE331925AB6F00A911A9 /* CCConfiguration.h in Headers */, B665E2101AA80A6500DDB1C5 /* CCPUBaseForceAffector.h in Headers */, + 382F7ADE1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */, 15AE199519AAD39600C27E9E /* LayoutReader.h in Headers */, 15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */, 15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */, @@ -7667,6 +7676,7 @@ B665E3751AA80A6500DDB1C5 /* CCPUParticleFollower.h in Headers */, 15AE185D19AAD31200C27E9E /* CocosDenshion.h in Headers */, 15AE194319AAD35100C27E9E /* CCColliderDetector.h in Headers */, + 382F7ADF1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */, D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */, 15AE1BC419AADFFB00C27E9E /* ExtensionMacros.h in Headers */, 15AE185A19AAD31200C27E9E /* CDConfig.h in Headers */, @@ -8180,6 +8190,7 @@ 15AE182C19AAD2F700C27E9E /* CCMeshVertexIndexData.cpp in Sources */, 15AE1A8C19AAD40300C27E9E /* b2RevoluteJoint.cpp in Sources */, 50ABBD4C1925AB0000A911A9 /* MathUtil.cpp in Sources */, + 382F7ADC1AB1292A002EBECF /* CCObjectExtensionData.cpp in Sources */, 15AE191719AAD35000C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, B665E2E21AA80A6500DDB1C5 /* CCPULineAffectorTranslator.cpp in Sources */, 1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */, @@ -8607,6 +8618,7 @@ 1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */, B276EF621988D1D500CD400F /* CCVertexIndexData.cpp in Sources */, 50ABBE561925AB6F00A911A9 /* CCEventFocus.cpp in Sources */, + 382F7ADD1AB1292A002EBECF /* CCObjectExtensionData.cpp in Sources */, 15AE183D19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, 503DD8E11926736A00CD74DD /* CCApplication-ios.mm in Sources */, 15AE1AAC19AAD40300C27E9E /* b2WorldCallbacks.cpp in Sources */, diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj old mode 100644 new mode 100755 index b572b062b8..c2432f1adb --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -502,6 +502,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1055,6 +1056,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters old mode 100644 new mode 100755 index a637060725..6a5664a0b0 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1786,6 +1786,9 @@ extension\Particle3D + + cocostudio\json + @@ -3496,6 +3499,9 @@ extension\Particle3D + + cocostudio\json + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index e05aa93b75..430cb070f4 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -365,6 +365,7 @@ + @@ -932,6 +933,7 @@ + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 264ade0262..2295b95218 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1734,6 +1734,9 @@ + + cocostudio\json + @@ -3294,6 +3297,9 @@ + + cocostudio\json + diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index a9ea9dda03..2bd3354056 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -526,6 +526,7 @@ + @@ -1164,6 +1165,7 @@ + diff --git a/cocos/2d/libcocos2d_wp8.vcxproj.filters b/cocos/2d/libcocos2d_wp8.vcxproj.filters index a9a98652dd..93d1161219 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj.filters +++ b/cocos/2d/libcocos2d_wp8.vcxproj.filters @@ -1806,6 +1806,9 @@ extension\Particle3D + + cocostudio\json + @@ -3510,6 +3513,9 @@ extension\Particle3D + + cocostudio\json + diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index cf3fc88605..24b055574b 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -24,6 +24,8 @@ THE SOFTWARE. #include "CCActionTimeline.h" +#include "cocostudio/CCObjectExtensionData.h" + USING_NS_CC; NS_TIMELINE_BEGIN @@ -235,7 +237,7 @@ void ActionTimeline::startWithTarget(Node *target) foreachNodeDescendant(target, [this, target](Node* child) { - ActionTimelineData* data = dynamic_cast(child->getUserObject()); + ObjectExtensionData* data = dynamic_cast(child->getUserObject()); if(data) { diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index e15606ad9a..9f07ff1af8 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -74,7 +74,8 @@ ActionTimeline/CCActionTimelineNode.cpp \ ActionTimeline/CSLoader.cpp \ FlatBuffersSerialize.cpp \ WidgetCallBackHandlerProtocol.cpp \ -WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp +WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp \ +CCObjectExtensionData.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. diff --git a/cocos/editor-support/cocostudio/CCObjectExtensionData.cpp b/cocos/editor-support/cocostudio/CCObjectExtensionData.cpp new file mode 100644 index 0000000000..ebf78c4451 --- /dev/null +++ b/cocos/editor-support/cocostudio/CCObjectExtensionData.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** + Copyright (c) 2015 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCObjectExtensionData.h" + +#include "cocostudio/ActionTimeline/CCActionTimeline.h" + + +namespace cocostudio +{ + + ObjectExtensionData* ObjectExtensionData::create() + { + ObjectExtensionData * ret = new (std::nothrow) ObjectExtensionData(); + if (ret && ret->init()) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + return ret; + } + + ObjectExtensionData::ObjectExtensionData() + : _customProperty("") + , _timelineData(nullptr) + { + } + + bool ObjectExtensionData::init() + { + _timelineData = cocostudio::timeline::ActionTimelineData::create(0); + + return true; + } + + void ObjectExtensionData::setActionTag(int actionTag) + { + _timelineData->setActionTag(actionTag); + } + + const int ObjectExtensionData::getActionTag() const + { + return _timelineData->getActionTag(); + } + +} diff --git a/cocos/editor-support/cocostudio/CCObjectExtensionData.h b/cocos/editor-support/cocostudio/CCObjectExtensionData.h new file mode 100644 index 0000000000..0855146e47 --- /dev/null +++ b/cocos/editor-support/cocostudio/CCObjectExtensionData.h @@ -0,0 +1,67 @@ +/**************************************************************************** + Copyright (c) 2015 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __cocos2d_libs__CCObjectExtensionData__ +#define __cocos2d_libs__CCObjectExtensionData__ + +#include + +#include "base/CCRef.h" + +#include "cocostudio/CocosStudioExport.h" + +namespace cocostudio +{ + namespace timeline + { + class ActionTimelineData; + } +} + +namespace cocostudio +{ + class CC_STUDIO_DLL ObjectExtensionData : public cocos2d::Ref + { + + public: + static ObjectExtensionData* create(); + + virtual void setCustomProperty(const std::string& customProperty) { _customProperty = customProperty; } + virtual std::string getCustomProperty() const { return _customProperty; }; + + virtual void setActionTag(int actionTag); + virtual const int getActionTag() const; + + CC_CONSTRUCTOR_ACCESS: + ObjectExtensionData(); + virtual bool init(); + + protected: + std::string _customProperty; + cocostudio::timeline::ActionTimelineData* _timelineData; + }; +} + + +#endif /* defined(__cocos2d_libs__CCObjectExtensionData__) */ diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index d380007eab..888b4f8146 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -43,6 +43,7 @@ set(COCOS_CS_SRC editor-support/cocostudio/TriggerMng.cpp editor-support/cocostudio/TriggerObj.cpp editor-support/cocostudio/FlatBuffersSerialize.cpp + editor-support/cocostudio/CCObjectExtensionData.cpp editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp editor-support/cocostudio/WidgetReader/SingleNodeReader/SingleNodeReader.cpp editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp index 47d1e4e74c..42fe6d7c8e 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.cpp @@ -324,7 +324,10 @@ Offset FlatBuffersSerialize::createNodeTree(const tinyxml2::XMLElement readername.append("Reader"); NodeReaderProtocol* reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readername)); - options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + if (reader != nullptr) + { + options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + } } @@ -1265,7 +1268,10 @@ Offset FlatBuffersSerialize::createNodeTreeForSimulator(const tinyxml2 readername.append("Reader"); NodeReaderProtocol* reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readername)); - options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + if (reader != nullptr) + { + options = CreateOptions(*_builder, reader->createOptionsWithFlatBuffers(objectData, _builder)); + } } diff --git a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp index 494450d6f9..499b418a63 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.cpp @@ -26,6 +26,7 @@ #include "cocostudio/CSParseBinary_generated.h" #include "cocostudio/ActionTimeline/CCActionTimeline.h" +#include "cocostudio/CCObjectExtensionData.h" #include "tinyxml2.h" #include "flatbuffers/flatbuffers.h" @@ -182,6 +183,10 @@ namespace cocostudio { touchEnabled = (value == "True") ? true : false; } + else if (attriname == "UserData") + { + customProperty = value; + } else if (attriname == "FrameEvent") { frameEvent = value; @@ -477,6 +482,7 @@ namespace cocostudio float h = options->size()->height(); int alpha = options->alpha(); Color3B color(options->color()->r(), options->color()->g(), options->color()->b()); + std::string customProperty = options->customProperty()->c_str(); node->setName(name); @@ -508,6 +514,12 @@ namespace cocostudio node->setTag(tag); node->setUserObject(timeline::ActionTimelineData::create(actionTag)); + ObjectExtensionData* extensionData = ObjectExtensionData::create(); + extensionData->setCustomProperty(customProperty); + extensionData->setActionTag(actionTag); + node->setUserObject(extensionData); + + node->setCascadeColorEnabled(true); node->setCascadeOpacityEnabled(true); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index b342b73f6d..6b714395f4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -5,6 +5,7 @@ #include "cocostudio/CocoLoader.h" #include "ui/UIButton.h" #include "../ActionTimeline/CCActionTimeline.h" +#include "cocostudio/CCObjectExtensionData.h" #include "cocostudio/CSParseBinary_generated.h" #include "tinyxml2.h" @@ -480,6 +481,10 @@ namespace cocostudio { touchEnabled = (value == "True") ? true : false; } + else if (attriname == "UserData") + { + customProperty = value; + } else if (attriname == "FrameEvent") { frameEvent = value; @@ -786,6 +791,14 @@ namespace cocostudio int actionTag = options->actionTag(); widget->setActionTag(actionTag); + + std::string customProperty = options->customProperty()->c_str(); + + ObjectExtensionData* extensionData = ObjectExtensionData::create(); + extensionData->setCustomProperty(customProperty); + extensionData->setActionTag(actionTag); + node->setUserObject(extensionData); + widget->setUserObject(timeline::ActionTimelineData::create(actionTag)); bool touchEnabled = options->touchEnabled() != 0;