mirror of https://github.com/axmolengine/axmol.git
commit
8ea95eebd6
|
@ -91,7 +91,7 @@ void AnimationCache::parseVersion1(const ValueMap& animations)
|
|||
{
|
||||
const ValueMap& animationDict = anim.second.asValueMap();
|
||||
const ValueVector& frameNames = animationDict.at("frames").asValueVector();
|
||||
float delay = animationDict.at("delay").asFloat();
|
||||
float delay = animationDict.at("delay").toFloat();
|
||||
Animation* animation = nullptr;
|
||||
|
||||
if ( frameNames.empty() )
|
||||
|
@ -143,7 +143,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
|
|||
ValueMap& animationDict = const_cast<ValueMap&>(anim.second.asValueMap());
|
||||
|
||||
const Value& loops = animationDict["loops"];
|
||||
bool restoreOriginalFrame = animationDict["restoreOriginalFrame"].asBool();
|
||||
bool restoreOriginalFrame = animationDict["restoreOriginalFrame"].toBool();
|
||||
|
||||
ValueVector& frameArray = animationDict["frames"].asValueVector();
|
||||
|
||||
|
@ -168,7 +168,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
|
|||
continue;
|
||||
}
|
||||
|
||||
float delayUnits = entry["delayUnits"].asFloat();
|
||||
float delayUnits = entry["delayUnits"].toFloat();
|
||||
Value& userInfo = entry["notification"];
|
||||
|
||||
AnimationFrame *animFrame = AnimationFrame::create(spriteFrame, delayUnits, userInfo.getType() == Value::Type::MAP ? userInfo.asValueMap() : ValueMapNull);
|
||||
|
@ -176,8 +176,8 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
|
|||
array.pushBack(animFrame);
|
||||
}
|
||||
|
||||
float delayPerUnit = animationDict["delayPerUnit"].asFloat();
|
||||
Animation *animation = Animation::create(array, delayPerUnit, loops.getType() != Value::Type::NONE ? loops.asInt() : 1);
|
||||
float delayPerUnit = animationDict["delayPerUnit"].toFloat();
|
||||
Animation *animation = Animation::create(array, delayPerUnit, loops.getType() != Value::Type::NONE ? loops.toInt() : 1);
|
||||
|
||||
animation->setRestoreOriginalFrame(restoreOriginalFrame);
|
||||
|
||||
|
@ -201,7 +201,7 @@ void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary,cons
|
|||
if(propsItr != dictionary.end() )
|
||||
{
|
||||
const ValueMap& properties = propsItr->second.asValueMap();
|
||||
version = properties.at("format").asInt();
|
||||
version = properties.at("format").toInt();
|
||||
const ValueVector& spritesheets = properties.at("spritesheets").asValueVector();
|
||||
|
||||
for(const auto &value : spritesheets) {
|
||||
|
|
|
@ -763,11 +763,11 @@ void FastTMXLayer::parseInternalProperties()
|
|||
{
|
||||
_useAutomaticVertexZ = true;
|
||||
auto alphaFuncVal = getProperty("cc_alpha_func");
|
||||
_alphaFuncValue = alphaFuncVal.asFloat();
|
||||
_alphaFuncValue = alphaFuncVal.toFloat();
|
||||
}
|
||||
else
|
||||
{
|
||||
_vertexZvalue = vertexz.asInt();
|
||||
_vertexZvalue = vertexz.toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ FontCharMap * FontCharMap::create(const std::string& plistFile)
|
|||
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr);
|
||||
|
||||
CCASSERT(dict["version"].asInt() == 1, "Unsupported version. Upgrade cocos2d version");
|
||||
CCASSERT(dict["version"].toInt() == 1, "Unsupported version. Upgrade cocos2d version");
|
||||
|
||||
std::string textureFilename = relPathStr + dict["textureFilename"].asString();
|
||||
|
||||
unsigned int width = dict["itemWidth"].asInt();
|
||||
unsigned int height = dict["itemHeight"].asInt();
|
||||
unsigned int startChar = dict["firstChar"].asInt();
|
||||
unsigned int width = dict["itemWidth"].toInt();
|
||||
unsigned int height = dict["itemHeight"].toInt();
|
||||
unsigned int startChar = dict["firstChar"].toInt();
|
||||
|
||||
Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(textureFilename);
|
||||
if (!tempTexture)
|
||||
|
|
|
@ -109,13 +109,13 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
|
|||
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr);
|
||||
|
||||
CCASSERT(dict["version"].asInt() == 1, "Unsupported version. Upgrade cocos2d version");
|
||||
CCASSERT(dict["version"].toInt() == 1, "Unsupported version. Upgrade cocos2d version");
|
||||
|
||||
std::string textureFilename = relPathStr + dict["textureFilename"].asString();
|
||||
|
||||
unsigned int width = dict["itemWidth"].asInt() / CC_CONTENT_SCALE_FACTOR();
|
||||
unsigned int height = dict["itemHeight"].asInt() / CC_CONTENT_SCALE_FACTOR();
|
||||
unsigned int startChar = dict["firstChar"].asInt();
|
||||
unsigned int width = dict["itemWidth"].toInt() / CC_CONTENT_SCALE_FACTOR();
|
||||
unsigned int height = dict["itemHeight"].toInt() / CC_CONTENT_SCALE_FACTOR();
|
||||
unsigned int startChar = dict["firstChar"].toInt();
|
||||
|
||||
|
||||
this->initWithString(theString, textureFilename, width, height, startChar);
|
||||
|
|
|
@ -364,7 +364,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
|
|||
for(const auto &child : _children) {
|
||||
CCASSERT(row < rows.size(), "row should less than rows.size()!");
|
||||
|
||||
rowColumns = rows[row].asInt();
|
||||
rowColumns = rows[row].toInt();
|
||||
// can not have zero columns on a row
|
||||
CCASSERT(rowColumns, "rowColumns can't be 0.");
|
||||
|
||||
|
@ -397,7 +397,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
|
|||
for(const auto &child : _children) {
|
||||
if (rowColumns == 0)
|
||||
{
|
||||
rowColumns = rows[row].asInt();
|
||||
rowColumns = rows[row].toInt();
|
||||
w = winSize.width / (1 + rowColumns);
|
||||
x = w;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
// check if too many menu items for the amount of rows/columns
|
||||
CCASSERT(column < columns.size(), "column should be less than columns.size().");
|
||||
|
||||
columnRows = columns[column].asInt();
|
||||
columnRows = columns[column].toInt();
|
||||
// can't have zero rows on a column
|
||||
CCASSERT(columnRows, "columnRows can't be 0.");
|
||||
|
||||
|
@ -498,7 +498,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
for(const auto &child : _children) {
|
||||
if (columnRows == 0)
|
||||
{
|
||||
columnRows = columns[column].asInt();
|
||||
columnRows = columns[column].toInt();
|
||||
y = (float) columnHeights[column];
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
Image *image = nullptr;
|
||||
do
|
||||
{
|
||||
int maxParticles = dictionary["maxParticles"].asInt();
|
||||
int maxParticles = dictionary["maxParticles"].toInt();
|
||||
// self, not super
|
||||
if(this->initWithTotalParticles(maxParticles))
|
||||
{
|
||||
|
@ -328,91 +328,91 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
_configName = dictionary["configName"].toString();
|
||||
|
||||
// angle
|
||||
_angle = dictionary["angle"].asFloat();
|
||||
_angleVar = dictionary["angleVariance"].asFloat();
|
||||
_angle = dictionary["angle"].toFloat();
|
||||
_angleVar = dictionary["angleVariance"].toFloat();
|
||||
|
||||
// duration
|
||||
_duration = dictionary["duration"].asFloat();
|
||||
_duration = dictionary["duration"].toFloat();
|
||||
|
||||
// blend function
|
||||
if (!_configName.empty())
|
||||
{
|
||||
_blendFunc.src = utils::toBackendBlendFactor((int)dictionary["blendFuncSource"].asFloat());
|
||||
_blendFunc.src = utils::toBackendBlendFactor((int)dictionary["blendFuncSource"].toFloat());
|
||||
}
|
||||
else
|
||||
{
|
||||
_blendFunc.src = utils::toBackendBlendFactor(dictionary["blendFuncSource"].asInt());
|
||||
_blendFunc.src = utils::toBackendBlendFactor(dictionary["blendFuncSource"].toInt());
|
||||
}
|
||||
_blendFunc.dst = utils::toBackendBlendFactor(dictionary["blendFuncDestination"].asInt());
|
||||
_blendFunc.dst = utils::toBackendBlendFactor(dictionary["blendFuncDestination"].toInt());
|
||||
|
||||
// color
|
||||
_startColor.r = dictionary["startColorRed"].asFloat();
|
||||
_startColor.g = dictionary["startColorGreen"].asFloat();
|
||||
_startColor.b = dictionary["startColorBlue"].asFloat();
|
||||
_startColor.a = dictionary["startColorAlpha"].asFloat();
|
||||
_startColor.r = dictionary["startColorRed"].toFloat();
|
||||
_startColor.g = dictionary["startColorGreen"].toFloat();
|
||||
_startColor.b = dictionary["startColorBlue"].toFloat();
|
||||
_startColor.a = dictionary["startColorAlpha"].toFloat();
|
||||
|
||||
_startColorVar.r = dictionary["startColorVarianceRed"].asFloat();
|
||||
_startColorVar.g = dictionary["startColorVarianceGreen"].asFloat();
|
||||
_startColorVar.b = dictionary["startColorVarianceBlue"].asFloat();
|
||||
_startColorVar.a = dictionary["startColorVarianceAlpha"].asFloat();
|
||||
_startColorVar.r = dictionary["startColorVarianceRed"].toFloat();
|
||||
_startColorVar.g = dictionary["startColorVarianceGreen"].toFloat();
|
||||
_startColorVar.b = dictionary["startColorVarianceBlue"].toFloat();
|
||||
_startColorVar.a = dictionary["startColorVarianceAlpha"].toFloat();
|
||||
|
||||
_endColor.r = dictionary["finishColorRed"].asFloat();
|
||||
_endColor.g = dictionary["finishColorGreen"].asFloat();
|
||||
_endColor.b = dictionary["finishColorBlue"].asFloat();
|
||||
_endColor.a = dictionary["finishColorAlpha"].asFloat();
|
||||
_endColor.r = dictionary["finishColorRed"].toFloat();
|
||||
_endColor.g = dictionary["finishColorGreen"].toFloat();
|
||||
_endColor.b = dictionary["finishColorBlue"].toFloat();
|
||||
_endColor.a = dictionary["finishColorAlpha"].toFloat();
|
||||
|
||||
_endColorVar.r = dictionary["finishColorVarianceRed"].asFloat();
|
||||
_endColorVar.g = dictionary["finishColorVarianceGreen"].asFloat();
|
||||
_endColorVar.b = dictionary["finishColorVarianceBlue"].asFloat();
|
||||
_endColorVar.a = dictionary["finishColorVarianceAlpha"].asFloat();
|
||||
_endColorVar.r = dictionary["finishColorVarianceRed"].toFloat();
|
||||
_endColorVar.g = dictionary["finishColorVarianceGreen"].toFloat();
|
||||
_endColorVar.b = dictionary["finishColorVarianceBlue"].toFloat();
|
||||
_endColorVar.a = dictionary["finishColorVarianceAlpha"].toFloat();
|
||||
|
||||
// particle size
|
||||
_startSize = dictionary["startParticleSize"].asFloat();
|
||||
_startSizeVar = dictionary["startParticleSizeVariance"].asFloat();
|
||||
_endSize = dictionary["finishParticleSize"].asFloat();
|
||||
_endSizeVar = dictionary["finishParticleSizeVariance"].asFloat();
|
||||
_startSize = dictionary["startParticleSize"].toFloat();
|
||||
_startSizeVar = dictionary["startParticleSizeVariance"].toFloat();
|
||||
_endSize = dictionary["finishParticleSize"].toFloat();
|
||||
_endSizeVar = dictionary["finishParticleSizeVariance"].toFloat();
|
||||
|
||||
// position
|
||||
float x = dictionary["sourcePositionx"].asFloat();
|
||||
float y = dictionary["sourcePositiony"].asFloat();
|
||||
float x = dictionary["sourcePositionx"].toFloat();
|
||||
float y = dictionary["sourcePositiony"].toFloat();
|
||||
if(!_sourcePositionCompatible) {
|
||||
this->setSourcePosition(Vec2(x, y));
|
||||
}
|
||||
else {
|
||||
this->setPosition(Vec2(x, y));
|
||||
}
|
||||
_posVar.x = dictionary["sourcePositionVariancex"].asFloat();
|
||||
_posVar.y = dictionary["sourcePositionVariancey"].asFloat();
|
||||
_posVar.x = dictionary["sourcePositionVariancex"].toFloat();
|
||||
_posVar.y = dictionary["sourcePositionVariancey"].toFloat();
|
||||
|
||||
// Spinning
|
||||
_startSpin = dictionary["rotationStart"].asFloat();
|
||||
_startSpinVar = dictionary["rotationStartVariance"].asFloat();
|
||||
_endSpin= dictionary["rotationEnd"].asFloat();
|
||||
_endSpinVar= dictionary["rotationEndVariance"].asFloat();
|
||||
_startSpin = dictionary["rotationStart"].toFloat();
|
||||
_startSpinVar = dictionary["rotationStartVariance"].toFloat();
|
||||
_endSpin= dictionary["rotationEnd"].toFloat();
|
||||
_endSpinVar= dictionary["rotationEndVariance"].toFloat();
|
||||
|
||||
_emitterMode = (Mode) dictionary["emitterType"].asInt();
|
||||
_emitterMode = (Mode) dictionary["emitterType"].toInt();
|
||||
|
||||
// Mode A: Gravity + tangential accel + radial accel
|
||||
if (_emitterMode == Mode::GRAVITY)
|
||||
{
|
||||
// gravity
|
||||
modeA.gravity.x = dictionary["gravityx"].asFloat();
|
||||
modeA.gravity.y = dictionary["gravityy"].asFloat();
|
||||
modeA.gravity.x = dictionary["gravityx"].toFloat();
|
||||
modeA.gravity.y = dictionary["gravityy"].toFloat();
|
||||
|
||||
// speed
|
||||
modeA.speed = dictionary["speed"].asFloat();
|
||||
modeA.speedVar = dictionary["speedVariance"].asFloat();
|
||||
modeA.speed = dictionary["speed"].toFloat();
|
||||
modeA.speedVar = dictionary["speedVariance"].toFloat();
|
||||
|
||||
// radial acceleration
|
||||
modeA.radialAccel = dictionary["radialAcceleration"].asFloat();
|
||||
modeA.radialAccelVar = dictionary["radialAccelVariance"].asFloat();
|
||||
modeA.radialAccel = dictionary["radialAcceleration"].toFloat();
|
||||
modeA.radialAccelVar = dictionary["radialAccelVariance"].toFloat();
|
||||
|
||||
// tangential acceleration
|
||||
modeA.tangentialAccel = dictionary["tangentialAcceleration"].asFloat();
|
||||
modeA.tangentialAccelVar = dictionary["tangentialAccelVariance"].asFloat();
|
||||
modeA.tangentialAccel = dictionary["tangentialAcceleration"].toFloat();
|
||||
modeA.tangentialAccelVar = dictionary["tangentialAccelVariance"].toFloat();
|
||||
|
||||
// rotation is dir
|
||||
modeA.rotationIsDir = dictionary["rotationIsDir"].asBool();
|
||||
modeA.rotationIsDir = dictionary["rotationIsDir"].toBool();
|
||||
}
|
||||
|
||||
// or Mode B: radius movement
|
||||
|
@ -420,25 +420,25 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
{
|
||||
if (!_configName.empty())
|
||||
{
|
||||
modeB.startRadius = dictionary["maxRadius"].asInt();
|
||||
modeB.startRadius = dictionary["maxRadius"].toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB.startRadius = dictionary["maxRadius"].asFloat();
|
||||
modeB.startRadius = dictionary["maxRadius"].toFloat();
|
||||
}
|
||||
modeB.startRadiusVar = dictionary["maxRadiusVariance"].asFloat();
|
||||
modeB.startRadiusVar = dictionary["maxRadiusVariance"].toFloat();
|
||||
if (!_configName.empty())
|
||||
{
|
||||
modeB.endRadius = dictionary["minRadius"].asInt();
|
||||
modeB.endRadius = dictionary["minRadius"].toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB.endRadius = dictionary["minRadius"].asFloat();
|
||||
modeB.endRadius = dictionary["minRadius"].toFloat();
|
||||
}
|
||||
|
||||
if (dictionary.find("minRadiusVariance") != dictionary.end())
|
||||
{
|
||||
modeB.endRadiusVar = dictionary["minRadiusVariance"].asFloat();
|
||||
modeB.endRadiusVar = dictionary["minRadiusVariance"].toFloat();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -447,13 +447,13 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
|
||||
if (!_configName.empty())
|
||||
{
|
||||
modeB.rotatePerSecond = dictionary["rotatePerSecond"].asInt();
|
||||
modeB.rotatePerSecond = dictionary["rotatePerSecond"].toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
modeB.rotatePerSecond = dictionary["rotatePerSecond"].asFloat();
|
||||
modeB.rotatePerSecond = dictionary["rotatePerSecond"].toFloat();
|
||||
}
|
||||
modeB.rotatePerSecondVar = dictionary["rotatePerSecondVariance"].asFloat();
|
||||
modeB.rotatePerSecondVar = dictionary["rotatePerSecondVariance"].toFloat();
|
||||
|
||||
} else {
|
||||
CCASSERT( false, "Invalid emitterType in config file");
|
||||
|
@ -461,8 +461,8 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
}
|
||||
|
||||
// life span
|
||||
_life = dictionary["particleLifespan"].asFloat();
|
||||
_lifeVar = dictionary["particleLifespanVariance"].asFloat();
|
||||
_life = dictionary["particleLifespan"].toFloat();
|
||||
_lifeVar = dictionary["particleLifespanVariance"].toFloat();
|
||||
|
||||
// emission Rate
|
||||
_emissionRate = _totalParticles / _life;
|
||||
|
@ -539,7 +539,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
}
|
||||
}
|
||||
|
||||
_yCoordFlipped = dictionary.find("yCoordFlipped") == dictionary.end() ? 1 : dictionary.at("yCoordFlipped").asInt();
|
||||
_yCoordFlipped = dictionary.find("yCoordFlipped") == dictionary.end() ? 1 : dictionary.at("yCoordFlipped").toInt();
|
||||
|
||||
if( !this->_texture)
|
||||
CCLOGWARN("cocos2d: Warning: ParticleSystemQuad system without a texture");
|
||||
|
|
|
@ -140,7 +140,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
if (metaItr != dictionary.end())
|
||||
{
|
||||
ValueMap& metadataDict = metaItr->second.asValueMap();
|
||||
format = metadataDict["format"].asInt();
|
||||
format = metadataDict["format"].toInt();
|
||||
|
||||
if(metadataDict.find("size") != metadataDict.end())
|
||||
{
|
||||
|
@ -166,14 +166,14 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
|
||||
if(format == 0)
|
||||
{
|
||||
float x = frameDict["x"].asFloat();
|
||||
float y = frameDict["y"].asFloat();
|
||||
float w = frameDict["width"].asFloat();
|
||||
float h = frameDict["height"].asFloat();
|
||||
float ox = frameDict["offsetX"].asFloat();
|
||||
float oy = frameDict["offsetY"].asFloat();
|
||||
int ow = frameDict["originalWidth"].asInt();
|
||||
int oh = frameDict["originalHeight"].asInt();
|
||||
float x = frameDict["x"].toFloat();
|
||||
float y = frameDict["y"].toFloat();
|
||||
float w = frameDict["width"].toFloat();
|
||||
float h = frameDict["height"].toFloat();
|
||||
float ox = frameDict["offsetX"].toFloat();
|
||||
float oy = frameDict["offsetY"].toFloat();
|
||||
int ow = frameDict["originalWidth"].toInt();
|
||||
int oh = frameDict["originalHeight"].toInt();
|
||||
// check ow/oh
|
||||
if(!ow || !oh)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
// rotation
|
||||
if (format == 2)
|
||||
{
|
||||
rotated = frameDict["rotated"].asBool();
|
||||
rotated = frameDict["rotated"].toBool();
|
||||
}
|
||||
|
||||
Vec2 offset = PointFromString(frameDict["offset"].asString());
|
||||
|
@ -219,7 +219,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
Vec2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString());
|
||||
Rect textureRect = RectFromString(frameDict["textureRect"].asString());
|
||||
bool textureRotated = frameDict["textureRotated"].asBool();
|
||||
bool textureRotated = frameDict["textureRotated"].toBool();
|
||||
|
||||
// get aliases
|
||||
ValueVector& aliases = frameDict["aliases"].asValueVector();
|
||||
|
@ -554,7 +554,7 @@ void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Te
|
|||
if (dictionary.find("metadata") != dictionary.end())
|
||||
{
|
||||
ValueMap& metadataDict = dictionary["metadata"].asValueMap();
|
||||
format = metadataDict["format"].asInt();
|
||||
format = metadataDict["format"].toInt();
|
||||
}
|
||||
|
||||
// check the format
|
||||
|
@ -571,14 +571,14 @@ void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Te
|
|||
|
||||
if (format == 0)
|
||||
{
|
||||
float x = frameDict["x"].asFloat();
|
||||
float y = frameDict["y"].asFloat();
|
||||
float w = frameDict["width"].asFloat();
|
||||
float h = frameDict["height"].asFloat();
|
||||
float ox = frameDict["offsetX"].asFloat();
|
||||
float oy = frameDict["offsetY"].asFloat();
|
||||
int ow = frameDict["originalWidth"].asInt();
|
||||
int oh = frameDict["originalHeight"].asInt();
|
||||
float x = frameDict["x"].toFloat();
|
||||
float y = frameDict["y"].toFloat();
|
||||
float w = frameDict["width"].toFloat();
|
||||
float h = frameDict["height"].toFloat();
|
||||
float ox = frameDict["offsetX"].toFloat();
|
||||
float oy = frameDict["offsetY"].toFloat();
|
||||
int ow = frameDict["originalWidth"].toInt();
|
||||
int oh = frameDict["originalHeight"].toInt();
|
||||
// check ow/oh
|
||||
if (!ow || !oh)
|
||||
{
|
||||
|
@ -603,7 +603,7 @@ void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Te
|
|||
// rotation
|
||||
if (format == 2)
|
||||
{
|
||||
rotated = frameDict["rotated"].asBool();
|
||||
rotated = frameDict["rotated"].toBool();
|
||||
}
|
||||
|
||||
Vec2 offset = PointFromString(frameDict["offset"].asString());
|
||||
|
@ -624,7 +624,7 @@ void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Te
|
|||
Vec2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString());
|
||||
Rect textureRect = RectFromString(frameDict["textureRect"].asString());
|
||||
bool textureRotated = frameDict["textureRotated"].asBool();
|
||||
bool textureRotated = frameDict["textureRotated"].toBool();
|
||||
|
||||
// get aliases
|
||||
ValueVector& aliases = frameDict["aliases"].asValueVector();
|
||||
|
|
|
@ -247,7 +247,7 @@ void TMXLayer::parseInternalProperties()
|
|||
{
|
||||
_useAutomaticVertexZ = true;
|
||||
auto alphaFuncVal = getProperty("cc_alpha_func");
|
||||
float alphaFuncValue = alphaFuncVal.asFloat();
|
||||
float alphaFuncValue = alphaFuncVal.toFloat();
|
||||
|
||||
setProgramStateWithRegistry(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST, nullptr);
|
||||
|
||||
|
@ -259,7 +259,7 @@ void TMXLayer::parseInternalProperties()
|
|||
}
|
||||
else
|
||||
{
|
||||
_vertexZvalue = vertexz.asInt();
|
||||
_vertexZvalue = vertexz.toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,16 +271,16 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
}
|
||||
|
||||
|
||||
float hexSideLength = attributeDict["hexsidelength"].asFloat();
|
||||
float hexSideLength = attributeDict["hexsidelength"].toFloat();
|
||||
tmxMapInfo->setHexSideLength(hexSideLength);
|
||||
|
||||
Size s;
|
||||
s.width = attributeDict["width"].asFloat();
|
||||
s.height = attributeDict["height"].asFloat();
|
||||
s.width = attributeDict["width"].toFloat();
|
||||
s.height = attributeDict["height"].toFloat();
|
||||
tmxMapInfo->setMapSize(s);
|
||||
|
||||
s.width = attributeDict["tilewidth"].asFloat();
|
||||
s.height = attributeDict["tileheight"].asFloat();
|
||||
s.width = attributeDict["tilewidth"].toFloat();
|
||||
s.height = attributeDict["tileheight"].toFloat();
|
||||
tmxMapInfo->setTileSize(s);
|
||||
|
||||
|
||||
|
@ -308,7 +308,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
}
|
||||
externalTilesetFilename = FileUtils::getInstance()->fullPathForFilename(externalTilesetFilename);
|
||||
|
||||
_currentFirstGID = attributeDict["firstgid"].asInt();
|
||||
_currentFirstGID = attributeDict["firstgid"].toInt();
|
||||
if (_currentFirstGID < 0)
|
||||
{
|
||||
_currentFirstGID = 0;
|
||||
|
@ -325,7 +325,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
if (_recordFirstGID)
|
||||
{
|
||||
// unset before, so this is tmx file.
|
||||
tileset->_firstGid = attributeDict["firstgid"].asInt();
|
||||
tileset->_firstGid = attributeDict["firstgid"].toInt();
|
||||
|
||||
if (tileset->_firstGid < 0)
|
||||
{
|
||||
|
@ -338,11 +338,11 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
_currentFirstGID = 0;
|
||||
}
|
||||
|
||||
tileset->_spacing = attributeDict["spacing"].asInt();
|
||||
tileset->_margin = attributeDict["margin"].asInt();
|
||||
tileset->_spacing = attributeDict["spacing"].toInt();
|
||||
tileset->_margin = attributeDict["margin"].toInt();
|
||||
Size s;
|
||||
s.width = attributeDict["tilewidth"].asFloat();
|
||||
s.height = attributeDict["tileheight"].asFloat();
|
||||
s.width = attributeDict["tilewidth"].toFloat();
|
||||
s.height = attributeDict["tileheight"].toFloat();
|
||||
tileset->_tileSize = s;
|
||||
|
||||
tmxMapInfo->getTilesets().pushBack(tileset);
|
||||
|
@ -355,7 +355,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
{
|
||||
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
|
||||
Size layerSize = layer->_layerSize;
|
||||
uint32_t gid = static_cast<uint32_t>(attributeDict["gid"].asUnsignedInt());
|
||||
uint32_t gid = static_cast<uint32_t>(attributeDict["gid"].toUnsignedInt());
|
||||
int tilesAmount = layerSize.width*layerSize.height;
|
||||
|
||||
if (_xmlTileIndex < tilesAmount)
|
||||
|
@ -366,7 +366,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
else
|
||||
{
|
||||
TMXTilesetInfo* info = tmxMapInfo->getTilesets().back();
|
||||
tmxMapInfo->setParentGID(info->_firstGid + attributeDict["id"].asInt());
|
||||
tmxMapInfo->setParentGID(info->_firstGid + attributeDict["id"].toInt());
|
||||
tmxMapInfo->getTileProperties()[tmxMapInfo->getParentGID()] = Value(ValueMap());
|
||||
tmxMapInfo->setParentElement(TMXPropertyTile);
|
||||
}
|
||||
|
@ -377,18 +377,18 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
layer->_name = attributeDict["name"].toString();
|
||||
|
||||
Size s;
|
||||
s.width = attributeDict["width"].asFloat();
|
||||
s.height = attributeDict["height"].asFloat();
|
||||
s.width = attributeDict["width"].toFloat();
|
||||
s.height = attributeDict["height"].toFloat();
|
||||
layer->_layerSize = s;
|
||||
|
||||
Value& visibleValue = attributeDict["visible"];
|
||||
layer->_visible = visibleValue.isNull() ? true : visibleValue.asBool();
|
||||
layer->_visible = visibleValue.isNull() ? true : visibleValue.toBool();
|
||||
|
||||
Value& opacityValue = attributeDict["opacity"];
|
||||
layer->_opacity = opacityValue.isNull() ? 255 : (unsigned char)(255.0f * opacityValue.asFloat());
|
||||
layer->_opacity = opacityValue.isNull() ? 255 : (unsigned char)(255.0f * opacityValue.toFloat());
|
||||
|
||||
float x = attributeDict["x"].asFloat();
|
||||
float y = attributeDict["y"].asFloat();
|
||||
float x = attributeDict["x"].toFloat();
|
||||
float y = attributeDict["y"].toFloat();
|
||||
layer->_offset.set(x, y);
|
||||
|
||||
tmxMapInfo->getLayers().pushBack(layer);
|
||||
|
@ -402,8 +402,8 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
TMXObjectGroup *objectGroup = new (std::nothrow) TMXObjectGroup();
|
||||
objectGroup->setGroupName(attributeDict["name"].toString());
|
||||
Vec2 positionOffset;
|
||||
positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
|
||||
positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
|
||||
positionOffset.x = attributeDict["x"].toFloat() * tmxMapInfo->getTileSize().width;
|
||||
positionOffset.y = attributeDict["y"].toFloat() * tmxMapInfo->getTileSize().height;
|
||||
objectGroup->setPositionOffset(positionOffset);
|
||||
|
||||
tmxMapInfo->getObjectGroups().pushBack(objectGroup);
|
||||
|
@ -416,9 +416,9 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
{
|
||||
TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();
|
||||
|
||||
float tileOffsetX = attributeDict["x"].asFloat();
|
||||
float tileOffsetX = attributeDict["x"].toFloat();
|
||||
|
||||
float tileOffsetY = attributeDict["y"].asFloat();
|
||||
float tileOffsetY = attributeDict["y"].toFloat();
|
||||
|
||||
tileset->_tileOffset = Vec2(tileOffsetX, tileOffsetY);
|
||||
|
||||
|
@ -503,23 +503,23 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
|
|||
|
||||
// But X and Y since they need special treatment
|
||||
// X
|
||||
int x = attributeDict["x"].asInt();
|
||||
int x = attributeDict["x"].toInt();
|
||||
// Y
|
||||
int y = attributeDict["y"].asInt();
|
||||
int y = attributeDict["y"].toInt();
|
||||
|
||||
Vec2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().y - attributeDict["height"].asInt());
|
||||
Vec2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().y - attributeDict["height"].toInt());
|
||||
p = CC_POINT_PIXELS_TO_POINTS(p);
|
||||
dict["x"] = Value(p.x);
|
||||
dict["y"] = Value(p.y);
|
||||
|
||||
int width = attributeDict["width"].asInt();
|
||||
int height = attributeDict["height"].asInt();
|
||||
int width = attributeDict["width"].toInt();
|
||||
int height = attributeDict["height"].toInt();
|
||||
Size s(width, height);
|
||||
s = CC_SIZE_PIXELS_TO_POINTS(s);
|
||||
dict["width"] = Value(s.width);
|
||||
dict["height"] = Value(s.height);
|
||||
|
||||
dict["rotation"] = attributeDict["rotation"].asDouble();
|
||||
dict["rotation"] = attributeDict["rotation"].toDouble();
|
||||
|
||||
// Add the object to the objectGroup
|
||||
objectGroup->getObjects().push_back(Value(dict));
|
||||
|
|
|
@ -144,7 +144,7 @@ void TileMapAtlas::setTile(const Color3B& tile, const Vec2& position)
|
|||
// FIXME:: this method consumes a lot of memory
|
||||
// FIXME:: a tree of something like that shall be implemented
|
||||
std::string key = StringUtils::toString(position.x) + "," + StringUtils::toString(position.y);
|
||||
int num = _posToAtlasIndex[key].asInt();
|
||||
int num = _posToAtlasIndex[key].toInt();
|
||||
|
||||
this->updateAtlasValueAt(position, tile, num);
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ void Configuration::loadConfigFile(const std::string& filename)
|
|||
|
||||
if (formatIter != metadata.cend())
|
||||
{
|
||||
int format = formatIter->second.asInt();
|
||||
int format = formatIter->second.toInt();
|
||||
|
||||
// Support format: 1
|
||||
if (format == 1)
|
||||
|
@ -376,25 +376,25 @@ void Configuration::loadConfigFile(const std::string& filename)
|
|||
//light info
|
||||
std::string name = "cocos2d.x.3d.max_dir_light_in_shader";
|
||||
if (_valueDict.find(name) != _valueDict.end())
|
||||
_maxDirLightInShader = _valueDict[name].asInt();
|
||||
_maxDirLightInShader = _valueDict[name].toInt();
|
||||
else
|
||||
_valueDict[name] = Value(_maxDirLightInShader);
|
||||
|
||||
name = "cocos2d.x.3d.max_point_light_in_shader";
|
||||
if (_valueDict.find(name) != _valueDict.end())
|
||||
_maxPointLightInShader = _valueDict[name].asInt();
|
||||
_maxPointLightInShader = _valueDict[name].toInt();
|
||||
else
|
||||
_valueDict[name] = Value(_maxPointLightInShader);
|
||||
|
||||
name = "cocos2d.x.3d.max_spot_light_in_shader";
|
||||
if (_valueDict.find(name) != _valueDict.end())
|
||||
_maxSpotLightInShader = _valueDict[name].asInt();
|
||||
_maxSpotLightInShader = _valueDict[name].toInt();
|
||||
else
|
||||
_valueDict[name] = Value(_maxSpotLightInShader);
|
||||
|
||||
name = "cocos2d.x.3d.animate_quality";
|
||||
if (_valueDict.find(name) != _valueDict.end())
|
||||
_animate3DQuality = (Animate3DQuality)_valueDict[name].asInt();
|
||||
_animate3DQuality = (Animate3DQuality)_valueDict[name].toInt();
|
||||
else
|
||||
_valueDict[name] = Value((int)_animate3DQuality);
|
||||
|
||||
|
|
|
@ -203,11 +203,11 @@ void Director::setDefaultValues()
|
|||
Configuration *conf = Configuration::getInstance();
|
||||
|
||||
// default FPS
|
||||
float fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).asFloat();
|
||||
float fps = conf->getValue("cocos2d.x.fps", Value(kDefaultFPS)).toFloat();
|
||||
_oldAnimationInterval = _animationInterval = 1.0f / fps;
|
||||
|
||||
// Display FPS
|
||||
_displayStats = conf->getValue("cocos2d.x.display_fps", Value(false)).asBool();
|
||||
_displayStats = conf->getValue("cocos2d.x.display_fps", Value(false)).toBool();
|
||||
|
||||
// GL projection
|
||||
std::string projection = conf->getValue("cocos2d.x.gl.projection", Value("3d")).asString();
|
||||
|
@ -221,7 +221,7 @@ void Director::setDefaultValues()
|
|||
CCASSERT(false, "Invalid projection value");
|
||||
|
||||
// Default pixel format for PNG images with alpha
|
||||
std::string pixel_format = conf->getValue("cocos2d.x.texture.pixel_format_for_png", Value("rgba8888")).asString();
|
||||
std::string pixel_format = conf->getValue("cocos2d.x.texture.pixel_format_for_png", Value("rgba8888")).toString();
|
||||
if (pixel_format == "rgba8888")
|
||||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGBA8888);
|
||||
else if(pixel_format == "rgba4444")
|
||||
|
@ -230,7 +230,7 @@ void Director::setDefaultValues()
|
|||
Texture2D::setDefaultAlphaPixelFormat(backend::PixelFormat::RGB5A1);
|
||||
|
||||
// PVR v2 has alpha premultiplied ?
|
||||
bool pvr_alpha_premultiplied = conf->getValue("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", Value(false)).asBool();
|
||||
bool pvr_alpha_premultiplied = conf->getValue("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", Value(false)).toBool();
|
||||
Image::setPVRImagesHavePremultipliedAlpha(pvr_alpha_premultiplied);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ const ValueMapIntKey ValueMapIntKeyNull;
|
|||
|
||||
const Value Value::Null;
|
||||
|
||||
const std::string Value::NullString;
|
||||
|
||||
Value::Value()
|
||||
: _type(Type::NONE)
|
||||
{
|
||||
|
@ -440,7 +442,7 @@ bool Value::operator== (const Value& v) const
|
|||
}
|
||||
|
||||
/// Convert value to a specified type
|
||||
unsigned char Value::asByte() const
|
||||
unsigned char Value::toByte() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
|
||||
|
@ -482,7 +484,7 @@ unsigned char Value::asByte() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Value::asInt() const
|
||||
int Value::toInt() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
if (_type == Type::INTEGER)
|
||||
|
@ -525,7 +527,7 @@ int Value::asInt() const
|
|||
}
|
||||
|
||||
|
||||
unsigned int Value::asUnsignedInt() const
|
||||
unsigned int Value::toUnsignedInt() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
if (_type == Type::UNSIGNED)
|
||||
|
@ -568,7 +570,7 @@ unsigned int Value::asUnsignedInt() const
|
|||
return 0u;
|
||||
}
|
||||
|
||||
float Value::asFloat() const
|
||||
float Value::toFloat() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
if (_type == Type::FLOAT)
|
||||
|
@ -609,7 +611,7 @@ float Value::asFloat() const
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
double Value::asDouble() const
|
||||
double Value::toDouble() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
if (_type == Type::DOUBLE)
|
||||
|
@ -650,7 +652,7 @@ double Value::asDouble() const
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
bool Value::asBool() const
|
||||
bool Value::toBool() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
if (_type == Type::BOOLEAN)
|
||||
|
@ -691,18 +693,6 @@ bool Value::asBool() const
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string& Value::asString()
|
||||
{
|
||||
CCASSERT(_type == Type::STRING, "The value type isn't Type::STRING");
|
||||
return *_field.strVal;
|
||||
}
|
||||
|
||||
const std::string& Value::asString() const
|
||||
{
|
||||
CCASSERT(_type == Type::STRING, "The value type isn't Type::STRING");
|
||||
return *_field.strVal;
|
||||
}
|
||||
|
||||
std::string Value::toString() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted");
|
||||
|
@ -740,6 +730,18 @@ std::string Value::toString() const
|
|||
return ret.str();
|
||||
}
|
||||
|
||||
const std::string& Value::asString() const
|
||||
{
|
||||
if (_type == Type::STRING)
|
||||
return *_field.strVal;
|
||||
return Value::NullString;
|
||||
}
|
||||
|
||||
const std::string& Value::asStringUnsafe() const
|
||||
{
|
||||
CCASSERT(_type == Type::STRING, "The value type isn't Type::STRING");
|
||||
return *_field.strVal;
|
||||
}
|
||||
|
||||
ValueVector& Value::asValueVector()
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ class CC_DLL Value
|
|||
public:
|
||||
/** A predefined Value that has not value. */
|
||||
static const Value Null;
|
||||
static const std::string NullString;
|
||||
|
||||
/** Default constructor. */
|
||||
Value();
|
||||
|
@ -155,24 +156,23 @@ public:
|
|||
bool operator== (const Value& v) const;
|
||||
|
||||
/** Gets as a byte value. Will convert to unsigned char if possible, or will trigger assert error. */
|
||||
unsigned char asByte() const;
|
||||
unsigned char toByte() const;
|
||||
/** Gets as an integer value. Will convert to integer if possible, or will trigger assert error. */
|
||||
int asInt() const;
|
||||
int toInt() const;
|
||||
/** Gets as an unsigned value. Will convert to unsigned if possible, or will trigger assert error. */
|
||||
unsigned int asUnsignedInt() const;
|
||||
unsigned int toUnsignedInt() const;
|
||||
/** Gets as a float value. Will convert to float if possible, or will trigger assert error. */
|
||||
float asFloat() const;
|
||||
float toFloat() const;
|
||||
/** Gets as a double value. Will convert to double if possible, or will trigger assert error. */
|
||||
double asDouble() const;
|
||||
double toDouble() const;
|
||||
/** Gets as a bool value. Will convert to bool if possible, or will trigger assert error. */
|
||||
bool asBool() const;
|
||||
bool toBool() const;
|
||||
/** to as a string value. Will convert to string if possible, or will trigger assert error. */
|
||||
std::string toString() const;
|
||||
|
||||
/** Gets as a string value. Will convert to string if possible, or will trigger assert error. */
|
||||
std::string& asString();
|
||||
/** Gets as a string value. Will convert to string if possible, or will trigger assert error. */
|
||||
const std::string& asString() const;
|
||||
/** to as a string value. Will convert to string if possible, or will trigger assert error. */
|
||||
std::string toString() const;
|
||||
const std::string& asStringUnsafe() const;
|
||||
|
||||
/** Gets as a ValueVector reference. Will convert to ValueVector if possible, or will trigger assert error. */
|
||||
ValueVector& asValueVector();
|
||||
|
|
|
@ -73,7 +73,7 @@ int ComAttribute::getInt(const std::string& key, int def) const
|
|||
if (_dict.find(key) != _dict.end())
|
||||
{
|
||||
const cocos2d::Value& v = _dict.at(key);
|
||||
return v.asInt();
|
||||
return v.toInt();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
|
@ -89,7 +89,7 @@ float ComAttribute::getFloat(const std::string& key, float def) const
|
|||
if (_dict.find(key) != _dict.end())
|
||||
{
|
||||
const cocos2d::Value& v = _dict.at(key);
|
||||
return v.asFloat();
|
||||
return v.toFloat();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
|
@ -104,7 +104,7 @@ bool ComAttribute::getBool(const std::string& key, bool def) const
|
|||
if (_dict.find(key) != _dict.end())
|
||||
{
|
||||
const cocos2d::Value& v = _dict.at(key);
|
||||
return v.asBool();
|
||||
return v.toBool();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
|
|
|
@ -158,8 +158,8 @@ cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const
|
|||
keyWidth.append("width");
|
||||
std::string keyHeight = fileName;
|
||||
keyHeight.append("height");
|
||||
float w = _fileDesignSizes.at(keyWidth).asFloat();
|
||||
float h = _fileDesignSizes.at(keyHeight).asFloat();
|
||||
float w = _fileDesignSizes.at(keyWidth).toFloat();
|
||||
float h = _fileDesignSizes.at(keyHeight).toFloat();
|
||||
return Size(w, h);
|
||||
}
|
||||
|
||||
|
|
|
@ -1002,7 +1002,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename
|
|||
if (!dict.empty())
|
||||
{
|
||||
ValueMap& metadata = dict["metadata"].asValueMap();
|
||||
int version = metadata["version"].asInt();
|
||||
int version = metadata["version"].toInt();
|
||||
if (version != 1)
|
||||
{
|
||||
CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %d. Filename: %s", version, filename.c_str());
|
||||
|
|
|
@ -73,22 +73,22 @@ static id convertCCValueToNSObject(const cocos2d::Value &value)
|
|||
return [NSString stringWithCString:value.asString().c_str() encoding:NSUTF8StringEncoding];
|
||||
|
||||
case Value::Type::BYTE:
|
||||
return [NSNumber numberWithInt:value.asByte()];
|
||||
return [NSNumber numberWithInt:value.toByte()];
|
||||
|
||||
case Value::Type::INTEGER:
|
||||
return [NSNumber numberWithInt:value.asInt()];
|
||||
return [NSNumber numberWithInt:value.toInt()];
|
||||
|
||||
case Value::Type::UNSIGNED:
|
||||
return [NSNumber numberWithUnsignedInt:value.asUnsignedInt()];
|
||||
return [NSNumber numberWithUnsignedInt:value.toUnsignedInt()];
|
||||
|
||||
case Value::Type::FLOAT:
|
||||
return [NSNumber numberWithFloat:value.asFloat()];
|
||||
return [NSNumber numberWithFloat:value.toFloat()];
|
||||
|
||||
case Value::Type::DOUBLE:
|
||||
return [NSNumber numberWithDouble:value.asDouble()];
|
||||
return [NSNumber numberWithDouble:value.toDouble()];
|
||||
|
||||
case Value::Type::BOOLEAN:
|
||||
return [NSNumber numberWithBool:value.asBool()];
|
||||
return [NSNumber numberWithBool:value.toBool()];
|
||||
|
||||
case Value::Type::VECTOR: {
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
|
|
|
@ -2758,14 +2758,14 @@ void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue)
|
|||
switch (obj.getType())
|
||||
{
|
||||
case Value::Type::BOOLEAN:
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_pushboolean(L, obj.toBool());
|
||||
break;
|
||||
case Value::Type::FLOAT:
|
||||
case Value::Type::DOUBLE:
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_pushnumber(L, obj.toDouble());
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
lua_pushinteger(L, obj.toInt());
|
||||
break;
|
||||
case Value::Type::STRING:
|
||||
lua_pushstring(L, obj.asString().c_str());
|
||||
|
@ -2799,7 +2799,7 @@ void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue)
|
|||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_pushboolean(L, obj.toBool());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
|
@ -2807,14 +2807,14 @@ void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue)
|
|||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_pushnumber(L, obj.toDouble());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
lua_pushinteger(L, obj.toInt());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
|
@ -2871,7 +2871,7 @@ void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inV
|
|||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_pushboolean(L, obj.toBool());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
|
@ -2879,14 +2879,14 @@ void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inV
|
|||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_pushnumber(L, obj.toDouble());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
lua_pushinteger(L, obj.toInt());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
|
@ -2938,7 +2938,7 @@ void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue)
|
|||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_pushboolean(L, obj.toBool());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
|
@ -2947,7 +2947,7 @@ void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue)
|
|||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_pushnumber(L, obj.toDouble());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
|
@ -2955,7 +2955,7 @@ void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue)
|
|||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushnumber(L, obj.asInt());
|
||||
lua_pushnumber(L, obj.toInt());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
|
|
|
@ -429,16 +429,16 @@ MyXMLVisitor::MyXMLVisitor(RichText* richText)
|
|||
src = tagAttrValueMap.at("src").asString();
|
||||
}
|
||||
if (tagAttrValueMap.find("height") != tagAttrValueMap.end()) {
|
||||
height = tagAttrValueMap.at("height").asInt();
|
||||
height = tagAttrValueMap.at("height").toInt();
|
||||
}
|
||||
if (tagAttrValueMap.find("width") != tagAttrValueMap.end()) {
|
||||
width = tagAttrValueMap.at("width").asInt();
|
||||
width = tagAttrValueMap.at("width").toInt();
|
||||
}
|
||||
if (tagAttrValueMap.find("type") != tagAttrValueMap.end()) {
|
||||
// texture type
|
||||
// 0: normal file path
|
||||
// 1: sprite frame name
|
||||
int type = tagAttrValueMap.at("type").asInt();
|
||||
int type = tagAttrValueMap.at("type").toInt();
|
||||
resType = type == 0 ? Widget::TextureResType::LOCAL : Widget::TextureResType::PLIST;
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ void MyXMLVisitor::startElement(void* /*ctx*/, const char *elementName, const ch
|
|||
Attributes attributes;
|
||||
|
||||
if (attrValueMap.find(RichText::KEY_FONT_SIZE) != attrValueMap.end()) {
|
||||
attributes.fontSize = attrValueMap.at(RichText::KEY_FONT_SIZE).asFloat();
|
||||
attributes.fontSize = attrValueMap.at(RichText::KEY_FONT_SIZE).toFloat();
|
||||
}
|
||||
if (attrValueMap.find(RichText::KEY_FONT_SMALL) != attrValueMap.end()) {
|
||||
attributes.fontSize = getFontSize() * 0.8f;
|
||||
|
@ -711,7 +711,7 @@ void MyXMLVisitor::startElement(void* /*ctx*/, const char *elementName, const ch
|
|||
attributes.outlineColor = _richText->color3BWithString(attrValueMap.at(RichText::KEY_TEXT_OUTLINE_COLOR).asString());
|
||||
}
|
||||
if (attrValueMap.find(RichText::KEY_TEXT_OUTLINE_SIZE) != attrValueMap.end()) {
|
||||
attributes.outlineSize = attrValueMap.at(RichText::KEY_TEXT_OUTLINE_SIZE).asInt();
|
||||
attributes.outlineSize = attrValueMap.at(RichText::KEY_TEXT_OUTLINE_SIZE).toInt();
|
||||
}
|
||||
}
|
||||
else if (keyTextStyle == RichText::VALUE_TEXT_STYLE_SHADOW) {
|
||||
|
@ -721,11 +721,11 @@ void MyXMLVisitor::startElement(void* /*ctx*/, const char *elementName, const ch
|
|||
}
|
||||
if ((attrValueMap.find(RichText::KEY_TEXT_SHADOW_OFFSET_WIDTH) != attrValueMap.end())
|
||||
&& (attrValueMap.find(RichText::KEY_TEXT_SHADOW_OFFSET_HEIGHT) != attrValueMap.end())) {
|
||||
attributes.shadowOffset = Size(attrValueMap.at(RichText::KEY_TEXT_SHADOW_OFFSET_WIDTH).asFloat(),
|
||||
attrValueMap.at(RichText::KEY_TEXT_SHADOW_OFFSET_HEIGHT).asFloat());
|
||||
attributes.shadowOffset = Size(attrValueMap.at(RichText::KEY_TEXT_SHADOW_OFFSET_WIDTH).toFloat(),
|
||||
attrValueMap.at(RichText::KEY_TEXT_SHADOW_OFFSET_HEIGHT).toFloat());
|
||||
}
|
||||
if (attrValueMap.find(RichText::KEY_TEXT_SHADOW_BLUR_RADIUS) != attrValueMap.end()) {
|
||||
attributes.shadowBlurRadius = attrValueMap.at(RichText::KEY_TEXT_SHADOW_BLUR_RADIUS).asInt();
|
||||
attributes.shadowBlurRadius = attrValueMap.at(RichText::KEY_TEXT_SHADOW_BLUR_RADIUS).toInt();
|
||||
}
|
||||
}
|
||||
else if (keyTextStyle == RichText::VALUE_TEXT_STYLE_GLOW) {
|
||||
|
@ -995,12 +995,12 @@ void RichText::removeElement(RichElement *element)
|
|||
|
||||
RichText::WrapMode RichText::getWrapMode() const
|
||||
{
|
||||
return static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).asInt());
|
||||
return static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).toInt());
|
||||
}
|
||||
|
||||
void RichText::setWrapMode(RichText::WrapMode wrapMode)
|
||||
{
|
||||
if (static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).asInt()) != wrapMode)
|
||||
if (static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).toInt()) != wrapMode)
|
||||
{
|
||||
_defaults[KEY_WRAP_MODE] = static_cast<int>(wrapMode);
|
||||
_formatTextDirty = true;
|
||||
|
@ -1009,12 +1009,12 @@ void RichText::setWrapMode(RichText::WrapMode wrapMode)
|
|||
|
||||
RichText::HorizontalAlignment RichText::getHorizontalAlignment() const
|
||||
{
|
||||
return static_cast<RichText::HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).asInt());
|
||||
return static_cast<RichText::HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).toInt());
|
||||
}
|
||||
|
||||
void RichText::setHorizontalAlignment(cocos2d::ui::RichText::HorizontalAlignment a)
|
||||
{
|
||||
if (static_cast<RichText::HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).asInt()) != a)
|
||||
if (static_cast<RichText::HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).toInt()) != a)
|
||||
{
|
||||
_defaults[KEY_HORIZONTAL_ALIGNMENT] = static_cast<int>(a);
|
||||
_formatTextDirty = true;
|
||||
|
@ -1043,7 +1043,7 @@ void RichText::setFontSize(float size)
|
|||
|
||||
float RichText::getFontSize()
|
||||
{
|
||||
return _defaults.at(KEY_FONT_SIZE).asFloat();
|
||||
return _defaults.at(KEY_FONT_SIZE).toFloat();
|
||||
}
|
||||
|
||||
void RichText::setFontFace(const std::string& face)
|
||||
|
@ -1078,7 +1078,7 @@ void RichText::setAnchorTextBold(bool enable)
|
|||
|
||||
bool RichText::isAnchorTextBoldEnabled()
|
||||
{
|
||||
return _defaults[KEY_ANCHOR_TEXT_BOLD].asBool();
|
||||
return _defaults[KEY_ANCHOR_TEXT_BOLD].toBool();
|
||||
}
|
||||
|
||||
void RichText::setAnchorTextItalic(bool enable)
|
||||
|
@ -1088,7 +1088,7 @@ void RichText::setAnchorTextItalic(bool enable)
|
|||
|
||||
bool RichText::isAnchorTextItalicEnabled()
|
||||
{
|
||||
return _defaults[KEY_ANCHOR_TEXT_ITALIC].asBool();
|
||||
return _defaults[KEY_ANCHOR_TEXT_ITALIC].toBool();
|
||||
}
|
||||
|
||||
void RichText::setAnchorTextDel(bool enable)
|
||||
|
@ -1143,7 +1143,7 @@ Color3B RichText::getAnchorTextOutlineColor3B()
|
|||
int RichText::getAnchorTextOutlineSize()
|
||||
{
|
||||
if (_defaults.find(KEY_ANCHOR_TEXT_OUTLINE_SIZE) != _defaults.end()) {
|
||||
return _defaults.at(KEY_ANCHOR_TEXT_OUTLINE_SIZE).asInt();
|
||||
return _defaults.at(KEY_ANCHOR_TEXT_OUTLINE_SIZE).toInt();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -1178,10 +1178,10 @@ Size RichText::getAnchorTextShadowOffset()
|
|||
float width = 2.0f;
|
||||
float height = -2.0f;
|
||||
if (_defaults.find(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH) != _defaults.end()) {
|
||||
width = _defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH).asFloat();
|
||||
width = _defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH).toFloat();
|
||||
}
|
||||
if (_defaults.find(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT) != _defaults.end()) {
|
||||
height = _defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT).asFloat();
|
||||
height = _defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT).toFloat();
|
||||
}
|
||||
return Size(width, height);
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ Size RichText::getAnchorTextShadowOffset()
|
|||
int RichText::getAnchorTextShadowBlurRadius()
|
||||
{
|
||||
if (_defaults.find(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS) != _defaults.end()) {
|
||||
return _defaults.at(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS).asInt();
|
||||
return _defaults.at(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS).toInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1219,19 +1219,19 @@ Color3B RichText::getAnchorTextGlowColor3B()
|
|||
void RichText::setDefaults(const ValueMap& defaults)
|
||||
{
|
||||
if (defaults.find(KEY_VERTICAL_SPACE) != defaults.end()) {
|
||||
_defaults[KEY_VERTICAL_SPACE] = defaults.at(KEY_VERTICAL_SPACE).asFloat();
|
||||
_defaults[KEY_VERTICAL_SPACE] = defaults.at(KEY_VERTICAL_SPACE).toFloat();
|
||||
}
|
||||
if (defaults.find(KEY_WRAP_MODE) != defaults.end()) {
|
||||
_defaults[KEY_WRAP_MODE] = defaults.at(KEY_WRAP_MODE).asInt();
|
||||
_defaults[KEY_WRAP_MODE] = defaults.at(KEY_WRAP_MODE).toInt();
|
||||
}
|
||||
if (defaults.find(KEY_HORIZONTAL_ALIGNMENT) != defaults.end()) {
|
||||
_defaults[KEY_HORIZONTAL_ALIGNMENT] = defaults.at(KEY_HORIZONTAL_ALIGNMENT).asInt();
|
||||
_defaults[KEY_HORIZONTAL_ALIGNMENT] = defaults.at(KEY_HORIZONTAL_ALIGNMENT).toInt();
|
||||
}
|
||||
if (defaults.find(KEY_FONT_COLOR_STRING) != defaults.end()) {
|
||||
_defaults[KEY_FONT_COLOR_STRING] = defaults.at(KEY_FONT_COLOR_STRING).asString();
|
||||
}
|
||||
if (defaults.find(KEY_FONT_SIZE) != defaults.end()) {
|
||||
_defaults[KEY_FONT_SIZE] = defaults.at(KEY_FONT_SIZE).asFloat();
|
||||
_defaults[KEY_FONT_SIZE] = defaults.at(KEY_FONT_SIZE).toFloat();
|
||||
}
|
||||
if (defaults.find(KEY_FONT_FACE) != defaults.end()) {
|
||||
_defaults[KEY_FONT_FACE] = defaults.at(KEY_FONT_FACE).asString();
|
||||
|
@ -1240,10 +1240,10 @@ void RichText::setDefaults(const ValueMap& defaults)
|
|||
_defaults[KEY_ANCHOR_FONT_COLOR_STRING] = defaults.at(KEY_ANCHOR_FONT_COLOR_STRING).asString();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_BOLD) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_BOLD] = defaults.at(KEY_ANCHOR_TEXT_BOLD).asBool();
|
||||
_defaults[KEY_ANCHOR_TEXT_BOLD] = defaults.at(KEY_ANCHOR_TEXT_BOLD).toBool();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_ITALIC) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_ITALIC] = defaults.at(KEY_ANCHOR_TEXT_ITALIC).asBool();
|
||||
_defaults[KEY_ANCHOR_TEXT_ITALIC] = defaults.at(KEY_ANCHOR_TEXT_ITALIC).toBool();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_LINE) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_LINE] = defaults.at(KEY_ANCHOR_TEXT_LINE).asString();
|
||||
|
@ -1255,19 +1255,19 @@ void RichText::setDefaults(const ValueMap& defaults)
|
|||
_defaults[KEY_ANCHOR_TEXT_OUTLINE_COLOR] = defaults.at(KEY_ANCHOR_TEXT_OUTLINE_COLOR).asString();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_OUTLINE_SIZE) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_OUTLINE_SIZE] = defaults.at(KEY_ANCHOR_TEXT_OUTLINE_SIZE).asInt();
|
||||
_defaults[KEY_ANCHOR_TEXT_OUTLINE_SIZE] = defaults.at(KEY_ANCHOR_TEXT_OUTLINE_SIZE).toInt();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_SHADOW_COLOR) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_COLOR] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_COLOR).asString();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH).asFloat();
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH).toFloat();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT).asFloat();
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT).toFloat();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS).asInt();
|
||||
_defaults[KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS] = defaults.at(KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS).toInt();
|
||||
}
|
||||
if (defaults.find(KEY_ANCHOR_TEXT_GLOW_COLOR) != defaults.end()) {
|
||||
_defaults[KEY_ANCHOR_TEXT_GLOW_COLOR] = defaults.at(KEY_ANCHOR_TEXT_GLOW_COLOR).asString();
|
||||
|
@ -1645,7 +1645,7 @@ void RichText::handleTextRenderer(const std::string& text, const std::string& fo
|
|||
const Color3B& glowColor)
|
||||
{
|
||||
bool fileExist = FileUtils::getInstance()->isFileExist(fontName);
|
||||
RichText::WrapMode wrapMode = static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).asInt());
|
||||
RichText::WrapMode wrapMode = static_cast<RichText::WrapMode>(_defaults.at(KEY_WRAP_MODE).toInt());
|
||||
|
||||
// split text by \n
|
||||
std::stringstream ss(text);
|
||||
|
@ -1784,8 +1784,8 @@ void RichText::addNewLine()
|
|||
|
||||
void RichText::formatRenderers()
|
||||
{
|
||||
float verticalSpace = _defaults[KEY_VERTICAL_SPACE].asFloat();
|
||||
float fontSize = _defaults[KEY_FONT_SIZE].asFloat();
|
||||
float verticalSpace = _defaults[KEY_VERTICAL_SPACE].toFloat();
|
||||
float fontSize = _defaults[KEY_FONT_SIZE].toFloat();
|
||||
|
||||
if (_ignoreSize)
|
||||
{
|
||||
|
@ -1890,7 +1890,7 @@ namespace {
|
|||
}
|
||||
|
||||
void RichText::doHorizontalAlignment(const Vector<cocos2d::Node*> &row, float rowWidth) {
|
||||
const auto alignment = static_cast<HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).asInt());
|
||||
const auto alignment = static_cast<HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).toInt());
|
||||
if ( alignment != HorizontalAlignment::LEFT ) {
|
||||
const auto diff = stripTrailingWhitespace(row);
|
||||
const auto leftOver = getContentSize().width - (rowWidth + diff);
|
||||
|
|
|
@ -112,13 +112,13 @@ void ConfigurationDefault::onEnter()
|
|||
else
|
||||
log("1. Test OK!");
|
||||
|
||||
bool b_value = Configuration::getInstance()->getValue("invalid.key", Value(true)).asBool();
|
||||
bool b_value = Configuration::getInstance()->getValue("invalid.key", Value(true)).toBool();
|
||||
if( ! b_value )
|
||||
log("2. Test failed!");
|
||||
else
|
||||
log("2. Test OK!");
|
||||
|
||||
double d_value = Configuration::getInstance()->getValue("invalid.key", Value(42.42)).asDouble();
|
||||
double d_value = Configuration::getInstance()->getValue("invalid.key", Value(42.42)).toDouble();
|
||||
if( d_value != 42.42 )
|
||||
log("3. Test failed!");
|
||||
else
|
||||
|
|
|
@ -817,16 +817,16 @@ void TestWriteValueMap::onEnter()
|
|||
readDataStr += " vectorValue:[2]" + readVectorInMap.at(1).asString() + "\n";
|
||||
|
||||
// read bool data
|
||||
readDataStr += " boolValue:" + StringUtils::format("%d", readValueMap["data3"].asBool()) + "\n";
|
||||
readDataStr += " boolValue:" + StringUtils::format("%d", readValueMap["data3"].toBool()) + "\n";
|
||||
|
||||
// read int data
|
||||
readDataStr += " intValue:" + StringUtils::format("%d", readValueMap["data4"].asInt()) + "\n";
|
||||
readDataStr += " intValue:" + StringUtils::format("%d", readValueMap["data4"].toInt()) + "\n";
|
||||
|
||||
// read float data
|
||||
readDataStr += " floatValue:" + StringUtils::format("%f", readValueMap["data5"].asFloat()) + "\n";
|
||||
readDataStr += " floatValue:" + StringUtils::format("%f", readValueMap["data5"].toFloat()) + "\n";
|
||||
|
||||
// read double data
|
||||
readDataStr += " doubleValue:" + StringUtils::format("%f", readValueMap["data6"].asDouble()) + "\n";
|
||||
readDataStr += " doubleValue:" + StringUtils::format("%f", readValueMap["data6"].toDouble()) + "\n";
|
||||
|
||||
readResult->setString(readDataStr);
|
||||
}
|
||||
|
@ -920,16 +920,16 @@ void TestWriteValueVector::onEnter()
|
|||
readDataStr += " vectorValue:[2]" + readVectorInArray.at(1).asString() + "\n";
|
||||
|
||||
// read bool data
|
||||
readDataStr += " boolValue:" + StringUtils::format("%d", readArray.at(3).asBool()) + "\n";
|
||||
readDataStr += " boolValue:" + StringUtils::format("%d", readArray.at(3).toBool()) + "\n";
|
||||
|
||||
// read int data
|
||||
readDataStr += " intValue:" + StringUtils::format("%d", readArray.at(4).asInt()) + "\n";
|
||||
readDataStr += " intValue:" + StringUtils::format("%d", readArray.at(4).toInt()) + "\n";
|
||||
|
||||
// read float data
|
||||
readDataStr += " floatValue:" + StringUtils::format("%f", readArray.at(5).asFloat()) + "\n";
|
||||
readDataStr += " floatValue:" + StringUtils::format("%f", readArray.at(5).toFloat()) + "\n";
|
||||
|
||||
// read double data
|
||||
readDataStr += " doubleValue:" + StringUtils::format("%f", readArray.at(6).asDouble()) + "\n";
|
||||
readDataStr += " doubleValue:" + StringUtils::format("%f", readArray.at(6).toDouble()) + "\n";
|
||||
|
||||
readResult->setString(readDataStr);
|
||||
}
|
||||
|
|
|
@ -781,10 +781,10 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
Color4F color(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
|
@ -834,10 +834,10 @@ TMXIsoObjectsTest::TMXIsoObjectsTest()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
Color4F color(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
|
@ -1512,10 +1512,10 @@ TMXGIDObjectsTest::TMXGIDObjectsTest()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
|
||||
drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
|
||||
|
|
|
@ -671,10 +671,10 @@ TMXOrthoObjectsTestNew::TMXOrthoObjectsTestNew()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
|
||||
drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
|
||||
|
@ -722,10 +722,10 @@ TMXIsoObjectsTestNew::TMXIsoObjectsTestNew()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
|
||||
drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
|
||||
|
@ -1364,10 +1364,10 @@ TMXGIDObjectsTestNew::TMXGIDObjectsTestNew()
|
|||
{
|
||||
ValueMap& dict = obj.asValueMap();
|
||||
|
||||
float x = dict["x"].asFloat();
|
||||
float y = dict["y"].asFloat();
|
||||
float width = dict["width"].asFloat();
|
||||
float height = dict["height"].asFloat();
|
||||
float x = dict["x"].toFloat();
|
||||
float y = dict["y"].toFloat();
|
||||
float width = dict["width"].toFloat();
|
||||
float height = dict["height"].toFloat();
|
||||
|
||||
drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
|
||||
drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
|
||||
|
|
Loading…
Reference in New Issue