2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.h"
|
2014-11-21 15:15:38 +08:00
|
|
|
|
2014-03-11 17:13:54 +08:00
|
|
|
#include "ui/UISlider.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "2d/CCSpriteFrameCache.h"
|
|
|
|
#include "platform/CCFileUtils.h"
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "editor-support/cocostudio/CocoLoader.h"
|
|
|
|
#include "editor-support/cocostudio/CSParseBinary_generated.h"
|
|
|
|
#include "editor-support/cocostudio/FlatBuffersSerialize.h"
|
2014-11-21 15:15:38 +08:00
|
|
|
|
|
|
|
#include "flatbuffers/flatbuffers.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-03-06 16:15:03 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
using namespace ui;
|
2014-11-21 15:15:38 +08:00
|
|
|
using namespace flatbuffers;
|
2014-03-06 16:15:03 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
namespace cocostudio
|
|
|
|
{
|
2014-06-19 17:04:14 +08:00
|
|
|
static const char* P_Scale9Enable = "scale9Enable";
|
|
|
|
static const char* P_Percent = "percent";
|
|
|
|
static const char* P_BarFileNameData = "barFileNameData";
|
|
|
|
static const char* P_Length = "length";
|
|
|
|
static const char* P_BallNormalData = "ballNormalData";
|
|
|
|
static const char* P_BallPressedData = "ballPressedData";
|
|
|
|
static const char* P_BallDisabledData = "ballDisabledData";
|
|
|
|
static const char* P_ProgressBarData = "progressBarData";
|
|
|
|
|
2014-07-10 00:45:27 +08:00
|
|
|
static SliderReader* instanceSliderReader = nullptr;
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
IMPLEMENT_CLASS_NODE_READER_INFO(SliderReader)
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
SliderReader::SliderReader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SliderReader::~SliderReader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SliderReader* SliderReader::getInstance()
|
|
|
|
{
|
|
|
|
if (!instanceSliderReader)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
instanceSliderReader = new (std::nothrow) SliderReader();
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
return instanceSliderReader;
|
|
|
|
}
|
|
|
|
|
2015-03-30 16:46:33 +08:00
|
|
|
void SliderReader::destroyInstance()
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(instanceSliderReader);
|
|
|
|
}
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
void SliderReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *cocoLoader, stExpCocoNode* cocoNode)
|
2014-06-05 10:25:08 +08:00
|
|
|
{
|
2014-06-11 09:35:24 +08:00
|
|
|
this->beginSetBasicProperties(widget);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Slider* slider = static_cast<Slider*>(widget);
|
2019-11-24 23:15:56 +08:00
|
|
|
|
2014-06-05 10:25:08 +08:00
|
|
|
float barLength = 0.0f;
|
2014-06-18 14:44:00 +08:00
|
|
|
int percent = slider->getPercent();
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
|
|
|
std::string key = stChildArray[i].GetName(cocoLoader);
|
2014-07-01 16:31:17 +08:00
|
|
|
std::string value = stChildArray[i].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-19 15:16:56 +08:00
|
|
|
//read all basic properties of widget
|
|
|
|
CC_BASIC_PROPERTY_BINARY_READER
|
|
|
|
//read all color related properties of widget
|
|
|
|
CC_COLOR_PROPERTY_BINARY_READER
|
2014-06-11 09:35:24 +08:00
|
|
|
|
|
|
|
//control custom properties
|
2014-06-19 17:04:14 +08:00
|
|
|
else if (key == P_Scale9Enable) {
|
2014-06-05 10:25:08 +08:00
|
|
|
slider->setScale9Enabled(valueToBool(value));
|
|
|
|
}
|
2014-06-19 17:04:14 +08:00
|
|
|
else if(key == P_Percent){
|
2014-06-18 14:44:00 +08:00
|
|
|
percent = valueToInt(value);
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_BarFileNameData){
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
2016-09-12 09:45:34 +08:00
|
|
|
std::string resType = backGroundChildren[2].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
|
2019-11-24 23:15:56 +08:00
|
|
|
auto fileData = cocos2d::wext::makeResourceData(std::move(backgroundValue), (int)imageFileNameType);
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, fileData, 0);
|
|
|
|
slider->loadBarTexture(fileData.file, imageFileNameType);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_Length){
|
2014-06-05 10:25:08 +08:00
|
|
|
barLength = valueToFloat(value);
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_BallNormalData){
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
2016-09-12 09:45:34 +08:00
|
|
|
std::string resType = backGroundChildren[2].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
|
2019-11-24 23:15:56 +08:00
|
|
|
auto fileData = cocos2d::wext::makeResourceData(std::move(backgroundValue), (int)imageFileNameType);
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, fileData, 1);
|
|
|
|
slider->loadSlidBallTextureNormal(fileData.file, imageFileNameType);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_BallPressedData){
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
2016-09-12 09:45:34 +08:00
|
|
|
std::string resType = backGroundChildren[2].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
|
2019-11-24 23:15:56 +08:00
|
|
|
auto fileData = cocos2d::wext::makeResourceData(std::move(backgroundValue), (int)imageFileNameType);
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, fileData, 2);
|
|
|
|
slider->loadSlidBallTexturePressed(fileData.file, imageFileNameType);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_BallDisabledData){
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
2016-09-12 09:45:34 +08:00
|
|
|
std::string resType = backGroundChildren[2].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
|
2019-11-24 23:15:56 +08:00
|
|
|
auto fileData = cocos2d::wext::makeResourceData(std::move(backgroundValue), (int)imageFileNameType);
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, fileData, 3);
|
|
|
|
slider->loadSlidBallTextureDisabled(fileData.file, imageFileNameType);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
}else if(key == P_ProgressBarData){
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
2016-09-12 09:45:34 +08:00
|
|
|
std::string resType = backGroundChildren[2].GetValue(cocoLoader);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
|
|
|
|
2014-06-23 10:02:09 +08:00
|
|
|
std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);
|
2019-11-24 23:15:56 +08:00
|
|
|
auto fileData = cocos2d::wext::makeResourceData(std::move(backgroundValue), (int)imageFileNameType);
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, fileData, 4);
|
|
|
|
slider->loadProgressBarTexture(fileData.file, imageFileNameType);
|
2014-06-05 10:25:08 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} //end of for loop
|
|
|
|
|
|
|
|
if (slider->isScale9Enabled()) {
|
2014-07-10 00:45:27 +08:00
|
|
|
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
2014-06-05 10:25:08 +08:00
|
|
|
}
|
2014-06-18 14:44:00 +08:00
|
|
|
slider->setPercent(percent);
|
2014-06-11 09:35:24 +08:00
|
|
|
|
|
|
|
this->endSetBasicProperties(widget);
|
2014-06-05 10:25:08 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
void SliderReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
|
|
|
{
|
|
|
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
|
|
|
|
2014-04-04 17:35:15 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
Slider* slider = static_cast<Slider*>(widget);
|
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
|
2014-03-04 16:51:35 +08:00
|
|
|
slider->setScale9Enabled(barTextureScale9Enable);
|
2014-04-04 17:35:15 +08:00
|
|
|
|
2014-06-19 17:04:14 +08:00
|
|
|
slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
|
2014-04-04 17:35:15 +08:00
|
|
|
|
|
|
|
|
2014-07-01 14:01:27 +08:00
|
|
|
// bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
|
2014-07-01 10:57:12 +08:00
|
|
|
float barLength = DICTOOL->getFloatValue_json(options, P_Length,290);
|
2014-07-01 14:01:27 +08:00
|
|
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
|
|
|
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
|
|
|
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
|
|
|
|
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
2014-04-04 17:35:15 +08:00
|
|
|
|
2014-07-01 14:01:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (barTextureScale9Enable)
|
|
|
|
{
|
|
|
|
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
|
2014-04-04 17:35:15 +08:00
|
|
|
//loading normal slider ball texture
|
2014-06-19 17:04:14 +08:00
|
|
|
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData);
|
|
|
|
int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType);
|
2014-07-01 14:01:27 +08:00
|
|
|
imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
|
2014-05-09 14:56:05 +08:00
|
|
|
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);
|
2014-04-04 17:35:15 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-04-04 17:35:15 +08:00
|
|
|
//loading slider ball press texture
|
2014-06-19 17:04:14 +08:00
|
|
|
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, P_BallPressedData);
|
|
|
|
int pressedType = DICTOOL->getIntValue_json(pressedDic, P_ResourceType);
|
|
|
|
std::string pressedFileName = this->getResourcePath(pressedDic, P_Path, (Widget::TextureResType)pressedType);
|
2014-05-09 14:56:05 +08:00
|
|
|
slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType);
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2016-10-17 10:12:54 +08:00
|
|
|
//loading slider ball disable texture
|
2014-06-19 17:04:14 +08:00
|
|
|
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, P_BallDisabledData);
|
|
|
|
int disabledType = DICTOOL->getIntValue_json(disabledDic, P_ResourceType);
|
|
|
|
std::string disabledFileName = this->getResourcePath(disabledDic, P_Path, (Widget::TextureResType)disabledType);
|
2014-05-09 14:56:05 +08:00
|
|
|
slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType);
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-04-04 17:35:15 +08:00
|
|
|
//load slider progress texture
|
2014-06-19 17:04:14 +08:00
|
|
|
const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, P_ProgressBarData);
|
|
|
|
int progressBarType = DICTOOL->getIntValue_json(progressBarDic, P_ResourceType);
|
|
|
|
std::string progressBarFileName = this->getResourcePath(progressBarDic, P_Path, (Widget::TextureResType)progressBarType);
|
2014-05-09 14:56:05 +08:00
|
|
|
slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType);
|
2014-04-04 17:35:15 +08:00
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
2014-12-01 12:46:29 +08:00
|
|
|
}
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
Offset<Table> SliderReader::createOptionsWithFlatBuffers(pugi::xml_node objectData,
|
2014-11-21 15:15:38 +08:00
|
|
|
flatbuffers::FlatBufferBuilder *builder)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
auto temp = WidgetReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
|
|
|
|
auto widgetOptions = *(Offset<WidgetOptions>*)(&temp);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string barFileNamePath = "";
|
|
|
|
std::string barFileNamePlistFile = "";
|
|
|
|
int barFileNameResourceType = 0;
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string ballNormalPath = "";
|
|
|
|
std::string ballNormalPlistFile = "";
|
|
|
|
int ballNormalResourceType = 0;
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string ballPressedPath = "";
|
|
|
|
std::string ballPressedPlistFile = "";
|
|
|
|
int ballPressedResourceType = 0;
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string ballDisabledPath = "";
|
|
|
|
std::string ballDisabledPlistFile = "";
|
|
|
|
int ballDisabledResourceType = 0;
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string progressBarPath = "";
|
|
|
|
std::string progressBarPlistFile = "";
|
|
|
|
int progressBarResourceType = 0;
|
|
|
|
|
2014-12-01 19:58:48 +08:00
|
|
|
int percent = 0;
|
2014-11-21 15:15:38 +08:00
|
|
|
bool displaystate = true;
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
// attributes
|
2019-11-24 23:15:56 +08:00
|
|
|
auto attribute = objectData.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (name == "PercentInfo")
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
|
|
|
percent = atoi(value.c_str());
|
|
|
|
}
|
|
|
|
else if (name == "DisplayState")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
displaystate = (value == "True") ? true : false;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// child elements
|
2019-11-24 23:15:56 +08:00
|
|
|
auto child = objectData.first_child();
|
2014-10-09 18:28:09 +08:00
|
|
|
while (child)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string name = child.name();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "BackGroundData")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string texture = "";
|
|
|
|
std::string texturePng = "";
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
barFileNamePath = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
barFileNameResourceType = getResourceType(value);
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
barFileNamePlistFile = value;
|
|
|
|
texture = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (barFileNameResourceType == 1)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
fbs->_textures.push_back(builder->CreateString(texture));
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "BallNormalData")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string texture = "";
|
|
|
|
std::string texturePng = "";
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballNormalPath = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballNormalResourceType = getResourceType(value);
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballNormalPlistFile = value;
|
|
|
|
texture = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (ballNormalResourceType == 1)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
fbs->_textures.push_back(builder->CreateString(texture));
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "BallPressedData")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string texture = "";
|
|
|
|
std::string texturePng = "";
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballPressedPath = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballPressedResourceType = getResourceType(value);
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballPressedPlistFile = value;
|
|
|
|
texture = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (ballPressedResourceType == 1)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
fbs->_textures.push_back(builder->CreateString(texture));
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "BallDisabledData")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string texture = "";
|
|
|
|
std::string texturePng = "";
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballDisabledPath = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballDisabledResourceType = getResourceType(value);
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
ballDisabledPlistFile = value;
|
2014-12-11 19:15:04 +08:00
|
|
|
texture = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (ballDisabledResourceType == 1)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
fbs->_textures.push_back(builder->CreateString(texture));
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "ProgressBarData")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
std::string texture = "";
|
|
|
|
std::string texturePng = "";
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
progressBarPath = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
progressBarResourceType = getResourceType(value);
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
progressBarPlistFile = value;
|
2014-12-11 19:15:04 +08:00
|
|
|
texture = value;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
if (progressBarResourceType == 1)
|
2014-10-09 18:28:09 +08:00
|
|
|
{
|
2014-11-21 15:15:38 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2014-12-11 19:15:04 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(texture));
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
auto options = CreateSliderOptions(*builder,
|
|
|
|
widgetOptions,
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(barFileNamePath),
|
|
|
|
builder->CreateString(barFileNamePlistFile),
|
|
|
|
barFileNameResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(ballNormalPath),
|
|
|
|
builder->CreateString(ballNormalPlistFile),
|
|
|
|
ballNormalResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(ballPressedPath),
|
|
|
|
builder->CreateString(ballPressedPlistFile),
|
|
|
|
ballPressedResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(ballDisabledPath),
|
|
|
|
builder->CreateString(ballDisabledPlistFile),
|
|
|
|
ballDisabledResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(progressBarPath),
|
|
|
|
builder->CreateString(progressBarPlistFile),
|
|
|
|
progressBarResourceType),
|
|
|
|
percent,
|
|
|
|
displaystate);
|
|
|
|
|
|
|
|
return *(Offset<Table>*)(&options);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SliderReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *sliderOptions)
|
|
|
|
{
|
|
|
|
Slider* slider = static_cast<Slider*>(node);
|
2019-11-24 23:15:56 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
auto options = (SliderOptions*)sliderOptions;
|
|
|
|
|
|
|
|
int percent = options->percent();
|
2015-07-10 17:00:16 +08:00
|
|
|
//slider->setPercent(percent);
|
2014-11-21 15:15:38 +08:00
|
|
|
|
2014-12-17 19:00:24 +08:00
|
|
|
bool imageFileExist = false;
|
|
|
|
std::string imageErrorFilePath = "";
|
2019-11-24 23:15:56 +08:00
|
|
|
auto imageFileNameDic = cocos2d::wext::makeResourceData(options->barFileNameData());
|
|
|
|
int imageFileNameType = imageFileNameDic.type;
|
|
|
|
std::string& imageFileName = imageFileNameDic.file;
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, imageFileNameDic, 0);
|
2014-12-17 19:00:24 +08:00
|
|
|
switch (imageFileNameType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(imageFileName))
|
|
|
|
{
|
|
|
|
imageFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imageErrorFilePath = imageFileName;
|
|
|
|
imageFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string plist = imageFileNameDic.plist;
|
2014-12-17 19:00:24 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
|
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
imageFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
|
|
|
{
|
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
imageErrorFilePath = textureFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imageErrorFilePath = plist;
|
|
|
|
}
|
|
|
|
imageFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (imageFileExist)
|
|
|
|
{
|
|
|
|
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
|
|
|
}
|
2015-05-22 18:21:59 +08:00
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// auto label = Label::create();
|
|
|
|
// label->setString(__String::createWithFormat("%s missed", imageErrorFilePath.c_str())->getCString());
|
|
|
|
// slider->addChild(label);
|
|
|
|
//}
|
2014-11-21 15:15:38 +08:00
|
|
|
|
|
|
|
//loading normal slider ball texture
|
2014-12-17 19:00:24 +08:00
|
|
|
bool normalFileExist = false;
|
|
|
|
std::string normalErrorFilePath = "";
|
2019-11-24 23:15:56 +08:00
|
|
|
auto normalDic = cocos2d::wext::makeResourceData(options->ballNormalData());
|
|
|
|
int normalType = normalDic.type;
|
|
|
|
std::string& normalFileName = normalDic.file;
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, normalDic, 1);
|
2014-12-17 19:00:24 +08:00
|
|
|
switch (normalType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(normalFileName))
|
|
|
|
{
|
|
|
|
normalFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
normalErrorFilePath = normalFileName;
|
|
|
|
normalFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string plist = normalDic.plist;
|
2014-12-17 19:00:24 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(normalFileName);
|
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
normalFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
|
|
|
{
|
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
normalErrorFilePath = textureFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
normalErrorFilePath = plist;
|
|
|
|
}
|
|
|
|
normalFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (normalFileExist)
|
|
|
|
{
|
|
|
|
slider->loadSlidBallTextureNormal(normalFileName, (Widget::TextureResType)normalType);
|
|
|
|
}
|
2015-05-22 18:21:59 +08:00
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// auto label = Label::create();
|
|
|
|
// label->setString(__String::createWithFormat("%s missed", normalErrorFilePath.c_str())->getCString());
|
|
|
|
// slider->addChild(label);
|
|
|
|
//}
|
2014-11-21 15:15:38 +08:00
|
|
|
|
|
|
|
//loading slider ball press texture
|
2014-12-17 19:00:24 +08:00
|
|
|
bool pressedFileExist = false;
|
|
|
|
std::string pressedErrorFilePath = "";
|
2019-11-24 23:15:56 +08:00
|
|
|
auto pressedDic = cocos2d::wext::makeResourceData(options->ballPressedData());
|
|
|
|
int pressedType = pressedDic.type;
|
|
|
|
std::string& pressedFileName = pressedDic.file;
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, pressedDic, 2);
|
2014-12-17 19:00:24 +08:00
|
|
|
switch (pressedType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(pressedFileName))
|
|
|
|
{
|
|
|
|
pressedFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pressedErrorFilePath = pressedFileName;
|
|
|
|
pressedFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string plist = pressedDic.plist;
|
2014-12-17 19:00:24 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pressedFileName);
|
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
pressedFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
|
|
|
{
|
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
pressedErrorFilePath = textureFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pressedErrorFilePath = plist;
|
|
|
|
}
|
|
|
|
pressedFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pressedFileExist)
|
|
|
|
{
|
|
|
|
slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType);
|
|
|
|
}
|
2015-05-22 18:21:59 +08:00
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// auto label = Label::create();
|
|
|
|
// label->setString(__String::createWithFormat("%s missed", pressedErrorFilePath.c_str())->getCString());
|
|
|
|
// slider->addChild(label);
|
|
|
|
//}
|
2014-11-21 15:15:38 +08:00
|
|
|
|
2016-10-17 10:12:54 +08:00
|
|
|
//loading slider ball disable texture
|
2014-12-17 19:00:24 +08:00
|
|
|
bool disabledFileExist = false;
|
|
|
|
std::string disabledErrorFilePath = "";
|
2019-11-24 23:15:56 +08:00
|
|
|
auto disabledDic = cocos2d::wext::makeResourceData(options->ballDisabledData());
|
|
|
|
int disabledType = disabledDic.type;
|
|
|
|
std::string& disabledFileName = disabledDic.file;
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, disabledDic, 3);
|
2014-12-17 19:00:24 +08:00
|
|
|
switch (disabledType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(disabledFileName))
|
|
|
|
{
|
|
|
|
disabledFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
disabledErrorFilePath = disabledFileName;
|
|
|
|
disabledFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string plist = disabledDic.plist;
|
2014-12-17 19:00:24 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(disabledFileName);
|
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
disabledFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
|
|
|
{
|
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
disabledErrorFilePath = textureFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
disabledErrorFilePath = plist;
|
|
|
|
}
|
|
|
|
disabledFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (disabledFileExist)
|
|
|
|
{
|
|
|
|
slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType);
|
|
|
|
}
|
2015-05-22 18:21:59 +08:00
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// auto label = Label::create();
|
|
|
|
// label->setString(__String::createWithFormat("%s missed", disabledErrorFilePath.c_str())->getCString());
|
|
|
|
// slider->addChild(label);
|
|
|
|
//}
|
2014-11-21 15:15:38 +08:00
|
|
|
|
|
|
|
//load slider progress texture
|
2014-12-17 19:00:24 +08:00
|
|
|
bool progressFileExist = false;
|
|
|
|
std::string progressErrorFilePath = "";
|
2019-11-24 23:15:56 +08:00
|
|
|
auto progressBarDic = cocos2d::wext::makeResourceData(options->progressBarData());
|
|
|
|
int progressBarType = progressBarDic.type;
|
|
|
|
std::string& progressBarFileName = progressBarDic.file;
|
|
|
|
cocos2d::wext::onBeforeLoadObjectAsset(slider, progressBarDic, 4);
|
2014-12-17 19:00:24 +08:00
|
|
|
switch (progressBarType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(progressBarFileName))
|
|
|
|
{
|
|
|
|
progressFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
progressErrorFilePath = progressBarFileName;
|
|
|
|
progressFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string plist = progressBarDic.plist;
|
2014-12-17 19:00:24 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(progressBarFileName);
|
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
progressFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
|
|
|
{
|
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
progressErrorFilePath = textureFileName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
progressErrorFilePath = plist;
|
|
|
|
}
|
|
|
|
progressFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (progressFileExist)
|
|
|
|
{
|
|
|
|
slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType);
|
|
|
|
}
|
2015-05-22 18:21:59 +08:00
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// auto label = Label::create();
|
|
|
|
// label->setString(__String::createWithFormat("%s missed", progressErrorFilePath.c_str())->getCString());
|
|
|
|
// slider->addChild(label);
|
|
|
|
//}
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2015-01-23 09:02:33 +08:00
|
|
|
bool displaystate = options->displaystate() != 0;
|
2014-12-04 20:38:46 +08:00
|
|
|
slider->setBright(displaystate);
|
|
|
|
slider->setEnabled(displaystate);
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
auto widgetReader = WidgetReader::getInstance();
|
|
|
|
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
|
2015-07-10 17:00:16 +08:00
|
|
|
slider->setPercent(percent);
|
2014-11-21 15:15:38 +08:00
|
|
|
}
|
|
|
|
|
2014-11-26 11:50:42 +08:00
|
|
|
Node* SliderReader::createNodeWithFlatBuffers(const flatbuffers::Table *sliderOptions)
|
2014-11-21 15:15:38 +08:00
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
Slider* slider = wext::aSlider(); // Slider::create();
|
2014-10-09 18:28:09 +08:00
|
|
|
|
2014-11-21 15:15:38 +08:00
|
|
|
setPropsWithFlatBuffers(slider, (Table*)sliderOptions);
|
|
|
|
|
|
|
|
return slider;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SliderReader::getResourceType(std::string key)
|
|
|
|
{
|
|
|
|
if(key == "Normal" || key == "Default")
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
if(fbs->_isSimulator)
|
|
|
|
{
|
|
|
|
if(key == "MarkedSubImage")
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
2014-10-09 18:28:09 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|