2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 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 __CCDATAREADERHELPER_H__
|
|
|
|
#define __CCDATAREADERHELPER_H__
|
|
|
|
|
|
|
|
#include "CCArmatureDefine.h"
|
|
|
|
#include "../datas/CCDatas.h"
|
|
|
|
#include "../utils/CCConstValue.h"
|
|
|
|
#include "../CCArmature.h"
|
|
|
|
#include "../external_tool/Json/CSContentJsonDictionary.h"
|
|
|
|
|
2013-06-07 18:29:47 +08:00
|
|
|
namespace tinyxml2 { class XMLElement; }
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-17 21:32:15 +08:00
|
|
|
namespace cocos2d { namespace extension { namespace armature {
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class DataReaderHelper
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
public:
|
|
|
|
/**
|
2013-06-07 10:52:32 +08:00
|
|
|
* Scale the position data, used for multiresolution adapter
|
|
|
|
* It won't effect the data already read.
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
|
|
|
static void setPositionReadScale(float scale);
|
|
|
|
static float getPositionReadScale();
|
|
|
|
|
|
|
|
static void addDataFromFile(const char *filePath);
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
static void clear();
|
2013-06-06 12:02:54 +08:00
|
|
|
public:
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Translate XML export from Dragon Bone flash tool to datas, and save them.
|
2013-06-07 10:52:32 +08:00
|
|
|
* When you add a new xml, the data already saved will be keeped.
|
2013-06-06 12:02:54 +08:00
|
|
|
*
|
|
|
|
* @param xmlPath Path of xml file
|
|
|
|
*/
|
|
|
|
static void addDataFromXML(const char *xmlPath);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Translate XML export from Dragon Bone flash tool to datas, and save them.
|
2013-06-07 10:52:32 +08:00
|
|
|
* When you add a new xml, the data already saved will be keeped.
|
2013-06-06 12:02:54 +08:00
|
|
|
*
|
2013-08-01 21:40:13 +08:00
|
|
|
* @param xmlPakPath Path of pak file
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
|
|
|
static void addDataFromXMLPak(const char *xmlPakPath);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Translate XML export from Dragon Bone flash tool to datas, and save them.
|
2013-06-07 10:52:32 +08:00
|
|
|
* When you add a new xml, the data already saved will be keeped.
|
2013-06-06 12:02:54 +08:00
|
|
|
*
|
2013-08-01 21:40:13 +08:00
|
|
|
* @param fileContent The cache of the xml
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2013-08-01 21:40:13 +08:00
|
|
|
static void addDataFromCache(const char *fileContent);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Decode Armature Datas from xml export from Dragon Bone flash tool
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML);
|
|
|
|
static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML);
|
|
|
|
static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Decode ArmatureAnimation Datas from xml export from Dragon Bone flash tool
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML);
|
|
|
|
static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData);
|
|
|
|
static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData);
|
|
|
|
static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Decode Texture Datas from xml export from Dragon Bone flash tool
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
/**
|
2013-06-20 14:15:53 +08:00
|
|
|
* Decode Contour Datas from xml export from Dragon Bone flash tool
|
2013-06-06 12:02:54 +08:00
|
|
|
*/
|
2013-06-20 14:15:53 +08:00
|
|
|
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-07 14:01:03 +08:00
|
|
|
public:
|
2013-06-06 12:02:54 +08:00
|
|
|
|
|
|
|
static void addDataFromJson(const char *filePath);
|
2013-06-07 10:52:32 +08:00
|
|
|
static void addDataFromJsonCache(const char *fileContent);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
static ArmatureData *decodeArmature(cs::CSJsonDictionary &json);
|
|
|
|
static BoneData *decodeBone(cs::CSJsonDictionary &json);
|
|
|
|
static DisplayData *decodeBoneDisplay(cs::CSJsonDictionary &json);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
static AnimationData *decodeAnimation(cs::CSJsonDictionary &json);
|
|
|
|
static MovementData *decodeMovement(cs::CSJsonDictionary &json);
|
|
|
|
static MovementBoneData *decodeMovementBone(cs::CSJsonDictionary &json);
|
|
|
|
static FrameData *decodeFrame(cs::CSJsonDictionary &json);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
static TextureData *decodeTexture(cs::CSJsonDictionary &json);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
static ContourData *decodeContour(cs::CSJsonDictionary &json);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
static void decodeNode(BaseData *node, cs::CSJsonDictionary &json);
|
2013-06-06 12:02:54 +08:00
|
|
|
};
|
|
|
|
|
2013-06-17 21:32:15 +08:00
|
|
|
}}} // namespace cocos2d { namespace extension { namespace armature {
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
#endif /*__CCDATAREADERHELPER_H__*/
|