author | koda |
Sun, 12 Feb 2012 15:04:17 +0100 | |
changeset 6673 | 1ee72dcea263 |
parent 6078 | 8c0cc07731e5 |
child 6700 | e04da46ee43c |
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" |
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:
6000
diff
changeset
|
23 |
|
3703
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 { |
6673 | 33 |
[self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]]; |
3787 | 34 |
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
|
35 |
|
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
|
36 |
NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()]; |
3787 | 37 |
self.people = array; |
38 |
[array release]; |
|
4030 | 39 |
|
40 |
NSString *imgName; |
|
41 |
if (IS_IPAD()) |
|
42 |
imgName = @"smallerBackground~ipad.png"; |
|
43 |
else |
|
44 |
imgName = @"smallerBackground~iphone.png"; |
|
45 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName]; |
|
6673 | 46 |
UIImageView *background = [[UIImageView alloc] initWithImage:img]; |
4030 | 47 |
[img release]; |
6673 | 48 |
background.frame = self.view.frame; |
49 |
background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
|
50 |
[self.view insertSubview:background atIndex:0]; |
|
51 |
[background release]; |
|
52 |
||
3787 | 53 |
[super viewDidLoad]; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
54 |
} |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
55 |
|
3753 | 56 |
-(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
|
57 |
[AudioManagerController playBackSound]; |
3753 | 58 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
59 |
} |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
60 |
|
3787 | 61 |
-(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
|
62 |
[AudioManagerController playClickSound]; |
3787 | 63 |
[self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
64 |
[self.tableView reloadData]; |
|
65 |
} |
|
66 |
||
67 |
#pragma mark - |
|
68 |
#pragma mark Table view data source |
|
69 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
70 |
return 1; |
|
71 |
} |
|
72 |
||
73 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
74 |
return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; |
|
75 |
} |
|
76 |
||
77 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
78 |
static NSString *CellIdentifier = @"Cell"; |
|
79 |
||
80 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
81 |
if (cell == nil) |
|
82 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; |
|
83 |
||
84 |
// first all the names, then the title (which is offset 5) |
|
85 |
cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
|
5985 | 86 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
87 |
cell.textLabel.minimumFontSize = 8; |
|
3787 | 88 |
cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; |
89 |
||
90 |
return cell; |
|
91 |
} |
|
92 |
||
93 |
#pragma mark - |
|
94 |
#pragma mark Table view delegate |
|
95 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
96 |
// do nothing |
|
97 |
} |
|
98 |
||
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
99 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
100 |
return 95; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
101 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
102 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
103 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
104 |
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
105 |
char *fullver; |
4603 | 106 |
int proto; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
107 |
HW_versionInfo(&proto, &fullver); |
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 |
NSString *footerString = [[NSString alloc] initWithFormat: |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
110 |
@"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
|
111 |
version, fullver, proto]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
112 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
113 |
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
|
114 |
footer.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
115 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
116 |
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
|
117 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 45); |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
118 |
label.textAlignment = UITextAlignmentCenter; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
119 |
label.font = [UIFont systemFontOfSize:16]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
120 |
label.textColor = [UIColor lightGrayColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
121 |
label.numberOfLines = 5; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
122 |
label.text = footerString; |
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 |
label.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
125 |
[footer addSubview:label]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
126 |
[label release]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
127 |
return [footer autorelease]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
128 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
129 |
|
3787 | 130 |
#pragma mark - |
131 |
#pragma mark Memory Management |
|
132 |
-(void) didReceiveMemoryWarning { |
|
3971 | 133 |
self.people = nil; |
3787 | 134 |
[super didReceiveMemoryWarning]; |
135 |
} |
|
136 |
||
137 |
-(void) viewDidUnload { |
|
138 |
self.tableView = nil; |
|
139 |
self.segmentedControl = nil; |
|
140 |
self.people = nil; |
|
141 |
[super viewDidUnload]; |
|
142 |
} |
|
143 |
||
144 |
-(void) dealloc { |
|
5208 | 145 |
releaseAndNil(tableView); |
146 |
releaseAndNil(segmentedControl); |
|
147 |
releaseAndNil(people); |
|
3787 | 148 |
[super dealloc]; |
149 |
} |
|
150 |
||
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
151 |
@end |