project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m
changeset 4349 8efa91f98274
parent 4287 7dbdc862097c
child 4356 d1d26f8963a3
equal deleted inserted replaced
4348:d4f659e96a4a 4349:8efa91f98274
    21 
    21 
    22 #import "SchemeWeaponConfigViewController.h"
    22 #import "SchemeWeaponConfigViewController.h"
    23 #import "CommodityFunctions.h"
    23 #import "CommodityFunctions.h"
    24 #import "SDL_uikitappdelegate.h"
    24 #import "SDL_uikitappdelegate.h"
    25 
    25 
       
    26 #define LABEL_TAG 57423
       
    27 
    26 @implementation SchemeWeaponConfigViewController
    28 @implementation SchemeWeaponConfigViewController
    27 @synthesize listOfSchemes, listOfWeapons, lastIndexPath_sc, lastIndexPath_we, selectedScheme, selectedWeapon, syncSwitch;
    29 @synthesize listOfSchemes, listOfWeapons, lastIndexPath_sc, lastIndexPath_we, selectedScheme, selectedWeapon, syncSwitch;
    28 
    30 
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    31 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    30     return rotationManager(interfaceOrientation);
    32     return rotationManager(interfaceOrientation);
    79 
    81 
    80 
    82 
    81 #pragma mark -
    83 #pragma mark -
    82 #pragma mark Table view data source
    84 #pragma mark Table view data source
    83 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    85 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    84     return 3;
    86     if (hideSections)
       
    87         return 0;
       
    88     else
       
    89         return 3;
    85 }
    90 }
    86 
    91 
    87 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    92 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    88     if (section == 0)
    93     if (section == 0)
    89         return [self.listOfSchemes count];
    94         return [self.listOfSchemes count];
   213         [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
   218         [aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
   214     }
   219     }
   215     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   220     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
   216 }
   221 }
   217 
   222 
       
   223 -(void) fillSections {
       
   224     if (hideSections == YES) {
       
   225         hideSections = NO;
       
   226         NSRange range;
       
   227         range.location = 0;
       
   228         range.length = 3;
       
   229         NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range];
       
   230         [self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade];
       
   231         self.selectedScheme = @"Default.plist";
       
   232         self.selectedWeapon = @"Default.plist";
       
   233 
       
   234         self.tableView.scrollEnabled = YES;
       
   235 
       
   236         [[self.view viewWithTag:LABEL_TAG] removeFromSuperview];
       
   237     }
       
   238 }
       
   239 
       
   240 -(void) emptySections {
       
   241     hideSections = YES;
       
   242     NSRange range;
       
   243     range.location = 0;
       
   244     range.length = 3;
       
   245     NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range];
       
   246     [self.tableView deleteSections:sections withRowAnimation:UITableViewRowAnimationFade];
       
   247     self.selectedScheme = @"Default.plist";
       
   248     self.selectedWeapon = @"Default.plist";
       
   249 
       
   250     self.tableView.scrollEnabled = NO;
       
   251 
       
   252     CGRect frame = CGRectMake(0, 0, self.view.frame.size.width * 80/100, 60);
       
   253     UILabel *theLabel = createBlueLabel(NSLocalizedString(@"Missions don't need further configuration",@""), frame);
       
   254     theLabel.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
       
   255     theLabel.numberOfLines = 2;
       
   256     theLabel.tag = LABEL_TAG;
       
   257 
       
   258     [self.view addSubview:theLabel];
       
   259     [theLabel release];
       
   260 }
       
   261 
   218 #pragma mark -
   262 #pragma mark -
   219 #pragma mark Memory management
   263 #pragma mark Memory management
   220 -(void) didReceiveMemoryWarning {
   264 -(void) didReceiveMemoryWarning {
   221     if ([[SDLUIKitDelegate sharedAppDelegate] isInGame]) {
   265     if ([[SDLUIKitDelegate sharedAppDelegate] isInGame]) {
   222         self.lastIndexPath_sc = nil;
   266         self.lastIndexPath_sc = nil;