Use toString instead.

This commit is contained in:
halx99 2019-11-25 17:06:01 +08:00
parent 2c48f4e4f7
commit 5f1dc7c748
1 changed files with 19 additions and 19 deletions

View File

@ -232,12 +232,12 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
} }
if (elementName == "map") if (elementName == "map")
{ {
std::string version = attributeDict["version"].asString(); std::string version = attributeDict["version"].toString();
if ( version != "1.0") if ( version != "1.0")
{ {
CCLOG("cocos2d: TMXFormat: Unsupported TMX version: %s", version.c_str()); CCLOG("cocos2d: TMXFormat: Unsupported TMX version: %s", version.c_str());
} }
std::string orientationStr = attributeDict["orientation"].asString(); std::string orientationStr = attributeDict["orientation"].toString();
if (orientationStr == "orthogonal") { if (orientationStr == "orthogonal") {
tmxMapInfo->setOrientation(TMXOrientationOrtho); tmxMapInfo->setOrientation(TMXOrientationOrtho);
} }
@ -254,7 +254,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
CCLOG("cocos2d: TMXFomat: Unsupported orientation: %d", tmxMapInfo->getOrientation()); CCLOG("cocos2d: TMXFomat: Unsupported orientation: %d", tmxMapInfo->getOrientation());
} }
std::string staggerAxisStr = attributeDict["staggeraxis"].asString(); std::string staggerAxisStr = attributeDict["staggeraxis"].toString();
if (staggerAxisStr == "x") { if (staggerAxisStr == "x") {
tmxMapInfo->setStaggerAxis(TMXStaggerAxis_X); tmxMapInfo->setStaggerAxis(TMXStaggerAxis_X);
} }
@ -262,7 +262,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
tmxMapInfo->setStaggerAxis(TMXStaggerAxis_Y); tmxMapInfo->setStaggerAxis(TMXStaggerAxis_Y);
} }
std::string staggerIndex = attributeDict["staggerindex"].asString(); std::string staggerIndex = attributeDict["staggerindex"].toString();
if (staggerIndex == "odd") { if (staggerIndex == "odd") {
tmxMapInfo->setStaggerIndex(TMXStaggerIndex_Odd); tmxMapInfo->setStaggerIndex(TMXStaggerIndex_Odd);
} }
@ -291,7 +291,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
else if (elementName == "tileset") else if (elementName == "tileset")
{ {
// If this is an external tileset then start parsing that // If this is an external tileset then start parsing that
std::string externalTilesetFilename = attributeDict["source"].asString(); std::string externalTilesetFilename = attributeDict["source"].toString();
if (externalTilesetFilename != "") if (externalTilesetFilename != "")
{ {
_externalTilesetFilename = externalTilesetFilename; _externalTilesetFilename = externalTilesetFilename;
@ -320,7 +320,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
else else
{ {
TMXTilesetInfo *tileset = new (std::nothrow) TMXTilesetInfo(); TMXTilesetInfo *tileset = new (std::nothrow) TMXTilesetInfo();
tileset->_name = attributeDict["name"].asString(); tileset->_name = attributeDict["name"].toString();
if (_recordFirstGID) if (_recordFirstGID)
{ {
@ -374,7 +374,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
else if (elementName == "layer") else if (elementName == "layer")
{ {
TMXLayerInfo *layer = new (std::nothrow) TMXLayerInfo(); TMXLayerInfo *layer = new (std::nothrow) TMXLayerInfo();
layer->_name = attributeDict["name"].asString(); layer->_name = attributeDict["name"].toString();
Size s; Size s;
s.width = attributeDict["width"].asFloat(); s.width = attributeDict["width"].asFloat();
@ -400,7 +400,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
else if (elementName == "objectgroup") else if (elementName == "objectgroup")
{ {
TMXObjectGroup *objectGroup = new (std::nothrow) TMXObjectGroup(); TMXObjectGroup *objectGroup = new (std::nothrow) TMXObjectGroup();
objectGroup->setGroupName(attributeDict["name"].asString()); objectGroup->setGroupName(attributeDict["name"].toString());
Vec2 positionOffset; Vec2 positionOffset;
positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width; positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height; positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
@ -428,7 +428,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back(); TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();
// build full path // build full path
std::string imagename = attributeDict["source"].asString(); std::string imagename = attributeDict["source"].toString();
tileset->_originSourceImage = imagename; tileset->_originSourceImage = imagename;
if (_TMXFileName.find_last_of('/') != string::npos) if (_TMXFileName.find_last_of('/') != string::npos)
@ -443,8 +443,8 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
} }
else if (elementName == "data") else if (elementName == "data")
{ {
std::string encoding = attributeDict["encoding"].asString(); std::string encoding = attributeDict["encoding"].toString();
std::string compression = attributeDict["compression"].asString(); std::string compression = attributeDict["compression"].toString();
if (encoding == "") if (encoding == "")
{ {
@ -532,13 +532,13 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
if ( tmxMapInfo->getParentElement() == TMXPropertyNone ) if ( tmxMapInfo->getParentElement() == TMXPropertyNone )
{ {
CCLOG( "TMX tile map: Parent element is unsupported. Cannot add property named '%s' with value '%s'", CCLOG( "TMX tile map: Parent element is unsupported. Cannot add property named '%s' with value '%s'",
attributeDict["name"].asString().c_str(), attributeDict["value"].asString().c_str() ); attributeDict["name"].toString().c_str(), attributeDict["value"].toString().c_str() );
} }
else if ( tmxMapInfo->getParentElement() == TMXPropertyMap ) else if ( tmxMapInfo->getParentElement() == TMXPropertyMap )
{ {
// The parent element is the map // The parent element is the map
Value value = attributeDict["value"]; Value value = attributeDict["value"];
std::string key = attributeDict["name"].asString(); std::string key = attributeDict["name"].toString();
tmxMapInfo->getProperties().emplace(key, value); tmxMapInfo->getProperties().emplace(key, value);
} }
else if ( tmxMapInfo->getParentElement() == TMXPropertyLayer ) else if ( tmxMapInfo->getParentElement() == TMXPropertyLayer )
@ -546,7 +546,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
// The parent element is the last layer // The parent element is the last layer
TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
Value value = attributeDict["value"]; Value value = attributeDict["value"];
std::string key = attributeDict["name"].asString(); std::string key = attributeDict["name"].toString();
// Add the property to the layer // Add the property to the layer
layer->getProperties().emplace(key, value); layer->getProperties().emplace(key, value);
} }
@ -555,7 +555,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
// The parent element is the last object group // The parent element is the last object group
TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back(); TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back();
Value value = attributeDict["value"]; Value value = attributeDict["value"];
std::string key = attributeDict["name"].asString(); std::string key = attributeDict["name"].toString();
objectGroup->getProperties().emplace(key, value); objectGroup->getProperties().emplace(key, value);
} }
else if ( tmxMapInfo->getParentElement() == TMXPropertyObject ) else if ( tmxMapInfo->getParentElement() == TMXPropertyObject )
@ -564,14 +564,14 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back(); TMXObjectGroup* objectGroup = tmxMapInfo->getObjectGroups().back();
ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap();
std::string propertyName = attributeDict["name"].asString(); std::string propertyName = attributeDict["name"].toString();
dict[propertyName] = attributeDict["value"]; dict[propertyName] = attributeDict["value"];
} }
else if ( tmxMapInfo->getParentElement() == TMXPropertyTile ) else if ( tmxMapInfo->getParentElement() == TMXPropertyTile )
{ {
ValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asValueMap(); ValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asValueMap();
std::string propertyName = attributeDict["name"].asString(); std::string propertyName = attributeDict["name"].toString();
dict[propertyName] = attributeDict["value"]; dict[propertyName] = attributeDict["value"];
} }
} }
@ -582,7 +582,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap();
// get points value string // get points value string
std::string value = attributeDict["points"].asString(); std::string value = attributeDict["points"].toString();
if (!value.empty()) if (!value.empty())
{ {
ValueVector pointsArray; ValueVector pointsArray;
@ -627,7 +627,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap();
// get points value string // get points value string
std::string value = attributeDict["points"].asString(); std::string value = attributeDict["points"].toString();
if (!value.empty()) if (!value.empty())
{ {
ValueVector pointsArray; ValueVector pointsArray;