project_files/HedgewarsMobile/Classes/StatsPageViewController.m
author raptor <buckyballreaction@gmail.com>
Tue, 13 Aug 2019 13:10:12 -0600
changeset 15317 5b2dec63f4cf
parent 13171 ba5c794adae3
permissions -rw-r--r--
Fix compiling on MacOS X by requiring c++11 standard. Building now requires MacOS X 10.8+ and CMake 3.9+
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     1
/*
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
6700
e04da46ee43c the most important commit of the year
koda
parents: 6078
diff changeset
     3
 * Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com>
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     4
 *
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     8
 *
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    13
 *
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 6869
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    17
 */
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    18
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    19
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    20
#import "StatsPageViewController.h"
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    21
6832
fae8fd118da9 dates are no more!
koda
parents: 6711
diff changeset
    22
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    23
@implementation StatsPageViewController
4760
224c31b3ce7d simplify stats handling
koda
parents: 4757
diff changeset
    24
@synthesize statsArray;
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    25
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    26
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    27
    return rotationManager(interfaceOrientation);
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    28
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    29
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    30
- (void)viewDidLoad {
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    31
    UITableView *aTableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
11217
6e5fd5ea5acb - Fix for autorotation of table view of StatsPageVC
antonc27 <antonc27@mail.ru>
parents: 11118
diff changeset
    32
    aTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    33
    [aTableView setBackgroundColorForAnyTable:[UIColor clearColor]];
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    34
6708
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    35
    NSString *imgName = (IS_IPAD()) ? @"mediumBackground~ipad.png" : @"smallerBackground~iphone.png";
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    36
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName];
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    37
    UIImageView *background = [[UIImageView alloc] initWithImage:img];
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    38
    background.frame = self.view.frame;
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    39
    background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
    40
    [self.view insertSubview:background atIndex:0];
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    41
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    42
    aTableView.separatorColor = [UIColor darkYellowColor];
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    43
    aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    44
    aTableView.delegate = self;
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    45
    aTableView.dataSource = self;
11118
600a5af8d61f - Fix for strange problem with table view in StatsPage - rowHeight is 1 by default. So, fixed by implicit size.
antonc27 <antonc27@mail.ru>
parents: 11116
diff changeset
    46
    
600a5af8d61f - Fix for strange problem with table view in StatsPage - rowHeight is 1 by default. So, fixed by implicit size.
antonc27 <antonc27@mail.ru>
parents: 11116
diff changeset
    47
    aTableView.rowHeight = 44;
600a5af8d61f - Fix for strange problem with table view in StatsPage - rowHeight is 1 by default. So, fixed by implicit size.
antonc27 <antonc27@mail.ru>
parents: 11116
diff changeset
    48
    
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
    49
    [self.view addSubview:aTableView];
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    50
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    51
    [super viewDidLoad];
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    52
}
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
    53
11227
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    54
#pragma mark - Helpers
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    55
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    56
- (NSString *)teamNameFromInfo: (NSArray *)info
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    57
{
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    58
    NSString *teamName = [NSString stringWithString:[info objectAtIndex:2]];
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    59
    
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    60
    for (int i=3; i < [info count]; i++)
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    61
    {
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    62
        teamName = [teamName stringByAppendingFormat:@" %@", [info objectAtIndex:i]];
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    63
    }
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    64
    
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    65
    return teamName;
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    66
}
93bc68aa41d3 - Workaround for team's name with spaces in StatsPage
antonc27 <antonc27@mail.ru>
parents: 11217
diff changeset
    67
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    68
#pragma mark -
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    69
#pragma mark Table view data source
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    70
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
    71
    return 3;
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    72
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    73
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    74
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section {
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
    75
    if (section == 0)
4760
224c31b3ce7d simplify stats handling
koda
parents: 4757
diff changeset
    76
        return 1;
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    77
    else if (section == 1)
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    78
        return [[self.statsArray objectAtIndex:0] count];
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    79
    else
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    80
        return [self.statsArray count] - 2;
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    81
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    82
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    83
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    84
    static NSString *CellIdentifier0 = @"Cell0";
4760
224c31b3ce7d simplify stats handling
koda
parents: 4757
diff changeset
    85
    NSInteger section = [indexPath section];
224c31b3ce7d simplify stats handling
koda
parents: 4757
diff changeset
    86
    NSInteger row = [indexPath row];
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
    87
    NSString *imgName = @"";
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5976
diff changeset
    88
    NSString *imgPath = ICONS_DIRECTORY();
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    89
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    90
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    91
    if (cell == nil)
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
    92
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0];
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
    93
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    94
    if (section == 0) {         // winning team
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
    95
        imgName = @"star";
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
    96
        imgPath = [[NSBundle mainBundle] resourcePath];
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    97
        cell.textLabel.text = [self.statsArray objectAtIndex:1];
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 6017
diff changeset
    98
        cell.textLabel.textColor = [UIColor lightYellowColor];
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
    99
    } else if (section == 1) {  // teams ranking
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   100
        // color, # kills, teamname
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   101
        NSArray *info = [[[self.statsArray objectAtIndex:0] objectAtIndex:row] componentsSeparatedByString:@" "];
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   102
        NSUInteger color = [[info objectAtIndex:0] intValue];
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   103
        cell.textLabel.textColor = [UIColor colorWithRed:((color >> 16) & 0xFF)/255.0f
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   104
                                                   green:((color >> 8) & 0xFF)/255.0f
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   105
                                                    blue:(color & 0xFF)/255.0f
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   106
                                                   alpha:1.0f];
11235
bb3e57426a07 - Localization for missed strings in StatsPage (for both eng and rus)
antonc27 <antonc27@mail.ru>
parents: 11227
diff changeset
   107
        cell.textLabel.text = [NSString stringWithFormat:@"%d. %@ (%@ %@)", row+1, [self teamNameFromInfo:info], [info objectAtIndex:1], NSLocalizedString(@"kills", nil)];
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   108
        imgName = [NSString stringWithFormat:@"StatsMedal%d",row+1];
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   109
    } else if (section == 2) {  // general info
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   110
        imgName = @"iconDamage";
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   111
        cell.textLabel.text = [self.statsArray objectAtIndex:row + 2];
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 6017
diff changeset
   112
        cell.textLabel.textColor = [UIColor lightYellowColor];
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   113
    }
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   114
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   115
    NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",imgPath,imgName];
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   116
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
4856
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   117
    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   118
    cell.imageView.image = img;
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   119
    cell.accessoryView = imgView;
