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