mirror of https://github.com/axmolengine/axmol.git
Update that avoid crash during load resource which serialize by flat buffers
This commit is contained in:
parent
e7fc2a5607
commit
79acf80fb1
|
@ -547,21 +547,195 @@ namespace cocostudio
|
||||||
bool scale9Enabled = options->scale9Enabled();
|
bool scale9Enabled = options->scale9Enabled();
|
||||||
button->setScale9Enabled(scale9Enabled);
|
button->setScale9Enabled(scale9Enabled);
|
||||||
|
|
||||||
|
bool normalFileExist = false;
|
||||||
|
std::string normalErrorFilePath = "";
|
||||||
auto normalDic = options->normalData();
|
auto normalDic = options->normalData();
|
||||||
int normalType = normalDic->resourceType();
|
int normalType = normalDic->resourceType();
|
||||||
std::string normalTexturePath = normalDic->path()->c_str();
|
std::string normalTexturePath = this->getResourcePath(normalDic->path()->c_str(), (Widget::TextureResType)normalType);
|
||||||
button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType);
|
switch (normalType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if (FileUtils::getInstance()->isFileExist(normalTexturePath))
|
||||||
|
{
|
||||||
|
normalFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalErrorFilePath = normalTexturePath;
|
||||||
|
normalFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = normalDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(normalTexturePath);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
normalFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
normalErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
normalFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (normalFileExist)
|
||||||
|
{
|
||||||
|
button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", normalErrorFilePath.c_str())->getCString());
|
||||||
|
button->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pressedFileExist = false;
|
||||||
|
std::string pressedErrorFilePath = "";
|
||||||
auto pressedDic = options->pressedData();
|
auto pressedDic = options->pressedData();
|
||||||
int pressedType = pressedDic->resourceType();
|
int pressedType = pressedDic->resourceType();
|
||||||
std::string pressedTexturePath = pressedDic->path()->c_str();
|
std::string pressedTexturePath = this->getResourcePath(pressedDic->path()->c_str(), (Widget::TextureResType)pressedType);
|
||||||
button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType);
|
switch (pressedType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(pressedTexturePath))
|
||||||
|
{
|
||||||
|
pressedFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = pressedTexturePath;
|
||||||
|
pressedFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = pressedDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pressedTexturePath);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
pressedFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
pressedFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pressedFileExist)
|
||||||
|
{
|
||||||
|
button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", pressedErrorFilePath.c_str())->getCString());
|
||||||
|
button->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool disabledFileExist = false;
|
||||||
|
std::string disabledErrorFilePath = "";
|
||||||
auto disabledDic = options->disabledData();
|
auto disabledDic = options->disabledData();
|
||||||
int disabledType = disabledDic->resourceType();
|
int disabledType = disabledDic->resourceType();
|
||||||
std::string disabledTexturePath = disabledDic->path()->c_str();
|
std::string disabledTexturePath = this->getResourcePath(disabledDic->path()->c_str(), (Widget::TextureResType)disabledType);
|
||||||
|
switch (disabledType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(disabledTexturePath))
|
||||||
|
{
|
||||||
|
disabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = disabledTexturePath;
|
||||||
|
disabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = disabledDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(disabledTexturePath);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
disabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
disabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (disabledFileExist)
|
||||||
|
{
|
||||||
button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType);
|
button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", disabledErrorFilePath.c_str())->getCString());
|
||||||
|
button->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
std::string titleText = options->text()->c_str();
|
std::string titleText = options->text()->c_str();
|
||||||
button->setTitleText(titleText);
|
button->setTitleText(titleText);
|
||||||
|
@ -577,11 +751,31 @@ namespace cocostudio
|
||||||
button->setTitleFontName(titleFontName);
|
button->setTitleFontName(titleFontName);
|
||||||
|
|
||||||
auto resourceData = options->fontResource();
|
auto resourceData = options->fontResource();
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
std::string path = resourceData->path()->c_str();
|
std::string path = resourceData->path()->c_str();
|
||||||
if (path != "")
|
if (path != "")
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
{
|
{
|
||||||
button->setTitleFontName(path);
|
button->setTitleFontName(path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
button->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool displaystate = options->displaystate();
|
bool displaystate = options->displaystate();
|
||||||
button->setBright(displaystate);
|
button->setBright(displaystate);
|
||||||
|
|
|
@ -429,34 +429,329 @@ namespace cocostudio
|
||||||
CheckBox* checkBox = static_cast<CheckBox*>(node);
|
CheckBox* checkBox = static_cast<CheckBox*>(node);
|
||||||
|
|
||||||
//load background image
|
//load background image
|
||||||
|
bool backGroundFileExist = false;
|
||||||
|
std::string backGroundErrorFilePath = "";
|
||||||
auto backGroundDic = options->backGroundBoxData();
|
auto backGroundDic = options->backGroundBoxData();
|
||||||
int backGroundType = backGroundDic->resourceType();
|
int backGroundType = backGroundDic->resourceType();
|
||||||
std::string backGroundTexturePath = backGroundDic->path()->c_str();
|
std::string backGroundTexturePath = this->getResourcePath(backGroundDic->path()->c_str(), (Widget::TextureResType)backGroundType);
|
||||||
|
switch (backGroundType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(backGroundTexturePath))
|
||||||
|
{
|
||||||
|
backGroundFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundErrorFilePath = backGroundTexturePath;
|
||||||
|
backGroundFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = backGroundDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundTexturePath);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
backGroundFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
backGroundErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
backGroundFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (backGroundFileExist)
|
||||||
|
{
|
||||||
checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
|
checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", backGroundErrorFilePath.c_str())->getCString());
|
||||||
|
checkBox->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//load background selected image
|
//load background selected image
|
||||||
|
bool backGroundSelectedfileExist = false;
|
||||||
|
std::string backGroundSelectedErrorFilePath = "";
|
||||||
auto backGroundSelectedDic = options->backGroundBoxSelectedData();
|
auto backGroundSelectedDic = options->backGroundBoxSelectedData();
|
||||||
int backGroundSelectedType = backGroundSelectedDic->resourceType();
|
int backGroundSelectedType = backGroundSelectedDic->resourceType();
|
||||||
std::string backGroundSelectedTexturePath = backGroundSelectedDic->path()->c_str();
|
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic->path()->c_str(), (Widget::TextureResType)backGroundSelectedType);
|
||||||
|
switch (backGroundSelectedType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(backGroundSelectedTexturePath))
|
||||||
|
{
|
||||||
|
backGroundSelectedfileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundSelectedErrorFilePath = backGroundSelectedTexturePath;
|
||||||
|
backGroundSelectedfileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = backGroundSelectedDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundSelectedTexturePath);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
backGroundSelectedfileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
backGroundSelectedErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundSelectedErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
backGroundSelectedfileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (backGroundSelectedfileExist)
|
||||||
|
{
|
||||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
|
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", backGroundSelectedErrorFilePath.c_str())->getCString());
|
||||||
|
checkBox->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//load frontCross image
|
//load frontCross image
|
||||||
|
bool frontCrossFileExist = false;
|
||||||
|
std::string frontCrossErrorFilePath = "";
|
||||||
auto frontCrossDic = options->frontCrossData();
|
auto frontCrossDic = options->frontCrossData();
|
||||||
int frontCrossType = frontCrossDic->resourceType();
|
int frontCrossType = frontCrossDic->resourceType();
|
||||||
std::string frontCrossFileName = frontCrossDic->path()->c_str();
|
std::string frontCrossFileName = this->getResourcePath(frontCrossDic->path()->c_str(), (Widget::TextureResType)frontCrossType);
|
||||||
|
switch (frontCrossType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(frontCrossFileName))
|
||||||
|
{
|
||||||
|
frontCrossFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frontCrossErrorFilePath = frontCrossFileName;
|
||||||
|
frontCrossFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = frontCrossDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(frontCrossFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
frontCrossFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
frontCrossErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frontCrossErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
frontCrossFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (frontCrossFileExist)
|
||||||
|
{
|
||||||
checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
|
checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", frontCrossErrorFilePath.c_str())->getCString());
|
||||||
|
checkBox->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//load backGroundBoxDisabledData
|
//load backGroundBoxDisabledData
|
||||||
|
bool backGroundBoxDisabledFileExist = false;
|
||||||
|
std::string backGroundBoxDisabledErrorFilePath = "";
|
||||||
auto backGroundDisabledDic = options->backGroundBoxDisabledData();
|
auto backGroundDisabledDic = options->backGroundBoxDisabledData();
|
||||||
int backGroundDisabledType = backGroundDisabledDic->resourceType();
|
int backGroundDisabledType = backGroundDisabledDic->resourceType();
|
||||||
std::string backGroundDisabledFileName = backGroundDisabledDic->path()->c_str();
|
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic->path()->c_str(), (Widget::TextureResType)backGroundDisabledType);
|
||||||
|
switch (backGroundDisabledType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(backGroundDisabledFileName))
|
||||||
|
{
|
||||||
|
backGroundBoxDisabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundBoxDisabledErrorFilePath = backGroundDisabledFileName;
|
||||||
|
backGroundBoxDisabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = backGroundDisabledDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundDisabledFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
backGroundBoxDisabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
backGroundBoxDisabledErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backGroundBoxDisabledErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
backGroundBoxDisabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (backGroundBoxDisabledFileExist)
|
||||||
|
{
|
||||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
|
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", backGroundBoxDisabledErrorFilePath.c_str())->getCString());
|
||||||
|
checkBox->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
///load frontCrossDisabledData
|
///load frontCrossDisabledData
|
||||||
|
bool frontCrossDisabledFileExist = false;
|
||||||
|
std::string frontCrossDisabledErrorFilePath = "";
|
||||||
auto frontCrossDisabledDic = options->frontCrossDisabledData();
|
auto frontCrossDisabledDic = options->frontCrossDisabledData();
|
||||||
int frontCrossDisabledType = frontCrossDisabledDic->resourceType();
|
int frontCrossDisabledType = frontCrossDisabledDic->resourceType();
|
||||||
std::string frontCrossDisabledFileName = frontCrossDisabledDic->path()->c_str();
|
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic->path()->c_str(), (Widget::TextureResType)frontCrossDisabledType);
|
||||||
|
switch (frontCrossDisabledType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(frontCrossDisabledFileName))
|
||||||
|
{
|
||||||
|
frontCrossDisabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frontCrossDisabledErrorFilePath = frontCrossDisabledFileName;
|
||||||
|
frontCrossDisabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = frontCrossDisabledDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(frontCrossDisabledFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
frontCrossDisabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
frontCrossDisabledErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frontCrossDisabledErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
frontCrossDisabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (frontCrossDisabledFileExist)
|
||||||
|
{
|
||||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType);
|
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", frontCrossDisabledErrorFilePath.c_str())->getCString());
|
||||||
|
checkBox->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
bool selectedstate = options->selectedState();
|
bool selectedstate = options->selectedState();
|
||||||
checkBox->setSelected(selectedstate);
|
checkBox->setSelected(selectedstate);
|
||||||
|
|
|
@ -134,17 +134,22 @@ namespace cocostudio
|
||||||
auto options = (GameMapOptions*)gameMapOptions;
|
auto options = (GameMapOptions*)gameMapOptions;
|
||||||
auto fileNameData = options->fileNameData();
|
auto fileNameData = options->fileNameData();
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
|
std::string path = fileNameData->path()->c_str();
|
||||||
int resourceType = fileNameData->resourceType();
|
int resourceType = fileNameData->resourceType();
|
||||||
switch (resourceType)
|
switch (resourceType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
std::string path = fileNameData->path()->c_str();
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
const char* tmxFile = path.c_str();
|
|
||||||
|
|
||||||
if (tmxFile && strcmp("", tmxFile) != 0)
|
|
||||||
{
|
{
|
||||||
tmx = TMXTiledMap::create(tmxFile);
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -152,11 +157,23 @@ namespace cocostudio
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
|
tmx = TMXTiledMap::create(path);
|
||||||
if (tmx)
|
if (tmx)
|
||||||
{
|
{
|
||||||
setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions);
|
setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Node* node = Node::create();
|
||||||
|
setPropsWithFlatBuffers(node, (Table*)gameMapOptions);
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
node->addChild(label);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
return tmx;
|
return tmx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,10 +291,69 @@ namespace cocostudio
|
||||||
auto options = (ImageViewOptions*)imageViewOptions;
|
auto options = (ImageViewOptions*)imageViewOptions;
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->fileNameData();
|
auto imageFileNameDic = options->fileNameData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
imageView->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
bool scale9Enabled = options->scale9Enabled();
|
bool scale9Enabled = options->scale9Enabled();
|
||||||
imageView->setScale9Enabled(scale9Enabled);
|
imageView->setScale9Enabled(scale9Enabled);
|
||||||
|
|
|
@ -598,10 +598,72 @@ namespace cocostudio
|
||||||
panel->setBackGroundColorOpacity(bgColorOpacity);
|
panel->setBackGroundColorOpacity(bgColorOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->backGroundImageData();
|
auto imageFileNameDic = options->backGroundImageData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
|
if (imageFileName != "")
|
||||||
|
{
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
panel->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetOptions = options->widgetOptions();
|
auto widgetOptions = options->widgetOptions();
|
||||||
auto f_color = widgetOptions->color();
|
auto f_color = widgetOptions->color();
|
||||||
|
@ -614,6 +676,7 @@ namespace cocostudio
|
||||||
auto widgetReader = WidgetReader::getInstance();
|
auto widgetReader = WidgetReader::getInstance();
|
||||||
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
||||||
|
|
||||||
|
|
||||||
if (backGroundScale9Enabled)
|
if (backGroundScale9Enabled)
|
||||||
{
|
{
|
||||||
auto f_capInsets = options->capInsets();
|
auto f_capInsets = options->capInsets();
|
||||||
|
|
|
@ -426,10 +426,72 @@ namespace cocostudio
|
||||||
listView->setBackGroundColorOpacity(bgColorOpacity);
|
listView->setBackGroundColorOpacity(bgColorOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->backGroundImageData();
|
auto imageFileNameDic = options->backGroundImageData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = imageFileNameDic->path()->c_str();
|
||||||
|
if (imageFileName != "")
|
||||||
|
{
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
listView->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetOptions = options->widgetOptions();
|
auto widgetOptions = options->widgetOptions();
|
||||||
auto f_color = widgetOptions->color();
|
auto f_color = widgetOptions->color();
|
||||||
|
@ -442,9 +504,15 @@ namespace cocostudio
|
||||||
auto f_innerSize = options->innerSize();
|
auto f_innerSize = options->innerSize();
|
||||||
Size innerSize(f_innerSize->width(), f_innerSize->height());
|
Size innerSize(f_innerSize->width(), f_innerSize->height());
|
||||||
listView->setInnerContainerSize(innerSize);
|
listView->setInnerContainerSize(innerSize);
|
||||||
|
// int direction = options->direction();
|
||||||
|
// listView->setDirection((ScrollView::Direction)direction);
|
||||||
bool bounceEnabled = options->bounceEnabled();
|
bool bounceEnabled = options->bounceEnabled();
|
||||||
listView->setBounceEnabled(bounceEnabled);
|
listView->setBounceEnabled(bounceEnabled);
|
||||||
|
|
||||||
|
// int gravityValue = options->gravity();
|
||||||
|
// ListView::Gravity gravity = (ListView::Gravity)gravityValue;
|
||||||
|
// listView->setGravity(gravity);
|
||||||
|
|
||||||
std::string directionType = options->directionType()->c_str();
|
std::string directionType = options->directionType()->c_str();
|
||||||
if (directionType == "")
|
if (directionType == "")
|
||||||
{
|
{
|
||||||
|
@ -499,7 +567,6 @@ namespace cocostudio
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto widgetOptions = options->widgetOptions();
|
|
||||||
if (!listView->isIgnoreContentAdaptWithSize())
|
if (!listView->isIgnoreContentAdaptWithSize())
|
||||||
{
|
{
|
||||||
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
||||||
|
|
|
@ -241,10 +241,69 @@ namespace cocostudio
|
||||||
LoadingBar* loadingBar = static_cast<LoadingBar*>(node);
|
LoadingBar* loadingBar = static_cast<LoadingBar*>(node);
|
||||||
auto options = (LoadingBarOptions*)loadingBarOptions;
|
auto options = (LoadingBarOptions*)loadingBarOptions;
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->textureData();
|
auto imageFileNameDic = options->textureData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
loadingBar->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
int direction = options->direction();
|
int direction = options->direction();
|
||||||
loadingBar->setDirection(LoadingBar::Direction(direction));
|
loadingBar->setDirection(LoadingBar::Direction(direction));
|
||||||
|
|
|
@ -339,11 +339,72 @@ namespace cocostudio
|
||||||
pageView->setBackGroundColorOpacity(bgColorOpacity);
|
pageView->setBackGroundColorOpacity(bgColorOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->backGroundImageData();
|
auto imageFileNameDic = options->backGroundImageData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
pageView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
if (imageFileName != "")
|
||||||
|
{
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
|
pageView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
pageView->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetOptions = options->widgetOptions();
|
auto widgetOptions = options->widgetOptions();
|
||||||
auto f_color = widgetOptions->color();
|
auto f_color = widgetOptions->color();
|
||||||
|
|
|
@ -134,15 +134,22 @@ namespace cocostudio
|
||||||
auto options = (ParticleSystemOptions*)particleOptions;
|
auto options = (ParticleSystemOptions*)particleOptions;
|
||||||
auto fileNameData = options->fileNameData();
|
auto fileNameData = options->fileNameData();
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
|
std::string path = fileNameData->path()->c_str();
|
||||||
int resourceType = fileNameData->resourceType();
|
int resourceType = fileNameData->resourceType();
|
||||||
switch (resourceType)
|
switch (resourceType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
std::string path = fileNameData->path()->c_str();
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
if (path != "")
|
|
||||||
{
|
{
|
||||||
particle = ParticleSystemQuad::create(path);
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -150,11 +157,23 @@ namespace cocostudio
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
|
particle = ParticleSystemQuad::create(path);
|
||||||
if (particle)
|
if (particle)
|
||||||
{
|
{
|
||||||
setPropsWithFlatBuffers(particle, (Table*)particleOptions);
|
setPropsWithFlatBuffers(particle, (Table*)particleOptions);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Node* node = Node::create();
|
||||||
|
setPropsWithFlatBuffers(node, (Table*)particleOptions);
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
node->addChild(label);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,10 +425,72 @@ namespace cocostudio
|
||||||
scrollView->setBackGroundColorOpacity(bgColorOpacity);
|
scrollView->setBackGroundColorOpacity(bgColorOpacity);
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto imageFileNameDic = options->backGroundImageData();
|
auto imageFileNameDic = options->backGroundImageData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
|
if (imageFileName != "")
|
||||||
|
{
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = imageFileName;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
scrollView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
scrollView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
scrollView->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetOptions = options->widgetOptions();
|
auto widgetOptions = options->widgetOptions();
|
||||||
auto f_color = widgetOptions->color();
|
auto f_color = widgetOptions->color();
|
||||||
|
|
|
@ -463,34 +463,329 @@ namespace cocostudio
|
||||||
int percent = options->percent();
|
int percent = options->percent();
|
||||||
slider->setPercent(percent);
|
slider->setPercent(percent);
|
||||||
|
|
||||||
|
bool imageFileExist = false;
|
||||||
|
std::string imageErrorFilePath = "";
|
||||||
auto imageFileNameDic = options->barFileNameData();
|
auto imageFileNameDic = options->barFileNameData();
|
||||||
int imageFileNameType = imageFileNameDic->resourceType();
|
int imageFileNameType = imageFileNameDic->resourceType();
|
||||||
std::string imageFileName = imageFileNameDic->path()->c_str();
|
std::string imageFileName = this->getResourcePath(imageFileNameDic->path()->c_str(), (Widget::TextureResType)imageFileNameType);
|
||||||
|
switch (imageFileNameType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
||||||
|
{
|
||||||
|
imageFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageErrorFilePath = imageFileName;
|
||||||
|
imageFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = imageFileNameDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
imageFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
imageErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
imageFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (imageFileExist)
|
||||||
|
{
|
||||||
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", imageErrorFilePath.c_str())->getCString());
|
||||||
|
slider->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//loading normal slider ball texture
|
//loading normal slider ball texture
|
||||||
|
bool normalFileExist = false;
|
||||||
|
std::string normalErrorFilePath = "";
|
||||||
auto normalDic = options->ballNormalData();
|
auto normalDic = options->ballNormalData();
|
||||||
int normalType = normalDic->resourceType();
|
int normalType = normalDic->resourceType();
|
||||||
std::string normalFileName = normalDic->path()->c_str();
|
std::string normalFileName = this->getResourcePath(normalDic->path()->c_str(), (Widget::TextureResType)normalType);
|
||||||
|
switch (normalType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(normalFileName))
|
||||||
|
{
|
||||||
|
normalFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalErrorFilePath = normalFileName;
|
||||||
|
normalFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = normalDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(normalFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
normalFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
normalErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
normalFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (normalFileExist)
|
||||||
|
{
|
||||||
slider->loadSlidBallTextureNormal(normalFileName, (Widget::TextureResType)normalType);
|
slider->loadSlidBallTextureNormal(normalFileName, (Widget::TextureResType)normalType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", normalErrorFilePath.c_str())->getCString());
|
||||||
|
slider->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//loading slider ball press texture
|
//loading slider ball press texture
|
||||||
|
bool pressedFileExist = false;
|
||||||
|
std::string pressedErrorFilePath = "";
|
||||||
auto pressedDic = options->ballPressedData();
|
auto pressedDic = options->ballPressedData();
|
||||||
int pressedType = pressedDic->resourceType();
|
int pressedType = pressedDic->resourceType();
|
||||||
std::string pressedFileName = pressedDic->path()->c_str();
|
std::string pressedFileName = this->getResourcePath(pressedDic->path()->c_str(), (Widget::TextureResType)pressedType);
|
||||||
|
switch (pressedType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(pressedFileName))
|
||||||
|
{
|
||||||
|
pressedFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = pressedFileName;
|
||||||
|
pressedFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = pressedDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pressedFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
pressedFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pressedErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
pressedFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pressedFileExist)
|
||||||
|
{
|
||||||
slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType);
|
slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", pressedErrorFilePath.c_str())->getCString());
|
||||||
|
slider->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//loading silder ball disable texture
|
//loading silder ball disable texture
|
||||||
|
bool disabledFileExist = false;
|
||||||
|
std::string disabledErrorFilePath = "";
|
||||||
auto disabledDic = options->ballDisabledData();
|
auto disabledDic = options->ballDisabledData();
|
||||||
int disabledType = disabledDic->resourceType();
|
int disabledType = disabledDic->resourceType();
|
||||||
std::string disabledFileName = disabledDic->path()->c_str();
|
std::string disabledFileName = this->getResourcePath(disabledDic->path()->c_str(), (Widget::TextureResType)disabledType);
|
||||||
|
switch (disabledType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(disabledFileName))
|
||||||
|
{
|
||||||
|
disabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = disabledFileName;
|
||||||
|
disabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = disabledDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(disabledFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
disabledFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disabledErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
disabledFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (disabledFileExist)
|
||||||
|
{
|
||||||
slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType);
|
slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", disabledErrorFilePath.c_str())->getCString());
|
||||||
|
slider->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
//load slider progress texture
|
//load slider progress texture
|
||||||
|
bool progressFileExist = false;
|
||||||
|
std::string progressErrorFilePath = "";
|
||||||
auto progressBarDic = options->progressBarData();
|
auto progressBarDic = options->progressBarData();
|
||||||
int progressBarType = progressBarDic->resourceType();
|
int progressBarType = progressBarDic->resourceType();
|
||||||
std::string progressBarFileName = progressBarDic->path()->c_str();
|
std::string progressBarFileName = this->getResourcePath(progressBarDic->path()->c_str(), (Widget::TextureResType)progressBarType);
|
||||||
|
switch (progressBarType)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(progressBarFileName))
|
||||||
|
{
|
||||||
|
progressFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressErrorFilePath = progressBarFileName;
|
||||||
|
progressFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
std::string plist = progressBarDic->plistFile()->c_str();
|
||||||
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(progressBarFileName);
|
||||||
|
if (spriteFrame)
|
||||||
|
{
|
||||||
|
progressFileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
progressErrorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
progressErrorFilePath = plist;
|
||||||
|
}
|
||||||
|
progressFileExist = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (progressFileExist)
|
||||||
|
{
|
||||||
slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType);
|
slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", progressErrorFilePath.c_str())->getCString());
|
||||||
|
slider->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
bool displaystate = options->displaystate();
|
bool displaystate = options->displaystate();
|
||||||
slider->setBright(displaystate);
|
slider->setBright(displaystate);
|
||||||
|
|
|
@ -141,24 +141,54 @@ namespace cocostudio
|
||||||
auto fileNameData = options->fileNameData();
|
auto fileNameData = options->fileNameData();
|
||||||
|
|
||||||
int resourceType = fileNameData->resourceType();
|
int resourceType = fileNameData->resourceType();
|
||||||
|
std::string path = fileNameData->path()->c_str();
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
|
|
||||||
switch (resourceType)
|
switch (resourceType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
std::string path = fileNameData->path()->c_str();
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
if (path != "")
|
|
||||||
{
|
{
|
||||||
sprite->setTexture(path);
|
sprite->setTexture(path);
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
std::string path = fileNameData->path()->c_str();
|
std::string plist = fileNameData->plistFile()->c_str();
|
||||||
if (path != "")
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
|
||||||
|
if (spriteFrame)
|
||||||
{
|
{
|
||||||
sprite->setSpriteFrame(path);
|
sprite->setSpriteFrame(spriteFrame);
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(plist))
|
||||||
|
{
|
||||||
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
||||||
|
ValueMap metadata = value["metadata"].asValueMap();
|
||||||
|
std::string textureFileName = metadata["textureFileName"].asString();
|
||||||
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
||||||
|
{
|
||||||
|
errorFilePath = textureFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = plist;
|
||||||
|
}
|
||||||
|
fileExist = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +196,12 @@ namespace cocostudio
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!fileExist)
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
sprite->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto nodeReader = NodeReader::getInstance();
|
auto nodeReader = NodeReader::getInstance();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "TextBMFontReader.h"
|
#include "TextBMFontReader.h"
|
||||||
|
|
||||||
|
#include "2d/CCFontAtlasCache.h"
|
||||||
#include "ui/UITextBMFont.h"
|
#include "ui/UITextBMFont.h"
|
||||||
#include "cocostudio/CocoLoader.h"
|
#include "cocostudio/CocoLoader.h"
|
||||||
#include "cocostudio/CSParseBinary_generated.h"
|
#include "cocostudio/CSParseBinary_generated.h"
|
||||||
|
@ -190,23 +191,50 @@ namespace cocostudio
|
||||||
auto options = (TextBMFontOptions*)textBMFontOptions;
|
auto options = (TextBMFontOptions*)textBMFontOptions;
|
||||||
|
|
||||||
auto cmftDic = options->fileNameData();
|
auto cmftDic = options->fileNameData();
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
|
std::string errorContent = "";
|
||||||
|
std::string path = cmftDic->path()->c_str();
|
||||||
int cmfType = cmftDic->resourceType();
|
int cmfType = cmftDic->resourceType();
|
||||||
switch (cmfType)
|
switch (cmfType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
const char* cmfPath = cmftDic->path()->c_str();
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
labelBMFont->setFntFile(cmfPath);
|
{
|
||||||
|
FontAtlas* newAtlas = FontAtlasCache::getFontAtlasFNT(path);
|
||||||
|
if (newAtlas)
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorContent = "has problem";
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorContent = "missed";
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1:
|
|
||||||
CCLOG("Wrong res type of LabelAtlas!");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (fileExist)
|
||||||
|
{
|
||||||
|
labelBMFont->setFntFile(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s %s", errorFilePath.c_str(), errorContent.c_str())->getCString());
|
||||||
|
labelBMFont->addChild(label);
|
||||||
|
}
|
||||||
|
|
||||||
std::string text = options->text()->c_str();
|
std::string text = options->text()->c_str();
|
||||||
labelBMFont->setString(text);
|
labelBMFont->setString(text);
|
||||||
|
|
|
@ -303,12 +303,32 @@ namespace cocostudio
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto resourceData = options->fontResource();
|
auto resourceData = options->fontResource();
|
||||||
std::string path = resourceData->path()->c_str();
|
std::string path = resourceData->path()->c_str();
|
||||||
if (path != "")
|
if (path != "")
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
{
|
{
|
||||||
textField->setFontName(path);
|
textField->setFontName(path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto label = Label::create();
|
||||||
|
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
textField->addChild(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetReader = WidgetReader::getInstance();
|
auto widgetReader = WidgetReader::getInstance();
|
||||||
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
||||||
|
@ -323,6 +343,8 @@ namespace cocostudio
|
||||||
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
||||||
textField->setContentSize(contentSize);
|
textField->setContentSize(contentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* TextFieldReader::createNodeWithFlatBuffers(const flatbuffers::Table *textFieldOptions)
|
Node* TextFieldReader::createNodeWithFlatBuffers(const flatbuffers::Table *textFieldOptions)
|
||||||
|
|
|
@ -294,6 +294,7 @@ namespace cocostudio
|
||||||
|
|
||||||
bool touchScaleEnabled = options->touchScaleEnable();
|
bool touchScaleEnabled = options->touchScaleEnable();
|
||||||
label->setTouchScaleChangeEnabled(touchScaleEnabled);
|
label->setTouchScaleChangeEnabled(touchScaleEnabled);
|
||||||
|
|
||||||
std::string text = options->text()->c_str();
|
std::string text = options->text()->c_str();
|
||||||
label->setString(text);
|
label->setString(text);
|
||||||
|
|
||||||
|
@ -315,12 +316,32 @@ namespace cocostudio
|
||||||
TextVAlignment v_alignment = (TextVAlignment)options->vAlignment();
|
TextVAlignment v_alignment = (TextVAlignment)options->vAlignment();
|
||||||
label->setTextVerticalAlignment((TextVAlignment)v_alignment);
|
label->setTextVerticalAlignment((TextVAlignment)v_alignment);
|
||||||
|
|
||||||
|
bool fileExist = false;
|
||||||
|
std::string errorFilePath = "";
|
||||||
auto resourceData = options->fontResource();
|
auto resourceData = options->fontResource();
|
||||||
std::string path = resourceData->path()->c_str();
|
std::string path = resourceData->path()->c_str();
|
||||||
if (path != "")
|
if (path != "")
|
||||||
|
{
|
||||||
|
if (FileUtils::getInstance()->isFileExist(path))
|
||||||
|
{
|
||||||
|
fileExist = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorFilePath = path;
|
||||||
|
fileExist = false;
|
||||||
|
}
|
||||||
|
if (fileExist)
|
||||||
{
|
{
|
||||||
label->setFontName(path);
|
label->setFontName(path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto alert = Label::create();
|
||||||
|
alert->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
|
||||||
|
label->addChild(alert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widgetReader = WidgetReader::getInstance();
|
auto widgetReader = WidgetReader::getInstance();
|
||||||
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
||||||
|
@ -336,6 +357,7 @@ namespace cocostudio
|
||||||
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
Size contentSize(widgetOptions->size()->width(), widgetOptions->size()->height());
|
||||||
label->setContentSize(contentSize);
|
label->setContentSize(contentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* TextReader::createNodeWithFlatBuffers(const flatbuffers::Table *textOptions)
|
Node* TextReader::createNodeWithFlatBuffers(const flatbuffers::Table *textOptions)
|
||||||
|
|
Loading…
Reference in New Issue