#include "TextBMFontReader.h" #include "gui/UITextBMFont.h" namespace cocostudio { static TextBMFontReader* instanceTextBMFontReader = NULL; IMPLEMENT_CLASS_WIDGET_READER_INFO(TextBMFontReader) TextBMFontReader::TextBMFontReader() { } TextBMFontReader::~TextBMFontReader() { } TextBMFontReader* TextBMFontReader::getInstance() { if (!instanceTextBMFontReader) { instanceTextBMFontReader = new TextBMFontReader(); } return instanceTextBMFontReader; } void TextBMFontReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) { WidgetReader::setPropsFromJsonDictionary(widget, options); std::string jsonPath = GUIReader::getInstance()->getFilePath(); TextBMFont* labelBMFont = static_cast(widget); const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); switch (cmfType) { case 0: { std::string tp_c = jsonPath; const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); labelBMFont->setFntFile(cmf_tp); break; } case 1: CCLOG("Wrong res type of LabelAtlas!"); break; default: break; } const char* text = DICTOOL->getStringValue_json(options, "text"); labelBMFont->setText(text); WidgetReader::setColorPropsFromJsonDictionary(widget, options); } }