project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 4290 82f1f1d819c0
parent 4287 7dbdc862097c
child 4349 8efa91f98274
equal deleted inserted replaced
4287:7dbdc862097c 4290:82f1f1d819c0
   348     }
   348     }
   349     self.mapGenCommand = mapgen;
   349     self.mapGenCommand = mapgen;
   350     self.staticMapCommand = staticmap;
   350     self.staticMapCommand = staticmap;
   351     self.missionCommand = mission;
   351     self.missionCommand = mission;
   352 
   352 
   353     // nice animation for updating the table when appropriate (on iphone)
       
   354     /*
       
   355     if (IS_IPAD() == NO)
       
   356         if (((oldPage == 0 || oldPage == 2) && (newPage == 1 || newPage == 3)) ||
       
   357             ((oldPage == 1 || oldPage == 3) && (newPage == 0 || newPage == 2)) ||
       
   358             ((oldPage == 1 && newPage == 3) || (oldPage == 3 || newPage == 1))) {
       
   359             self.tableView.frame = CGRectMake(480, 0, 185, 276);
       
   360             [UIView beginAnimations:@"moving in table" context:NULL];
       
   361             self.tableView.frame = CGRectMake(295, 0, 185, 276);
       
   362             [UIView commitAnimations];
       
   363         }
       
   364     */
       
   365 
       
   366     [self.tableView reloadData];
   353     [self.tableView reloadData];
   367     [self updatePreview];
   354     [self updatePreview];
   368     oldPage = newPage;
   355     oldPage = newPage;
   369 }
   356 }
   370 
   357 
   383                                                           error:NULL];
   370                                                           error:NULL];
   384     NSMutableArray *themeArray = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
   371     NSMutableArray *themeArray = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
   385     [string release];
   372     [string release];
   386     // remove a trailing "" element
   373     // remove a trailing "" element
   387     [themeArray removeLastObject];
   374     [themeArray removeLastObject];
   388     NSArray *mapArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
   375     NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
   389     NSArray *missionArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL];
   376     NSMutableArray *mapArray = [[NSMutableArray alloc] init];
       
   377     for (NSString *str in mapArrayFull) {
       
   378         CGSize imgSize = PSPNGSizeFromMetaData([MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]);
       
   379         //DLog(@"%@ %f %f", str, imgSize.width, imgSize.height);
       
   380         if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f)
       
   381             continue;
       
   382         if (IS_IPAD() && imgSize.height > 1280.0f)
       
   383             continue;
       
   384         [mapArray addObject:str];
       
   385     }
   390     
   386     
       
   387     NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL];
       
   388     NSMutableArray *missionArray = [[NSMutableArray alloc] init];
       
   389     for (NSString *str in missionArrayFull) {
       
   390         CGSize imgSize = PSPNGSizeFromMetaData([MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]);
       
   391         //DLog(@"%@ %f %f", str, imgSize.width, imgSize.height);
       
   392         if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f)
       
   393             continue;
       
   394         if (IS_IPAD() && imgSize.height > 1280.0f)
       
   395             continue;
       
   396         [missionArray addObject:str];
       
   397     }
   391     NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil];
   398     NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil];
       
   399     [missionArray release];
       
   400     [themeArray release];
       
   401     [mapArray release];
       
   402 
   392     self.dataSourceArray = array;
   403     self.dataSourceArray = array;
   393     [array release];
   404     [array release];
   394     [themeArray release];
       
   395 }
   405 }
   396 
   406 
   397 -(void) viewDidLoad {
   407 -(void) viewDidLoad {
   398     [super viewDidLoad];
   408     [super viewDidLoad];
   399 
   409 
   467 }
   477 }
   468 
   478 
   469 -(void) didReceiveMemoryWarning {
   479 -(void) didReceiveMemoryWarning {
   470     self.dataSourceArray = nil;
   480     self.dataSourceArray = nil;
   471 
   481 
   472     self.previewButton = nil;
       
   473     self.tableView = nil;
   482     self.tableView = nil;
   474     self.maxLabel = nil;
   483     self.maxLabel = nil;
   475     self.sizeLabel = nil;
   484     self.sizeLabel = nil;
   476     self.segmentedControl = nil;
       
   477     self.slider = nil;
   485     self.slider = nil;
   478 
   486 
   479     MSG_MEMCLEAN();
   487     MSG_MEMCLEAN();
   480     [super didReceiveMemoryWarning];
   488     [super didReceiveMemoryWarning];
   481 }
   489 }