mirror of https://github.com/axmolengine/axmol.git
593 lines
23 KiB
C++
593 lines
23 KiB
C++
/**
|
||
* The MIT License (MIT)
|
||
*
|
||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||
*
|
||
* 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 DRAGONBONES_BASE_FACTORY_H
|
||
#define DRAGONBONES_BASE_FACTORY_H
|
||
|
||
#include "../parser/JSONDataParser.h"
|
||
#include "../parser/BinaryDataParser.h"
|
||
#include "../armature/Armature.h"
|
||
#include "../armature/Bone.h"
|
||
#include "../armature/Slot.h"
|
||
#include "../armature/Constraint.h"
|
||
#include "../animation/Animation.h"
|
||
|
||
DRAGONBONES_NAMESPACE_BEGIN
|
||
/**
|
||
* - Base class for the factory that create the armatures. (Typically only one global factory instance is required)
|
||
* The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances.
|
||
* Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance.
|
||
* @see dragonBones.DragonBonesData
|
||
* @see dragonBones.TextureAtlasData
|
||
* @see dragonBones.ArmatureData
|
||
* @see dragonBones.Armature
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD><EFBFBD><EFBFBD>ǼܵĹ<DCB5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ <20><>ͨ<EFBFBD><CDA8>ֻ<EFBFBD><D6BB>Ҫһ<D2AA><D2BB>ȫ<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
|
||
* <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD> TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽܡ<C7BC>
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ٴν<D9B4><CEBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @see dragonBones.DragonBonesData
|
||
* @see dragonBones.TextureAtlasData
|
||
* @see dragonBones.ArmatureData
|
||
* @see dragonBones.Armature
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
class BaseFactory
|
||
{
|
||
protected:
|
||
static JSONDataParser _jsonParser;
|
||
static BinaryDataParser _binaryParser;
|
||
|
||
public:
|
||
/**
|
||
* @private
|
||
*/
|
||
bool autoSearch;
|
||
|
||
protected:
|
||
std::map<std::string, DragonBonesData*> _dragonBonesDataMap;
|
||
std::map<std::string, std::vector<TextureAtlasData*>> _textureAtlasDataMap;
|
||
DragonBones* _dragonBones;
|
||
DataParser* _dataParser;
|
||
|
||
public:
|
||
/**
|
||
* - Create a factory instance. (typically only one global factory instance is required)
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> <20><>ͨ<EFBFBD><CDA8>ֻ<EFBFBD><D6BB>Ҫһ<D2AA><D2BB>ȫ<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
BaseFactory(DataParser* dataParser = nullptr) :
|
||
autoSearch(false),
|
||
_dragonBonesDataMap(),
|
||
_textureAtlasDataMap(),
|
||
_dragonBones(nullptr),
|
||
_dataParser(nullptr)
|
||
{
|
||
_dataParser = dataParser != nullptr ? dataParser : &BaseFactory::_jsonParser;
|
||
}
|
||
virtual ~BaseFactory()
|
||
{
|
||
clear();
|
||
|
||
_dragonBones = nullptr;
|
||
_dataParser = nullptr;
|
||
}
|
||
|
||
protected:
|
||
virtual inline bool _isSupportMesh() const
|
||
{
|
||
return true;
|
||
}
|
||
virtual TextureData* _getTextureData(const std::string& textureAtlasName, const std::string& textureName) const;
|
||
virtual bool _fillBuildArmaturePackage(
|
||
BuildArmaturePackage& dataPackage,
|
||
const std::string& dragonBonesName, const std::string& armatureName, const std::string& skinName, const std::string& textureAtlasName
|
||
) const;
|
||
virtual void _buildBones(const BuildArmaturePackage& dataPackage, Armature* armature) const;
|
||
/**
|
||
* @private
|
||
*/
|
||
virtual void _buildSlots(const BuildArmaturePackage& dataPackage, Armature* armature) const;
|
||
virtual Armature* _buildChildArmature(const BuildArmaturePackage* dataPackage, Slot* slot, DisplayData* displayData) const;
|
||
virtual std::pair<void*, DisplayType> _getSlotDisplay(const BuildArmaturePackage* dataPackage, DisplayData* displayData, DisplayData* rawDisplayData, Slot* slot) const;
|
||
virtual TextureAtlasData* _buildTextureAtlasData(TextureAtlasData* textureAtlasData, void* textureAtlas) const = 0;
|
||
virtual Armature* _buildArmature(const BuildArmaturePackage& dataPackage) const = 0;
|
||
virtual Slot* _buildSlot(const BuildArmaturePackage& dataPackage, const SlotData* slotData, Armature* armature) const = 0;
|
||
|
||
public:
|
||
/**
|
||
* - Parse the raw data to a DragonBonesData instance and cache it to the factory.
|
||
* @param rawData - The raw data.
|
||
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
|
||
* @param scale - Specify a scaling value for all armatures. (Default: 1.0)
|
||
* @returns DragonBonesData instance
|
||
* @see #getDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 4.5
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><>ԭʼ<D4AD><CABC><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>Ϊ DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||
* @param rawData - ԭʼ<D4AD><CABC><EFBFBD>ݡ<EFBFBD>
|
||
* @param name - Ϊ<><CEAA>ʵ<EFBFBD><CAB5>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>ȡ<EFBFBD><C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʹ<EFBFBD>ø<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||
* @param scale - Ϊ<><CEAA><EFBFBD>еĹǼ<C4B9>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5> <20><>Ĭ<EFBFBD><C4AC>: 1.0<EFBFBD><EFBFBD>
|
||
* @returns DragonBonesData ʵ<><CAB5>
|
||
* @see #getDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 4.5
|
||
* @language zh_CN
|
||
*/
|
||
virtual DragonBonesData* parseDragonBonesData(const char* rawData, const std::string& name = "", float scale = 1.0f);
|
||
/**
|
||
* - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory.
|
||
* @param rawData - The raw texture atlas data.
|
||
* @param textureAtlas - The texture atlas object.
|
||
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
|
||
* @param scale - Specify a scaling value for the map set. (Default: 1.0)
|
||
* @returns TextureAtlasData instance
|
||
* @see #getTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 4.5
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><>ԭʼ<D4AD><CABC>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||
* @param rawData - ԭʼ<D4AD><CABC>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @param textureAtlas - <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param name - Ϊ<><CEAA>ʵ<EFBFBD><CAB5>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>ȡ<EFBFBD><C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʹ<EFBFBD>ø<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||
* @param scale - Ϊ<><CEAA>ͼ<EFBFBD><CDBC>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5> <20><>Ĭ<EFBFBD><C4AC>: 1.0<EFBFBD><EFBFBD>
|
||
* @returns TextureAtlasData ʵ<><CAB5>
|
||
* @see #getTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 4.5
|
||
* @language zh_CN
|
||
*/
|
||
virtual TextureAtlasData* parseTextureAtlasData(const char* rawData, void* textureAtlas, const std::string& name = "", float scale = 1.0f);
|
||
/**
|
||
* - Get a specific DragonBonesData instance.
|
||
* @param name - The DragonBonesData instance cache name.
|
||
* @returns DragonBonesData instance
|
||
* @see #parseDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><>ȡ<EFBFBD>ض<EFBFBD><D8B6><EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param name - DragonBonesData ʵ<><CAB5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @returns DragonBonesData ʵ<><CAB5>
|
||
* @see #parseDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
inline DragonBonesData* getDragonBonesData(const std::string& name) const
|
||
{
|
||
return mapFind(_dragonBonesDataMap, name);
|
||
}
|
||
/**
|
||
* - Cache a DragonBonesData instance to the factory.
|
||
* @param data - The DragonBonesData instance.
|
||
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
|
||
* @see #parseDragonBonesData()
|
||
* @see #getDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||
* @param data - DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param name - Ϊ<><CEAA>ʵ<EFBFBD><CAB5>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>ȡ<EFBFBD><C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʹ<EFBFBD>ø<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||
* @see #parseDragonBonesData()
|
||
* @see #getDragonBonesData()
|
||
* @see #removeDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
virtual void addDragonBonesData(DragonBonesData* data, const std::string& name = "");
|
||
/**
|
||
* - Remove a DragonBonesData instance.
|
||
* @param name - The DragonBonesData instance cache name.
|
||
* @param disposeData - Whether to dispose data. (Default: true)
|
||
* @see #parseDragonBonesData()
|
||
* @see #getDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20>Ƴ<EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param name - DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param disposeData - <20>Ƿ<EFBFBD><C7B7>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ݡ<EFBFBD> <20><>Ĭ<EFBFBD><C4AC>: true<75><65>
|
||
* @see #parseDragonBonesData()
|
||
* @see #getDragonBonesData()
|
||
* @see #addDragonBonesData()
|
||
* @see dragonBones.DragonBonesData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
virtual void removeDragonBonesData(const std::string& name, bool disposeData = true);
|
||
/**
|
||
* - Get a list of specific TextureAtlasData instances.
|
||
* @param name - The TextureAtlasData cahce name.
|
||
* @see #parseTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><>ȡ<EFBFBD>ض<EFBFBD><D8B6><EFBFBD> TextureAtlasData ʵ<><CAB5><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
||
* @param name - TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @see #parseTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
inline std::vector<TextureAtlasData*>* getTextureAtlasData(const std::string& name)
|
||
{
|
||
return mapFindB(_textureAtlasDataMap, name);
|
||
}
|
||
/**
|
||
* - Cache a TextureAtlasData instance to the factory.
|
||
* @param data - The TextureAtlasData instance.
|
||
* @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead)
|
||
* @see #parseTextureAtlasData()
|
||
* @see #getTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><> TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>
|
||
* @param data - TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param name - Ϊ<><CEAA>ʵ<EFBFBD><CAB5>ָ<EFBFBD><D6B8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>ȡ<EFBFBD><C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʹ<EFBFBD>ø<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||
* @see #parseTextureAtlasData()
|
||
* @see #getTextureAtlasData()
|
||
* @see #removeTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
virtual void addTextureAtlasData(TextureAtlasData* data, const std::string& name = "");
|
||
/**
|
||
* - Remove a TextureAtlasData instance.
|
||
* @param name - The TextureAtlasData instance cache name.
|
||
* @param disposeData - Whether to dispose data.
|
||
* @see #parseTextureAtlasData()
|
||
* @see #getTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20>Ƴ<EFBFBD> TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param name - TextureAtlasData ʵ<><CAB5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param disposeData - <20>Ƿ<EFBFBD><C7B7>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @see #parseTextureAtlasData()
|
||
* @see #getTextureAtlasData()
|
||
* @see #addTextureAtlasData()
|
||
* @see dragonBones.TextureAtlasData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
virtual void removeTextureAtlasData(const std::string& name, bool disposeData = true);
|
||
/**
|
||
* - Get a specific armature data.
|
||
* @param name - The armature data name.
|
||
* @param dragonBonesName - The cached name for DragonbonesData instance.
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 5.1
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><>ȡ<EFBFBD>ض<EFBFBD><D8B6>ĹǼ<C4B9><C7BC><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @param name - <20>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param dragonBonesName - DragonBonesData ʵ<><CAB5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 5.1
|
||
* @language zh_CN
|
||
*/
|
||
virtual ArmatureData* getArmatureData(const std::string& name, const std::string& dragonBonesName = "") const;
|
||
/**
|
||
* - Clear all cached DragonBonesData instances and TextureAtlasData instances.
|
||
* @param disposeData - Whether to dispose data.
|
||
* @version DragonBones 4.5
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD> TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @param disposeData - <20>Ƿ<EFBFBD><C7B7>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @version DragonBones 4.5
|
||
* @language zh_CN
|
||
*/
|
||
virtual void clear(bool disposeData = true);
|
||
/**
|
||
* - Create a armature from cached DragonBonesData instances and TextureAtlasData instances.
|
||
* Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}.
|
||
* @param armatureName - The armature data name.
|
||
* @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature)
|
||
* @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
|
||
* @returns The armature.
|
||
* @example
|
||
* TypeScript style, for reference only.
|
||
* <pre>
|
||
* let armature = factory.buildArmature("armatureName", "dragonBonesName");
|
||
* armature.clock = factory.clock;
|
||
* </pre>
|
||
* @see dragonBones.DragonBonesData
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 3.0
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD> TextureAtlasData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ǽܡ<C7BC>
|
||
* ע<>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>ĹǼܲ<C7BC><DCB2><EFBFBD>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʽ<EFBFBD>ͷ<EFBFBD> {@link #dragonBones.Armature#dispose()}<7D><>
|
||
* @param armatureName - <20>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param dragonBonesName - DragonBonesData ʵ<><CAB5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DragonBonesData ʵ<><CAB5><EFBFBD>а<EFBFBD><D0B0><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ĹǼ<C4B9><C7BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<D7BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>ĹǼܣ<C7BC>
|
||
* @param skinName - Ƥ<><C6A4><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><DDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD>ϵ<EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>
|
||
* @returns <20>Ǽܡ<C7BC>
|
||
* @example
|
||
* TypeScript <20><><EFBFBD><EFBFBD><F1A3ACBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>
|
||
* <pre>
|
||
* let armature = factory.buildArmature("armatureName", "dragonBonesName");
|
||
* armature.clock = factory.clock;
|
||
* </pre>
|
||
* @see dragonBones.DragonBonesData
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 3.0
|
||
* @language zh_CN
|
||
*/
|
||
virtual Armature* buildArmature(const std::string& armatureName, const std::string& dragonBonesName = "", const std::string& skinName = "", const std::string & textureAtlasName = "") const;
|
||
/**
|
||
* @private
|
||
*/
|
||
virtual void replaceDisplay(Slot* slot, DisplayData* displayData, int displayIndex) const;
|
||
/**
|
||
* - Replaces the current display data for a particular slot with a specific display data.
|
||
* Specify display data with "dragonBonesName/armatureName/slotName/displayName".
|
||
* @param dragonBonesName - The DragonBonesData instance cache name.
|
||
* @param armatureName - The armature data name.
|
||
* @param slotName - The slot data name.
|
||
* @param displayName - The display data name.
|
||
* @param slot - The slot.
|
||
* @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data)
|
||
* @example
|
||
* TypeScript style, for reference only.
|
||
* <pre>
|
||
* let slot = armature.getSlot("weapon");
|
||
* factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
|
||
* </pre>
|
||
* @version DragonBones 4.5
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻<EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD>۵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* <20><> "dragonBonesName/armatureName/slotName/displayName" ָ<><D6B8><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @param dragonBonesName - DragonBonesData ʵ<><CAB5><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param armatureName - <20>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param slotName - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param displayName - <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD>
|
||
* @param slot - <20><><EFBFBD>ۡ<EFBFBD>
|
||
* @param displayIndex - <20><><EFBFBD>滻<EFBFBD><E6BBBB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD>滻<EFBFBD><E6BBBB>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>
|
||
* @example
|
||
* TypeScript <20><><EFBFBD><EFBFBD><F1A3ACBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>
|
||
* <pre>
|
||
* let slot = armature.getSlot("weapon");
|
||
* factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
|
||
* </pre>
|
||
* @version DragonBones 4.5
|
||
* @language zh_CN
|
||
*/
|
||
virtual bool replaceSlotDisplay(
|
||
const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName, const std::string& displayName,
|
||
Slot* slot, int displayIndex = -1
|
||
) const;
|
||
/**
|
||
* @private
|
||
*/
|
||
virtual bool replaceSlotDisplayList(
|
||
const std::string& dragonBonesName, const std::string& armatureName, const std::string& slotName,
|
||
Slot* slot
|
||
) const;
|
||
/**
|
||
* - Share specific skin data with specific armature.
|
||
* @param armature - The armature.
|
||
* @param skin - The skin data.
|
||
* @param isOverride - Whether it completely override the original skin. (Default: false)
|
||
* @param exclude - A list of slot names that do not need to be replace.
|
||
* @example
|
||
* TypeScript style, for reference only.
|
||
* <pre>
|
||
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
|
||
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
|
||
* if (armatureDataB && armatureDataB.defaultSkin) {
|
||
* factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
|
||
* }
|
||
* </pre>
|
||
* @see dragonBones.Armature
|
||
* @see dragonBones.SkinData
|
||
* @version DragonBones 5.6
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>ĹǼ<C4B9>ʹ<EFBFBD>á<EFBFBD>
|
||
* @param armature - <20>Ǽܡ<C7BC>
|
||
* @param skin - Ƥ<><C6A4><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @param isOverride - <20>Ƿ<EFBFBD><C7B7><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD> <20><>Ĭ<EFBFBD><C4AC>: false<73><65>
|
||
* @param exclude - <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>滻<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
|
||
* @example
|
||
* TypeScript <20><><EFBFBD><EFBFBD><F1A3ACBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>
|
||
* <pre>
|
||
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
|
||
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
|
||
* if (armatureDataB && armatureDataB.defaultSkin) {
|
||
* factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
|
||
* }
|
||
* </pre>
|
||
* @see dragonBones.Armature
|
||
* @see dragonBones.SkinData
|
||
* @version DragonBones 5.6
|
||
* @language zh_CN
|
||
*/
|
||
virtual bool replaceSkin(Armature* armature, SkinData* skin, bool isOverride = false, const std::vector<std::string>* exclude = nullptr) const;
|
||
/**
|
||
* - Replaces the existing animation data for a specific armature with the animation data for the specific armature data.
|
||
* This enables you to make a armature template so that other armature without animations can share it's animations.
|
||
* @param armature - The armtaure.
|
||
* @param armatureData - The armature data.
|
||
* @param isOverride - Whether to completely overwrite the original animation. (Default: false)
|
||
* @example
|
||
* TypeScript style, for reference only.
|
||
* <pre>
|
||
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
|
||
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
|
||
* if (armatureDataB) {
|
||
* factory.replaceAnimation(armatureA, armatureDataB);
|
||
* }
|
||
* </pre>
|
||
* @see dragonBones.Armature
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 5.6
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD>ض<EFBFBD><D8B6>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>滻<EFBFBD>ض<EFBFBD><D8B6>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ǽܶ<C7BC><DCB6><EFBFBD>ģ<EFBFBD>壬<EFBFBD><E5A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĹǼܹ<C7BC><DCB9><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>
|
||
* @param armature - <20>Ǽܡ<C7BC>
|
||
* @param armatureData - <20>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
||
* @param isOverride - <20>Ƿ<EFBFBD><C7B7><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>: false<73><65>
|
||
* @example
|
||
* TypeScript <20><><EFBFBD><EFBFBD><F1A3ACBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD>
|
||
* <pre>
|
||
* let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
|
||
* let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
|
||
* if (armatureDataB) {
|
||
* factory.replaceAnimation(armatureA, armatureDataB);
|
||
* }
|
||
* </pre>
|
||
* @see dragonBones.Armature
|
||
* @see dragonBones.ArmatureData
|
||
* @version DragonBones 5.6
|
||
* @language zh_CN
|
||
*/
|
||
virtual bool replaceAnimation(Armature* armature, ArmatureData* armatureData, bool isReplaceAll = true) const;
|
||
/**
|
||
* @private
|
||
*/
|
||
inline const std::map<std::string, std::vector<TextureAtlasData*>>& getAllTextureAtlasData() const
|
||
{
|
||
return _textureAtlasDataMap;
|
||
}
|
||
/**
|
||
* @private
|
||
*/
|
||
inline const std::map<std::string, DragonBonesData*>& getAllDragonBonesData() const
|
||
{
|
||
return _dragonBonesDataMap;
|
||
}
|
||
/**
|
||
* - An Worldclock instance updated by engine.
|
||
* @version DragonBones 5.7
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WorldClock ʵ<><CAB5><EFBFBD><EFBFBD>
|
||
* @version DragonBones 5.7
|
||
* @language zh_CN
|
||
*/
|
||
inline WorldClock* getClock() const
|
||
{
|
||
return _dragonBones->getClock();
|
||
}
|
||
|
||
/**
|
||
* - Deprecated, please refer to {@link #replaceSkin}.
|
||
* @deprecated
|
||
* @language en_US
|
||
*/
|
||
/**
|
||
* - <20>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD> {@link #replaceSkin}<7D><>
|
||
* @deprecated
|
||
* @language zh_CN
|
||
*/
|
||
inline bool changeSkin(Armature* armature, SkinData* skin, const std::vector<std::string>* exclude = nullptr) const
|
||
{
|
||
return replaceSkin(armature, skin, false, exclude);
|
||
}
|
||
};
|
||
/**
|
||
* @internal
|
||
*/
|
||
class BuildArmaturePackage
|
||
{
|
||
DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(BuildArmaturePackage)
|
||
|
||
public:
|
||
std::string dataName;
|
||
std::string textureAtlasName;
|
||
DragonBonesData* data;
|
||
ArmatureData* armature;
|
||
SkinData* skin;
|
||
|
||
BuildArmaturePackage() :
|
||
dataName(),
|
||
textureAtlasName(),
|
||
data(nullptr),
|
||
armature(nullptr),
|
||
skin(nullptr)
|
||
{}
|
||
~BuildArmaturePackage() {}
|
||
};
|
||
|
||
DRAGONBONES_NAMESPACE_END
|
||
#endif // DRAGONBONES_BASE_FACTORY_H
|