mirror of https://github.com/axmolengine/axmol.git
issue #2397: FileUtils::sharedFileUtils --> FileUtils::getInstance() for all platforms
This commit is contained in:
parent
88a28b041e
commit
a678d12615
|
@ -50,7 +50,7 @@ namespace CocosDenshion {
|
|||
static std::string getFullPathWithoutAssetsPrefix(const char* pszFilename)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilename);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilename);
|
||||
// Removing `assets` since it isn't needed for the API of playing sound.
|
||||
size_t pos = fullPath.find("assets/");
|
||||
if (pos == 0)
|
||||
|
|
|
@ -32,7 +32,7 @@ void SimpleAudioEngine::end() {
|
|||
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath,
|
||||
bool bLoop) {
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
oAudioPlayer->playBackgroundMusic(fullPath.c_str(), bLoop);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ bool SimpleAudioEngine::isBackgroundMusicPlaying() {
|
|||
|
||||
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
return oAudioPlayer->preloadBackgroundMusic(fullPath.c_str());
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
|
|||
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
||||
float pitch, float pan, float gain) {
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
return oAudioPlayer->playEffect(fullPath.c_str(), bLoop, pitch, pan, gain);
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,13 @@ void SimpleAudioEngine::stopEffect(unsigned int nSoundId) {
|
|||
|
||||
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) {
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
return oAudioPlayer->preloadEffect(fullPath.c_str());
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::unloadEffect(const char* pszFilePath) {
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
return oAudioPlayer->unloadEffect(fullPath.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
s3eFile *fileHandle = s3eFileOpen(fullPath.c_str(), "rb");
|
||||
|
||||
IwAssertMsg(GAME, fileHandle, ("Open file %s Failed. s3eFileError Code : %i", fullPath.c_str(), s3eFileGetError()));
|
||||
|
@ -120,7 +120,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
s3eResult result;
|
||||
|
||||
result = s3eAudioPlayFromBuffer(g_AudioBuffer, g_AudioFileSize, bLoop ? 0 : 1);
|
||||
|
@ -198,7 +198,7 @@ namespace CocosDenshion
|
|||
float pitch, float pan, float gain)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
|
||||
if( it==g_pSoundFxMap->end() ) {
|
||||
s3eFile *fileHandle = s3eFileOpen(fullPath.c_str(), "rb");
|
||||
|
@ -248,7 +248,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
// effect must not be playing!
|
||||
|
||||
SoundFxMap::iterator it = g_pSoundFxMap->find(fullPath) ;
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath);
|
||||
if (it == s_backgroundMusics.end())
|
||||
|
@ -244,7 +244,7 @@ namespace CocosDenshion
|
|||
stopBackgroundMusic(false);
|
||||
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
BackgroundMusicsMap::const_iterator it = s_backgroundMusics.find(fullPath);
|
||||
if (it == s_backgroundMusics.end())
|
||||
|
@ -358,7 +358,7 @@ namespace CocosDenshion
|
|||
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
||||
float pitch, float pan, float gain)
|
||||
{
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
EffectsMap::iterator iter = s_effects.find(fullPath);
|
||||
|
||||
|
@ -402,7 +402,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
EffectsMap::iterator iter = s_effects.find(fullPath);
|
||||
|
||||
|
@ -453,7 +453,7 @@ namespace CocosDenshion
|
|||
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
|
||||
{
|
||||
// Changing file path to full path
|
||||
std::string fullPath = FileUtils::sharedFileUtils()->fullPathForFilename(pszFilePath);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszFilePath);
|
||||
|
||||
EffectsMap::iterator iter = s_effects.find(fullPath);
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ void SimpleAudioEngine::setEffectsVolume(float volume)
|
|||
|
||||
static std::string _FullPath(const char * szPath)
|
||||
{
|
||||
return FileUtils::sharedFileUtils()->fullPathForFilename(szPath);
|
||||
return FileUtils::getInstance()->fullPathForFilename(szPath);
|
||||
}
|
||||
|
||||
unsigned int _Hash(const char *key)
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -64,6 +64,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsAndroid::FileUtilsAndroid()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
// Do a full lookup for the font path using FileUtils in case the given font name is a relative path to a font file asset,
|
||||
// or the path has been mapped to a different location in the app package:
|
||||
std::string fullPathOrFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
|
||||
std::string fullPathOrFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
|
||||
|
||||
// If the path name returned includes the 'assets' dir then that needs to be removed, because the android.content.Context
|
||||
// requires this portion of the path to be omitted for assets inside the app package.
|
||||
|
|
|
@ -82,7 +82,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
_resourceRootPath += '/';
|
||||
}
|
||||
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
|
||||
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
|
|
|
@ -45,13 +45,13 @@ public:
|
|||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -19,6 +19,13 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
|
||||
FileUtilsBlackberry::FileUtilsBlackberry()
|
||||
{}
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ bool Image::initWithString(
|
|||
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||
|
||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||
fullFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
|
||||
fullFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
|
||||
}
|
||||
//CCLog("-----pText=%s and Font File is %s nWidth= %d,nHeight=%d",pText,fullFontName.c_str(),nWidth,nHeight);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
_resourceRootPath += '/';
|
||||
}
|
||||
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
|
||||
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
|
|
|
@ -45,13 +45,13 @@ public:
|
|||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -19,6 +19,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsEmscripten::FileUtilsEmscripten()
|
||||
{}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ void TextureCacheEmscripten::addImageAsync(const char *path, Object *target, SEL
|
|||
Texture2D *texture = NULL;
|
||||
|
||||
// optimization
|
||||
std::string pathKey = FileUtils::sharedFileUtils()->fullPathForFilename(path);
|
||||
std::string pathKey = FileUtils::getInstance()->fullPathForFilename(path);
|
||||
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
|
||||
|
||||
std::string fullpath = pathKey;
|
||||
|
|
|
@ -73,7 +73,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
_resourceRootPath += '/';
|
||||
}
|
||||
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
|
||||
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
|
|
|
@ -43,13 +43,13 @@ public:
|
|||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -28,6 +28,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsLinux::FileUtilsLinux()
|
||||
{}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ public:
|
|||
std::string lowerCasePath = fontPath;
|
||||
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||
fontPath = cocos2d::FileUtils::sharedFileUtils()->fullPathForFilename(fontPath.c_str());
|
||||
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
|
||||
|
||||
FILE *f = fopen(fontPath.c_str(), "r");
|
||||
if ( f ) {
|
||||
|
@ -439,7 +439,7 @@ bool Image::initWithString(
|
|||
|
||||
BitmapDC &dc = sharedBitmapDC();
|
||||
|
||||
//const char* pFullFontName = FileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
|
||||
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName);
|
||||
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -19,6 +19,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsMarmalade::FileUtilsMarmalade()
|
||||
{}
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
|
|||
IW_CALLSTACK("UIImage::initWithImageFile");
|
||||
bool bRet = false;
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = FileUtils::sharedFileUtils()->getFileData(strPath, "rb", &nSize);
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(strPath, "rb", &nSize);
|
||||
if (pBuffer != NULL && nSize > 0)
|
||||
{
|
||||
bRet = initWithImageData(pBuffer, nSize, eImgFmt);
|
||||
|
@ -536,7 +536,7 @@ bool Image::initWithImageFileThreadSafe( const char *fullpath, EImageFormat imag
|
|||
CC_UNUSED_PARAM(imageType);
|
||||
bool bRet = false;
|
||||
unsigned long nSize = 0;
|
||||
unsigned char *pBuffer = FileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
|
||||
unsigned char *pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
|
||||
if (pBuffer != NULL && nSize > 0)
|
||||
{
|
||||
bRet = initWithImageData(pBuffer, nSize, imageType);
|
||||
|
@ -873,7 +873,7 @@ bool Image::initWithString(
|
|||
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||
|
||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||
fullFontName = FileUtils::sharedFileUtils()->fullPathForFilename(pFontName);
|
||||
fullFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
|
||||
}
|
||||
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, fullFontName.c_str(), nSize));
|
||||
|
|
|
@ -30,7 +30,7 @@ using namespace std;
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -40,6 +40,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
std::string FileUtilsNaCl::getWritablePath()
|
||||
{
|
||||
//return current resource path
|
||||
|
|
|
@ -452,7 +452,7 @@ bool Image::initWithString(
|
|||
|
||||
BitmapDC &dc = sharedBitmapDC();
|
||||
|
||||
//const char* pFullFontName = FileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
|
||||
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName);
|
||||
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ using namespace Tizen::Base;
|
|||
using namespace Tizen::Io;
|
||||
using namespace Tizen::Text;
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -50,6 +50,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsTizen::FileUtilsTizen()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ public:
|
|||
std::string lowerCasePath = fontPath;
|
||||
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||
fontPath = cocos2d::FileUtils::sharedFileUtils()->fullPathForFilename(fontPath.c_str());
|
||||
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
|
||||
|
||||
FILE *f = fopen(fontPath.c_str(), "r");
|
||||
if ( f ) {
|
||||
|
@ -439,7 +439,7 @@ bool Image::initWithString(
|
|||
|
||||
BitmapDC &dc = sharedBitmapDC();
|
||||
|
||||
//const char* pFullFontName = FileUtils::sharedFileUtils()->fullPathFromRelativePath(pFontName);
|
||||
//const char* pFullFontName = FileUtils::getInstance()->fullPathFromRelativePath(pFontName);
|
||||
|
||||
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, pFontName, nSize));
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ void Application::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
_resourceRootPath += '/';
|
||||
}
|
||||
FileUtils* pFileUtils = FileUtils::sharedFileUtils();
|
||||
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), _resourceRootPath);
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
|
|
|
@ -38,13 +38,13 @@ public:
|
|||
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use FileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||
* @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ static void _checkPath()
|
|||
}
|
||||
}
|
||||
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
FileUtils* FileUtils::getInstance()
|
||||
{
|
||||
if (s_sharedFileUtils == NULL)
|
||||
{
|
||||
|
@ -53,6 +53,12 @@ FileUtils* FileUtils::sharedFileUtils()
|
|||
return s_sharedFileUtils;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
FileUtils* FileUtils::sharedFileUtils()
|
||||
{
|
||||
return FileUtils::getInstance();
|
||||
}
|
||||
|
||||
FileUtilsWin32::FileUtilsWin32()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
int nFindTTF = fontName.find(".TTF");
|
||||
if (nFindttf >= 0 || nFindTTF >= 0)
|
||||
{
|
||||
fontPath = FileUtils::sharedFileUtils()->fullPathForFilename(fontName.c_str());
|
||||
fontPath = FileUtils::getInstance()->fullPathForFilename(fontName.c_str());
|
||||
int nFindPos = fontName.rfind("/");
|
||||
fontName = &fontName[nFindPos+1];
|
||||
nFindPos = fontName.rfind(".");
|
||||
|
|
|
@ -127,9 +127,9 @@ void UpdateLayer::enter(cocos2d::Object *pSender)
|
|||
// Because AssetsManager will set
|
||||
if (! isUpdateItemClicked)
|
||||
{
|
||||
vector<string> searchPaths = FileUtils::sharedFileUtils()->getSearchPaths();
|
||||
vector<string> searchPaths = FileUtils::getInstance()->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), pathToSave);
|
||||
FileUtils::sharedFileUtils()->setSearchPaths(searchPaths);
|
||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
||||
}
|
||||
|
||||
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
|
@ -182,7 +182,7 @@ AssetsManager* UpdateLayer::getAssetsManager()
|
|||
|
||||
void UpdateLayer::createDownloadedDir()
|
||||
{
|
||||
pathToSave = FileUtils::sharedFileUtils()->getWritablePath();
|
||||
pathToSave = FileUtils::getInstance()->getWritablePath();
|
||||
pathToSave += "tmpdir";
|
||||
|
||||
// Create the folder if it doesn't exist
|
||||
|
|
|
@ -157,7 +157,7 @@ local function main()
|
|||
|
||||
local function menuCallbackOpenPopup()
|
||||
-- loop test sound effect
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath)
|
||||
menuPopup:setVisible(true)
|
||||
end
|
||||
|
@ -187,10 +187,10 @@ local function main()
|
|||
-- play background music, preload effect
|
||||
|
||||
-- uncomment below for the BlackBerry version
|
||||
-- local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.mp3")
|
||||
-- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3")
|
||||
SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true)
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
SimpleAudioEngine:sharedEngine():preloadEffect(effectPath)
|
||||
|
||||
-- run
|
||||
|
|
|
@ -1196,7 +1196,7 @@ local function TMXOrthoFromXMLTest()
|
|||
local resources = "TileMaps" -- partial paths are OK as resource paths.
|
||||
local file = resources.."/orthogonal-test1.tmx"
|
||||
|
||||
local str = CCString:createWithContentsOfFile(CCFileUtils:sharedFileUtils():fullPathForFilename(file)):getCString()
|
||||
local str = CCString:createWithContentsOfFile(CCFileUtils:getInstance():fullPathForFilename(file)):getCString()
|
||||
-- CCAssert(str != NULL, "Unable to open file")
|
||||
if (str == nil) then
|
||||
cclog("Unable to open file")
|
||||
|
|
|
@ -46,7 +46,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
tolua_web_socket_open(tolua_s);
|
||||
#endif
|
||||
|
||||
std::string path = FileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename("hello.lua");
|
||||
pEngine->executeScriptFile(path.c_str());
|
||||
|
||||
return true;
|
||||
|
|
|
@ -158,7 +158,7 @@ local function main()
|
|||
|
||||
local function menuCallbackOpenPopup()
|
||||
-- loop test sound effect
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
effectID = AudioEngine.playEffect(effectPath)
|
||||
menuPopup:setVisible(true)
|
||||
end
|
||||
|
@ -188,10 +188,10 @@ local function main()
|
|||
-- play background music, preload effect
|
||||
|
||||
-- uncomment below for the BlackBerry version
|
||||
-- local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.mp3")
|
||||
-- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3")
|
||||
AudioEngine.playMusic(bgMusicPath, true)
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
AudioEngine.preloadEffect(effectPath)
|
||||
|
||||
-- run
|
||||
|
|
|
@ -36,7 +36,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
LuaEngine* pEngine = LuaEngine::defaultEngine();
|
||||
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
|
||||
std::string path = FileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename("hello.lua");
|
||||
pEngine->executeScriptFile(path.c_str());
|
||||
|
||||
return true;
|
||||
|
|
|
@ -157,7 +157,7 @@ local function main()
|
|||
|
||||
local function menuCallbackOpenPopup()
|
||||
-- loop test sound effect
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath)
|
||||
menuPopup:setVisible(true)
|
||||
end
|
||||
|
@ -187,10 +187,10 @@ local function main()
|
|||
-- play background music, preload effect
|
||||
|
||||
-- uncomment below for the BlackBerry version
|
||||
-- local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:sharedFileUtils():fullPathForFilename("background.mp3")
|
||||
-- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg")
|
||||
local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3")
|
||||
SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true)
|
||||
local effectPath = CCFileUtils:sharedFileUtils():fullPathForFilename("effect1.wav")
|
||||
local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav")
|
||||
SimpleAudioEngine:sharedEngine():preloadEffect(effectPath)
|
||||
|
||||
-- run
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
class CCFileUtils
|
||||
{
|
||||
static CCFileUtils* sharedFileUtils();
|
||||
static CCFileUtils* getInstance();
|
||||
static void purgeFileUtils();
|
||||
|
||||
void purgeCachedEntries();
|
||||
|
|
Loading…
Reference in New Issue