Skip to content

Commit

Permalink
dont trigger fallback on icons, in a very stupid way
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Jun 15, 2024
1 parent aaad88a commit e94aa6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "v1.6.0",
"gd": {
"win": "2.206",
"android": "*",
"android": "2.206",
"mac": "2.206"
},
"id": "geode.texture-loader",
Expand Down
18 changes: 18 additions & 0 deletions src/Fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ class $modify(CCSpriteFrameCache) {
cocos2d::CCSpriteFrame* spriteFrameByName(char const* name) {
auto* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name);
if (frame == nullptr) {
// this is stupid but rob intentionally doesnt load all icons at startup,
// probably to save memory, so do this to not use fallback on icons
static constexpr std::string_view prefixes[] = {
"player_",
"ship_",
"dart_",
"bird_",
"robot_",
"spider_",
"swing_",
"jetpack_",
};
const std::string_view nameStr = name;
for (auto const& prefix : prefixes) {
if (nameStr.find(prefix) != -1) {
return frame;
}
}
frame = CCSpriteFrame::create("fallback.png"_spr, {ccp(0, 0), ccp(128, 128)});
}
return frame;
Expand Down

0 comments on commit e94aa6f

Please sign in to comment.