Browse Source

The iOS game list screen now also displays folders that contain main.lua.

Alex Szpakowski 10 years ago
parent
commit
9a1c4ad565

+ 16 - 3
src/common/iOS.mm

@@ -130,9 +130,22 @@ static NSString *getDocumentsDirectory()
 
 static NSArray *getLovesInDocuments()
 {
-	NSString *documents = getDocumentsDirectory();
-	NSArray *filepaths = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documents error:nil];
-	return [filepaths pathsMatchingExtensions:@[@"love"]];
+	NSMutableArray *paths = [NSMutableArray new];
+
+	NSFileManager *manager = [NSFileManager defaultManager];
+	NSDirectoryEnumerator *enumerator = [manager enumeratorAtPath:getDocumentsDirectory()];
+
+	NSString *path = nil;
+	while ((path = [enumerator nextObject]))
+	{
+		//  Add .love files plus folders that contain main.lua to our list.
+		if ([path.pathExtension isEqualToString:@"love"])
+			[paths addObject:path];
+		else if ([path.lastPathComponent isEqualToString:@"main.lua"])
+			[paths addObject:path.stringByDeletingLastPathComponent];
+	}
+
+	return paths;
 }
 
 static bool deleteFileInDocuments(NSString *filename)

+ 2 - 2
src/common/macosx.h

@@ -29,7 +29,7 @@
 
 namespace love
 {
-namespace osx
+namespace macosx
 {
 
 /**
@@ -55,7 +55,7 @@ std::string getExecutablePath();
  **/
 void requestAttention(bool continuous);
 
-} // osx
+} // macosx
 } // love
 
 #endif // LOVE_MACOSX

+ 1 - 1
src/common/macosx.mm

@@ -29,7 +29,7 @@
 
 namespace love
 {
-namespace osx
+namespace macosx
 {
 
 std::string getLoveInResources()

+ 2 - 2
src/love.cpp

@@ -111,7 +111,7 @@ static void get_app_arguments(int argc, char **argv, int &new_argc, char **&new_
 
 #ifdef LOVE_MACOSX
 	// Check for a drop file string.
-	std::string dropfilestr = love::osx::checkDropEvents();
+	std::string dropfilestr = love::macosx::checkDropEvents();
 	if (!dropfilestr.empty())
 	{
 		temp_argv.insert(temp_argv.begin() + 1, dropfilestr);
@@ -123,7 +123,7 @@ static void get_app_arguments(int argc, char **argv, int &new_argc, char **&new_
 		std::string loveResourcesPath;
 		bool fused = true;
 #if defined(LOVE_MACOSX)
-		loveResourcesPath = love::osx::getLoveInResources();
+		loveResourcesPath = love::macosx::getLoveInResources();
 #elif defined(LOVE_IOS)
 		loveResourcesPath = love::ios::getLoveInResources(fused);
 #endif

+ 1 - 1
src/modules/filesystem/Filesystem.cpp

@@ -74,7 +74,7 @@ bool Filesystem::isRealDirectory(const std::string &path) const
 std::string Filesystem::getExecutablePath() const
 {
 #if defined(LOVE_MACOSX)
-	return love::osx::getExecutablePath();
+	return love::macosx::getExecutablePath();
 #elif defined(LOVE_IOS)
 	return love::ios::getExecutablePath();
 #elif defined(LOVE_WINDOWS)

+ 1 - 1
src/modules/window/sdl/Window.cpp

@@ -1031,7 +1031,7 @@ void Window::requestAttention(bool continuous)
 
 #elif defined(LOVE_MACOSX)
 
-	love::osx::requestAttention(continuous);
+	love::macosx::requestAttention(continuous);
 
 #else