mirror of https://github.com/axmolengine/axmol.git
Add function to texture cache for studio to check if texture have been already loaded
This commit is contained in:
parent
944184b5d0
commit
faddbd8e71
|
@ -292,6 +292,18 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist)
|
|||
}
|
||||
}
|
||||
|
||||
bool SpriteFrameCache::isSpriteFramesWithFileLoaded(const std::string& plist)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (_loadedFileNames->find(plist) != _loadedFileNames->end())
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFrame(SpriteFrame* frame, const std::string& frameName)
|
||||
{
|
||||
_spriteFrames.insert(frameName, frame);
|
||||
|
|
|
@ -140,6 +140,15 @@ public:
|
|||
*/
|
||||
void addSpriteFrame(SpriteFrame *frame, const std::string& frameName);
|
||||
|
||||
/** Check if multiple Sprite Frames from a plist file have been loaded.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*
|
||||
* @param plist Plist file name.
|
||||
* @return True if the file is loaded.
|
||||
*/
|
||||
bool isSpriteFramesWithFileLoaded(const std::string& plist);
|
||||
|
||||
/** Purges the dictionary of loaded sprite frames.
|
||||
* Call this method if you receive the "Memory Warning".
|
||||
* In the short term: it will free some resources preventing your app from being killed.
|
||||
|
|
|
@ -403,6 +403,21 @@ Texture2D* TextureCache::addImage(Image *image, const std::string &key)
|
|||
return texture;
|
||||
}
|
||||
|
||||
bool TextureCache::isTextureLoaded(const std::string& fileName)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
if (fullpath.size() > 0)
|
||||
{
|
||||
if (_textures.find(fullpath) != _textures.end()) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TextureCache::reloadTexture(const std::string& fileName)
|
||||
{
|
||||
Texture2D * texture = nullptr;
|
||||
|
|
|
@ -151,6 +151,13 @@ public:
|
|||
Texture2D* getTextureForKey(const std::string& key) const;
|
||||
CC_DEPRECATED_ATTRIBUTE Texture2D* textureForKey(const std::string& key) const { return getTextureForKey(key); }
|
||||
|
||||
/** Check if texture file have already been loaded to cache.
|
||||
* If the file have been loaded before, return true; otherwise return false.
|
||||
* @param fileName It's the related/absolute path of the file image.
|
||||
* @return True if the texture file is loaded.
|
||||
*/
|
||||
bool isTextureLoaded(const std::string& fileName);
|
||||
|
||||
/** Reload texture from the image file.
|
||||
* If the file image hasn't loaded before, load it.
|
||||
* Otherwise the texture will be reloaded from the file image.
|
||||
|
|
Loading…
Reference in New Issue