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 #import "SchemeWeaponConfigViewController.h" |
26 #import "SchemeWeaponConfigViewController.h" |
|
27 #import "GameConfigViewController.h" |
27 |
28 |
28 #define scIndex self.segmentedControl.selectedSegmentIndex |
29 #define scIndex self.segmentedControl.selectedSegmentIndex |
29 #define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
30 #define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
30 |
31 |
31 @implementation MapConfigViewController |
32 @implementation MapConfigViewController |
32 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand, |
33 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand, |
33 missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, externalController; |
34 missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, |
|
35 externalController, parentController; |
34 |
36 |
35 |
37 |
36 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
38 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
37 return rotationManager(interfaceOrientation); |
39 return rotationManager(interfaceOrientation); |
38 } |
40 } |
367 [self updatePreview]; |
369 [self updatePreview]; |
368 oldPage = newPage; |
370 oldPage = newPage; |
369 } |
371 } |
370 |
372 |
371 -(IBAction) buttonPressed:(id) sender { |
373 -(IBAction) buttonPressed:(id) sender { |
372 [[NSNotificationCenter defaultCenter] postNotificationName:@"buttonPressed" |
374 [self.parentController buttonPressed:sender]; |
373 object:nil |
|
374 userInfo:[NSDictionary dictionaryWithObject:sender forKey:@"sender"]]; |
|
375 } |
375 } |
376 |
376 |
377 #pragma mark - |
377 #pragma mark - |
378 #pragma mark view management |
378 #pragma mark view management |
379 -(void) loadDataSourceArray { |
379 -(void) loadDataSourceArray { |
390 for (NSString *str in mapArrayFull) { |
390 for (NSString *str in mapArrayFull) { |
391 CGSize imgSize = PSPNGSizeFromMetaData([MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
391 CGSize imgSize = PSPNGSizeFromMetaData([MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
392 // remove images that are too big for certain devices |
392 // remove images that are too big for certain devices |
393 if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f) |
393 if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f) |
394 continue; |
394 continue; |
395 if ([modelType() hasPrefix:@"iPad1"] && [[[UIDevice currentDevice] systemVersion] intValue] < 4 && imgSize.height > 1280.0f) |
395 if ([modelType() hasPrefix:@"iPad1"] && imgSize.height > 1280.0f) |
396 continue; |
396 continue; |
397 [mapArray addObject:str]; |
397 [mapArray addObject:str]; |
398 } |
398 } |
399 |
399 |
400 NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
400 NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
402 for (NSString *str in missionArrayFull) { |
402 for (NSString *str in missionArrayFull) { |
403 CGSize imgSize = PSPNGSizeFromMetaData([MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
403 CGSize imgSize = PSPNGSizeFromMetaData([MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
404 // remove images that are too big for certain devices |
404 // remove images that are too big for certain devices |
405 if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f) |
405 if (IS_NOT_POWERFUL() && imgSize.height > 1024.0f) |
406 continue; |
406 continue; |
407 if ([modelType() hasPrefix:@"iPad1"] && [[[UIDevice currentDevice] systemVersion] intValue] < 4 && imgSize.height > 1280.0f) |
407 if ([modelType() hasPrefix:@"iPad1"] && imgSize.height > 1280.0f) |
408 continue; |
408 continue; |
409 [missionArray addObject:str]; |
409 [missionArray addObject:str]; |
410 } |
410 } |
411 NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil]; |
411 NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil]; |
412 [missionArray release]; |
412 [missionArray release]; |