mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1219 from minggo/iss1441_testcpp_resources
fixed #1441: put hd and ipad resources into separate directory
This commit is contained in:
commit
7a6f5cd872
|
@ -193,20 +193,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
if( ! [relPath isAbsolutePath] ) {
|
if( ! [relPath isAbsolutePath] ) {
|
||||||
|
|
||||||
// pathForResource also searches in .lproj directories. issue #1230
|
// pathForResource also searches in .lproj directories. issue #1230
|
||||||
NSString *file = [relPath lastPathComponent];
|
NSString *lastPathComponent = [relPath lastPathComponent];
|
||||||
|
|
||||||
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
|
||||||
NSMutableString *imageDirectoryWithDirectory = imageDirectory;
|
NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
||||||
[imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
|
[imageDirectoryByAppendDirectory appendString:imageDirectory];
|
||||||
|
|
||||||
// search path from directory set by setResourceDirectory
|
// search path from directory set by setResourceDirectory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectoryWithDirectory];
|
inDirectory:imageDirectoryByAppendDirectory];
|
||||||
if (fullpath == nil)
|
if (fullpath == nil)
|
||||||
{
|
{
|
||||||
// search from root directory
|
// search from root directory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectory];
|
inDirectory:imageDirectory];
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,20 +193,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
if( ! [relPath isAbsolutePath] ) {
|
if( ! [relPath isAbsolutePath] ) {
|
||||||
|
|
||||||
// pathForResource also searches in .lproj directories. issue #1230
|
// pathForResource also searches in .lproj directories. issue #1230
|
||||||
NSString *file = [relPath lastPathComponent];
|
NSString *lastPathComponent = [relPath lastPathComponent];
|
||||||
|
|
||||||
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
|
||||||
NSMutableString *imageDirectoryWithDirectory = imageDirectory;
|
NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
||||||
[imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
|
[imageDirectoryByAppendDirectory appendString:imageDirectory];
|
||||||
|
|
||||||
// search path from directory set by setResourceDirectory
|
// search path from directory set by setResourceDirectory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectoryWithDirectory];
|
inDirectory:imageDirectoryByAppendDirectory];
|
||||||
if (fullpath == nil)
|
if (fullpath == nil)
|
||||||
{
|
{
|
||||||
// search from root directory
|
// search from root directory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectory];
|
inDirectory:imageDirectory];
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,20 +349,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
||||||
std::string externalTilesetFilename = valueForKey("source", attributeDict);
|
std::string externalTilesetFilename = valueForKey("source", attributeDict);
|
||||||
if (externalTilesetFilename != "")
|
if (externalTilesetFilename != "")
|
||||||
{
|
{
|
||||||
if (m_sTMXFileName.length() == 0)
|
if (m_sTMXFileName.find_last_of("/") != string::npos)
|
||||||
{
|
{
|
||||||
string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str());
|
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
|
||||||
if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1)
|
externalTilesetFilename = dir + externalTilesetFilename;
|
||||||
{
|
|
||||||
pszFullPath.append("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName());
|
externalTilesetFilename = m_sResources + "/" + externalTilesetFilename;
|
||||||
}
|
}
|
||||||
|
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(externalTilesetFilename.c_str());
|
||||||
|
|
||||||
pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str());
|
pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -448,19 +445,15 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
||||||
|
|
||||||
// build full path
|
// build full path
|
||||||
std::string imagename = valueForKey("source", attributeDict);
|
std::string imagename = valueForKey("source", attributeDict);
|
||||||
if (m_sTMXFileName.length() == 0)
|
|
||||||
{
|
|
||||||
string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str());
|
|
||||||
if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1)
|
|
||||||
{
|
|
||||||
pszFullPath.append("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() );
|
if (m_sTMXFileName.find_last_of("/") != string::npos)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName());
|
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
|
||||||
|
tileset->m_sSourceImage = dir + imagename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tileset->m_sSourceImage = m_sResources + "/" + imagename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(elementName == "data")
|
else if(elementName == "data")
|
||||||
|
|
|
@ -22,8 +22,32 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
TargetPlatform target = getTargetPlatform();
|
||||||
// pDirector->enableRetinaDisplay(true);
|
|
||||||
|
if (target == kTargetIpad)
|
||||||
|
{
|
||||||
|
// ipad
|
||||||
|
|
||||||
|
if (pDirector->enableRetinaDisplay(true))
|
||||||
|
{
|
||||||
|
// ipad hd
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (target == kTargetIphone)
|
||||||
|
{
|
||||||
|
// iphone
|
||||||
|
|
||||||
|
if (pDirector->enableRetinaDisplay(true))
|
||||||
|
{
|
||||||
|
// iphone hd
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayStats(true);
|
pDirector->setDisplayStats(true);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
a6ca8414e453957fa2fbc456b47160ac402ea35e
|
|
@ -1 +1 @@
|
||||||
9dc4229a0e1a4577d300081dc8e3abc2a1e2f1f2
|
48e6afe7da949d2c64a81cb7d583fb1335e10969
|
|
@ -1 +1 @@
|
||||||
756534a58c37d049b7033828eccf2ec0fb0a221a
|
dbcfed31d505836a286d749e72f74276b36a50e7
|
Loading…
Reference in New Issue