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