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

75 lines
3.4 KiB
C++
Raw Normal View History

2014-03-04 16:51:35 +08:00
#include "CheckBoxReader.h"
2014-03-11 17:13:54 +08:00
#include "ui/UICheckBox.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 CheckBoxReader* instanceCheckBoxReader = NULL;
IMPLEMENT_CLASS_WIDGET_READER_INFO(CheckBoxReader)
CheckBoxReader::CheckBoxReader()
{
}
CheckBoxReader::~CheckBoxReader()
{
}
CheckBoxReader* CheckBoxReader::getInstance()
{
if (!instanceCheckBoxReader)
{
instanceCheckBoxReader = new CheckBoxReader();
}
return instanceCheckBoxReader;
}
void CheckBoxReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
WidgetReader::setPropsFromJsonDictionary(widget, options);
CheckBox* checkBox = static_cast<CheckBox*>(widget);
2014-04-04 17:12:47 +08:00
//load background image
2014-03-04 16:51:35 +08:00
const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData");
int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType");
2014-04-04 17:12:47 +08:00
std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (TextureResType)backGroundType);
checkBox->loadTextureBackGround(backGroundTexturePath, (TextureResType)backGroundType);
2014-03-04 16:51:35 +08:00
2014-04-04 17:12:47 +08:00
//load background selected image
2014-03-04 16:51:35 +08:00
const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData");
int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType");
2014-04-04 17:12:47 +08:00
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (TextureResType)backGroundSelectedType);
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (TextureResType)backGroundSelectedType);
2014-03-04 16:51:35 +08:00
2014-04-04 17:12:47 +08:00
//load frontCross image
2014-03-04 16:51:35 +08:00
const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData");
int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType");
2014-04-04 17:12:47 +08:00
std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (TextureResType)frontCrossType);
checkBox->loadTextureFrontCross(frontCrossFileName, (TextureResType)frontCrossType);
2014-03-04 16:51:35 +08:00
2014-04-04 17:12:47 +08:00
//load backGroundBoxDisabledData
2014-03-04 16:51:35 +08:00
const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData");
int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType");
2014-04-04 17:12:47 +08:00
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (TextureResType)backGroundDisabledType);
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (TextureResType)backGroundDisabledType);
2014-03-04 16:51:35 +08:00
2014-04-04 17:12:47 +08:00
///load frontCrossDisabledData
2014-03-04 16:51:35 +08:00
const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData");
int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType");
2014-04-04 17:12:47 +08:00
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (TextureResType)frontCrossDisabledType);
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (TextureResType)frontCrossDisabledType);
2014-03-04 16:51:35 +08:00
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}
}