project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 3670 4c673e57f0d7
parent 3662 a44406f4369b
child 3697 d5b30d6373fc
equal deleted inserted replaced
3668:3f7a95234d8a 3670:4c673e57f0d7
   162     self.seedCommand = seedCmd;
   162     self.seedCommand = seedCmd;
   163     [seedCmd release];
   163     [seedCmd release];
   164     
   164     
   165     NSIndexPath *theIndex;
   165     NSIndexPath *theIndex;
   166     if (segmentedControl.selectedSegmentIndex != 1) {
   166     if (segmentedControl.selectedSegmentIndex != 1) {
   167         // prevent other events and add an activity while the preview is beign generated
   167         // remove the current preview and title
   168         [self turnOffWidgets];
   168         [self.previewButton setImage:nil forState:UIControlStateNormal];
       
   169         [self.previewButton setTitle:nil forState:UIControlStateNormal];
   169         
   170         
   170         // remove the current preview
   171         // don't display preview on slower device, too slow and memory hog
   171         [self.previewButton setImage:nil forState:UIControlStateNormal];
   172         NSString *modelId = modelType();
       
   173         if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) {
       
   174             busy = NO;
       
   175             [self.previewButton setTitle:NSLocalizedString(@"Preview not available",@"") forState:UIControlStateNormal];
       
   176         } else {
       
   177             // prevent other events and add an activity while the preview is beign generated
       
   178             [self turnOffWidgets];
       
   179             
       
   180             // add a very nice spinning wheel
       
   181             UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] 
       
   182                                                   initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
       
   183             indicator.center = CGPointMake(previewButton.bounds.size.width / 2, previewButton.bounds.size.height / 2);
       
   184             indicator.tag = INDICATOR_TAG;
       
   185             [indicator startAnimating];
       
   186             [self.previewButton addSubview:indicator];
       
   187             [indicator release];
       
   188             
       
   189             // let's draw in a separate thread so the gui can work; at the end it restore other widgets
       
   190             [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
       
   191         }
   172         
   192         
   173         // add a very nice spinning wheel
       
   174         UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] 
       
   175                                               initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
       
   176         indicator.center = CGPointMake(previewButton.bounds.size.width / 2, previewButton.bounds.size.height / 2);
       
   177         indicator.tag = INDICATOR_TAG;
       
   178         [indicator startAnimating];
       
   179         [self.previewButton addSubview:indicator];
       
   180         [indicator release];
       
   181         
       
   182         // let's draw in a separate thread so the gui can work; at the end it restore other widgets
       
   183         [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
       
   184     
       
   185         theIndex = [NSIndexPath indexPathForRow:(random()%[self.themeArray count]) inSection:0];
   193         theIndex = [NSIndexPath indexPathForRow:(random()%[self.themeArray count]) inSection:0];
   186     } else {
   194     } else {
   187         theIndex = [NSIndexPath indexPathForRow:(random()%[self.mapArray count]) inSection:0];
   195         theIndex = [NSIndexPath indexPathForRow:(random()%[self.mapArray count]) inSection:0];
   188     }
   196     }
   189     [self.tableView reloadData];
   197     [self.tableView reloadData];
   514     [self restoreBackgroundImage];
   522     [self restoreBackgroundImage];
   515     
   523     
   516     // initialize some "default" values
   524     // initialize some "default" values
   517     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   525     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   518     self.slider.value = 0.05f;
   526     self.slider.value = 0.05f;
   519     self.segmentedControl.selectedSegmentIndex = 0;
   527     
       
   528     // on slower device we show directly the static map
       
   529     NSString *modelId = modelType();
       
   530     if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])
       
   531         self.segmentedControl.selectedSegmentIndex = 1;
       
   532     else
       
   533         self.segmentedControl.selectedSegmentIndex = 0;
   520 
   534 
   521     self.templateFilterCommand = @"e$template_filter 0";
   535     self.templateFilterCommand = @"e$template_filter 0";
   522     self.mazeSizeCommand = @"e$maze_size 0";
   536     self.mazeSizeCommand = @"e$maze_size 0";
   523     self.mapGenCommand = @"e$mapgen 0";
   537     self.mapGenCommand = @"e$mapgen 0";
   524     self.staticMapCommand = @"";
   538     self.staticMapCommand = @"";