project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 6109 f6726ec81e64
parent 6108 7a8da11a6144
child 6115 485cfecadc9a
equal deleted inserted replaced
6108:7a8da11a6144 6109:f6726ec81e64
    36 
    36 
    37 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    37 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    38     return rotationManager(interfaceOrientation);
    38     return rotationManager(interfaceOrientation);
    39 }
    39 }
    40 
    40 
    41 -(IBAction) mapButtonPressed {
    41 -(IBAction) mapButtonPressed:(id) sender {
    42     [AudioManagerController playClickSound];
    42     [AudioManagerController playClickSound];
    43     [self updatePreview];
    43     [self updatePreview];
    44 }
    44 }
    45 
    45 
    46 -(void) updatePreview {
    46 -(void) updatePreview {
    55     NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
    55     NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
    56     self.seedCommand = seedCmd;
    56     self.seedCommand = seedCmd;
    57     [seedCmd release];
    57     [seedCmd release];
    58 
    58 
    59     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
    59     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
    60     NSIndexPath *theIndex;
       
    61     if (isRandomness()) {
    60     if (isRandomness()) {
    62         // prevent other events and add an activity while the preview is beign generated
    61         // prevent other events and add an activity while the preview is beign generated
    63         [self turnOffWidgets];
    62         [self turnOffWidgets];
    64         [self.previewButton updatePreviewWithSeed:seed];
    63         [self.previewButton updatePreviewWithSeed:seed];
    65         theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
       
    66     } else {
       
    67         theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
       
    68         // the preview for static maps is loaded in didSelectRowAtIndexPath
    64         // the preview for static maps is loaded in didSelectRowAtIndexPath
    69     }
    65     }
    70     [seed release];
    66     [seed release];
    71 
    67 
    72     // perform as if user clicked on an entry
    68     // perform as if user clicked on an entry
       
    69     NSIndexPath *theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
    73     [self tableView:self.tableView didSelectRowAtIndexPath:theIndex];
    70     [self tableView:self.tableView didSelectRowAtIndexPath:theIndex];
    74     if (IS_NOT_POWERFUL([HWUtils modelType]) == NO)
    71     if (IS_NOT_POWERFUL([HWUtils modelType]) == NO)
    75         [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    72         [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
    76 }
    73 }
    77 
    74 
   411         [array release];
   408         [array release];
   412     }
   409     }
   413     return dataSourceArray;
   410     return dataSourceArray;
   414 }
   411 }
   415 
   412 
       
   413 -(MapPreviewButtonView *)previewButton {
       
   414     if (previewButton == nil) {
       
   415         MapPreviewButtonView *preview = [[MapPreviewButtonView alloc] initWithFrame:CGRectMake(736, 26, 256, 128)];
       
   416         preview.delegate = self;
       
   417         [preview addTarget:self action:@selector(mapButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
       
   418         [self.view addSubview:preview];
       
   419         self.previewButton = preview;
       
   420         [preview release];
       
   421     }
       
   422     return previewButton;
       
   423 }
       
   424 
   416 -(void) viewDidLoad {
   425 -(void) viewDidLoad {
   417     [super viewDidLoad];
   426     [super viewDidLoad];
   418 
   427 
   419     srandom(time(NULL));
   428     srandom(time(NULL));
   420 
   429 
   486     [super viewDidUnload];
   495     [super viewDidUnload];
   487 }
   496 }
   488 
   497 
   489 -(void) didReceiveMemoryWarning {
   498 -(void) didReceiveMemoryWarning {
   490     self.dataSourceArray = nil;
   499     self.dataSourceArray = nil;
       
   500     self.previewButton = nil;
   491     [super didReceiveMemoryWarning];
   501     [super didReceiveMemoryWarning];
   492 
   502 
   493     if (self.view.superview == nil) {
   503     if (self.view.superview == nil) {
   494         self.tableView = nil;
   504         self.tableView = nil;
   495         self.maxLabel = nil;
   505         self.maxLabel = nil;