project_files/HedgewarsMobile/Classes/MapConfigViewController.m
changeset 3911 46d7a5cf8ac6
parent 3910 dd47efbdec46
child 3912 e11df2de6af2
equal deleted inserted replaced
3910:dd47efbdec46 3911:46d7a5cf8ac6
    22 #import "MapConfigViewController.h"
    22 #import "MapConfigViewController.h"
    23 #import "PascalImports.h"
    23 #import "PascalImports.h"
    24 #import "CommodityFunctions.h"
    24 #import "CommodityFunctions.h"
    25 #import "UIImageExtra.h"
    25 #import "UIImageExtra.h"
    26 
    26 
       
    27 #define scIndex         self.segmentedControl.selectedSegmentIndex
       
    28 #define isRandomness()  (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2)
    27 
    29 
    28 @implementation MapConfigViewController
    30 @implementation MapConfigViewController
    29 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand,
    31 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand,
    30             tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, themeArray, mapArray, busy, delegate;
    32             missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, delegate;
    31 
    33 
    32 
    34 
    33 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    35 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    34     return rotationManager(interfaceOrientation);
    36     return rotationManager(interfaceOrientation);
    35 }
    37 }
    50     CFRelease(uuid);
    52     CFRelease(uuid);
    51     NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
    53     NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
    52     self.seedCommand = seedCmd;
    54     self.seedCommand = seedCmd;
    53     [seedCmd release];
    55     [seedCmd release];
    54 
    56 
       
    57     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
    55     NSIndexPath *theIndex;
    58     NSIndexPath *theIndex;
    56     if (segmentedControl.selectedSegmentIndex != 1) {
    59     if (isRandomness()) {
    57         // prevent other events and add an activity while the preview is beign generated
    60         // prevent other events and add an activity while the preview is beign generated
    58         [self turnOffWidgets];
    61         [self turnOffWidgets];
    59         [self.previewButton updatePreviewWithSeed:seed];
    62         [self.previewButton updatePreviewWithSeed:seed];
    60         theIndex = [NSIndexPath indexPathForRow:(random()%[self.themeArray count]) inSection:0];
    63         theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
    61     } else {
    64     } else {
    62         theIndex = [NSIndexPath indexPathForRow:(random()%[self.mapArray count]) inSection:0];
    65         theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0];
    63         // the preview for static maps is loaded in didSelectRowAtIndexPath
    66         // the preview for static maps is loaded in didSelectRowAtIndexPath
    64     }
    67     }
    65     [seed release];
    68     [seed release];
    66 
    69 
    67     // perform as if user clicked on an entry
    70     // perform as if user clicked on an entry
   106 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
   109 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
   107     return 1;
   110     return 1;
   108 }
   111 }
   109 
   112 
   110 -(NSInteger) tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger) section {
   113 -(NSInteger) tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger) section {
   111     if (self.segmentedControl.selectedSegmentIndex != 1)
   114     return [[self.dataSourceArray objectAtIndex:scIndex] count];
   112         return [themeArray count];
       
   113     else
       
   114         return [mapArray count];
       
   115 }
   115 }
   116 
   116 
   117 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   117 -(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   118     static NSString *CellIdentifier = @"Cell";
   118     static NSString *CellIdentifier = @"Cell";
   119     NSInteger row = [indexPath row];
   119     NSInteger row = [indexPath row];
   123         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
   123         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
   124 
   124 
   125     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   125     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
   126         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   126         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   127 
   127 
   128     if (self.segmentedControl.selectedSegmentIndex != 1) {
   128     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
   129         // the % prevents a strange bug that occurs sporadically
   129 
   130         NSString *themeName = [self.themeArray objectAtIndex:row % [self.themeArray count]];
   130     NSString *labelString = [source objectAtIndex:row];
   131         cell.textLabel.text = themeName;
   131     cell.textLabel.text = labelString;
   132         UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),themeName]];
   132 
       
   133     if (isRandomness()) {
       
   134         UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),labelString]];
   133         cell.imageView.image = image;
   135         cell.imageView.image = image;
   134         [image release];
   136         [image release];
   135     } else {
   137     } else
   136         cell.textLabel.text = [self.mapArray objectAtIndex:row];
       
   137         cell.imageView.image = nil;
   138         cell.imageView.image = nil;
   138     }
       
   139 
   139 
   140     if (row == [self.lastIndexPath row]) {
   140     if (row == [self.lastIndexPath row]) {
   141         UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]];
   141         UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]];
   142         cell.accessoryView = checkbox;
   142         cell.accessoryView = checkbox;
   143         [checkbox release];
   143         [checkbox release];
   148     return cell;
   148     return cell;
   149 }
   149 }
   150 
   150 
   151 // this set details for a static map (called by didSelectRowAtIndexPath)
   151 // this set details for a static map (called by didSelectRowAtIndexPath)
   152 -(void) setDetailsForStaticMap:(NSInteger) index {
   152 -(void) setDetailsForStaticMap:(NSInteger) index {
   153     // update label
   153     NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
   154     maxHogs = 18;
   154     
   155     NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg", MAPS_DIRECTORY(),[self.mapArray objectAtIndex:index]];
   155     NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg", 
       
   156                          (scIndex == 1) ? MAPS_DIRECTORY() : MISSIONS_DIRECTORY(),[source objectAtIndex:index]];
   156     NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL];
   157     NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL];
   157     [fileCfg release];
   158     [fileCfg release];
   158     NSArray *split = [contents componentsSeparatedByString:@"\n"];
   159     NSArray *split = [contents componentsSeparatedByString:@"\n"];
   159     [contents release];
   160     [contents release];
   160 
   161 
   161     // set the theme and map here
       
   162     self.themeCommand = [NSString stringWithFormat:@"etheme %@", [split objectAtIndex:0]];
       
   163     self.staticMapCommand = [NSString stringWithFormat:@"emap %@", [self.mapArray objectAtIndex:index]];
       
   164 
       
   165     // if the number is not set we keep 18 standard;
   162     // if the number is not set we keep 18 standard;
   166     // sometimes it's not set but there are trailing characters, we get around them with the second equation
   163     // sometimes it's not set but there are trailing characters, we get around them with the second equation
   167     if ([split count] > 1 && [[split objectAtIndex:1] intValue] > 0)
   164     if ([split count] > 1 && [[split objectAtIndex:1] intValue] > 0)
   168         maxHogs = [[split objectAtIndex:1] intValue];
   165         maxHogs = [[split objectAtIndex:1] intValue];
       
   166     else
       
   167         maxHogs = 18;
   169     NSString *max = [[NSString alloc] initWithFormat:@"%d",maxHogs];
   168     NSString *max = [[NSString alloc] initWithFormat:@"%d",maxHogs];
   170     self.maxLabel.text = max;
   169     self.maxLabel.text = max;
   171     [max release];
   170     [max release];
       
   171     
       
   172     self.themeCommand = [NSString stringWithFormat:@"etheme %@", [split objectAtIndex:0]];
       
   173     self.staticMapCommand = [NSString stringWithFormat:@"emap %@", [source objectAtIndex:index]];
       
   174     if (scIndex != 3)
       
   175         self.missionCommand = @"";
       
   176     else
       
   177         self.missionCommand = [NSString stringWithFormat:@"escript %@/%@/map.lua",MISSIONS_DIRECTORY(),[source objectAtIndex:index]];
   172 }
   178 }
   173 
   179 
   174 #pragma mark -
   180 #pragma mark -
   175 #pragma mark Table view delegate
   181 #pragma mark Table view delegate
   176 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   182 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   177     int newRow = [indexPath row];
   183     int newRow = [indexPath row];
   178     int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
   184     int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
   179 
   185 
   180     if (newRow != oldRow) {
   186     if (newRow != oldRow) {
   181         [self.tableView reloadData];
   187         NSArray *source = [self.dataSourceArray objectAtIndex:scIndex];
   182         if (self.segmentedControl.selectedSegmentIndex != 1) {
   188         if (isRandomness()) {
   183             // just change the theme, don't update preview
   189             // just change the theme, don't update preview
   184             self.themeCommand = [NSString stringWithFormat:@"etheme %@", [self.themeArray objectAtIndex:newRow]];
   190             self.themeCommand = [NSString stringWithFormat:@"etheme %@", [source objectAtIndex:newRow]];
   185         } else {
   191         } else {
   186             NSString *fileImage = [NSString stringWithFormat:@"%@/%@/preview.png",MAPS_DIRECTORY(),[self.mapArray objectAtIndex:newRow]];
   192             NSString *fileImage = [NSString stringWithFormat:@"%@/%@/preview.png",
       
   193                                    (scIndex == 1) ? MAPS_DIRECTORY() : MISSIONS_DIRECTORY(),[source objectAtIndex:newRow]];
   187             [self.previewButton updatePreviewWithFile:fileImage];
   194             [self.previewButton updatePreviewWithFile:fileImage];
   188             [self setDetailsForStaticMap:newRow];
   195             [self setDetailsForStaticMap:newRow];
   189         }
   196         }
   190 
   197 
   191         UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
   198         UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
   288 }
   295 }
   289 
   296 
   290 // perform actions based on the activated section, then call updatePreview to visually update the selection
   297 // perform actions based on the activated section, then call updatePreview to visually update the selection
   291 // and if necessary update the table with a slide animation
   298 // and if necessary update the table with a slide animation
   292 -(IBAction) segmentedControlChanged:(id) sender {
   299 -(IBAction) segmentedControlChanged:(id) sender {
   293     NSString *mapgen, *staticmap;
   300     NSString *mapgen, *staticmap, *mission;
   294     NSInteger newPage = self.segmentedControl.selectedSegmentIndex;
   301     NSInteger newPage = self.segmentedControl.selectedSegmentIndex;
   295 
   302 
   296     playSound(@"selSound");
   303     playSound(@"selSound");
   297     switch (newPage) {
   304     switch (newPage) {
   298         case 0: // Random
   305         case 0: // Random
   299             mapgen = @"e$mapgen 0";
   306             mapgen = @"e$mapgen 0";
   300             staticmap = @"";
   307             staticmap = @"";
       
   308             mission = @"";
   301             [self sliderChanged:nil];
   309             [self sliderChanged:nil];
   302             self.slider.enabled = YES;
   310             self.slider.enabled = YES;
   303             break;
   311             break;
   304 
   312 
   305         case 1: // Map
   313         case 1: // Map
       
   314         case 3: // Mission
   306             mapgen = @"e$mapgen 0";
   315             mapgen = @"e$mapgen 0";
   307             // dummy value, everything is set by -updatePreview -> -didSelectRowAtIndexPath -> -updatePreviewWithMap
   316             // dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap
   308             staticmap = @"map Bamboo";
   317             staticmap = @"map Bamboo";
       
   318             mission = @"";
   309             self.slider.enabled = NO;
   319             self.slider.enabled = NO;
   310             self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
   320             self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
   311             break;
   321             break;
   312 
   322 
   313         case 2: // Maze
   323         case 2: // Maze
   314             mapgen = @"e$mapgen 1";
   324             mapgen = @"e$mapgen 1";
   315             staticmap = @"";
   325             staticmap = @"";
       
   326             mission = @"";
   316             [self sliderChanged:nil];
   327             [self sliderChanged:nil];
   317             self.slider.enabled = YES;
   328             self.slider.enabled = YES;
   318             break;
   329             break;
   319 
   330 
   320         default:
   331         default:
   321             mapgen = nil;
   332             mapgen = nil;
   322             staticmap = nil;
   333             staticmap = nil;
       
   334             mission = nil;
   323             break;
   335             break;
   324     }
   336     }
   325     self.mapGenCommand = mapgen;
   337     self.mapGenCommand = mapgen;
   326     self.staticMapCommand = staticmap;
   338     self.staticMapCommand = staticmap;
   327     [self updatePreview];
   339     self.missionCommand = mission;
   328 
   340 
   329     // nice animation for updating the table when appropriate (on iphone)
   341     // nice animation for updating the table when appropriate (on iphone)
   330     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
   342     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
   331         if (((oldPage == 0 || oldPage == 2) && newPage == 1) ||
   343         if (((oldPage == 0 || oldPage == 2) && (newPage == 1 || newPage == 3)) ||
   332             (oldPage == 1 && (newPage == 0 || newPage == 2))) {
   344             ((oldPage == 1 || oldPage == 3) && (newPage == 0 || newPage == 2)) ||
   333             [UIView beginAnimations:@"moving out table" context:NULL];
   345             ((oldPage == 1 && newPage == 3) || (oldPage == 3 || newPage == 1))) {
   334             self.tableView.frame = CGRectMake(480, 0, 185, 276);
   346             self.tableView.frame = CGRectMake(480, 0, 185, 276);
       
   347             [UIView beginAnimations:@"moving in table" context:NULL];
       
   348             self.tableView.frame = CGRectMake(295, 0, 185, 276);
   335             [UIView commitAnimations];
   349             [UIView commitAnimations];
   336             [self performSelector:@selector(moveTable) withObject:nil afterDelay:0.2];
       
   337         }
   350         }
       
   351 
       
   352     [self.tableView reloadData];
       
   353     [self updatePreview];
   338     oldPage = newPage;
   354     oldPage = newPage;
   339 }
   355 }
   340 
   356 
   341 // update data when table is not visible and then show it
   357 #pragma mark -
   342 -(void) moveTable {
   358 #pragma mark delegate functions for iPad
   343     [self.tableView reloadData];
   359 -(IBAction) buttonPressed:(id) sender {
   344 
   360     if (self.delegate != nil && [delegate respondsToSelector:@selector(buttonPressed:)])
   345     [UIView beginAnimations:@"moving in table" context:NULL];
   361         [self.delegate buttonPressed:(UIButton *)sender];
   346     self.tableView.frame = CGRectMake(295, 0, 185, 276);
   362 }
   347     [UIView commitAnimations];
   363 
       
   364 -(void) loadDataSourceArray {
       
   365     // themes.cfg contains all the user-selectable themes
       
   366     NSString *string = [[NSString alloc] initWithContentsOfFile:[THEMES_DIRECTORY() stringByAppendingString:@"/themes.cfg"]
       
   367                                                        encoding:NSUTF8StringEncoding
       
   368                                                           error:NULL];
       
   369     NSMutableArray *themeArray = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
       
   370     [string release];
       
   371     // remove a trailing "" element
       
   372     [themeArray removeLastObject];
       
   373     NSArray *mapArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
       
   374     NSArray *missionArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL];
       
   375     
       
   376     NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil];
       
   377     self.dataSourceArray = array;
       
   378     [array release];
       
   379     [themeArray release];
   348 }
   380 }
   349 
   381 
   350 #pragma mark -
   382 #pragma mark -
   351 #pragma mark view management
   383 #pragma mark view management
   352 -(void) viewDidLoad {
   384 -(void) viewDidLoad {
   354 
   386 
   355     srandom(time(NULL));
   387     srandom(time(NULL));
   356 
   388 
   357     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
   389     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
   358     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
   390     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
   359 
   391     
   360     // themes.cfg contains all the user-selectable themes
       
   361     NSString *string = [[NSString alloc] initWithContentsOfFile:[THEMES_DIRECTORY() stringByAppendingString:@"/themes.cfg"]
       
   362                                                        encoding:NSUTF8StringEncoding
       
   363                                                           error:NULL];
       
   364     NSMutableArray *array = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
       
   365     [string release];
       
   366     // remove a trailing "" element
       
   367     [array removeLastObject];
       
   368     self.themeArray = array;
       
   369     [array release];
       
   370     self.mapArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
       
   371 
       
   372     // initialize some "default" values
   392     // initialize some "default" values
   373     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   393     self.sizeLabel.text = NSLocalizedString(@"All",@"");
   374     self.slider.value = 0.05f;
   394     self.slider.value = 0.05f;
   375 
   395     oldValue = 5;
       
   396     
       
   397     busy = NO;
       
   398     [self loadDataSourceArray];
       
   399     self.lastIndexPath = [NSIndexPath indexPathForRow:-1 inSection:0];
       
   400     
   376     // select a map at first because it's faster - done in IB
   401     // select a map at first because it's faster - done in IB
   377     //self.segmentedControl.selectedSegmentIndex = 1;
   402     oldPage = 1;
   378     if (self.segmentedControl.selectedSegmentIndex == 1) {
   403     if (self.segmentedControl.selectedSegmentIndex == 1) {
   379         self.slider.enabled = NO;
   404         self.slider.enabled = NO;
   380         self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
   405         self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
   381     }
   406     }
   382 
   407 
   383     self.templateFilterCommand = @"e$template_filter 0";
   408     self.templateFilterCommand = @"e$template_filter 0";
   384     self.mazeSizeCommand = @"e$maze_size 0";
   409     self.mazeSizeCommand = @"e$maze_size 0";
   385     self.mapGenCommand = @"e$mapgen 0";
   410     self.mapGenCommand = @"e$mapgen 0";
   386     self.staticMapCommand = @"";
   411     self.staticMapCommand = @"";
   387 
   412     self.missionCommand = @"";
   388     self.lastIndexPath = [NSIndexPath indexPathForRow:-1 inSection:0];
       
   389 
       
   390     oldValue = 5;
       
   391     oldPage = 0;
       
   392     busy = NO;
       
   393 
   413 
   394     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   414     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   395         [self.tableView setBackgroundView:nil];
   415         [self.tableView setBackgroundView:nil];
   396         self.view.backgroundColor = [UIColor clearColor];
   416         self.view.backgroundColor = [UIColor clearColor];
   397         self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
   417         self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER;
   398         self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
   418         self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
   399         self.tableView.rowHeight = 45;
   419         self.tableView.rowHeight = 45;
   400     }
   420     }
   401 }
   421 }
   402 
   422 
       
   423 -(void) viewWillAppear:(BOOL)animated {
       
   424     if (self.dataSourceArray == nil)
       
   425         [self loadDataSourceArray];
       
   426     [super viewWillAppear:animated];
       
   427 }
       
   428 
   403 -(void) viewDidAppear:(BOOL) animated {
   429 -(void) viewDidAppear:(BOOL) animated {
   404     [self updatePreview];
   430     [self updatePreview];
   405     [super viewDidAppear:animated];
   431     [super viewDidAppear:animated];
   406 }
       
   407 
       
   408 #pragma mark -
       
   409 #pragma mark delegate functions for iPad
       
   410 -(IBAction) buttonPressed:(id) sender {
       
   411     if (self.delegate != nil && [delegate respondsToSelector:@selector(buttonPressed:)])
       
   412         [self.delegate buttonPressed:(UIButton *)sender];
       
   413 }
       
   414 
       
   415 #pragma mark -
       
   416 -(void) didReceiveMemoryWarning {
       
   417     [super didReceiveMemoryWarning];
       
   418     MSG_MEMCLEAN();
       
   419 }
   432 }
   420 
   433 
   421 -(void) viewDidUnload {
   434 -(void) viewDidUnload {
   422     self.delegate = nil;
   435     self.delegate = nil;
   423     
   436     
   426     self.templateFilterCommand = nil;
   439     self.templateFilterCommand = nil;
   427     self.mapGenCommand = nil;
   440     self.mapGenCommand = nil;
   428     self.mazeSizeCommand = nil;
   441     self.mazeSizeCommand = nil;
   429     self.themeCommand = nil;
   442     self.themeCommand = nil;
   430     self.staticMapCommand = nil;
   443     self.staticMapCommand = nil;
       
   444     self.missionCommand = nil;
   431 
   445 
   432     self.previewButton = nil;
   446     self.previewButton = nil;
   433     self.tableView = nil;
   447     self.tableView = nil;
   434     self.maxLabel = nil;
   448     self.maxLabel = nil;
   435     self.sizeLabel = nil;
   449     self.sizeLabel = nil;
   436     self.segmentedControl = nil;
   450     self.segmentedControl = nil;
   437     self.slider = nil;
   451     self.slider = nil;
   438 
   452 
   439     self.lastIndexPath = nil;
   453     self.lastIndexPath = nil;
   440     self.themeArray = nil;
   454     self.dataSourceArray = nil;
   441     self.mapArray = nil;
       
   442 
   455 
   443     MSG_DIDUNLOAD();
   456     MSG_DIDUNLOAD();
   444     [super viewDidUnload];
   457     [super viewDidUnload];
       
   458 }
       
   459 
       
   460 -(void) didReceiveMemoryWarning {
       
   461     [super didReceiveMemoryWarning];
       
   462     self.dataSourceArray = nil;
       
   463     // maybe we can save some more
       
   464     MSG_MEMCLEAN();
   445 }
   465 }
   446 
   466 
   447 -(void) dealloc {
   467 -(void) dealloc {
   448     self.delegate = nil;
   468     self.delegate = nil;
   449     
   469     
   451     [templateFilterCommand release];
   471     [templateFilterCommand release];
   452     [mapGenCommand release];
   472     [mapGenCommand release];
   453     [mazeSizeCommand release];
   473     [mazeSizeCommand release];
   454     [themeCommand release];
   474     [themeCommand release];
   455     [staticMapCommand release];
   475     [staticMapCommand release];
       
   476     [missionCommand release];
   456 
   477 
   457     [previewButton release];
   478     [previewButton release];
   458     [tableView release];
   479     [tableView release];
   459     [maxLabel release];
   480     [maxLabel release];
   460     [sizeLabel release];
   481     [sizeLabel release];
   461     [segmentedControl release];
   482     [segmentedControl release];
   462     [slider release];
   483     [slider release];
   463 
   484 
   464     [lastIndexPath release];
   485     [lastIndexPath release];
   465     [themeArray release];
   486     [dataSourceArray release];
   466     [mapArray release];
       
   467 
   487 
   468     [super dealloc];
   488     [super dealloc];
   469 }
   489 }
   470 
   490 
   471 @end
   491 @end