123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- #include "editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.h"
- #include "ui/UICheckBox.h"
- #include "platform/CCFileUtils.h"
- #include "2d/CCSpriteFrameCache.h"
- #include "editor-support/cocostudio/CocoLoader.h"
- #include "editor-support/cocostudio/CSParseBinary_generated.h"
- #include "editor-support/cocostudio/FlatBuffersSerialize.h"
- #include "tinyxml2.h"
- #include "flatbuffers/flatbuffers.h"
- USING_NS_CC;
- using namespace ui;
- using namespace flatbuffers;
- namespace cocostudio
- {
- static const char* P_BackGroundBoxData = "backGroundBoxData";
- static const char* P_BackGroundBoxSelectedData = "backGroundBoxSelectedData";
- static const char* P_FrontCrossData = "frontCrossData";
- static const char* P_BackGroundBoxDisabledData = "backGroundBoxDisabledData";
- static const char* P_FrontCrossDisabledData = "frontCrossDisabledData";
-
- static CheckBoxReader* instanceCheckBoxReader = nullptr;
-
- IMPLEMENT_CLASS_NODE_READER_INFO(CheckBoxReader)
-
- CheckBoxReader::CheckBoxReader()
- {
-
- }
-
- CheckBoxReader::~CheckBoxReader()
- {
-
- }
-
- CheckBoxReader* CheckBoxReader::getInstance()
- {
- if (!instanceCheckBoxReader)
- {
- instanceCheckBoxReader = new (std::nothrow) CheckBoxReader();
- }
- return instanceCheckBoxReader;
- }
-
- void CheckBoxReader::destroyInstance()
- {
- CC_SAFE_DELETE(instanceCheckBoxReader);
- }
-
- void CheckBoxReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *cocoLoader, stExpCocoNode *cocoNode)
- {
-
- CheckBox *checkBox = static_cast<CheckBox*>(widget);
- this->beginSetBasicProperties(widget);
- stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
-
- for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
- std::string key = stChildArray[i].GetName(cocoLoader);
- std::string value = stChildArray[i].GetValue(cocoLoader);
- //read all basic properties of widget
- CC_BASIC_PROPERTY_BINARY_READER
- //read all color related properties of widget
- CC_COLOR_PROPERTY_BINARY_READER
-
- else if (key == P_BackGroundBoxData){
-
- stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
- std::string resType = backGroundChildren[2].GetValue(cocoLoader);
-
- Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
-
- std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
-
- checkBox->loadTextureBackGround(backgroundValue, imageFileNameType);
- }else if(key == P_BackGroundBoxSelectedData){
- stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
- std::string resType = backGroundChildren[2].GetValue(cocoLoader);
-
- Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
-
- std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
-
- checkBox->loadTextureBackGroundSelected(backgroundValue, imageFileNameType);
- }else if(key == P_FrontCrossData){
- stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
- std::string resType = backGroundChildren[2].GetValue(cocoLoader);
-
- Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
-
- std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
-
- checkBox->loadTextureFrontCross(backgroundValue, imageFileNameType);
- }else if(key == P_BackGroundBoxDisabledData){
- stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
- std::string resType = backGroundChildren[2].GetValue(cocoLoader);
-
- Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
-
- std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
-
- checkBox->loadTextureBackGroundDisabled(backgroundValue, imageFileNameType);
- }else if (key == P_FrontCrossDisabledData){
- stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
- std::string resType = backGroundChildren[2].GetValue(cocoLoader);
-
- Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
-
- std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
-
- checkBox->loadTextureFrontCrossDisabled(backgroundValue, imageFileNameType);
- }
- // else if (key == "selectedState"){
- // checkBox->setSelectedState(valueToBool(value));
- // }
- }
-
- this->endSetBasicProperties(widget);
-
-
- }
-
- void CheckBoxReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
- {
- WidgetReader::setPropsFromJsonDictionary(widget, options);
-
- CheckBox* checkBox = static_cast<CheckBox*>(widget);
-
- //load background image
- const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, P_BackGroundBoxData);
- int backGroundType = DICTOOL->getIntValue_json(backGroundDic,P_ResourceType);
- std::string backGroundTexturePath = this->getResourcePath(backGroundDic, P_Path, (Widget::TextureResType)backGroundType);
- checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
-
- //load background selected image
- const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, P_BackGroundBoxSelectedData);
- int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, P_ResourceType);
- std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, P_Path, (Widget::TextureResType)backGroundSelectedType);
- checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
-
- //load frontCross image
- const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, P_FrontCrossData);
- int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, P_ResourceType);
- std::string frontCrossFileName = this->getResourcePath(frontCrossDic, P_Path, (Widget::TextureResType)frontCrossType);
- checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
-
- //load backGroundBoxDisabledData
- const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, P_BackGroundBoxDisabledData);
- int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, P_ResourceType);
- std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, P_Path, (Widget::TextureResType)backGroundDisabledType);
- checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
-
- ///load frontCrossDisabledData
- const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, P_FrontCrossDisabledData);
- int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, P_ResourceType);
- std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, P_Path, (Widget::TextureResType)frontCrossDisabledType);
- checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType);
-
-
- WidgetReader::setColorPropsFromJsonDictionary(widget, options);
- }
-
- Offset<Table> CheckBoxReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
- flatbuffers::FlatBufferBuilder *builder)
- {
- auto temp = WidgetReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
- auto widgetOptions = *(Offset<WidgetOptions>*)(&temp);
-
- bool selectedState = false;
- bool displaystate = true;
-
- int backgroundboxResourceType = 0;
- std::string backgroundboxPath = "";
- std::string backgroundboxPlistFile = "";
-
- int backGroundBoxSelectedResourceType = 0;
- std::string backGroundBoxSelectedPath = "";
- std::string backGroundBoxSelectedPlistFile = "";
-
- int frontCrossResourceType = 0;
- std::string frontCrossPath = "";
- std::string frontCrossPlistFile = "";
-
- int backGroundBoxDisabledResourceType = 0;
- std::string backGroundBoxDisabledPath = "";
- std::string backGroundBoxDisabledPlistFile = "";
-
-
- int frontCrossDisabledResourceType = 0;
- std::string frontCrossDisabledPath = "";
- std::string frontCrossDisabledPlistFile = "";
-
- // attributes
- const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
- while (attribute)
- {
- std::string name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "CheckedState")
- {
- selectedState = (value == "True") ? true : false;
- }
- else if (name == "DisplayState")
- {
- displaystate = (value == "True") ? true : false;
- }
- attribute = attribute->Next();
- }
-
- // child elements
- const tinyxml2::XMLElement* child = objectData->FirstChildElement();
- while (child)
- {
- std::string name = child->Name();
-
- if (name == "NormalBackFileData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child->FirstAttribute();
-
- while (attribute)
- {
- name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "Path")
- {
- backgroundboxPath = value;
- }
- else if (name == "Type")
- {
- backgroundboxResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- backgroundboxPlistFile = value;
- texture = value;
- }
-
- attribute = attribute->Next();
- }
-
- if (backgroundboxResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "PressedBackFileData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child->FirstAttribute();
-
- while (attribute)
- {
- name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "Path")
- {
- backGroundBoxSelectedPath = value;
- }
- else if (name == "Type")
- {
- backGroundBoxSelectedResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- backGroundBoxSelectedPlistFile = value;
- texture = value;
- }
-
- attribute = attribute->Next();
- }
-
- if (backGroundBoxSelectedResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "NodeNormalFileData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child->FirstAttribute();
-
- while (attribute)
- {
- name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "Path")
- {
- frontCrossPath = value;
- }
- else if (name == "Type")
- {
- frontCrossResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- frontCrossPlistFile = value;
- texture = value;
- }
-
- attribute = attribute->Next();
- }
-
- if (frontCrossResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "DisableBackFileData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child->FirstAttribute();
-
- while (attribute)
- {
- name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "Path")
- {
- backGroundBoxDisabledPath = value;
- }
- else if (name == "Type")
- {
- backGroundBoxDisabledResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- backGroundBoxDisabledPlistFile = value;
- texture = value;
- }
-
- attribute = attribute->Next();
- }
-
- if (backGroundBoxDisabledResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
- else if (name == "NodeDisableFileData")
- {
- std::string texture = "";
- std::string texturePng = "";
-
- attribute = child->FirstAttribute();
-
- while (attribute)
- {
- name = attribute->Name();
- std::string value = attribute->Value();
-
- if (name == "Path")
- {
- frontCrossDisabledPath = value;
- }
- else if (name == "Type")
- {
- frontCrossDisabledResourceType = getResourceType(value);
- }
- else if (name == "Plist")
- {
- frontCrossDisabledPlistFile = value;
- texture = value;
- }
-
- attribute = attribute->Next();
- }
-
- if (frontCrossDisabledResourceType == 1)
- {
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- fbs->_textures.push_back(builder->CreateString(texture));
- }
- }
-
- child = child->NextSiblingElement();
- }
-
- auto options = CreateCheckBoxOptions(*builder,
- widgetOptions,
- CreateResourceData(*builder,
- builder->CreateString(backgroundboxPath),
- builder->CreateString(backgroundboxPlistFile),
- backgroundboxResourceType),
- CreateResourceData(*builder,
- builder->CreateString(backGroundBoxSelectedPath),
- builder->CreateString(backGroundBoxSelectedPlistFile),
- backGroundBoxSelectedResourceType),
- CreateResourceData(*builder,
- builder->CreateString(frontCrossPath),
- builder->CreateString(frontCrossPlistFile),
- frontCrossResourceType),
- CreateResourceData(*builder,
- builder->CreateString(backGroundBoxDisabledPath),
- builder->CreateString(backGroundBoxDisabledPlistFile),
- backGroundBoxDisabledResourceType),
- CreateResourceData(*builder,
- builder->CreateString(frontCrossDisabledPath),
- builder->CreateString(frontCrossDisabledPlistFile),
- frontCrossDisabledResourceType),
- selectedState,
- displaystate
- );
-
- return *(Offset<Table>*)&options;
- }
-
- void CheckBoxReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *checkBoxOptions)
- {
-
-
- auto options = (CheckBoxOptions*)checkBoxOptions;
-
- CheckBox* checkBox = static_cast<CheckBox*>(node);
-
- //load background image
- bool backGroundFileExist = false;
- std::string backGroundErrorFilePath = "";
- auto backGroundDic = options->backGroundBoxData();
- int backGroundType = backGroundDic->resourceType();
- std::string backGroundTexturePath = backGroundDic->path()->c_str();
- 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);
- }
-
- //load background selected image
- bool backGroundSelectedfileExist = false;
- std::string backGroundSelectedErrorFilePath = "";
- auto backGroundSelectedDic = options->backGroundBoxSelectedData();
- int backGroundSelectedType = backGroundSelectedDic->resourceType();
- std::string backGroundSelectedTexturePath = backGroundSelectedDic->path()->c_str();
- 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);
- }
-
- //load frontCross image
- bool frontCrossFileExist = false;
- std::string frontCrossErrorFilePath = "";
- auto frontCrossDic = options->frontCrossData();
- int frontCrossType = frontCrossDic->resourceType();
- std::string frontCrossFileName = frontCrossDic->path()->c_str();
- 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);
- }
-
- //load backGroundBoxDisabledData
- bool backGroundBoxDisabledFileExist = false;
- std::string backGroundBoxDisabledErrorFilePath = "";
- auto backGroundDisabledDic = options->backGroundBoxDisabledData();
- int backGroundDisabledType = backGroundDisabledDic->resourceType();
- std::string backGroundDisabledFileName = backGroundDisabledDic->path()->c_str();
- 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);
- }
-
- ///load frontCrossDisabledData
- bool frontCrossDisabledFileExist = false;
- std::string frontCrossDisabledErrorFilePath = "";
- auto frontCrossDisabledDic = options->frontCrossDisabledData();
- int frontCrossDisabledType = frontCrossDisabledDic->resourceType();
- std::string frontCrossDisabledFileName = frontCrossDisabledDic->path()->c_str();
- 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);
- }
-
- bool selectedstate = options->selectedState() != 0;
- checkBox->setSelected(selectedstate);
-
- bool displaystate = options->displaystate() != 0;
- checkBox->setBright(displaystate);
- checkBox->setEnabled(displaystate);
-
-
- auto widgetReader = WidgetReader::getInstance();
- widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
-
- }
-
- Node* CheckBoxReader::createNodeWithFlatBuffers(const flatbuffers::Table *checkBoxOptions)
- {
- CheckBox* checkBox = CheckBox::create();
-
- setPropsWithFlatBuffers(checkBox, (Table*)checkBoxOptions);
-
- return checkBox;
- }
- int CheckBoxReader::getResourceType(std::string key)
- {
- if(key == "Normal" || key == "Default")
- {
- return 0;
- }
-
- FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
- if(fbs->_isSimulator)
- {
- if(key == "MarkedSubImage")
- {
- return 0;
- }
- }
- return 1;
- }
- }
|