2019-11-24 23:15:56 +08:00
|
|
|
#ifndef _SPINESKELETONDATACACHE_H_
|
|
|
|
#define _SPINESKELETONDATACACHE_H_
|
|
|
|
#include <cocos2d.h>
|
2020-08-04 21:13:26 +08:00
|
|
|
|
|
|
|
#if defined(CC_BUILD_WITH_SPINE) && CC_BUILD_WITH_SPINE
|
2019-11-24 23:15:56 +08:00
|
|
|
#include "spine/spine.h"
|
|
|
|
#include "spine/spine-cocos2dx.h"
|
2020-08-03 17:51:40 +08:00
|
|
|
#include "cocostudio/CocosStudioExport.h"
|
2019-11-30 01:32:12 +08:00
|
|
|
#include <functional>
|
2019-11-24 23:15:56 +08:00
|
|
|
|
|
|
|
class CC_STUDIO_DLL SpineSkeletonDataCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class SkeletonData : public cocos2d::Ref
|
|
|
|
{
|
|
|
|
public:
|
2019-12-12 23:24:50 +08:00
|
|
|
SkeletonData(spine::SkeletonData* d, spine::AttachmentLoader* loader) : data(d), attachmentLoader(loader) {}
|
2019-11-24 23:15:56 +08:00
|
|
|
~SkeletonData()
|
|
|
|
{
|
|
|
|
if (data != nullptr)
|
2019-12-12 23:24:50 +08:00
|
|
|
delete (data);
|
2019-11-24 23:15:56 +08:00
|
|
|
if (attachmentLoader != nullptr)
|
2019-12-12 23:24:50 +08:00
|
|
|
delete (attachmentLoader);
|
2019-11-24 23:15:56 +08:00
|
|
|
}
|
2019-12-12 23:24:50 +08:00
|
|
|
spine::AttachmentLoader* attachmentLoader;
|
|
|
|
spine::SkeletonData* data;
|
2019-11-24 23:15:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static SpineSkeletonDataCache* getInstance();
|
|
|
|
|
2019-11-30 01:32:12 +08:00
|
|
|
SpineSkeletonDataCache();
|
|
|
|
|
|
|
|
void setErrorReportFunc(void(*errorfunc)(const char* pszFormat, ...));
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
SkeletonData* addData(const char* dataFile, const char* atlasFile, float scale);
|
|
|
|
|
|
|
|
void removeData(const char* dataFile);
|
|
|
|
|
|
|
|
void removeAllData(void);
|
|
|
|
void removeAllUnusedData(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
std::map<std::string, SkeletonData*> _cacheTable;
|
2019-11-30 01:32:12 +08:00
|
|
|
void(*_reportError)(const char* pszFormat, ...);
|
2019-11-24 23:15:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-08-04 21:13:26 +08:00
|
|
|
#endif
|
|
|
|
|