author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 15 Apr 2019 22:00:20 +0200 | |
changeset 14805 | af0f06b77908 |
parent 13506 | 36f3f77e9b1b |
child 15934 | d754d03e4dfe |
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:
11229
diff
changeset
|
21 |
#import "Appirater.h" |
3884 | 22 |
|
23 |
@implementation SupportViewController |
|
4115 | 24 |
@synthesize waysToSupport; |
3884 | 25 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
26 |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
3884 | 27 |
return rotationManager(interfaceOrientation); |
28 |
} |
|
29 |
||
4115 | 30 |
#pragma mark - |
31 |
#pragma mark View lifecycle |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
32 |
- (void)viewDidLoad { |
4115 | 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 |
||
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
|
44 |
self.navigationItem.title = @"♥"; |
4115 | 45 |
self.tableView.rowHeight = 50; |
46 |
} |
|
47 |
||
48 |
#pragma mark - |
|
49 |
#pragma mark Table view data source |
|
50 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
|
51 |
return 2; |
|
52 |
} |
|
53 |
||
54 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
|
55 |
if (section == 0) |
|
56 |
return 1; |
|
57 |
else |
|
58 |
return [self.waysToSupport count] - 1; |
|
59 |
} |
|
60 |
||
61 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
62 |
static NSString *CellIdentifier = @"Cell"; |
|
63 |
NSInteger row = [indexPath row]; |
|
64 |
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
|
65 |
NSString *imgName = @""; |
4115 | 66 |
|
67 |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
|
68 |
if (cell == nil) |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
69 |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; |
4115 | 70 |
|
71 |
NSString *rowString = [self.waysToSupport objectAtIndex:(row + section)]; |
|
72 |
cell.textLabel.text = rowString; |
|
73 |
||
74 |
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
|
75 |
imgName = @"star"; |
11549
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
76 |
cell.textLabel.textAlignment = NSTextAlignmentCenter; |
4115 | 77 |
cell.imageView.image = nil; |
78 |
} else { |
|
11549
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
79 |
cell.textLabel.textAlignment = NSTextAlignmentLeft; |
4115 | 80 |
switch (row) { |
81 |
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
|
82 |
imgName = @"fb"; |
4115 | 83 |
break; |
84 |
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
|
85 |
imgName = @"tw"; |
4115 | 86 |
break; |
87 |
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
|
88 |
imgName = @"hedgehog"; |
4115 | 89 |
break; |
4341 | 90 |
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
|
91 |
imgName = @"irc"; |
4341 | 92 |
break; |
4115 | 93 |
default: |
94 |
DLog(@"No way"); |
|
95 |
break; |
|
96 |
} |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
97 |
cell.accessoryView = nil; |
4115 | 98 |
} |
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
|
99 |
|
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 |
NSString *imgString = [[NSString alloc] initWithFormat:@"%@/%@.png",[[NSBundle mainBundle] resourcePath],imgName]; |
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
101 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
102 |
cell.imageView.image = img; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
103 |
if (section == 0) { |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
104 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
105 |
cell.accessoryView = imgView; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
106 |
} |
8441 | 107 |
|
4115 | 108 |
return cell; |
109 |
} |
|
110 |
||
111 |
#pragma mark - |
|
112 |
#pragma mark Table view delegate |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
113 |
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
114 |
{ |
4115 | 115 |
if ([indexPath section] == 0) |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
116 |
{ |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
117 |
[Appirater rateApp]; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
118 |
} |
4115 | 119 |
else |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
120 |
{ |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
121 |
NSString *urlString = nil; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
122 |
switch ([indexPath row]) |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
123 |
{ |
4115 | 124 |
case 0: |
13506
36f3f77e9b1b
Switch from http:// to https:// URLs where possible
Wuzzy <Wuzzy2@mail.ru>
parents:
13166
diff
changeset
|
125 |
urlString = @"https://www.facebook.com/Hedgewars"; |
4115 | 126 |
break; |
127 |
case 1: |
|
13506
36f3f77e9b1b
Switch from http:// to https:// URLs where possible
Wuzzy <Wuzzy2@mail.ru>
parents:
13166
diff
changeset
|
128 |
urlString = @"https://twitter.com/hedgewars"; |
4115 | 129 |
break; |
130 |
case 2: |
|
13506
36f3f77e9b1b
Switch from http:// to https:// URLs where possible
Wuzzy <Wuzzy2@mail.ru>
parents:
13166
diff
changeset
|
131 |
urlString = @"https://www.hedgewars.org"; |
4115 | 132 |
break; |
4341 | 133 |
case 3: |
13506
36f3f77e9b1b
Switch from http:// to https:// URLs where possible
Wuzzy <Wuzzy2@mail.ru>
parents:
13166
diff
changeset
|
134 |
urlString = @"https://webchat.freenode.net/?channels=hedgewars"; |
4341 | 135 |
break; |
4115 | 136 |
default: |
137 |
DLog(@"No way"); |
|
138 |
break; |
|
139 |
} |
|
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
140 |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; |
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
141 |
} |
4115 | 142 |
} |
143 |
||
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
144 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { |
4115 | 145 |
if (section == 1) { |
146 |
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
|
147 |
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
|
148 |
|
4115 | 149 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"]; |
150 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
151 |
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
|
152 |
imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
4115 | 153 |
[footer addSubview:imgView]; |
8441 | 154 |
|
4115 | 155 |
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
|
156 |
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
11549
893722a2a1f9
- Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents:
11310
diff
changeset
|
157 |
label.textAlignment = NSTextAlignmentCenter; |
11229
b49dfdf628f6
- Some strings localizations for Settings
antonc27 <antonc27@mail.ru>
parents:
10108
diff
changeset
|
158 |
label.text = NSLocalizedString(@" ♥ THANK YOU ♥ ", nil); |
4115 | 159 |
label.backgroundColor = [UIColor clearColor]; |
160 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 250); |
|
161 |
[footer addSubview:label]; |
|
8441 | 162 |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
163 |
return footer; |
4115 | 164 |
} else |
165 |
return nil; |
|
166 |
} |
|
167 |
||
13166
ba5c794adae3
- Some not-so-important pretty formatting
antonc27 <antonc27@mail.ru>
parents:
12872
diff
changeset
|
168 |
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
4115 | 169 |
// image height + label height |
11310
9671c2bfce41
- Support screen refactoring:
antonc27 <antonc27@mail.ru>
parents:
11229
diff
changeset
|
170 |
return (section == 1) ? 265 : 20; |
4115 | 171 |
} |
172 |
||
173 |
#pragma mark - |
|
174 |
#pragma mark Memory management |
|
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
175 |
|
4115 | 176 |
-(void)didReceiveMemoryWarning { |
3884 | 177 |
[super didReceiveMemoryWarning]; |
12872
00215a7ec5f5
- BIG CHANGE: Convert iOS project to use ARC
antonc27 <antonc27@mail.ru>
parents:
11549
diff
changeset
|
178 |
MSG_MEMCLEAN(); |
3884 | 179 |
} |
180 |
||
181 |
@end |