Beispiel #1
0
 void TextAtlasReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *textAtlasOptions)
 {
     TextAtlas* labelAtlas = static_cast<TextAtlas*>(node);
     auto options = (TextAtlasOptions*)textAtlasOptions;
     
     auto cmftDic = options->charMapFileData();
     int cmfType = cmftDic->resourceType();
     switch (cmfType)
     {
         case 0:
         {
             const char* cmfPath = cmftDic->path()->c_str();
             
             bool fileExist = false;
             std::string errorFilePath = "";
             
             if (FileUtils::getInstance()->isFileExist(cmfPath))
             {
                 fileExist = true;
                 
                 std::string stringValue = options->stringValue()->c_str();
                 int itemWidth = options->itemWidth();
                 int itemHeight = options->itemHeight();
                 labelAtlas->setProperty(stringValue,
                                         cmfPath,
                                         itemWidth,
                                         itemHeight,
                                         options->startCharMap()->c_str());
             }
             else
             {
                 errorFilePath = cmfPath;
                 fileExist = false;
             }
             
             //if (!fileExist)
             //{
             //    auto label = Label::create();
             //    label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
             //    labelAtlas->addChild(label);
             //}
             break;
         }
             
         case 1:
             CCLOG("Wrong res type of LabelAtlas!");
             break;
             
         default:
             break;
     }
     
     auto widgetReader = WidgetReader::getInstance();
     widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
     
     labelAtlas->ignoreContentAdaptWithSize(true);
     
 }