update theme listing for ios
authorkoda
Tue, 21 Jun 2011 22:57:46 +0200
changeset 5281 3324e9897ea7
parent 5280 612527a48cd1
child 5282 f4f040891ee3
update theme listing for ios
QTfrontend/pageroomslist.cpp
project_files/HedgewarsMobile/Classes/MapConfigViewController.m
--- a/QTfrontend/pageroomslist.cpp	Tue Jun 21 22:57:10 2011 +0200
+++ b/QTfrontend/pageroomslist.cpp	Tue Jun 21 22:57:46 2011 +0200
@@ -135,7 +135,7 @@
 
 void PageRoomsList::setAdmin(bool flag)
 {
-    BtnAdmin->setVisible(flag);
+    //BtnAdmin->setVisible(flag);
 }
 
 void PageRoomsList::setRoomsList(const QStringList & list)
@@ -152,7 +152,7 @@
     if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0))
         selection = item->text();
     
-    roomsList->clear();
+    //roomsList->clear();
     roomsList->setColumnCount(7);
     roomsList->setHorizontalHeaderLabels(
             QStringList() <<
--- 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];