project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 3703 12d17c6e8855
parent 3697 d5b30d6373fc
child 3705 e1959819a542
equal deleted inserted replaced
3701:8c449776ebe6 3703:12d17c6e8855
   295     UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
   295     UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
   296     if (cell == nil)
   296     if (cell == nil)
   297         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
   297         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
   298 
   298 
   299     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   299     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   300         cell.textLabel.textColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1 ];
   300         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   301     }
   301     }
   302 
   302 
   303     if (self.segmentedControl.selectedSegmentIndex != 1) {
   303     if (self.segmentedControl.selectedSegmentIndex != 1) {
   304         // the % prevents a strange bug that occurs sporadically
   304         // the % prevents a strange bug that occurs sporadically
   305         NSString *themeName = [self.themeArray objectAtIndex:row % [self.themeArray count]];
   305         NSString *themeName = [self.themeArray objectAtIndex:row % [self.themeArray count]];
   310     } else {
   310     } else {
   311         cell.textLabel.text = [self.mapArray objectAtIndex:row];
   311         cell.textLabel.text = [self.mapArray objectAtIndex:row];
   312         cell.imageView.image = nil;
   312         cell.imageView.image = nil;
   313     }
   313     }
   314 
   314 
   315     if (row == [self.lastIndexPath row])
   315     if (row == [self.lastIndexPath row]) {
   316         cell.accessoryType = UITableViewCellAccessoryCheckmark;
   316         UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]];
   317     else
   317         cell.accessoryView = checkbox;
   318         cell.accessoryType = UITableViewCellAccessoryNone;
   318         [checkbox release];
   319 
   319     } else
       
   320         cell.accessoryView = nil;
       
   321 
       
   322     cell.backgroundColor = [UIColor blackColor];
   320     return cell;
   323     return cell;
   321 }
   324 }
   322 
   325 
   323 
   326 
   324 #pragma mark -
   327 #pragma mark -
   335             // theme and map are set in the function below
   338             // theme and map are set in the function below
   336             [self updatePreviewWithMap:newRow];
   339             [self updatePreviewWithMap:newRow];
   337         }
   340         }
   338 
   341 
   339         UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
   342         UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
   340         newCell.accessoryType = UITableViewCellAccessoryCheckmark;
   343         UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]];
       
   344         newCell.accessoryView = checkbox;
       
   345         [checkbox release];
   341         UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:self.lastIndexPath];
   346         UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:self.lastIndexPath];
   342         oldCell.accessoryType = UITableViewCellAccessoryNone;
   347         oldCell.accessoryView = nil;
   343 
   348 
   344         self.lastIndexPath = indexPath;
   349         self.lastIndexPath = indexPath;
   345         [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
   350         [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
   346     }
   351     }
   347     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   352     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   513     [array removeLastObject];
   518     [array removeLastObject];
   514     self.themeArray = array;
   519     self.themeArray = array;
   515     [array release];
   520     [array release];
   516     self.mapArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
   521     self.mapArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
   517 
   522 
   518     self.tableView.rowHeight = 42;
       
   519     busy = NO;
   523     busy = NO;
   520 
   524 
   521     // draw a white background
   525     // draw a white background
   522     [self restoreBackgroundImage];
   526     [self restoreBackgroundImage];
   523 
   527 
   525     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   529     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   526     self.slider.value = 0.05f;
   530     self.slider.value = 0.05f;
   527 
   531 
   528     // on slower device we show directly the static map
   532     // on slower device we show directly the static map
   529     NSString *modelId = modelType();
   533     NSString *modelId = modelType();
   530     if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])
   534     //if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])
       
   535     if (1)
   531         self.segmentedControl.selectedSegmentIndex = 1;
   536         self.segmentedControl.selectedSegmentIndex = 1;
   532     else
   537     else
   533         self.segmentedControl.selectedSegmentIndex = 0;
   538         self.segmentedControl.selectedSegmentIndex = 0;
   534 
   539 
   535     self.templateFilterCommand = @"e$template_filter 0";
   540     self.templateFilterCommand = @"e$template_filter 0";
   539 
   544 
   540     self.lastIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
   545     self.lastIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
   541 
   546 
   542     oldValue = 5;
   547     oldValue = 5;
   543     oldPage = 0;
   548     oldPage = 0;
       
   549     
       
   550     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       
   551         [self.tableView setBackgroundView:nil];
       
   552         self.view.backgroundColor = [UIColor clearColor];
       
   553         self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
       
   554         self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
       
   555         self.tableView.rowHeight = 45;
       
   556     }
   544 }
   557 }
   545 
   558 
   546 -(void) viewDidAppear:(BOOL) animated {
   559 -(void) viewDidAppear:(BOOL) animated {
   547     [super viewDidAppear:animated];
   560     [super viewDidAppear:animated];
   548     [self updatePreview];
   561     [self updatePreview];