add more getters + ranges utils

This commit is contained in:
HJfod 2022-10-27 15:12:31 +03:00
parent e30669d9ad
commit b252c69b8b
4 changed files with 23 additions and 0 deletions
loader
include/Geode
src/cocos2d-ext

View file

@ -152,6 +152,9 @@ public:
* @js getInstance
*/
static CCSpriteFrameCache* sharedSpriteFrameCache(void);
GEODE_ADD(
static CCSpriteFrameCache* get();
);
/** Purges the cache. It releases all the Sprite Frames and the retained instance. */
static void purgeSharedSpriteFrameCache(void);

View file

@ -91,6 +91,9 @@ public:
* @js getInstance
*/
static CCTextureCache * sharedTextureCache();
GEODE_ADD(
static CCTextureCache* get();
);
/** purges the cache. It releases the retained instance.
@since v0.99.0

View file

@ -169,6 +169,15 @@ namespace geode::utils::ranges {
return container;
}
template<ValidMutContainer C, ValidCUnaryPredicate<C> Predicate>
C& remove(C& container, Predicate fun) {
container.erase(
std::remove_if(container.begin(), container.end(), fun),
container.end()
);
return container;
}
template<ValidContainer C, ValidCUnaryPredicate<C> Predicate>
C filter(C const& container, Predicate filterFun) {
auto res = C();

View file

@ -28,4 +28,12 @@ CCFileUtils* CCFileUtils::get() {
return CCFileUtils::sharedFileUtils();
}
CCSpriteFrameCache* CCSpriteFrameCache::get() {
return CCSpriteFrameCache::sharedSpriteFrameCache();
}
CCTextureCache* CCTextureCache::get() {
return CCTextureCache::sharedTextureCache();
}
#pragma warning(pop)