mirror of https://github.com/axmolengine/axmol.git
add CCApplication::setResourceRootPath()
add CCApplication::setStartupScriptFilename()
This commit is contained in:
parent
6115769044
commit
affcb70ecc
|
@ -372,14 +372,13 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
|
|||
return pBuffer;
|
||||
}
|
||||
|
||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory, bool isWorkingDir)
|
||||
void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory)
|
||||
{
|
||||
m_obDirectory = pszResourceDirectory;
|
||||
if (m_obDirectory.size() > 0 && m_obDirectory[m_obDirectory.size() - 1] != '/')
|
||||
{
|
||||
m_obDirectory.append("/");
|
||||
}
|
||||
m_isWorkingDirectory = isWorkingDir;
|
||||
}
|
||||
|
||||
const char* CCFileUtils::getResourceDirectory()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "CCApplication.h"
|
||||
#include "CCEGLView.h"
|
||||
#include "CCDirector.h"
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
@brief This function change the PVRFrame show/hide setting in register.
|
||||
|
@ -142,6 +143,22 @@ TargetPlatform CCApplication::getTargetPlatform()
|
|||
return kTargetWindows;
|
||||
}
|
||||
|
||||
void CCApplication::setResourceRootPath(const std::string& rootResDir)
|
||||
{
|
||||
m_resourceRootPath = rootResDir;
|
||||
std::replace(m_resourceRootPath.begin(), m_resourceRootPath.end(), '\\', '/');
|
||||
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/')
|
||||
{
|
||||
m_resourceRootPath += '/';
|
||||
}
|
||||
}
|
||||
|
||||
void CCApplication::setStartupScriptFilename(const std::string& startupScriptFile)
|
||||
{
|
||||
m_startupScriptFilename = startupScriptFile;
|
||||
std::replace(m_startupScriptFilename.begin(), m_startupScriptFilename.end(), '\\', '/');
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <Windows.h>
|
||||
#include "platform/CCCommon.h"
|
||||
#include "platform/CCApplicationProtocol.h"
|
||||
#include <string>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -35,10 +36,28 @@ public:
|
|||
*/
|
||||
virtual TargetPlatform getTargetPlatform();
|
||||
|
||||
/* set the Resource root path */
|
||||
void setResourceRootPath(const std::string& rootResDir);
|
||||
|
||||
/* get the Resource root path */
|
||||
const std::string& getResourceRootPath(void)
|
||||
{
|
||||
return m_resourceRootPath;
|
||||
}
|
||||
|
||||
void setStartupScriptFilename(const std::string& startupScriptFile);
|
||||
|
||||
const std::string& getStartupScriptFilename(void)
|
||||
{
|
||||
return m_startupScriptFilename;
|
||||
}
|
||||
|
||||
protected:
|
||||
HINSTANCE m_hInstance;
|
||||
HACCEL m_hAccelTable;
|
||||
LARGE_INTEGER m_nAnimationInterval;
|
||||
std::string m_resourceRootPath;
|
||||
std::string m_startupScriptFilename;
|
||||
|
||||
static CCApplication * sm_pSharedApplication;
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
#include "platform/CCFileUtilsCommon_cpp.h"
|
||||
#include <windows.h>
|
||||
#include "CCDirector.h"
|
||||
#include "CCApplication.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -78,6 +79,7 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
|||
const char* resDir = m_obDirectory.c_str();
|
||||
CCString* pRet = CCString::create("");
|
||||
|
||||
const std::string& resourceRootPath = CCApplication::sharedApplication()->getResourceRootPath();
|
||||
if ((strlen(pszRelativePath) > 1 && pszRelativePath[1] == ':'))
|
||||
{
|
||||
// path start with "x:", is absolute path
|
||||
|
@ -91,9 +93,9 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
|||
pRet->m_sString = szDriver;
|
||||
pRet->m_sString += pszRelativePath;
|
||||
}
|
||||
else if (m_isWorkingDirectory)
|
||||
else if (resourceRootPath.length() > 0)
|
||||
{
|
||||
pRet->m_sString = m_obDirectory;
|
||||
pRet->m_sString = resourceRootPath.c_str();
|
||||
pRet->m_sString += pszRelativePath;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue