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

69 lines
1.8 KiB
C++
Raw Normal View History

2014-03-04 16:51:35 +08:00
#include "TextBMFontReader.h"
#include "gui/UITextBMFont.h"
2014-03-06 16:15:03 +08:00
USING_NS_CC;
using namespace ui;
2014-03-04 16:51:35 +08:00
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->setText(text);
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}
}