18 * File created on 22/04/2010. |
18 * File created on 22/04/2010. |
19 */ |
19 */ |
20 |
20 |
21 |
21 |
22 #import "MapConfigViewController.h" |
22 #import "MapConfigViewController.h" |
23 #import "PascalImports.h" |
|
24 #import "CommodityFunctions.h" |
|
25 #import "UIImageExtra.h" |
|
26 #import "SchemeWeaponConfigViewController.h" |
23 #import "SchemeWeaponConfigViewController.h" |
27 #import "GameConfigViewController.h" |
24 #import "GameConfigViewController.h" |
|
25 |
28 |
26 |
29 #define scIndex self.segmentedControl.selectedSegmentIndex |
27 #define scIndex self.segmentedControl.selectedSegmentIndex |
30 #define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
28 #define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
31 |
29 |
32 @implementation MapConfigViewController |
30 @implementation MapConfigViewController |
72 } |
70 } |
73 [seed release]; |
71 [seed release]; |
74 |
72 |
75 // perform as if user clicked on an entry |
73 // perform as if user clicked on an entry |
76 [self tableView:self.tableView didSelectRowAtIndexPath:theIndex]; |
74 [self tableView:self.tableView didSelectRowAtIndexPath:theIndex]; |
77 if (IS_NOT_POWERFUL(getModelType()) == NO) |
75 if (IS_NOT_POWERFUL([HWUtils modelType]) == NO) |
78 [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; |
76 [self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; |
79 } |
77 } |
80 |
78 |
81 -(void) turnOffWidgets { |
79 -(void) turnOffWidgets { |
82 busy = YES; |
80 busy = YES; |
136 |
134 |
137 NSString *labelString = [source objectAtIndex:row]; |
135 NSString *labelString = [source objectAtIndex:row]; |
138 cell.textLabel.text = labelString; |
136 cell.textLabel.text = labelString; |
139 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
137 cell.textLabel.adjustsFontSizeToFitWidth = YES; |
140 cell.textLabel.minimumFontSize = 7; |
138 cell.textLabel.minimumFontSize = 7; |
141 cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
139 cell.textLabel.textColor = [UIColor lightYellowColor]; |
142 cell.textLabel.backgroundColor = [UIColor clearColor]; |
140 cell.textLabel.backgroundColor = [UIColor clearColor]; |
143 |
141 |
144 if (isRandomness()) { |
142 if (isRandomness()) { |
145 UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),labelString]]; |
143 UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),labelString]]; |
146 cell.imageView.image = image; |
144 cell.imageView.image = image; |
153 cell.accessoryView = checkbox; |
151 cell.accessoryView = checkbox; |
154 [checkbox release]; |
152 [checkbox release]; |
155 } else |
153 } else |
156 cell.accessoryView = nil; |
154 cell.accessoryView = nil; |
157 |
155 |
158 cell.backgroundColor = UICOLOR_HW_ALMOSTBLACK; |
156 cell.backgroundColor = [UIColor blackColorTransparent]; |
159 return cell; |
157 return cell; |
160 } |
158 } |
161 |
159 |
162 // this set details for a static map (called by didSelectRowAtIndexPath) |
160 // this set details for a static map (called by didSelectRowAtIndexPath) |
163 -(void) setDetailsForStaticMap:(NSInteger) index { |
161 -(void) setDetailsForStaticMap:(NSInteger) index { |
376 } |
374 } |
377 |
375 |
378 #pragma mark - |
376 #pragma mark - |
379 #pragma mark view management |
377 #pragma mark view management |
380 -(void) loadDataSourceArray { |
378 -(void) loadDataSourceArray { |
381 NSString *model = getModelType(); |
379 NSString *model = [HWUtils modelType]; |
382 |
380 |
383 // only folders containing icon.png are a valid theme |
381 // only folders containing icon.png are a valid theme |
384 NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL]; |
382 NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL]; |
385 NSMutableArray *themeArray = [[NSMutableArray alloc] init]; |
383 NSMutableArray *themeArray = [[NSMutableArray alloc] init]; |
386 for (NSString *themeName in themeArrayFull) { |
384 for (NSString *themeName in themeArrayFull) { |
392 |
390 |
393 // remove images that are too big for certain devices without loading the whole image |
391 // remove images that are too big for certain devices without loading the whole image |
394 NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL]; |
392 NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL]; |
395 NSMutableArray *mapArray = [[NSMutableArray alloc] init]; |
393 NSMutableArray *mapArray = [[NSMutableArray alloc] init]; |
396 for (NSString *str in mapArrayFull) { |
394 for (NSString *str in mapArrayFull) { |
397 CGSize imgSize = PSPNGSizeFromMetaData([MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
395 CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
398 if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
396 if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
399 continue; |
397 continue; |
400 if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
398 if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
401 continue; |
399 continue; |
402 [mapArray addObject:str]; |
400 [mapArray addObject:str]; |
403 } |
401 } |
404 |
402 |
405 NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
403 NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
406 NSMutableArray *missionArray = [[NSMutableArray alloc] init]; |
404 NSMutableArray *missionArray = [[NSMutableArray alloc] init]; |
407 for (NSString *str in missionArrayFull) { |
405 for (NSString *str in missionArrayFull) { |
408 CGSize imgSize = PSPNGSizeFromMetaData([MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]); |
406 CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
409 if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
407 if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
410 continue; |
408 continue; |
411 if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
409 if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
412 continue; |
410 continue; |
413 [missionArray addObject:str]; |
411 [missionArray addObject:str]; |
452 self.missionCommand = @""; |
450 self.missionCommand = @""; |
453 |
451 |
454 if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
452 if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
455 [self.tableView setBackgroundView:nil]; |
453 [self.tableView setBackgroundView:nil]; |
456 self.tableView.backgroundColor = [UIColor clearColor]; |
454 self.tableView.backgroundColor = [UIColor clearColor]; |
457 self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER; |
455 self.tableView.separatorColor = [UIColor darkYellowColor]; |
458 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
456 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
459 } |
457 } |
460 |
458 |
461 -(void) viewWillAppear:(BOOL)animated { |
459 -(void) viewWillAppear:(BOOL)animated { |
462 if (self.dataSourceArray == nil) |
460 if (self.dataSourceArray == nil) |