axmol/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp

69 lines
1.8 KiB
C++

#include "TextBMFontReader.h"
#include "ui/UITextBMFont.h"
USING_NS_CC;
using namespace ui;
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<TextBMFont*>(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->setString(text);
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}
}