diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 828068e8d8..68a9ad64fd 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -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]; } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index 15fda27d90..41a43e057d 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -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") diff --git a/samples/TestCpp/Classes/AppDelegate.cpp b/samples/TestCpp/Classes/AppDelegate.cpp index 7204d6f56a..07f003403a 100644 --- a/samples/TestCpp/Classes/AppDelegate.cpp +++ b/samples/TestCpp/Classes/AppDelegate.cpp @@ -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); diff --git a/samples/TestCpp/Resources/Images/background1-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/Images/background1.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/Images/background1-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/Images/background1.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/Images/background2-hd.jpg.REMOVED.git-id b/samples/TestCpp/Resources/hd/Images/background2.jpg.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/Images/background2-hd.jpg.REMOVED.git-id rename to samples/TestCpp/Resources/hd/Images/background2.jpg.REMOVED.git-id diff --git a/samples/TestCpp/Resources/Images/background2-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/Images/background2.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/Images/background2-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/Images/background2.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/ccb/official/pub/res/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/ccb/official/src/res/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/extensions/background-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/extensions/background.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/extensions/background-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/extensions/background.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/hd/fonts/font-issue1343.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/fonts/font-issue1343.png.REMOVED.git-id new file mode 100644 index 0000000000..4d9f7c904d --- /dev/null +++ b/samples/TestCpp/Resources/hd/fonts/font-issue1343.png.REMOVED.git-id @@ -0,0 +1 @@ +a6ca8414e453957fa2fbc456b47160ac402ea35e \ No newline at end of file diff --git a/samples/TestCpp/Resources/fonts/markerFelt-hd.fnt.REMOVED.git-id b/samples/TestCpp/Resources/hd/fonts/markerFelt.fnt.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/fonts/markerFelt-hd.fnt.REMOVED.git-id rename to samples/TestCpp/Resources/hd/fonts/markerFelt.fnt.REMOVED.git-id diff --git a/samples/TestCpp/Resources/fonts/markerFelt-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/fonts/markerFelt.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/fonts/markerFelt-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/fonts/markerFelt.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/fonts/tuffy_bold_italic-charmap-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/hd/fonts/tuffy_bold_italic-charmap.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/fonts/tuffy_bold_italic-charmap-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/hd/fonts/tuffy_bold_italic-charmap.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id rename to samples/TestCpp/Resources/ipad/ccb/official/pub/res/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id rename to samples/TestCpp/Resources/ipad/ccb/official/src/res/burst.png.REMOVED.git-id diff --git a/samples/TestCpp/Resources/extensions/background-ipad.png.REMOVED.git-id b/samples/TestCpp/Resources/ipad/extensions/background.png.REMOVED.git-id similarity index 100% rename from samples/TestCpp/Resources/extensions/background-ipad.png.REMOVED.git-id rename to samples/TestCpp/Resources/ipad/extensions/background.png.REMOVED.git-id diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index c7c5b5c2c3..d0a81cb5db 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -9dc4229a0e1a4577d300081dc8e3abc2a1e2f1f2 \ No newline at end of file +48e6afe7da949d2c64a81cb7d583fb1335e10969 \ No newline at end of file diff --git a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 15fb07d4a3..5265b2fbf9 100644 --- a/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.mac/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -756534a58c37d049b7033828eccf2ec0fb0a221a \ No newline at end of file +dbcfed31d505836a286d749e72f74276b36a50e7 \ No newline at end of file