| 265 | } |
| 266 | |
| 267 | void Button::loadTextureNormal(std::string_view normal, TextureResType texType) |
| 268 | { |
| 269 | _normalFileName = normal; |
| 270 | _normalTexType = texType; |
| 271 | bool textureLoaded = true; |
| 272 | if (normal.empty()) |
| 273 | { |
| 274 | _buttonNormalRenderer->resetRender(); |
| 275 | textureLoaded = false; |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | switch (texType) |
| 280 | { |
| 281 | case TextureResType::LOCAL: |
| 282 | _buttonNormalRenderer->initWithFile(normal); |
| 283 | break; |
| 284 | case TextureResType::PLIST: |
| 285 | _buttonNormalRenderer->initWithSpriteFrameName(normal); |
| 286 | break; |
| 287 | default: |
| 288 | break; |
| 289 | } |
| 290 | } |
| 291 | // FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 |
| 292 | if (!_ignoreSize && _customSize.equals(Vec2::ZERO)) |
| 293 | { |
| 294 | _customSize = _buttonNormalRenderer->getContentSize(); |
| 295 | } |
| 296 | this->setupNormalTexture(textureLoaded); |
| 297 | } |
| 298 | |
| 299 | void Button::setupNormalTexture(bool textureLoaded) |
| 300 | { |