author | koda |
Tue, 18 Jan 2011 23:08:47 +0100 | |
changeset 4855 | 2480ab325057 |
parent 4819 | 63011cbaa438 |
child 4856 | dbc256913b35 |
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 |
} |
4819 | 90 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
4766 | 91 |
cell.backgroundColor = [UIColor blackColor]; |
92 |
cell.selectionStyle = UITableViewCellSelectionStyleNone; |
|
4757 | 93 |
|
94 |
return cell; |
|
95 |
} |
|
96 |
||
4766 | 97 |
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { |
98 |
return 160; |
|
99 |
} |
|
100 |
||
101 |
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { |
|
102 |
if (section == 0) { |
|
103 |
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 160)]; |
|
104 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"smallerTitle.png"]; |
|
105 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
106 |
[img release]; |
|
107 |
imgView.center = CGPointMake(self.tableView.frame.size.height/2, 160/2); |
|
108 |
[header addSubview:imgView]; |
|
109 |
[imgView release]; |
|
110 |
||
111 |
return [header autorelease]; |
|
112 |
} else |
|
113 |
return nil; |
|
114 |
} |
|
115 |
||
4757 | 116 |
#pragma mark - |
117 |
#pragma mark Table view delegate |
|
118 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
119 |
if ([indexPath section] == 2) |
|
120 |
[self dismissModalViewControllerAnimated:YES]; |
|
121 |
} |
|
122 |
||
123 |
#pragma mark - |
|
124 |
#pragma mark Memory management |
|
125 |
-(void) didReceiveMemoryWarning { |
|
126 |
// Releases the view if it doesn't have a superview. |
|
127 |
[super didReceiveMemoryWarning]; |
|
4760 | 128 |
self.statsArray = nil; |
4757 | 129 |
} |
130 |
||
131 |
-(void) dealloc { |
|
4760 | 132 |
[statsArray release]; |
4757 | 133 |
[super dealloc]; |
134 |
} |
|
135 |
||
136 |
||
137 |
@end |
|
138 |