diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp
index 0b299c6238..e4395820cf 100644
--- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp
+++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp
@@ -80,7 +80,6 @@
#include "editor-support/cocostudio/WidgetReader/SpineSkeletonReader/SpineSkeletonReader.h"
#include "editor-support/cocostudio/WidgetReader/RichTextReader/RichTextReader.h"
-#include "editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.h"
#include "editor-support/cocostudio/WidgetReader/RadioButtonReader/RadioButtonReader.h"
#include "editor-support/cocostudio/WidgetReader/RadioButtonReader/RadioButtonGroupReader.h"
#include "editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldExReader.h"
@@ -244,7 +243,6 @@ CSLoader::CSLoader()
/// Added by x-studio
CREATE_CLASS_NODE_READER_INFO(RichTextReader);
CREATE_CLASS_NODE_READER_INFO(SpineSkeletonReader);
- CREATE_CLASS_NODE_READER_INFO(ControlSwitchReader);
CREATE_CLASS_NODE_READER_INFO(RadioButtonReader);
CREATE_CLASS_NODE_READER_INFO(RadioButtonGroupReader);
diff --git a/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.cpp
deleted file mode 100644
index c42fd4f375..0000000000
--- a/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.cpp
+++ /dev/null
@@ -1,613 +0,0 @@
-/****************************************************************************
- Copyright (c) 2014 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 "editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.h"
-
-#include "2d/CCSprite.h"
-#include "2d/CCSpriteFrameCache.h"
-#include "platform/CCFileUtils.h"
-
-#include "editor-support/cocostudio/CSParseBinary_generated.h"
-#include "editor-support/cocostudio/FlatBuffersSerialize.h"
-#include "editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.h"
-
-#include "extensions/cocos-ext.h"
-
-
-#include "flatbuffers/flatbuffers.h"
-
-USING_NS_CC;
-using namespace flatbuffers;
-
-namespace cocostudio
-{
- static Sprite* createSprite(const cocos2d::ResourceData& fileData)
- {
- return fileData.type == 0 ? Sprite::create(fileData.file) : Sprite::createWithSpriteFrameName(fileData.file);
- }
-
- IMPLEMENT_CLASS_NODE_READER_INFO(ControlSwitchReader)
-
- ControlSwitchReader::ControlSwitchReader()
- {
-
- }
-
- ControlSwitchReader::~ControlSwitchReader()
- {
-
- }
-
- static ControlSwitchReader* _instanceSpriteReader = nullptr;
-
- ControlSwitchReader* ControlSwitchReader::getInstance()
- {
- if (!_instanceSpriteReader)
- {
- _instanceSpriteReader = new (std::nothrow) ControlSwitchReader();
- }
-
- return _instanceSpriteReader;
- }
-
- void ControlSwitchReader::purge()
- {
- CC_SAFE_DELETE(_instanceSpriteReader);
- }
-
- void ControlSwitchReader::destroyInstance()
- {
- CC_SAFE_DELETE(_instanceSpriteReader);
- }
-
- Offset
ControlSwitchReader::createOptionsWithFlatBuffers(pugi::xml_node objectData,
- flatbuffers::FlatBufferBuilder *builder)
- {
- auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
- auto nodeOptions = *(Offset*)(&temp);
-
- bool on = false;
- bool enabled = true;
-
- int maskImageResourceType = 0;
- std::string maskImage = "";
- std::string maskImagePlistFile = "";
-
- int onImageResourceType = 0;
- std::string onImage = "";
- std::string onImagePlistFile = "";
-
- int offImageResourceType = 0;
- std::string offImage = "";
- std::string offImagePlistFile = "";
-
- int thumbImageResourceType = 0;
- std::string thumbImage = "";
- std::string thumbImagePlistFile = "";
-
- cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
-
- // attributes
- auto attribute = objectData.first_attribute();
- while (attribute)
- {
- std::string name = attribute.name();
- std::string value = attribute.value();
-
- if (name == "On")
- {
- on = value == "True" ? true : false;
- }
-
- attribute = attribute.next_attribute();
- }
-
- //// child elements
- // child elements
- auto child = objectData.first_child();
- while (child)
- {
- std::string name = child.name();
-
- if (name == "MaskImageData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child.first_attribute();
-
- while (attribute)
- {
- name = attribute.name();
- std::string value = attribute.value();
-
- if (name == "Path")
- {
- maskImage = value;
- }
- else if (name == "Type")
- {
- maskImageResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- maskImagePlistFile = value;
- texture = value;
- }
-
- attribute = attribute.next_attribute();
- }
-
- if (maskImageResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "OnImageData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child.first_attribute();
-
- while (attribute)
- {
- name = attribute.name();
- std::string value = attribute.value();
-
- if (name == "Path")
- {
- onImage = value;
- }
- else if (name == "Type")
- {
- onImageResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- onImagePlistFile = value;
- texture = value;
- }
-
- attribute = attribute.next_attribute();
- }
-
- if (onImageResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "OffImageData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child.first_attribute();
-
- while (attribute)
- {
- name = attribute.name();
- std::string value = attribute.value();
-
- if (name == "Path")
- {
- offImage = value;
- }
- else if (name == "Type")
- {
- offImageResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- offImagePlistFile = value;
- texture = value;
- }
-
- attribute = attribute.next_attribute();
- }
-
- if (offImageResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "ThumbImageData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child.first_attribute();
-
- while (attribute)
- {
- name = attribute.name();
- std::string value = attribute.value();
-
- if (name == "Path")
- {
- thumbImage = value;
- }
- else if (name == "Type")
- {
- thumbImageResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- thumbImagePlistFile = value;
- texture = value;
- }
-
- attribute = attribute.next_attribute();
- }
-
- if (thumbImageResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
-
- child = child.next_sibling();
- }
-
- auto options = CreateControlSwitchOptions(*builder,
- nodeOptions,
- CreateResourceData(*builder,
- builder->CreateString(maskImage),
- builder->CreateString(maskImagePlistFile),
- maskImageResourceType),
- CreateResourceData(*builder,
- builder->CreateString(onImage),
- builder->CreateString(onImagePlistFile),
- onImageResourceType),
- CreateResourceData(*builder,
- builder->CreateString(offImage),
- builder->CreateString(offImagePlistFile),
- offImageResourceType),
- CreateResourceData(*builder,
- builder->CreateString(thumbImage),
- builder->CreateString(thumbImagePlistFile),
- thumbImageResourceType),
- on,
- enabled);
-
- return *(Offset*)(&options);
- }
-
- void ControlSwitchReader::setPropsWithFlatBuffers(cocos2d::Node *node,
- const flatbuffers::Table* spriteOptions)
- {
- Node** ppResult = (Node**)(node);
-
- auto options = (ControlSwitchOptions*)spriteOptions;
-
- //load background image
- bool backGroundFileExist = false;
- std::string backGroundErrorFilePath = "";
- auto backGroundDic = cocos2d::wext::makeResourceData(options->maskImage());
- int backGroundType = backGroundDic.type;
- std::string& backGroundTexturePath = backGroundDic.file;
- //cocos2d::wext::onBeforeLoadObjectAsset(checkBox, backGroundDic, 0);
- switch (backGroundType)
- {
- case 0:
- {
- if (FileUtils::getInstance()->isFileExist(backGroundTexturePath))
- {
- backGroundFileExist = true;
- }
- else
- {
- backGroundErrorFilePath = backGroundTexturePath;
- backGroundFileExist = false;
- }
- break;
- }
-
- case 1:
- {
- std::string plist = backGroundDic.plist;
- SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundTexturePath);
- if (spriteFrame)
- {
- backGroundFileExist = true;
- }
- else
- {
- if (FileUtils::getInstance()->isFileExist(plist))
- {
- ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
- ValueMap metadata = value["metadata"].asValueMap();
- std::string textureFileName = metadata["textureFileName"].asString();
- if (!FileUtils::getInstance()->isFileExist(textureFileName))
- {
- backGroundErrorFilePath = textureFileName;
- }
- }
- else
- {
- backGroundErrorFilePath = plist;
- }
- backGroundFileExist = false;
- }
- break;
- }
-
- default:
- break;
- }
- /*if (backGroundFileExist)
- {
- checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
- }*/
-
- //load background selected image
- bool backGroundSelectedfileExist = false;
- std::string backGroundSelectedErrorFilePath = "";
- auto backGroundSelectedDic = cocos2d::wext::makeResourceData(options->onImage());
- int backGroundSelectedType = backGroundSelectedDic.type;
- std::string& backGroundSelectedTexturePath = backGroundSelectedDic.file;
- // cocos2d::wext::onBeforeLoadObjectAsset(checkBox, backGroundSelectedDic, 1);
- switch (backGroundSelectedType)
- {
- case 0:
- {
- if (FileUtils::getInstance()->isFileExist(backGroundSelectedTexturePath))
- {
- backGroundSelectedfileExist = true;
- }
- else
- {
- backGroundSelectedErrorFilePath = backGroundSelectedTexturePath;
- backGroundSelectedfileExist = false;
- }
- break;
- }
-
- case 1:
- {
- std::string plist = backGroundSelectedDic.plist;
- SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundSelectedTexturePath);
- if (spriteFrame)
- {
- backGroundSelectedfileExist = true;
- }
- else
- {
- if (FileUtils::getInstance()->isFileExist(plist))
- {
- ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
- ValueMap metadata = value["metadata"].asValueMap();
- std::string textureFileName = metadata["textureFileName"].asString();
- if (!FileUtils::getInstance()->isFileExist(textureFileName))
- {
- backGroundSelectedErrorFilePath = textureFileName;
- }
- }
- else
- {
- backGroundSelectedErrorFilePath = plist;
- }
- backGroundSelectedfileExist = false;
- }
- break;
- }
-
- default:
- break;
- }
- /*if (backGroundSelectedfileExist)
- {
- checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
- }*/
-
- //load frontCross image
- bool frontCrossFileExist = false;
- std::string frontCrossErrorFilePath = "";
- auto frontCrossDic = cocos2d::wext::makeResourceData(options->offImage());
- int frontCrossType = frontCrossDic.type;
- std::string& frontCrossFileName = frontCrossDic.file;
- //cocos2d::wext::onBeforeLoadObjectAsset(checkBox, frontCrossDic, 2);
- switch (frontCrossType)
- {
- case 0:
- {
- if (FileUtils::getInstance()->isFileExist(frontCrossFileName))
- {
- frontCrossFileExist = true;
- }
- else
- {
- frontCrossErrorFilePath = frontCrossFileName;
- frontCrossFileExist = false;
- }
- break;
- }
-
- case 1:
- {
- std::string plist = frontCrossDic.plist;
- SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(frontCrossFileName);
- if (spriteFrame)
- {
- frontCrossFileExist = true;
- }
- else
- {
- if (FileUtils::getInstance()->isFileExist(plist))
- {
- ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
- ValueMap metadata = value["metadata"].asValueMap();
- std::string textureFileName = metadata["textureFileName"].asString();
- if (!FileUtils::getInstance()->isFileExist(textureFileName))
- {
- frontCrossErrorFilePath = textureFileName;
- }
- }
- else
- {
- frontCrossErrorFilePath = plist;
- }
- frontCrossFileExist = false;
- }
- break;
- }
-
- default:
- break;
- }
- /*if (frontCrossFileExist)
- {
- checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
- }*/
-
- //load backGroundBoxDisabledData
- bool backGroundBoxDisabledFileExist = false;
- std::string backGroundBoxDisabledErrorFilePath = "";
- auto backGroundDisabledDic = cocos2d::wext::makeResourceData(options->thumbImage());
- int backGroundDisabledType = backGroundDisabledDic.type;
- std::string& backGroundDisabledFileName = backGroundDisabledDic.file;
- // cocos2d::wext::onBeforeLoadObjectAsset(checkBox, backGroundDisabledDic, 3);
- switch (backGroundDisabledType)
- {
- case 0:
- {
- if (FileUtils::getInstance()->isFileExist(backGroundDisabledFileName))
- {
- backGroundBoxDisabledFileExist = true;
- }
- else
- {
- backGroundBoxDisabledErrorFilePath = backGroundDisabledFileName;
- backGroundBoxDisabledFileExist = false;
- }
- break;
- }
-
- case 1:
- {
- std::string plist = backGroundDisabledDic.plist;
- SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundDisabledFileName);
- if (spriteFrame)
- {
- backGroundBoxDisabledFileExist = true;
- }
- else
- {
- if (FileUtils::getInstance()->isFileExist(plist))
- {
- ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
- ValueMap metadata = value["metadata"].asValueMap();
- std::string textureFileName = metadata["textureFileName"].asString();
- if (!FileUtils::getInstance()->isFileExist(textureFileName))
- {
- backGroundBoxDisabledErrorFilePath = textureFileName;
- }
- }
- else
- {
- backGroundBoxDisabledErrorFilePath = plist;
- }
- backGroundBoxDisabledFileExist = false;
- }
- break;
- }
-
- default:
- break;
- }
- /*if (backGroundBoxDisabledFileExist)
- {
- checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
- }*/
-
- auto implNode = extension::ControlSwitch::create(createSprite(backGroundDic),
- createSprite(backGroundSelectedDic),
- createSprite(frontCrossDic),
- createSprite(backGroundDisabledDic));
-
- implNode->setOn(options->on());
- implNode->setTouchEnabled(options->enabled());
- // skeletonAnimation->setAnimation(0, options->animation()->c_str(), options->loop());
- // skeletonAnimation->setSkin(options->animation()->c_str());
-
- *ppResult = implNode;
-
- auto nodeReader = NodeReader::getInstance();
- nodeReader->setPropsWithFlatBuffers(implNode, (Table*)(options->nodeOptions()));
-
- // set Node Options
- // auto nodeOptions = options->nodeOptions();
-
- // uint8_t alpha = (uint8_t)nodeOptions->color()->a();
- // uint8_t red = (uint8_t)nodeOptions->color()->r();
- // uint8_t green = (uint8_t)nodeOptions->color()->g();
- // uint8_t blue = (uint8_t)nodeOptions->color()->b();
-
- //skeletonAnimation->setScaleX(nodeOptions->scale()->scaleX());
- //skeletonAnimation->setScaleY(nodeOptions->scale()->scaleY());
-
- //skeletonAnimation->setColor(Color3B(red, green, blue));
- //skeletonAnimation->setOpacity(alpha);
-
- /*bool flipX = nodeOptions->flipX() != 0;
- bool flipY = nodeOptions->flipY() != 0;
-
- if (flipX != false)
- sprite->setFlippedX(flipX);
- if (flipY != false)
- sprite->setFlippedY(flipY);*/
- }
-
- Node* ControlSwitchReader::createNodeWithFlatBuffers(const flatbuffers::Table *spriteOptions)
- {
- Node* spineAnimation = nullptr;
- // Sprite* sprite = wext::aSprite(); // Sprite::create();
- // #Hack
- setPropsWithFlatBuffers((Node*)(&spineAnimation), (Table*)spriteOptions);
-
- return spineAnimation;
- }
-
- int ControlSwitchReader::getResourceType(std::string key)
- {
- if (key == "Normal" || key == "Default")
- {
- return 0;
- }
-
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- if (fbs->_isSimulator)
- {
- if (key == "MarkedSubImage")
- {
- return 0;
- }
- }
- return 1;
- }
-}
diff --git a/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.h b/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.h
deleted file mode 100644
index 5db877b46d..0000000000
--- a/cocos/editor-support/cocostudio/WidgetReader/ControlSwitchReader/ControlSwitchReader.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
- Copyright (c) 2014 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 __X365LIBS__ControlSwitchReaderr__
-#define __X365LIBS__ControlSwitchReader__
-
-#include "editor-support/cocostudio/CocosStudioExport.h"
-#include "editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h"
-#include "editor-support/cocostudio/WidgetReader/NodeReaderDefine.h"
-
-
-namespace cocostudio
-{
- class CC_STUDIO_DLL ControlSwitchReader : public cocos2d::Ref, public NodeReaderProtocol
- {
- DECLARE_CLASS_NODE_READER_INFO
-
- public:
- ControlSwitchReader();
- ~ControlSwitchReader();
-
- static ControlSwitchReader* getInstance();
- /** @deprecated Use method destroyInstance() instead */
- CC_DEPRECATED_ATTRIBUTE static void purge();
- static void destroyInstance();
-
- flatbuffers::Offset createOptionsWithFlatBuffers(pugi::xml_node objectData,
- flatbuffers::FlatBufferBuilder* builder);
- void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* spriteOptions);
- cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* spriteOptions);
-
- int getResourceType(std::string key);
- };
-}
-
-#endif /* defined(__cocos2d_libs__SpriteReader__) */
diff --git a/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.cpp b/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.cpp
index 08fbb4e068..cabe5df579 100644
--- a/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.cpp
+++ b/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.cpp
@@ -32,19 +32,21 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char
return target->second;
}
- spSkeletonData* skeletonData = nullptr;
- spAttachmentLoader* loader = nullptr;
+ spine::SkeletonData* skeletonData = nullptr;
+ spine::AttachmentLoader* loader = nullptr;
bool ok = false;
auto fileExtension = cocos2d::FileUtils::getInstance()->getFileExtension(dataFile);
+ static spine::Cocos2dTextureLoader s_textureLoader;
+
do {
- spAtlas* atlas = spAtlas_createFromFile(atlasFile, 0);
+ auto atlas = new (__FILE__, __LINE__) spine::Atlas(atlasFile, &s_textureLoader);
if (nullptr == (atlas))
break;
- loader = (spAttachmentLoader*)Cocos2dAttachmentLoader_create(atlas);
+ loader = new (__FILE__, __LINE__) spine::Cocos2dAtlasAttachmentLoader(atlas);
int failed = 0;
@@ -53,49 +55,42 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char
** Cache, we just need SkeletonData & atlas.
*/
if (fileExtension == ".skel") {
- auto binary = spSkeletonBinary_createWithLoader(loader);
+ /*auto binary = new (__FILE__, __LINE__) spine::SkeletonBinary(loader);
if (nullptr == binary) {
- spAtlas_dispose(atlas);
+ delete (atlas);
break;
- }
+ }*/
+ spine::SkeletonBinary binary(loader);
- binary->scale = scale;
- skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, dataFile);
- if ((binary->error != nullptr)) {
+ binary.setScale(scale);
+ skeletonData = binary.readSkeletonDataFile(dataFile); // spSkeletonBinary_readSkeletonDataFile(binary, dataFile);
+ if ((!binary.getError().isEmpty())) {
++failed;
- _reportError("#parse spine .skel data file failed, error:%s", binary->error);
+ _reportError("#parse spine .skel data file failed, error:%s", binary.getError().buffer());
}
-
- spSkeletonBinary_dispose(binary);
}
else {
- spSkeletonJson* json = spSkeletonJson_createWithLoader(loader);
- if (nullptr == json) {
- spAtlas_dispose(atlas);
- break;
- }
+ spine::SkeletonJson json(loader);
- json->scale = scale;
- skeletonData = spSkeletonJson_readSkeletonDataFile(json, dataFile);
- if ((json->error != nullptr)) {
+ json.setScale(scale);
+ skeletonData = json.readSkeletonDataFile(dataFile);
+ if ((!json.getError().isEmpty())) {
++failed;
- _reportError("#parse spine .json data file failed, error:%s", json->error);
+ _reportError("#parse spine .json data file failed, error:%s", json.getError().buffer());
}
-
- spSkeletonJson_dispose(json);
}
- if ((loader->error1 != nullptr)) {
+ /*if ((loader->error1 != nullptr)) {
++failed;
_reportError("#parse spine attachment failed, error:%s%s", loader->error1, loader->error2);
- }
+ }*/
if (failed > 0) {
if (skeletonData != nullptr)
- spSkeletonData_dispose(skeletonData);
+ delete (skeletonData);
- spAtlas_dispose(atlas);
- spAttachmentLoader_dispose(loader);
+ delete (atlas);
+ delete (loader);
break;
}
diff --git a/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.h b/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.h
index e03fe1f84c..4546d5f683 100644
--- a/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.h
+++ b/cocos/editor-support/cocostudio/ext/SpineSkeletonDataCache.h
@@ -12,16 +12,16 @@ public:
class SkeletonData : public cocos2d::Ref
{
public:
- SkeletonData(spSkeletonData* d, spAttachmentLoader* loader) : data(d), attachmentLoader(loader) {}
+ SkeletonData(spine::SkeletonData* d, spine::AttachmentLoader* loader) : data(d), attachmentLoader(loader) {}
~SkeletonData()
{
if (data != nullptr)
- spSkeletonData_dispose(data);
+ delete (data);
if (attachmentLoader != nullptr)
- spAttachmentLoader_dispose(attachmentLoader);
+ delete (attachmentLoader);
}
- spAttachmentLoader* attachmentLoader;
- spSkeletonData* data;
+ spine::AttachmentLoader* attachmentLoader;
+ spine::SkeletonData* data;
};
static SpineSkeletonDataCache* getInstance();