project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 5281 3324e9897ea7
parent 5208 878e551f0b4a
child 5483 fc755bb8096d
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Tue Jun 21 22:57:10 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Tue Jun 21 22:57:46 2011 +0200
@@ -380,14 +380,14 @@
 -(void) loadDataSourceArray {
     NSString *model = getModelType();
 
-    // themes.cfg contains all the user-selectable themes
-    NSString *string = [[NSString alloc] initWithContentsOfFile:[THEMES_DIRECTORY() stringByAppendingString:@"/themes.cfg"]
-                                                       encoding:NSUTF8StringEncoding
-                                                          error:NULL];
-    NSMutableArray *themeArray = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
-    [string release];
-    // remove a trailing "" element
-    [themeArray removeLastObject];
+    // only folders containing icon.png are a valid theme
+    NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL];
+    NSMutableArray *themeArray = [[NSMutableArray alloc] init];
+    for (NSString *themeName in themeArrayFull) {
+        NSString *checkPath = [[NSString alloc] initWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),themeName];
+        if ([[NSFileManager defaultManager] fileExistsAtPath:checkPath])
+            [themeArray addObject:themeName];
+    }
 
     // remove images that are too big for certain devices without loading the whole image
     NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];