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

73 lines
2.4 KiB
C++
Raw Normal View History

2014-03-04 16:51:35 +08:00
#include "LoadingBarReader.h"
2014-03-11 17:13:54 +08:00
#include "ui/UILoadingBar.h"
2014-03-04 16:51:35 +08:00
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 LoadingBarReader* instanceLoadingBar = NULL;
IMPLEMENT_CLASS_WIDGET_READER_INFO(LoadingBarReader)
LoadingBarReader::LoadingBarReader()
{
}
LoadingBarReader::~LoadingBarReader()
{
}
LoadingBarReader* LoadingBarReader::getInstance()
{
if (!instanceLoadingBar)
{
instanceLoadingBar = new LoadingBarReader();
}
return instanceLoadingBar;
}
void LoadingBarReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
WidgetReader::setPropsFromJsonDictionary(widget, options);
LoadingBar* loadingBar = static_cast<LoadingBar*>(widget);
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData");
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
2014-04-04 17:25:20 +08:00
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
loadingBar->loadTexture(imageFileName, (TextureResType)imageFileNameType);
2014-03-04 16:51:35 +08:00
/* gui mark add load bar scale9 parse */
bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
loadingBar->setScale9Enabled(scale9Enable);
if (scale9Enable)
{
float cx = DICTOOL->getFloatValue_json(options, "capInsetsX");
float cy = DICTOOL->getFloatValue_json(options, "capInsetsY");
float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth");
float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight");
loadingBar->setCapInsets(Rect(cx, cy, cw, ch));
float width = DICTOOL->getFloatValue_json(options, "width");
float height = DICTOOL->getFloatValue_json(options, "height");
loadingBar->setSize(Size(width, height));
}
/**/
loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction")));
loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent"));
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}
}