author | koda |
Thu, 21 Apr 2016 11:54:21 -0400 | |
changeset 11663 | f87ed83568c8 |
parent 11554 | 893722a2a1f9 |
child 12877 | 00215a7ec5f5 |
permissions | -rw-r--r-- |
3884 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
3884 | 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:
8441
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3884 | 17 |
*/ |
18 |
||
3891 | 19 |
|
3884 | 20 |
#import "SupportViewController.h" |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
21 |
#import "Appirater.h" |
3884 | 22 |
|
23 |
@implementation SupportViewController |
|
4115 | 24 |
@synthesize waysToSupport; |
3884 | 25 |
|
4115 | 26 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
3884 | 27 |
return rotationManager(interfaceOrientation); |
28 |
} |
|
29 |
||
4115 | 30 |
#pragma mark - |
31 |
#pragma mark View lifecycle |
|
32 |
-(void) viewDidLoad { |
|
33 |
[super viewDidLoad]; |
|
34 |
||
35 |
NSArray *array = [[NSArray alloc] initWithObjects: |
|
36 |
NSLocalizedString(@"Leave a positive review on iTunes!",@""), |
|
37 |
NSLocalizedString(@"Join us on Facebook",@""), |
|
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
38 |
NSLocalizedString(@"Follow us on Twitter",@""), |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
39 |
NSLocalizedString(@"Visit our website",@""), |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
40 |
NSLocalizedString(@"Chat with the devs in IRC",@""), |
4115 | 41 |
nil]; |
42 |
self.waysToSupport = array; |
|
43 |
[array release]; |
|
44 |
||
6074
047eaed35cbb
ios major refactoring for ios settings, now they are presented differently on iphone/ipad, code is simplified and optimized, and ui is a little refreshed (eg. no more stuck selected fields)
koda
parents:
5976
diff
changeset
|
45 |
self.navigationItem.title = @"♥"; |
4115 | 46 |
self.tableView.rowHeight = 50; |
47 |
} |
|
48 |
||
49 |
#pragma mark - |
|
50 |
#pragma mark Table view data source |
|
51 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
52 |
return 2; |
|
53 |
} |
|
54 |
||
55 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
56 |
if (section == 0) |
|
57 |
return 1; |
|
58 |
else |
|
59 |
return [self.waysToSupport count] - 1; |
|
60 |
} |
|
61 |
||
62 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
63 |
static NSString *CellIdentifier = @"Cell"; |
|
64 |
NSInteger row = [indexPath row]; |
|
65 |
NSInteger section = [indexPath section]; |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
66 |
NSString *imgName = @""; |
4115 | 67 |
|
68 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
69 |
if (cell == nil) |
|
70 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
|
71 |
||
72 |
NSString *rowString = [self.waysToSupport objectAtIndex:(row + section)]; |
|
73 |
cell.textLabel.text = rowString; |
|
74 |
||
75 |
if (section == 0) { |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
76 |
imgName = @"star"; |
11554
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
77 |
cell.textLabel.textAlignment = NSTextAlignmentCenter; |
4115 | 78 |
cell.imageView.image = nil; |
79 |
} else { |
|
11554
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
80 |
cell.textLabel.textAlignment = NSTextAlignmentLeft; |
4115 | 81 |
switch (row) { |
82 |
case 0: |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
83 |
imgName = @"fb"; |
4115 | 84 |
break; |
85 |
case 1: |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
86 |
imgName = @"tw"; |
4115 | 87 |
break; |
88 |
case 2: |
|
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
89 |
imgName = @"hedgehog"; |
4115 | 90 |
break; |
4341 | 91 |
case 3: |
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
92 |
imgName = @"irc"; |
4341 | 93 |
break; |
4115 | 94 |
default: |
95 |
DLog(@"No way"); |
|
96 |
break; |
|
97 |
} |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
98 |
cell.accessoryView = nil; |
4115 | 99 |
} |
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
100 |
|
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
101 |
NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",[[NSBundle mainBundle] resourcePath],imgName]; |
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
102 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString]; |
5976
306cedbeb213
fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents:
5700
diff
changeset
|
103 |
[imgString release]; |
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
104 |
cell.imageView.image = img; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
105 |
if (section == 0) { |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
106 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
107 |
cell.accessoryView = imgView; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
108 |
[imgView release]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
109 |
} |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
110 |
[img release]; |
8441 | 111 |
|
4115 | 112 |
return cell; |
113 |
} |
|
114 |
||
115 |
#pragma mark - |
|
116 |
#pragma mark Table view delegate |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
117 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
118 |
{ |
4115 | 119 |
if ([indexPath section] == 0) |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
120 |
{ |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
121 |
[Appirater rateApp]; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
122 |
} |
4115 | 123 |
else |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
124 |
{ |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
125 |
NSString *urlString = nil; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
126 |
switch ([indexPath row]) |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
127 |
{ |
4115 | 128 |
case 0: |
129 |
urlString = @"http://www.facebook.com/Hedgewars"; |
|
130 |
break; |
|
131 |
case 1: |
|
132 |
urlString = @"http://twitter.com/hedgewars"; |
|
133 |
break; |
|
134 |
case 2: |
|
135 |
urlString = @"http://www.hedgewars.org"; |
|
136 |
break; |
|
4341 | 137 |
case 3: |
138 |
urlString = @"http://webchat.freenode.net/?channels=hedgewars"; |
|
139 |
break; |
|
4115 | 140 |
default: |
141 |
DLog(@"No way"); |
|
142 |
break; |
|
143 |
} |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
144 |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
145 |
} |
4115 | 146 |
} |
147 |
||
148 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
|
149 |
if (section == 1) { |
|
150 |
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 240)]; |
|
6658
2cccf6b2b89d
added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
6078
diff
changeset
|
151 |
footer.autoresizingMask = UIViewAutoresizingFlexibleWidth; |
2cccf6b2b89d
added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
6078
diff
changeset
|
152 |
|
4115 | 153 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"]; |
154 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
155 |
[img release]; |
|
156 |
imgView.center = CGPointMake(self.tableView.frame.size.width/2, 120); |
|
6658
2cccf6b2b89d
added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
6078
diff
changeset
|
157 |
imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
4115 | 158 |
[footer addSubview:imgView]; |
159 |
[imgView release]; |
|
8441 | 160 |
|
4115 | 161 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)]; |
6658
2cccf6b2b89d
added MGSplitViewController, popular replacement for uisplitviewcontrollers: this brings rotation support to our settings pages! weapons and schemes are the only controllers displaying minor glitches
koda
parents:
6078
diff
changeset
|
162 |
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
11554
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
163 |
label.textAlignment = NSTextAlignmentCenter; |
11233
b49dfdf628f6
- Some strings localizations for Settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
164 |
label.text = NSLocalizedString(@" ♥ THANK YOU ♥ ", nil); |
4115 | 165 |
label.backgroundColor = [UIColor clearColor]; |
166 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 250); |
|
167 |
[footer addSubview:label]; |
|
168 |
[label release]; |
|
8441 | 169 |
|
4115 | 170 |
return [footer autorelease]; |
171 |
} else |
|
172 |
return nil; |
|
173 |
} |
|
174 |
||
175 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
|
176 |
// image height + label height |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11233
diff
changeset
|
177 |
return (section == 1) ? 265 : 20; |
4115 | 178 |
} |
179 |
||
180 |
#pragma mark - |
|
181 |
#pragma mark Memory management |
|
182 |
-(void)didReceiveMemoryWarning { |
|
3884 | 183 |
[super didReceiveMemoryWarning]; |
184 |
} |
|
185 |
||
186 |
-(void) viewDidUnload { |
|
4115 | 187 |
self.waysToSupport = nil; |
188 |
MSG_DIDUNLOAD(); |
|
3884 | 189 |
[super viewDidUnload]; |
190 |
} |
|
191 |
||
192 |
-(void) dealloc { |
|
5208 | 193 |
releaseAndNil(waysToSupport); |
3884 | 194 |
[super dealloc]; |
195 |
} |
|
196 |
||
197 |
@end |