Skip to content

Commit e580276

Browse files
authored
Merge pull request #772 from askamn/dev
Replace getSpriteFrameByName() with findFrame() in cocos-studio
2 parents 654326e + 6c08914 commit e580276

File tree

17 files changed

+40
-37
lines changed

17 files changed

+40
-37
lines changed

extensions/cocostudio/ActionTimeline/CCActionTimelineCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ Frame* ActionTimelineCache::loadTextureFrame(const rapidjson::Value& json)
380380
{
381381
std::string path = texture;
382382

383-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
383+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(path);
384384
if (spriteFrame == nullptr)
385385
{
386386
std::string jsonPath = CSLoader::getInstance()->getJsonPath();

extensions/cocostudio/ActionTimeline/CCFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void TextureFrame::onEnter(Frame* /*nextFrame*/, int /*currentFrameIndex*/)
146146
if (_sprite)
147147
{
148148
auto spriteBlendFunc = _sprite->getBlendFunc();
149-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(_textureName);
149+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(_textureName);
150150

151151
if (spriteFrame != nullptr)
152152
_sprite->setSpriteFrame(spriteFrame);

extensions/cocostudio/ActionTimeline/CSLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ Node* CSLoader::loadSprite(const rapidjson::Value& json)
674674
{
675675
std::string path = filePath;
676676

677-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
677+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(path);
678678
if (!spriteFrame)
679679
{
680680
path = _jsonPath + path;

extensions/cocostudio/CCSkin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bool Skin::initWithSpriteFrameName(std::string_view spriteFrameName)
8585
{
8686
CCAssert(spriteFrameName != "", "");
8787

88-
SpriteFrame* pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
88+
SpriteFrame* pFrame = SpriteFrameCache::getInstance()->findFrame(spriteFrameName);
8989
bool ret = true;
9090

9191
if (pFrame != nullptr)

extensions/cocostudio/CCSpriteFrameCacheHelper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ void SpriteFrameCacheHelper::retainSpriteFrames(std::string_view plistPath)
6565
for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter)
6666
{
6767
auto& spriteFrameName = iter->first;
68-
SpriteFrame* spriteFrame = spriteFramesCache->getSpriteFrameByName(spriteFrameName);
68+
69+
SpriteFrame* spriteFrame = spriteFramesCache->findFrame(spriteFrameName);
70+
AXASSERT(spriteFrame, "spriteframe is null!");
71+
6972
vec.push_back(spriteFrame);
7073
AX_SAFE_RETAIN(spriteFrame);
7174
}

extensions/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ void ButtonReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers::
689689
{
690690
normalFileExist = true;
691691
}
692-
else if (SpriteFrameCache::getInstance()->getSpriteFrameByName(normalTexturePath))
692+
else if (SpriteFrameCache::getInstance()->findFrame(normalTexturePath))
693693
{
694694
normalFileExist = true;
695695
normalType = 1;
@@ -704,7 +704,7 @@ void ButtonReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers::
704704
case 1:
705705
{
706706
std::string plist = normalDic->plistFile()->c_str();
707-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(normalTexturePath);
707+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(normalTexturePath);
708708
if (spriteFrame)
709709
{
710710
normalFileExist = true;
@@ -762,7 +762,7 @@ void ButtonReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers::
762762
case 1:
763763
{
764764
std::string plist = pressedDic->plistFile()->c_str();
765-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pressedTexturePath);
765+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(pressedTexturePath);
766766
if (spriteFrame)
767767
{
768768
pressedFileExist = true;
@@ -820,7 +820,7 @@ void ButtonReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers::
820820
case 1:
821821
{
822822
std::string plist = disabledDic->plistFile()->c_str();
823-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(disabledTexturePath);
823+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(disabledTexturePath);
824824
if (spriteFrame)
825825
{
826826
disabledFileExist = true;

extensions/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void CheckBoxReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
458458
case 1:
459459
{
460460
std::string plist = backGroundDic->plistFile()->c_str();
461-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundTexturePath);
461+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundTexturePath);
462462
if (spriteFrame)
463463
{
464464
backGroundFileExist = true;
@@ -518,7 +518,7 @@ void CheckBoxReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
518518
case 1:
519519
{
520520
std::string plist = backGroundSelectedDic->plistFile()->c_str();
521-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundSelectedTexturePath);
521+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundSelectedTexturePath);
522522
if (spriteFrame)
523523
{
524524
backGroundSelectedfileExist = true;
@@ -578,7 +578,7 @@ void CheckBoxReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
578578
case 1:
579579
{
580580
std::string plist = frontCrossDic->plistFile()->c_str();
581-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(frontCrossFileName);
581+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(frontCrossFileName);
582582
if (spriteFrame)
583583
{
584584
frontCrossFileExist = true;
@@ -637,7 +637,7 @@ void CheckBoxReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
637637
case 1:
638638
{
639639
std::string plist = backGroundDisabledDic->plistFile()->c_str();
640-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(backGroundDisabledFileName);
640+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundDisabledFileName);
641641
if (spriteFrame)
642642
{
643643
backGroundBoxDisabledFileExist = true;
@@ -697,7 +697,7 @@ void CheckBoxReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
697697
case 1:
698698
{
699699
std::string plist = frontCrossDisabledDic->plistFile()->c_str();
700-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(frontCrossDisabledFileName);
700+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(frontCrossDisabledFileName);
701701
if (spriteFrame)
702702
{
703703
frontCrossDisabledFileExist = true;

extensions/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void ImageViewReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffer
300300
case 1:
301301
{
302302
std::string plist = imageFileNameDic->plistFile()->c_str();
303-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
303+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(imageFileName);
304304
if (spriteFrame)
305305
{
306306
fileExist = true;

extensions/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ void LayoutReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers::
598598
case 1:
599599
{
600600
std::string plist = imageFileNameDic->plistFile()->c_str();
601-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
601+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(imageFileName);
602602
if (spriteFrame)
603603
{
604604
fileExist = true;

extensions/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void ListViewReader::setPropsWithFlatBuffers(axis::Node* node, const flatbuffers
438438
case 1:
439439
{
440440
std::string plist = imageFileNameDic->plistFile()->c_str();
441-
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
441+
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(imageFileName);
442442
if (spriteFrame)
443443
{
444444
fileExist = true;

0 commit comments

Comments
 (0)