dbc256913b35 implemented ranking in ios stats pages
koda
parents: 4819
diff changeset
   120
11554
893722a2a1f9 - Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents: 11235
diff changeset
   121
    cell.textLabel.textAlignment = NSTextAlignmentCenter;
4819
63011cbaa438 ctf_blizzard ios fix
koda
parents: 4766
diff changeset
   122
    cell.textLabel.adjustsFontSizeToFitWidth = YES;
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   123
    cell.backgroundColor = [UIColor blackColor];
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   124
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   125
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   126
    return cell;
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   127
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   128
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
   129
- (CGFloat)tableView:(UITableView *)aTableView heightForHeaderInSection:(NSInteger)section {
11217
6e5fd5ea5acb - Fix for autorotation of table view of StatsPageVC
antonc27 <antonc27@mail.ru>
parents: 11118
diff changeset
   130
    return (section == 0) ? 160 : 40;
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   131
}
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   132
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   133
-(UIView *)tableView:(UITableView *)aTableView viewForHeaderInSection:(NSInteger)section {
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   134
    if (section == 0) {
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   135
        UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width, 160)];
6708
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
   136
        header.autoresizingMask = UIViewAutoresizingFlexibleWidth;
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
   137
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   138
        UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"smallerTitle.png"];
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   139
        UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   140
        imgView.center = CGPointMake(aTableView.frame.size.width/2, 160/2);
6708
314929f0a3e1 rotation support for other controllers
koda
parents: 6700
diff changeset
   141
        imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   142
        [header addSubview:imgView];
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   143
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   144
        return header;
4766
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   145
    } else
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   146
        return nil;
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   147
}
255e6c76c7e9 beautify stat page
koda
parents: 4763
diff changeset
   148
13171
ba5c794adae3 - Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents: 12877
diff changeset
   149
- (CGFloat)tableView:(UITableView *)aTableView heightForFooterInSection:(NSInteger)section {
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   150
    return aTableView.rowHeight + 30;
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   151
}
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   152
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   153
-(UIView *)tableView:(UITableView *)aTableView viewForFooterInSection:(NSInteger)section {
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   154
    if (section == 2) {
6709
018539298042 oh i thought i had converted every uitableviewcontroller to uiviewcontroller+tableview; this also restores displaying statitstics after game
koda
parents: 6708
diff changeset
   155
        UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width * 70 / 100, aTableView.rowHeight)];
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   156
        footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   157
6711
76e96101a84f prepare a styled button
koda
parents: 6709
diff changeset
   158
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 17, self.view.frame.size.width * 70 / 100, aTableView.rowHeight)
76e96101a84f prepare a styled button
koda
parents: 6709
diff changeset
   159
                                                  andTitle:NSLocalizedString(@"Done",@"")];
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   160
        button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   161
        [button addTarget:self action:@selector(dismissView) forControlEvents:UIControlEventTouchUpInside];
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   162
        [footer addSubview:button];
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   163
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   164
        return footer;
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   165
    } else
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   166
        return nil;
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   167
}
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   168
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   169
#pragma mark -
6004
b92a6626b0e5 use a real button instead of a cellview in statspage
koda
parents: 6000
diff changeset
   170
#pragma mark button delegate
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   171
- (void)dismissView {
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
   172
    [[AudioManagerController mainManager] playClickSound];
11116
102684240fe8 - Interscreen transitions fixed
Anton Malmygin <antonc27@mail.ru>
parents: 10108
diff changeset
   173
    [self dismissViewControllerAnimated:YES completion:nil];
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   174
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   175
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   176
#pragma mark -
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   177
#pragma mark Memory management
12877
00215a7ec5f5 - BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents: 11554
diff changeset
   178
- (void)didReceiveMemoryWarning {
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   179
    // Releases the view if it doesn't have a superview.
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   180
    [super didReceiveMemoryWarning];
4760
224c31b3ce7d simplify stats handling
koda
parents: 4757
diff changeset
   181
    self.statsArray = nil;
4757
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   182
}
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   183
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   184
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   185
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   186
@end
7ca9ebb6895d initial stats display
koda
parents:
diff changeset
   187