Use macro CC_BUILD_WITH_DRANGBONES to control whether build dragonbones, default is disabled.

This commit is contained in:
halx99 2019-11-30 01:32:12 +08:00
parent 4c57458c48
commit ded0e81e5a
3 changed files with 26 additions and 46 deletions

View File

@ -7,8 +7,9 @@
#include "editor-support/cocostudio/CSParseBinary_generated.h"
#include "editor-support/cocostudio/WidgetReader/ArmatureNodeReader/CSArmatureNode_generated.h"
#include "editor-support/cocostudio/CCArmature.h"
#if defined(CC_BUILD_WITH_DRANGBONES) && CC_BUILD_WITH_DRANGBONES
#include "editor-support/dragonBones/CCDragonBonesHeaders.h"
#endif
USING_NS_CC;
using namespace cocostudio;
@ -122,27 +123,6 @@ Offset<Table> ArmatureNodeReader::createOptionsWithFlatBuffers(pugi::xml_node ob
attribute = attribute.next_attribute();
}
}
/*else if (attriname == "TextureInfoFileData")
{
attribute = child.first_attribute();
while (attribute)
{
attriname = attribute.name();
std::string value = attribute.value();
if (attriname == "Type")
{
textureInfoFileType = 0;
}
else if (attriname == "Path")
{
textureInfoFilePath = value;
}
attribute = attribute.next_attribute();
}
}*/
child = child.next_sibling();
}
@ -157,11 +137,7 @@ Offset<Table> ArmatureNodeReader::createOptionsWithFlatBuffers(pugi::xml_node ob
builder->CreateString(currentAnimationName),
builder->CreateString(currentArmatureName),
timeScale,
armatureScale
/*
CreateResourceItemData(*builder,
textureInfoFileType,
builder->CreateString(textureInfoFilePath))*/);
armatureScale);
return *(Offset<Table>*)(&options);
}
@ -180,7 +156,7 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,
if (FileUtils::getInstance()->isFileExist(filepath))
{
fileExist = true;
#if defined(CC_BUILD_WITH_DRANGBONES) && CC_BUILD_WITH_DRANGBONES
auto filep = filepath.rfind('.');
if (filep != std::string::npos && strcmp(&filepath[filep], ".json") == 0)
{ // Currently, adjust by file ext, regard as DragonBones 4.5/5.0
@ -218,7 +194,9 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,
}
}
}
else {
else
#endif
{
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filepath);
std::string dirpath = fullpath.substr(0, fullpath.find_last_of('/'));

View File

@ -1,23 +1,21 @@
#include "SpineSkeletonDataCache.h"
static auto error_log = &cocos2d::log;
namespace spine {
extern void(*onLoadTextureFailed)(const char* format, ...);
}
void SpineSkeletonDataCache::setErrorLogFunc(void(*errorfunc)(const char* pszFormat, ...))
{
error_log = errorfunc;
spine::onLoadTextureFailed = errorfunc;
}
SpineSkeletonDataCache* SpineSkeletonDataCache::getInstance()
{
static SpineSkeletonDataCache internalShared;
return &internalShared;
}
SpineSkeletonDataCache::SpineSkeletonDataCache()
{
_reportError = &cocos2d::log;
}
void SpineSkeletonDataCache::setErrorReportFunc(void(*errorfunc)(const char* pszFormat, ...))
{
_reportError = std::move(errorfunc);
}
void SpineSkeletonDataCache::removeData(const char* dataFile)
{
auto target = _cacheTable.find(dataFile);
@ -65,7 +63,7 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char
skeletonData = spSkeletonBinary_readSkeletonDataFile(binary, dataFile);
if ((binary->error != nullptr)) {
++failed;
error_log("#parse spine .skel data file failed, error:%s", binary->error);
_reportError("#parse spine .skel data file failed, error:%s", binary->error);
}
spSkeletonBinary_dispose(binary);
@ -81,7 +79,7 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char
skeletonData = spSkeletonJson_readSkeletonDataFile(json, dataFile);
if ((json->error != nullptr)) {
++failed;
error_log("#parse spine .json data file failed, error:%s", json->error);
_reportError("#parse spine .json data file failed, error:%s", json->error);
}
spSkeletonJson_dispose(json);
@ -89,7 +87,7 @@ SpineSkeletonDataCache::SkeletonData* SpineSkeletonDataCache::addData(const char
if ((loader->error1 != nullptr)) {
++failed;
error_log("#parse spine attachment failed, error:%s%s", loader->error1, loader->error2);
_reportError("#parse spine attachment failed, error:%s%s", loader->error1, loader->error2);
}
if (failed > 0) {

View File

@ -4,6 +4,7 @@
#include "spine/spine.h"
#include "spine/spine-cocos2dx.h"
#include "editor-support/cocostudio/CocosStudioExport.h"
#include <functional>
class CC_STUDIO_DLL SpineSkeletonDataCache
{
@ -23,10 +24,12 @@ public:
spSkeletonData* data;
};
static void setErrorLogFunc(void(*)(const char* pszFormat, ...));
static SpineSkeletonDataCache* getInstance();
SpineSkeletonDataCache();
void setErrorReportFunc(void(*errorfunc)(const char* pszFormat, ...));
SkeletonData* addData(const char* dataFile, const char* atlasFile, float scale);
void removeData(const char* dataFile);
@ -36,6 +39,7 @@ public:
public:
std::map<std::string, SkeletonData*> _cacheTable;
void(*_reportError)(const char* pszFormat, ...);
};
#endif