mirror of https://github.com/axmolengine/axmol.git
issue #5057, refactor TextureResType to strong typed enum
This commit is contained in:
parent
57ce0ee2cf
commit
6a7277c38f
|
@ -48,22 +48,22 @@ namespace cocostudio
|
|||
|
||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData");
|
||||
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
||||
std::string normalTexturePath = this->getResourcePath(normalDic, "path", (TextureResType)normalType);
|
||||
button->loadTextureNormal(normalTexturePath, (TextureResType)normalType);
|
||||
std::string normalTexturePath = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType);
|
||||
button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType);
|
||||
|
||||
|
||||
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData");
|
||||
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
||||
|
||||
std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType);
|
||||
button->loadTexturePressed(pressedTexturePath, (TextureResType)pressedType);
|
||||
std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType);
|
||||
button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType);
|
||||
|
||||
|
||||
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData");
|
||||
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
||||
|
||||
std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType);
|
||||
button->loadTextureDisabled(disabledTexturePath, (TextureResType)disabledType);
|
||||
std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType);
|
||||
button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType);
|
||||
|
||||
if (scale9Enable)
|
||||
{
|
||||
|
|
|
@ -41,32 +41,32 @@ namespace cocostudio
|
|||
//load background image
|
||||
const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData");
|
||||
int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType");
|
||||
std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (TextureResType)backGroundType);
|
||||
checkBox->loadTextureBackGround(backGroundTexturePath, (TextureResType)backGroundType);
|
||||
std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (Widget::TextureResType)backGroundType);
|
||||
checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
|
||||
|
||||
//load background selected image
|
||||
const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData");
|
||||
int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType");
|
||||
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (TextureResType)backGroundSelectedType);
|
||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (TextureResType)backGroundSelectedType);
|
||||
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (Widget::TextureResType)backGroundSelectedType);
|
||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
|
||||
|
||||
//load frontCross image
|
||||
const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData");
|
||||
int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType");
|
||||
std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (TextureResType)frontCrossType);
|
||||
checkBox->loadTextureFrontCross(frontCrossFileName, (TextureResType)frontCrossType);
|
||||
std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (Widget::TextureResType)frontCrossType);
|
||||
checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
|
||||
|
||||
//load backGroundBoxDisabledData
|
||||
const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData");
|
||||
int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType");
|
||||
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (TextureResType)backGroundDisabledType);
|
||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (TextureResType)backGroundDisabledType);
|
||||
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (Widget::TextureResType)backGroundDisabledType);
|
||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
|
||||
|
||||
///load frontCrossDisabledData
|
||||
const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData");
|
||||
int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType");
|
||||
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (TextureResType)frontCrossDisabledType);
|
||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (TextureResType)frontCrossDisabledType);
|
||||
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (Widget::TextureResType)frontCrossDisabledType);
|
||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType);
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
|
|
|
@ -41,8 +41,8 @@ namespace cocostudio
|
|||
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData");
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||
imageView->loadTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType);
|
||||
imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
|
||||
|
||||
bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable");
|
||||
|
|
|
@ -85,8 +85,8 @@ namespace cocostudio
|
|||
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData");
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||
panel->setBackGroundImage(imageFileName, (TextureResType)imageFileNameType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType);
|
||||
panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
|
||||
|
||||
if (backGroundScale9Enable)
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace cocostudio
|
|||
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData");
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||
loadingBar->loadTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType);
|
||||
loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
|
||||
|
||||
/* gui mark add load bar scale9 parse */
|
||||
|
|
|
@ -50,8 +50,8 @@ namespace cocostudio
|
|||
{
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData");
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||
slider->loadBarTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType);
|
||||
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
|
||||
if (barTextureScale9Enable)
|
||||
{
|
||||
|
@ -62,27 +62,27 @@ namespace cocostudio
|
|||
//loading normal slider ball texture
|
||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData");
|
||||
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
||||
std::string imageFileName = this->getResourcePath(normalDic, "path", (TextureResType)normalType);
|
||||
slider->loadSlidBallTextureNormal(imageFileName, (TextureResType)normalType);
|
||||
std::string imageFileName = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType);
|
||||
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);
|
||||
|
||||
|
||||
//loading slider ball press texture
|
||||
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData");
|
||||
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
||||
std::string pressedFileName = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType);
|
||||
slider->loadSlidBallTexturePressed(pressedFileName, (TextureResType)pressedType);
|
||||
std::string pressedFileName = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType);
|
||||
slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType);
|
||||
|
||||
//loading silder ball disable texture
|
||||
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData");
|
||||
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
||||
std::string disabledFileName = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType);
|
||||
slider->loadSlidBallTextureDisabled(disabledFileName, (TextureResType)disabledType);
|
||||
std::string disabledFileName = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType);
|
||||
slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType);
|
||||
|
||||
//load slider progress texture
|
||||
const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData");
|
||||
int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType");
|
||||
std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (TextureResType)progressBarType);
|
||||
slider->loadProgressBarTexture(progressBarFileName, (TextureResType)progressBarType);
|
||||
std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (Widget::TextureResType)progressBarType);
|
||||
slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -175,17 +175,17 @@ namespace cocostudio
|
|||
|
||||
std::string WidgetReader::getResourcePath(const rapidjson::Value &dict,
|
||||
const std::string &key,
|
||||
cocos2d::ui::TextureResType texType)
|
||||
cocos2d::ui::Widget::TextureResType texType)
|
||||
{
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
const char* imageFileName = DICTOOL->getStringValue_json(dict, key.c_str());
|
||||
std::string imageFileName_tp;
|
||||
if (nullptr != imageFileName)
|
||||
{
|
||||
if (texType == UI_TEX_TYPE_LOCAL) {
|
||||
if (texType == ui::Widget::TextureResType::LOCAL) {
|
||||
imageFileName_tp = jsonPath + imageFileName;
|
||||
}
|
||||
else if(texType == UI_TEX_TYPE_PLIST){
|
||||
else if(texType == ui::Widget::TextureResType::PLIST){
|
||||
imageFileName_tp = imageFileName;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace cocostudio
|
|||
protected:
|
||||
std::string getResourcePath(const rapidjson::Value& dict,
|
||||
const std::string& key,
|
||||
cocos2d::ui::TextureResType texType);
|
||||
cocos2d::ui::Widget::TextureResType texType);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ _scale9Enabled(false),
|
|||
_capInsetsNormal(Rect::ZERO),
|
||||
_capInsetsPressed(Rect::ZERO),
|
||||
_capInsetsDisabled(Rect::ZERO),
|
||||
_normalTexType(UI_TEX_TYPE_LOCAL),
|
||||
_pressedTexType(UI_TEX_TYPE_LOCAL),
|
||||
_disabledTexType(UI_TEX_TYPE_LOCAL),
|
||||
_normalTexType(TextureResType::LOCAL),
|
||||
_pressedTexType(TextureResType::LOCAL),
|
||||
_disabledTexType(TextureResType::LOCAL),
|
||||
_normalTextureSize(_size),
|
||||
_pressedTextureSize(_size),
|
||||
_disabledTextureSize(_size),
|
||||
|
@ -229,10 +229,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
|
|||
extension::Scale9Sprite* normalRendererScale9 = static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer);
|
||||
switch (_normalTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
normalRendererScale9->initWithFile(normal);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
normalRendererScale9->initWithSpriteFrameName(normal);
|
||||
break;
|
||||
default:
|
||||
|
@ -245,10 +245,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
|
|||
Sprite* normalRenderer = static_cast<Sprite*>(_buttonNormalRenderer);
|
||||
switch (_normalTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
normalRenderer->setTexture(normal);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
normalRenderer->setSpriteFrame(normal);
|
||||
break;
|
||||
default:
|
||||
|
@ -277,10 +277,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy
|
|||
extension::Scale9Sprite* clickedRendererScale9 = static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer);
|
||||
switch (_pressedTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
clickedRendererScale9->initWithFile(selected);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
clickedRendererScale9->initWithSpriteFrameName(selected);
|
||||
break;
|
||||
default:
|
||||
|
@ -293,10 +293,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy
|
|||
Sprite* clickedRenderer = static_cast<Sprite*>(_buttonClickedRenderer);
|
||||
switch (_pressedTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
clickedRenderer->setTexture(selected);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
clickedRenderer->setSpriteFrame(selected);
|
||||
break;
|
||||
default:
|
||||
|
@ -324,10 +324,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT
|
|||
extension::Scale9Sprite* disabledScale9 = static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer);
|
||||
switch (_disabledTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
disabledScale9->initWithFile(disabled);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
disabledScale9->initWithSpriteFrameName(disabled);
|
||||
break;
|
||||
default:
|
||||
|
@ -340,10 +340,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT
|
|||
Sprite* disabledRenderer = static_cast<Sprite*>(_buttonDisableRenderer);
|
||||
switch (_disabledTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
disabledRenderer->setTexture(disabled);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
disabledRenderer->setSpriteFrame(disabled);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
static Button* create(const std::string& normalImage,
|
||||
const std::string& selectedImage = "",
|
||||
const std::string& disableImage = "",
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
void loadTextures(const std::string& normal,
|
||||
const std::string& selected,
|
||||
const std::string& disabled = "",
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load normal state texture for button.
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureNormal(const std::string& normal, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureNormal(const std::string& normal, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load selected state texture for button.
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTexturePressed(const std::string& selected, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTexturePressed(const std::string& selected, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load dark state texture for button.
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureDisabled(const std::string& disabled, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureDisabled(const std::string& disabled, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Sets capinsets for button, if button is using scale9 renderer.
|
||||
|
@ -190,7 +190,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual bool init(const std::string& normalImage,
|
||||
const std::string& selectedImage = "",
|
||||
const std::string& disableImage = "",
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
|
||||
protected:
|
||||
|
|
|
@ -45,11 +45,11 @@ _frontCrossDisabledRenderer(nullptr),
|
|||
_isSelected(true),
|
||||
_checkBoxEventListener(nullptr),
|
||||
_checkBoxEventSelector(nullptr),
|
||||
_backGroundTexType(UI_TEX_TYPE_LOCAL),
|
||||
_backGroundSelectedTexType(UI_TEX_TYPE_LOCAL),
|
||||
_frontCrossTexType(UI_TEX_TYPE_LOCAL),
|
||||
_backGroundDisabledTexType(UI_TEX_TYPE_LOCAL),
|
||||
_frontCrossDisabledTexType(UI_TEX_TYPE_LOCAL),
|
||||
_backGroundTexType(TextureResType::LOCAL),
|
||||
_backGroundSelectedTexType(TextureResType::LOCAL),
|
||||
_frontCrossTexType(TextureResType::LOCAL),
|
||||
_backGroundDisabledTexType(TextureResType::LOCAL),
|
||||
_frontCrossDisabledTexType(TextureResType::LOCAL),
|
||||
_backGroundFileName(""),
|
||||
_backGroundSelectedFileName(""),
|
||||
_frontCrossFileName(""),
|
||||
|
@ -174,10 +174,10 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp
|
|||
_backGroundTexType = texType;
|
||||
switch (_backGroundTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_backGroundBoxRenderer->setTexture(backGround);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_backGroundBoxRenderer->setSpriteFrame(backGround);
|
||||
break;
|
||||
default:
|
||||
|
@ -200,10 +200,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect
|
|||
_backGroundSelectedTexType = texType;
|
||||
switch (_backGroundSelectedTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_backGroundSelectedBoxRenderer->setTexture(backGroundSelected);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected);
|
||||
break;
|
||||
default:
|
||||
|
@ -225,10 +225,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex
|
|||
_frontCrossTexType = texType;
|
||||
switch (_frontCrossTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_frontCrossRenderer->setTexture(cross);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_frontCrossRenderer->setSpriteFrame(cross);
|
||||
break;
|
||||
default:
|
||||
|
@ -250,10 +250,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl
|
|||
_backGroundDisabledTexType = texType;
|
||||
switch (_backGroundDisabledTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_backGroundBoxDisabledRenderer->setTexture(backGroundDisabled);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled);
|
||||
break;
|
||||
default:
|
||||
|
@ -275,10 +275,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl
|
|||
_frontCrossDisabledTexType = texType;
|
||||
switch (_frontCrossDisabledTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_frontCrossDisabledRenderer->setTexture(frontCrossDisabled);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
const std::string& cross,
|
||||
const std::string& backGroundDisabled,
|
||||
const std::string& frontCrossDisabled,
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load textures for checkbox.
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
const std::string& cross,
|
||||
const std::string& backGroundDisabled,
|
||||
const std::string& frontCrossDisabled,
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load backGround texture for checkbox.
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGround(const std::string& backGround,TextureResType type = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureBackGround(const std::string& backGround,TextureResType type = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load backGroundSelected texture for checkbox.
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load cross texture for checkbox.
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureFrontCross(const std::string&,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureFrontCross(const std::string&,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load backGroundDisabled texture for checkbox.
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load frontCrossDisabled texture for checkbox.
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Sets selcted state for checkbox.
|
||||
|
@ -188,7 +188,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
const std::string& cross,
|
||||
const std::string& backGroundDisabled,
|
||||
const std::string& frontCrossDisabled,
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
protected:
|
||||
virtual void initRenderer() override;
|
||||
|
|
|
@ -37,6 +37,12 @@ CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::P
|
|||
CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType::ABSOLUTE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget::TextureResType::LOCAL;
|
||||
CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ _prevIgnoreSize(true),
|
|||
_capInsets(Rect::ZERO),
|
||||
_imageRenderer(nullptr),
|
||||
_textureFile(""),
|
||||
_imageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_imageTexType(TextureResType::LOCAL),
|
||||
_imageTextureSize(_size),
|
||||
_imageRendererAdaptDirty(true)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ bool ImageView::init()
|
|||
ret = false;
|
||||
break;
|
||||
}
|
||||
_imageTexType = UI_TEX_TYPE_LOCAL;
|
||||
_imageTexType = TextureResType::LOCAL;
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
|
|||
_imageTexType = texType;
|
||||
switch (_imageTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
|
||||
|
@ -134,7 +134,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
|
|||
imageRenderer->setTexture(fileName);
|
||||
}
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
static ImageView* create(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
static ImageView* create(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Updates the texture rect of the ImageView in points.
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
CC_CONSTRUCTOR_ACCESS:
|
||||
//initializes state of widget.
|
||||
virtual bool init() override;
|
||||
virtual bool init(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
virtual bool init(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
protected:
|
||||
virtual void initRenderer() override;
|
||||
|
|
|
@ -573,7 +573,7 @@ _backGroundImage(nullptr),
|
|||
_backGroundImageFileName(""),
|
||||
_backGroundImageCapInsets(Rect::ZERO),
|
||||
_colorType(LAYOUT_COLOR_NONE),
|
||||
_bgImageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_bgImageTexType(TextureResType::LOCAL),
|
||||
_colorRender(nullptr),
|
||||
_gradientRender(nullptr),
|
||||
_cColor(Color3B::WHITE),
|
||||
|
@ -1123,10 +1123,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
|
|||
extension::Scale9Sprite* bgiScale9 = static_cast<extension::Scale9Sprite*>(_backGroundImage);
|
||||
switch (_bgImageTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
bgiScale9->initWithFile(fileName);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
bgiScale9->initWithSpriteFrameName(fileName);
|
||||
break;
|
||||
default:
|
||||
|
@ -1138,10 +1138,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
|
|||
{
|
||||
switch (_bgImageTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
static_cast<Sprite*>(_backGroundImage)->setTexture(fileName);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
static_cast<Sprite*>(_backGroundImage)->setSpriteFrame(fileName);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
*
|
||||
* @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame.
|
||||
*/
|
||||
void setBackGroundImage(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void setBackGroundImage(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Sets a background image capinsets for layout, if the background image is a scale9 render.
|
||||
|
|
|
@ -38,7 +38,7 @@ _barType(LoadingBarTypeLeft),
|
|||
_percent(100),
|
||||
_totalLength(0),
|
||||
_barRenderer(nullptr),
|
||||
_renderBarTexType(UI_TEX_TYPE_LOCAL),
|
||||
_renderBarTexType(TextureResType::LOCAL),
|
||||
_barRendererTextureSize(Size::ZERO),
|
||||
_scale9Enabled(false),
|
||||
_prevIgnoreSize(true),
|
||||
|
@ -129,7 +129,7 @@ int LoadingBar::getDirection()
|
|||
_textureFile = texture;
|
||||
switch (_renderBarTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
|
||||
|
@ -141,7 +141,7 @@ int LoadingBar::getDirection()
|
|||
static_cast<Sprite*>(_barRenderer)->setTexture(texture);
|
||||
}
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadTexture(const std::string& texture,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadTexture(const std::string& texture,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Changes the progress direction of loadingbar.
|
||||
|
|
|
@ -56,11 +56,11 @@ _capInsetsBarRenderer(Rect::ZERO),
|
|||
_capInsetsProgressBarRenderer(Rect::ZERO),
|
||||
_sliderEventListener(nullptr),
|
||||
_sliderEventSelector(nullptr),
|
||||
_barTexType(UI_TEX_TYPE_LOCAL),
|
||||
_progressBarTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballNTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballPTexType(UI_TEX_TYPE_LOCAL),
|
||||
_ballDTexType(UI_TEX_TYPE_LOCAL),
|
||||
_barTexType(TextureResType::LOCAL),
|
||||
_progressBarTexType(TextureResType::LOCAL),
|
||||
_ballNTexType(TextureResType::LOCAL),
|
||||
_ballPTexType(TextureResType::LOCAL),
|
||||
_ballDTexType(TextureResType::LOCAL),
|
||||
_barRendererAdaptDirty(true),
|
||||
_progressBarRendererDirty(true)
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType)
|
|||
_barTexType = texType;
|
||||
switch (_barTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->initWithFile(fileName);
|
||||
|
@ -133,7 +133,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType)
|
|||
static_cast<Sprite*>(_barRenderer)->setTexture(fileName);
|
||||
}
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_barRenderer)->initWithSpriteFrameName(fileName);
|
||||
|
@ -162,7 +162,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType
|
|||
_progressBarTexType = texType;
|
||||
switch (_progressBarTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->initWithFile(fileName);
|
||||
|
@ -172,7 +172,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType
|
|||
static_cast<Sprite*>(_progressBarRenderer)->setTexture(fileName);
|
||||
}
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
if (_scale9Enabled)
|
||||
{
|
||||
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->initWithSpriteFrameName(fileName);
|
||||
|
@ -298,10 +298,10 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType
|
|||
_ballNTexType = texType;
|
||||
switch (_ballNTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_slidBallNormalRenderer->setTexture(normal);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_slidBallNormalRenderer->setSpriteFrame(normal);
|
||||
break;
|
||||
default:
|
||||
|
@ -320,10 +320,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp
|
|||
_ballPTexType = texType;
|
||||
switch (_ballPTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_slidBallPressedRenderer->setTexture(pressed);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_slidBallPressedRenderer->setSpriteFrame(pressed);
|
||||
break;
|
||||
default:
|
||||
|
@ -342,10 +342,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp
|
|||
_ballDTexType = texType;
|
||||
switch (_ballDTexType)
|
||||
{
|
||||
case UI_TEX_TYPE_LOCAL:
|
||||
case TextureResType::LOCAL:
|
||||
_slidBallDisabledRenderer->setTexture(disabled);
|
||||
break;
|
||||
case UI_TEX_TYPE_PLIST:
|
||||
case TextureResType::PLIST:
|
||||
_slidBallDisabledRenderer->setSpriteFrame(disabled);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadBarTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadBarTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Sets if slider is using scale9 renderer.
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
void loadSlidBallTextures(const std::string& normal,
|
||||
const std::string& pressed,
|
||||
const std::string& disabled,
|
||||
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load normal state texture for slider ball.
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load selected state texture for slider ball.
|
||||
|
@ -139,7 +139,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load dark state texture for slider ball.
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Load dark state texture for slider progress bar.
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
*
|
||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||
*/
|
||||
void loadProgressBarTexture(const std::string& fileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||
void loadProgressBarTexture(const std::string& fileName, TextureResType texType = TextureResType::LOCAL);
|
||||
|
||||
/**
|
||||
* Changes the progress direction of slider.
|
||||
|
|
|
@ -46,12 +46,6 @@ typedef enum
|
|||
WidgetTypeWidget, //control
|
||||
WidgetTypeContainer //container
|
||||
}WidgetType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UI_TEX_TYPE_LOCAL = 0,
|
||||
UI_TEX_TYPE_PLIST = 1
|
||||
}TextureResType;
|
||||
|
||||
|
||||
|
||||
|
@ -101,6 +95,12 @@ public:
|
|||
ENDED,
|
||||
CANCELED
|
||||
};
|
||||
|
||||
enum class TextureResType
|
||||
{
|
||||
LOCAL = 0,
|
||||
PLIST = 1
|
||||
};
|
||||
|
||||
|
||||
typedef std::function<void(Ref*,Widget::TouchEventType)> ccWidgetTouchCallback;
|
||||
|
|
Loading…
Reference in New Issue