2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
2020-10-17 16:32:16 +08:00
|
|
|
Copyright (c) 2013-2017 Chukong Technologies Inc.
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
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 __CCARMATUREDATAMANAGER_H__
|
|
|
|
#define __CCARMATUREDATAMANAGER_H__
|
|
|
|
|
2020-10-21 10:12:00 +08:00
|
|
|
#include "CCArmatureDefine.h"
|
|
|
|
#include "CCDatas.h"
|
|
|
|
#include "CocosStudioExport.h"
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
namespace cocostudio
|
|
|
|
{
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-10-31 17:28:14 +08:00
|
|
|
struct RelativeData
|
|
|
|
{
|
|
|
|
std::vector<std::string> plistFiles;
|
|
|
|
std::vector<std::string> armatures;
|
|
|
|
std::vector<std::string> animations;
|
|
|
|
std::vector<std::string> textures;
|
|
|
|
};
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief format and manage armature configuration and armature animation
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2020-10-17 16:32:16 +08:00
|
|
|
class CCS_DLL ArmatureDataManager : public cocos2d::Ref
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-06-17 13:16:06 +08:00
|
|
|
/** @deprecated Use getInstance() instead */
|
2021-12-25 10:04:45 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static ArmatureDataManager* sharedArmatureDataManager()
|
|
|
|
{
|
|
|
|
return ArmatureDataManager::getInstance();
|
|
|
|
}
|
2013-09-16 15:16:05 +08:00
|
|
|
|
2016-01-12 12:22:24 +08:00
|
|
|
/** @deprecated Use destroyInstance() instead */
|
2013-12-27 20:54:05 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static void purge() { ArmatureDataManager::destroyInstance(); };
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
static ArmatureDataManager* getInstance();
|
2013-12-27 20:54:05 +08:00
|
|
|
static void destroyInstance();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-10-17 16:32:16 +08:00
|
|
|
protected:
|
2015-06-17 13:16:06 +08:00
|
|
|
/**
|
2013-09-16 14:13:55 +08:00
|
|
|
* @js ctor
|
|
|
|
*/
|
2020-10-17 16:32:16 +08:00
|
|
|
ArmatureDataManager(void);
|
2013-09-16 14:13:55 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2020-10-17 16:32:16 +08:00
|
|
|
~ArmatureDataManager(void);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
public:
|
2013-08-01 20:55:43 +08:00
|
|
|
/**
|
2013-09-15 19:08:45 +08:00
|
|
|
* Init ArmatureDataManager
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
|
|
|
virtual bool init();
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add armature data
|
|
|
|
* @param id The id of the armature data
|
2013-09-15 19:08:45 +08:00
|
|
|
* @param armatureData ArmatureData *
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addArmatureData(std::string_view id, ArmatureData* armatureData, std::string_view configFilePath = "");
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief get armature data
|
|
|
|
* @param id the id of the armature data you want to get
|
|
|
|
* @return ArmatureData *
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
ArmatureData* getArmatureData(std::string_view id);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief remove armature data
|
|
|
|
* @param id the id of the armature data you want to get
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void removeArmatureData(std::string_view id);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-08-01 20:55:43 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief add animation data
|
|
|
|
* @param id the id of the animation data
|
2013-09-15 19:08:45 +08:00
|
|
|
* @return AnimationData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addAnimationData(std::string_view id, AnimationData* animationData, std::string_view configFilePath = "");
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief get animation data from _animationDatas(Dictionary)
|
|
|
|
* @param id the id of the animation data you want to get
|
2013-09-15 19:08:45 +08:00
|
|
|
* @return AnimationData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
AnimationData* getAnimationData(std::string_view id);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-08-01 20:55:43 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief remove animation data
|
|
|
|
* @param id the id of the animation data
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void removeAnimationData(std::string_view id);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief add texture data
|
|
|
|
* @param id the id of the texture data
|
2013-09-15 19:08:45 +08:00
|
|
|
* @return TextureData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addTextureData(std::string_view id, TextureData* textureData, std::string_view configFilePath = "");
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-08-01 20:55:43 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief get texture data
|
|
|
|
* @param id the id of the texture data you want to get
|
2013-09-15 19:08:45 +08:00
|
|
|
* @return TextureData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
TextureData* getTextureData(std::string_view id);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief remove texture data
|
|
|
|
* @param id the id of the texture data you want to get
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void removeTextureData(std::string_view id);
|
2013-08-01 20:55:43 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addArmatureFileInfo(std::string_view configFilePath);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
|
|
|
* It will load data in a new thread
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addArmatureFileInfoAsync(std::string_view configFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
cocos2d::Ref* target,
|
|
|
|
cocos2d::SEL_SCHEDULE selector);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-28 11:00:34 +08:00
|
|
|
void addArmatureFileInfo(std::string_view imagePath, std::string_view plistPath, std::string_view configFilePath);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
|
|
|
* It will load data in a new thread
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addArmatureFileInfoAsync(std::string_view imagePath,
|
|
|
|
std::string_view plistPath,
|
|
|
|
std::string_view configFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
cocos2d::Ref* target,
|
|
|
|
cocos2d::SEL_SCHEDULE selector);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void addSpriteFrameFromFile(std::string_view plistPath,
|
|
|
|
std::string_view imagePath,
|
|
|
|
std::string_view configFilePath = "");
|
2013-08-01 20:55:43 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual void removeArmatureFileInfo(std::string_view configFilePath);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* @brief Judge whether or not need auto load sprite file
|
2013-09-13 18:07:37 +08:00
|
|
|
*/
|
|
|
|
bool isAutoLoadSpriteFile();
|
|
|
|
|
2021-12-27 13:52:08 +08:00
|
|
|
const cocos2d::StringMap<ArmatureData*>& getArmatureDatas() const;
|
|
|
|
const cocos2d::StringMap<AnimationData*>& getAnimationDatas() const;
|
|
|
|
const cocos2d::StringMap<TextureData*>& getTextureDatas() const;
|
2013-10-31 17:28:14 +08:00
|
|
|
|
2020-10-17 16:32:16 +08:00
|
|
|
public:
|
2021-12-26 23:26:34 +08:00
|
|
|
void addRelativeData(std::string_view configFilePath);
|
|
|
|
RelativeData* getRelativeData(std::string_view configFilePath);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
private:
|
|
|
|
/**
|
2015-09-22 16:08:23 +08:00
|
|
|
* @brief save armature datas
|
2015-06-17 13:16:06 +08:00
|
|
|
* @key std::string
|
|
|
|
* @value ArmatureData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-27 13:52:08 +08:00
|
|
|
cocos2d::StringMap<ArmatureData*> _armarureDatas;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief save animation datas
|
|
|
|
* @key std::string
|
|
|
|
* @value AnimationData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-27 13:52:08 +08:00
|
|
|
cocos2d::StringMap<AnimationData*> _animationDatas;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-08-01 20:55:43 +08:00
|
|
|
/**
|
2015-06-17 13:16:06 +08:00
|
|
|
* @brief save texture datas
|
|
|
|
* @key std::string
|
|
|
|
* @value TextureData *
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2021-12-27 13:52:08 +08:00
|
|
|
cocos2d::StringMap<TextureData*> _textureDatas;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-15 20:24:25 +08:00
|
|
|
bool _autoLoadSpriteFile;
|
2013-10-31 17:28:14 +08:00
|
|
|
|
2021-12-27 13:52:08 +08:00
|
|
|
hlookup::string_map<RelativeData> _relativeDatas;
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
} // namespace cocostudio
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#endif /*__CCARMATUREDATAMANAGER_H__*/
|