mirror of https://github.com/axmolengine/axmol.git
issue #1683: Making CCApplication::setResourceRootPath deprecated.
This commit is contained in:
parent
78c16fdd22
commit
c24ca63a0c
|
@ -13,8 +13,6 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
|
||||
static std::string s_strRootResPath = "";
|
||||
|
||||
// sharedApplication pointer
|
||||
CCApplication * CCApplication::sm_pSharedApplication = 0;
|
||||
|
||||
|
@ -67,21 +65,23 @@ void CCApplication::setAnimationInterval(double interval)
|
|||
m_nAnimationInterval = interval*1000.0f;
|
||||
}
|
||||
|
||||
void CCApplication::setResourceRootPath(const char* pszRootResDir)
|
||||
void CCApplication::setResourceRootPath(const std::string& rootResDir)
|
||||
{
|
||||
if (pszRootResDir)
|
||||
{
|
||||
s_strRootResPath = pszRootResDir;
|
||||
if (s_strRootResPath[s_strRootResPath.length()-1] != '/')
|
||||
{
|
||||
s_strRootResPath += '/';
|
||||
}
|
||||
}
|
||||
m_resourceRootPath = rootResDir;
|
||||
std::replace(m_resourceRootPath.begin(), m_resourceRootPath.end(), '\\', '/');
|
||||
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/')
|
||||
{
|
||||
m_resourceRootPath += '/';
|
||||
}
|
||||
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
|
||||
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||
pFileUtils->setSearchPath(searchPaths);
|
||||
}
|
||||
|
||||
const char* CCApplication::getResourceRootPath(void)
|
||||
const std::string& CCApplication::getResourceRootPath(void)
|
||||
{
|
||||
return s_strRootResPath.c_str();
|
||||
return m_resourceRootPath;
|
||||
}
|
||||
|
||||
TargetPlatform CCApplication::getTargetPlatform()
|
||||
|
|
|
@ -40,11 +40,17 @@ public:
|
|||
/* override functions */
|
||||
virtual ccLanguageType getCurrentLanguage();
|
||||
|
||||
/* set the Resource root path */
|
||||
void setResourceRootPath(const char* pszRootResDir);
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const char* pszRootResDir);
|
||||
|
||||
/* get the Resource root path */
|
||||
const char* getResourceRootPath(void);
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const char* getResourceRootPath(void);
|
||||
|
||||
/**
|
||||
@brief Get target platform
|
||||
|
@ -52,7 +58,8 @@ public:
|
|||
virtual TargetPlatform getTargetPlatform();
|
||||
protected:
|
||||
long m_nAnimationInterval; //micro second
|
||||
|
||||
std::string m_resourceRootPath;
|
||||
|
||||
static CCApplication * sm_pSharedApplication;
|
||||
};
|
||||
|
||||
|
|
|
@ -69,11 +69,17 @@ public:
|
|||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
|
||||
/* set the Resource root path */
|
||||
void setResourceRootPath(const std::string& rootResDir);
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/* get the Resource root path */
|
||||
const std::string& getResourceRootPath(void);
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
void setStartupScriptFilename(const std::string& startupScriptFile);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#import "CCApplication.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "CCDirector.h"
|
||||
#import "CCDirectorCaller.h"
|
||||
|
@ -131,6 +131,10 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
m_resourceRootPath += '/';
|
||||
}
|
||||
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
|
||||
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||
pFileUtils->setSearchPath(searchPaths);
|
||||
}
|
||||
|
||||
const std::string& CCApplication::getResourceRootPath(void)
|
||||
|
|
|
@ -163,6 +163,15 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir)
|
|||
{
|
||||
m_resourceRootPath += '/';
|
||||
}
|
||||
CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPath();
|
||||
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||
pFileUtils->setSearchPath(searchPaths);
|
||||
}
|
||||
|
||||
const std::string& CCApplication::getResourceRootPath(void)
|
||||
{
|
||||
return m_resourceRootPath;
|
||||
}
|
||||
|
||||
void CCApplication::setStartupScriptFilename(const std::string& startupScriptFile)
|
||||
|
|
|
@ -36,14 +36,17 @@ public:
|
|||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
|
||||
/* set the Resource root path */
|
||||
void setResourceRootPath(const std::string& rootResDir);
|
||||
/**
|
||||
* Sets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/* get the Resource root path */
|
||||
const std::string& getResourceRootPath(void)
|
||||
{
|
||||
return m_resourceRootPath;
|
||||
}
|
||||
/**
|
||||
* Gets the Resource root path.
|
||||
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead.
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
|
||||
|
||||
void setStartupScriptFilename(const std::string& startupScriptFile);
|
||||
|
||||
|
|
Loading…
Reference in New Issue