author | koda |
Sat, 24 Sep 2011 04:53:53 +0200 | |
changeset 6008 | 215f0c9719e3 |
parent 6000 | dbcebcd3d79f |
child 6078 | 8c0cc07731e5 |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 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 |
|
5185
7607a64e1853
remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents:
4976
diff
changeset
|
37 |
NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()]; |
3787 | 38 |
self.people = array; |
39 |
[array release]; |
|
4030 | 40 |
|
41 |
NSString *imgName; |
|
42 |
if (IS_IPAD()) |
|
43 |
imgName = @"smallerBackground~ipad.png"; |
|
44 |
else |
|
45 |
imgName = @"smallerBackground~iphone.png"; |
|
46 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
47 |
self.view.backgroundColor = [UIColor colorWithPatternImage:img]; |
|
48 |
[img release]; |
|
3787 | 49 |
[super viewDidLoad]; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
50 |
} |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
51 |
|
3753 | 52 |
-(IBAction) buttonPressed:(id) sender { |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5985
diff
changeset
|
53 |
[AudioManagerController playBackSound]; |
3753 | 54 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
55 |
} |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
56 |
|
3787 | 57 |
-(IBAction) segmentedControlChanged:(id) sender { |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5985
diff
changeset
|
58 |
[AudioManagerController playClickSound]; |
3787 | 59 |
[self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
60 |
[self.tableView reloadData]; |
|
61 |
} |
|
62 |
||
63 |
#pragma mark - |
|
64 |
#pragma mark Table view data source |
|
65 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
66 |
return 1; |
|
67 |
} |
|
68 |
||
69 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
70 |
return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; |
|
71 |
} |
|
72 |
||
73 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
74 |
static NSString *CellIdentifier = @"Cell"; |
|
75 |
||
76 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
77 |
if (cell == nil) |
|
78 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; |
|
79 |
||
80 |
// first all the names, then the title (which is offset 5) |
|
81 |
cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
|
5985 | 82 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
83 |
cell.textLabel.minimumFontSize = 8; |
|
3787 | 84 |
cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; |
85 |
||
86 |
return cell; |
|
87 |
} |
|
88 |
||
89 |
#pragma mark - |
|
90 |
#pragma mark Table view delegate |
|
91 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
92 |
// do nothing |
|
93 |
} |
|
94 |
||
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
95 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
96 |
return 95; |
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 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
99 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
100 |
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
101 |
char *fullver; |
4603 | 102 |
int proto; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
103 |
HW_versionInfo(&proto, &fullver); |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
104 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
105 |
NSString *footerString = [[NSString alloc] initWithFormat: |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
106 |
@"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
|
107 |
version, fullver, proto]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
108 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
109 |
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
|
110 |
footer.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
111 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
112 |
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
|
113 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 45); |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
114 |
label.textAlignment = UITextAlignmentCenter; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
115 |
label.font = [UIFont systemFontOfSize:16]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
116 |
label.textColor = [UIColor lightGrayColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
117 |
label.numberOfLines = 5; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
118 |
label.text = footerString; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
119 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
120 |
label.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
121 |
[footer addSubview:label]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
122 |
[label release]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
123 |
return [footer autorelease]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
124 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
125 |
|
3787 | 126 |
#pragma mark - |
127 |
#pragma mark Memory Management |
|
128 |
-(void) didReceiveMemoryWarning { |
|
3971 | 129 |
self.people = nil; |
3787 | 130 |
[super didReceiveMemoryWarning]; |
131 |
} |
|
132 |
||
133 |
-(void) viewDidUnload { |
|
134 |
self.tableView = nil; |
|
135 |
self.segmentedControl = nil; |
|
136 |
self.people = nil; |
|
137 |
[super viewDidUnload]; |
|
138 |
} |
|
139 |
||
140 |
-(void) dealloc { |
|
5208 | 141 |
releaseAndNil(tableView); |
142 |
releaseAndNil(segmentedControl); |
|
143 |
releaseAndNil(people); |
|
3787 | 144 |
[super dealloc]; |
145 |
} |
|
146 |
||
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
147 |
@end |