author | sheepluva |
Wed, 29 Dec 2010 14:59:56 +0100 | |
changeset 4774 | d81c6e14416d |
parent 4603 | d362ab6c7f53 |
child 4976 | 088d40d8aba2 |
permissions | -rw-r--r-- |
3829 | 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 01/08/2010. |
|
19 |
*/ |
|
20 |
||
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
21 |
|
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
22 |
#import "AboutViewController.h" |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
23 |
#import "CommodityFunctions.h" |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
24 |
|
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
25 |
@implementation AboutViewController |
3787 | 26 |
@synthesize tableView, segmentedControl, people; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
27 |
|
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
28 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
29 |
return rotationManager(interfaceOrientation); |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
30 |
} |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
31 |
|
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
32 |
-(void) viewDidLoad { |
4115 | 33 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
4082 | 34 |
self.tableView.backgroundView = nil; |
3787 | 35 |
self.tableView.allowsSelection = NO; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
36 |
|
4000
ddc4a09889e7
engine: reorder GameFlags and update files, frontend and other stuff
koda
parents:
3971
diff
changeset
|
37 |
NSString *strPath = [NSString stringWithFormat:@"%@/credits.plist",IFRONTEND_DIRECTORY()]; |
3787 | 38 |
NSArray *array = [[NSArray alloc] initWithContentsOfFile:strPath]; |
39 |
self.people = array; |
|
40 |
[array release]; |
|
4030 | 41 |
|
42 |
NSString *imgName; |
|
43 |
if (IS_IPAD()) |
|
44 |
imgName = @"smallerBackground~ipad.png"; |
|
45 |
else |
|
46 |
imgName = @"smallerBackground~iphone.png"; |
|
47 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
48 |
self.view.backgroundColor = [UIColor colorWithPatternImage:img]; |
|
49 |
[img release]; |
|
3787 | 50 |
[super viewDidLoad]; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
51 |
} |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
52 |
|
3753 | 53 |
-(IBAction) buttonPressed:(id) sender { |
3783 | 54 |
playSound(@"backSound"); |
3753 | 55 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
56 |
} |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
57 |
|
3787 | 58 |
-(IBAction) segmentedControlChanged:(id) sender { |
59 |
playSound(@"clickSound"); |
|
60 |
[self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
|
61 |
[self.tableView reloadData]; |
|
62 |
} |
|
63 |
||
64 |
#pragma mark - |
|
65 |
#pragma mark Table view data source |
|
66 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
67 |
return 1; |
|
68 |
} |
|
69 |
||
70 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
71 |
return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; |
|
72 |
} |
|
73 |
||
74 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
75 |
static NSString *CellIdentifier = @"Cell"; |
|
76 |
||
77 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
78 |
if (cell == nil) |
|
79 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; |
|
80 |
||
81 |
// first all the names, then the title (which is offset 5) |
|
82 |
cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
|
83 |
cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; |
|
84 |
||
85 |
return cell; |
|
86 |
} |
|
87 |
||
88 |
#pragma mark - |
|
89 |
#pragma mark Table view delegate |
|
90 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
91 |
// do nothing |
|
92 |
} |
|
93 |
||
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
94 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
95 |
return 95; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
96 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
97 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
98 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
99 |
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
100 |
char *fullver; |
4603 | 101 |
int proto; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
102 |
HW_versionInfo(&proto, &fullver); |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
103 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
104 |
NSString *footerString = [[NSString alloc] initWithFormat: |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
105 |
@"You are running Hedgewars-iOS %@ based on Hedgewars version %s (protocol %d)", |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
106 |
version, fullver, proto]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
107 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
108 |
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
109 |
footer.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
110 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
111 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width*80/100, 90)]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
112 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 45); |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
113 |
label.textAlignment = UITextAlignmentCenter; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
114 |
label.font = [UIFont systemFontOfSize:16]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
115 |
label.textColor = [UIColor lightGrayColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
116 |
label.numberOfLines = 5; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
117 |
label.text = footerString; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
118 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
119 |
label.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
120 |
[footer addSubview:label]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
121 |
[label release]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
122 |
return [footer autorelease]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
123 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
124 |
|
3787 | 125 |
#pragma mark - |
126 |
#pragma mark Memory Management |
|
127 |
-(void) didReceiveMemoryWarning { |
|
3971 | 128 |
self.people = nil; |
3787 | 129 |
[super didReceiveMemoryWarning]; |
130 |
} |
|
131 |
||
132 |
-(void) viewDidUnload { |
|
133 |
self.tableView = nil; |
|
134 |
self.segmentedControl = nil; |
|
135 |
self.people = nil; |
|
136 |
[super viewDidUnload]; |
|
137 |
} |
|
138 |
||
139 |
-(void) dealloc { |
|
140 |
[tableView release]; |
|
141 |
[segmentedControl release]; |
|
142 |
[people release]; |
|
143 |
[super dealloc]; |
|
144 |
} |
|
145 |
||
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
146 |
@end |