author | unC0Rr |
Wed, 01 May 2024 16:49:16 +0200 | |
changeset 16041 | caba603f461f |
parent 13166 | ba5c794adae3 |
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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
6869
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3829 | 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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
26 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
3703
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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
30 |
- (void)viewDidLoad |
11308
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
31 |
{ |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
32 |
[super viewDidLoad]; |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
33 |
|
6673 | 34 |
[self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]]; |
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; |
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]; |
47 |
background.frame = self.view.frame; |
|
48 |
background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
|
49 |
[self.view insertSubview:background atIndex:0]; |
|
50 |
||
11308
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
51 |
[self localizeSegmentedControl]; |
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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
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]; |
11116
102684240fe8
- Interscreen transitions fixed
Anton Malmygin <antonc27@mail.ru>
parents:
10108
diff
changeset
|
56 |
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; |
3753 | 57 |
} |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff
changeset
|
58 |
|
11308
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
59 |
#pragma mark - Segmented Control |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
60 |
|
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
61 |
- (void)localizeSegmentedControl |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
62 |
{ |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
63 |
for (NSUInteger i = 0; i < self.segmentedControl.numberOfSegments; i++) |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
64 |
{ |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
65 |
NSString *oldTitle = [self.segmentedControl titleForSegmentAtIndex:i]; |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
66 |
[self.segmentedControl setTitle:NSLocalizedStringFromTable(oldTitle, @"About", nil) forSegmentAtIndex:i]; |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
67 |
} |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
68 |
} |
92b023095153
- Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents:
11307
diff
changeset
|
69 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
70 |
- (IBAction)segmentedControlChanged:(id)sender { |
6869
a187c280dd3d
ios: convert audio operation from class to instance, plays better with memory
koda
parents:
6832
diff
changeset
|
71 |
[[AudioManagerController mainManager] playClickSound]; |
3787 | 72 |
[self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; |
73 |
[self.tableView reloadData]; |
|
74 |
} |
|
75 |
||
76 |
#pragma mark - |
|
77 |
#pragma mark Table view data source |
|
78 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
79 |
return 1; |
|
80 |
} |
|
81 |
||
82 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
83 |
return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; |
|
84 |
} |
|
85 |
||
86 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
87 |
static NSString *CellIdentifier = @"Cell"; |
|
88 |
||
89 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
90 |
if (cell == nil) |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
91 |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; |
3787 | 92 |
|
93 |
// first all the names, then the title (which is offset 5) |
|
94 |
cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; |
|
5985 | 95 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
96 |
cell.textLabel.minimumFontSize = 8; |
|
11128
344d523ab9bb
- Fix for localization of detail labels at AboutViewController
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
97 |
NSString *detailsKey = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; |
344d523ab9bb
- Fix for localization of detail labels at AboutViewController
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
98 |
cell.detailTextLabel.text = NSLocalizedStringFromTable(detailsKey, @"About", nil); |
3787 | 99 |
|
100 |
return cell; |
|
101 |
} |
|
102 |
||
103 |
#pragma mark - |
|
104 |
#pragma mark Table view delegate |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
105 |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
3787 | 106 |
// do nothing |
107 |
} |
|
108 |
||
13166
ba5c794adae3
- Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents:
12872
diff
changeset
|
109 |
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
110 |
return 95; |
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 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
113 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
114 |
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
115 |
char *fullver; |
4603 | 116 |
int proto; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
117 |
HW_versionInfo(&proto, &fullver); |
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 |
NSString *footerString = [[NSString alloc] initWithFormat: |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
120 |
@"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
|
121 |
version, fullver, proto]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
122 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
123 |
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
|
124 |
footer.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
125 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
126 |
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
|
127 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 45); |
11549
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11308
diff
changeset
|
128 |
label.textAlignment = NSTextAlignmentCenter; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
129 |
label.font = [UIFont systemFontOfSize:16]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
130 |
label.textColor = [UIColor lightGrayColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
131 |
label.numberOfLines = 5; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
132 |
label.text = footerString; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
133 |
|
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
134 |
label.backgroundColor = [UIColor clearColor]; |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
135 |
[footer addSubview:label]; |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
136 |
return footer; |
4460
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
137 |
} |
bdace1e2f8aa
write some version information inside the application
koda
parents:
4115
diff
changeset
|
138 |
|
3787 | 139 |
#pragma mark - |
140 |
#pragma mark Memory Management |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
141 |
|
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
142 |
- (void)didReceiveMemoryWarning { |
3971 | 143 |
self.people = nil; |
3787 | 144 |
[super didReceiveMemoryWarning]; |
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 |