project_files/HedgewarsMobile/Classes/StatsPageViewController.m
changeset 6004 b92a6626b0e5
parent 6000 dbcebcd3d79f
child 6017 24631fd2fb9e
equal deleted inserted replaced
6002:7f790689205c 6004:b92a6626b0e5
    19  */
    19  */
    20 
    20 
    21 
    21 
    22 #import "StatsPageViewController.h"
    22 #import "StatsPageViewController.h"
    23 #import "CommodityFunctions.h"
    23 #import "CommodityFunctions.h"
       
    24 #import <QuartzCore/QuartzCore.h>
    24 
    25 
    25 @implementation StatsPageViewController
    26 @implementation StatsPageViewController
    26 @synthesize statsArray;
    27 @synthesize statsArray;
    27 
    28 
    28 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    55 }
    56 }
    56 
    57 
    57 #pragma mark -
    58 #pragma mark -
    58 #pragma mark Table view data source
    59 #pragma mark Table view data source
    59 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    60 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
    60     return 4;
    61     return 3;
    61 }
    62 }
    62 
    63 
    63 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    64 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    64     if (section == 0 || section == 3)
    65     if (section == 0)
    65         return 1;
    66         return 1;
    66     else if (section == 1)
    67     else if (section == 1)
    67         return [[self.statsArray objectAtIndex:0] count];
    68         return [[self.statsArray objectAtIndex:0] count];
    68     else
    69     else
    69         return [self.statsArray count] - 2;
    70         return [self.statsArray count] - 2;
    97         imgName = [NSString stringWithFormat:@"StatsMedal%d",row+1];
    98         imgName = [NSString stringWithFormat:@"StatsMedal%d",row+1];
    98     } else if (section == 2) {  // general info
    99     } else if (section == 2) {  // general info
    99         imgName = @"iconDamage";
   100         imgName = @"iconDamage";
   100         cell.textLabel.text = [self.statsArray objectAtIndex:row + 2];
   101         cell.textLabel.text = [self.statsArray objectAtIndex:row + 2];
   101         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   102         cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT;
   102     } else {                    // exit button
       
   103         cell.textLabel.text = NSLocalizedString(@"Done",@"");
       
   104         cell.textLabel.textColor = [UIColor whiteColor];
       
   105         cell.accessoryView = nil;
       
   106         cell.imageView.image = nil;
       
   107     }
   103     }
   108 
   104 
   109     NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",imgPath,imgName];
   105     NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",imgPath,imgName];
   110     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
   106     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
   111     [imgString release];
   107     [imgString release];
   140         return [header autorelease];
   136         return [header autorelease];
   141     } else
   137     } else
   142         return nil;
   138         return nil;
   143 }
   139 }
   144 
   140 
       
   141 -(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
       
   142     return self.tableView.rowHeight + 30;
       
   143 }
       
   144 
       
   145 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
       
   146     if (section == 2) {
       
   147 
       
   148         UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.tableView.rowHeight)];
       
   149         footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
       
   150 
       
   151         UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 17, self.view.frame.size.width, self.tableView.rowHeight)];
       
   152         button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
       
   153         [button setTitle:NSLocalizedString(@"Done",@"") forState:UIControlStateNormal];
       
   154         [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
       
   155         [button setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
       
   156 
       
   157         button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
       
   158         button.backgroundColor = UICOLOR_HW_ALMOSTBLACK;
       
   159         [button.layer setBorderWidth:1];
       
   160         [button.layer setBorderColor:UICOLOR_HW_YELLOW_BODER.CGColor];
       
   161         [button.layer setCornerRadius:9.0f];
       
   162         [button.layer setMasksToBounds:YES];
       
   163         [button addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside];
       
   164         [footer addSubview:button];
       
   165         [button release];
       
   166 
       
   167         return [footer autorelease];
       
   168     } else
       
   169         return nil;
       
   170 }
       
   171 
   145 #pragma mark -
   172 #pragma mark -
   146 #pragma mark Table view delegate
   173 #pragma mark button delegate
   147 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   174 -(void) dismissView {
   148     if ([indexPath section] == 3) {
   175     [AudioManagerController playClickSound];
   149         [AudioManagerController playBackSound];
   176     [self dismissModalViewControllerAnimated:YES];
   150         [self dismissModalViewControllerAnimated:YES];
       
   151     }
       
   152 }
   177 }
   153 
   178 
   154 #pragma mark -
   179 #pragma mark -
   155 #pragma mark Memory management
   180 #pragma mark Memory management
   156 -(void) didReceiveMemoryWarning {
   181 -(void) didReceiveMemoryWarning {