author | koda |
Fri, 31 Dec 2010 02:52:55 +0100 | |
changeset 4766 | 255e6c76c7e9 |
parent 4763 | c228a4841e3f |
child 4819 | 63011cbaa438 |
permissions | -rw-r--r-- |
4757 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
3 |
* Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
17 |
* |
|
18 |
* File created on 30/12/2010. |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
#import "StatsPageViewController.h" |
|
23 |
#import "CommodityFunctions.h" |
|
24 |
||
25 |
@implementation StatsPageViewController |
|
4760 | 26 |
@synthesize statsArray; |
4757 | 27 |
|
28 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
|
29 |
return rotationManager(interfaceOrientation); |
|
30 |
} |
|
31 |
||
4766 | 32 |
-(void) viewDidLoad { |
33 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
|
34 |
self.tableView.backgroundView = nil; |
|
35 |
||
36 |
NSString *imgName; |
|
37 |
if (IS_IPAD()) |
|
38 |
imgName = @"mediumBackground~ipad.png"; |
|
39 |
else |
|
40 |
imgName = @"smallerBackground~iphone.png"; |
|
41 |
||
42 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) { |
|
43 |
UIImage *backgroundImage = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
44 |
UIImageView *background = [[UIImageView alloc] initWithImage:backgroundImage]; |
|
45 |
[backgroundImage release]; |
|
46 |
[self.tableView setBackgroundView:background]; |
|
47 |
[background release]; |
|
48 |
} else |
|
49 |
self.view.backgroundColor = [UIColor blackColor]; |
|
50 |
||
51 |
self.tableView.separatorColor = UICOLOR_HW_YELLOW_BODER; |
|
52 |
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
|
53 |
||
54 |
[super viewDidLoad]; |
|
55 |
} |
|
56 |
||
4757 | 57 |
#pragma mark - |
58 |
#pragma mark Table view data source |
|
59 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
4760 | 60 |
return 3; |
4757 | 61 |
} |
62 |
||
63 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
4760 | 64 |
if (section == 0 || section == 2) |
65 |
return 1; |
|
4757 | 66 |
else |
4760 | 67 |
return [self.statsArray count] - 1; |
4757 | 68 |
} |
69 |
||
70 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
71 |
static NSString *CellIdentifier0 = @"Cell0"; |
|
4760 | 72 |
NSInteger section = [indexPath section]; |
73 |
NSInteger row = [indexPath row]; |
|
4757 | 74 |
|
75 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0]; |
|
76 |
if (cell == nil) |
|
77 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease]; |
|
78 |
||
79 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
|
4760 | 80 |
if (section == 0) { |
81 |
cell.textLabel.text = [self.statsArray objectAtIndex:row]; |
|
4766 | 82 |
cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
4760 | 83 |
} else if (section == 1) { |
84 |
cell.textLabel.text = [self.statsArray objectAtIndex:row + 1]; |
|
4766 | 85 |
cell.textLabel.textColor = UICOLOR_HW_YELLOW_TEXT; |
4757 | 86 |
} else { |
4763
c228a4841e3f
unify stats display on ipad and non-ipad and on saved and normal games
koda
parents:
4760
diff
changeset
|
87 |
cell.textLabel.text = NSLocalizedString(@"Done",@""); |
4766 | 88 |
cell.textLabel.textColor = [UIColor whiteColor]; |
4757 | 89 |
} |
4766 | 90 |
cell.backgroundColor = [UIColor blackColor]; |
91 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
|
4757 | 92 |
|
93 |
return cell; |
|
94 |
} |
|
95 |
||
4766 | 96 |
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { |
97 |
return 160; |
|
98 |
} |
|
99 |
||
100 |
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { |
|
101 |
if (section == 0) { |
|
102 |
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 160)]; |
|
103 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"smallerTitle.png"]; |
|
104 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
105 |
[img release]; |
|
106 |
imgView.center = CGPointMake(self.tableView.frame.size.height/2, 160/2); |
|
107 |
[header addSubview:imgView]; |
|
108 |
[imgView release]; |
|
109 |
||
110 |
return [header autorelease]; |
|
111 |
} else |
|
112 |
return nil; |
|
113 |
} |
|
114 |
||
4757 | 115 |
#pragma mark - |
116 |
#pragma mark Table view delegate |
|
117 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
118 |
if ([indexPath section] == 2) |
|
119 |
[self dismissModalViewControllerAnimated:YES]; |
|
120 |
} |
|
121 |
||
122 |
#pragma mark - |
|
123 |
#pragma mark Memory management |
|
124 |
-(void) didReceiveMemoryWarning { |
|
125 |
// Releases the view if it doesn't have a superview. |
|
126 |
[super didReceiveMemoryWarning]; |
|
4760 | 127 |
self.statsArray = nil; |
4757 | 128 |
} |
129 |
||
130 |
-(void) dealloc { |
|
4760 | 131 |
[statsArray release]; |
4757 | 132 |
[super dealloc]; |
133 |
} |
|
134 |
||
135 |
||
136 |
@end |
|
137 |