3884
|
1 |
/*
|
|
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices
|
4976
|
3 |
* Copyright (c) 2009-2011 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
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
17 |
*
|
|
18 |
* File created on 19/09/2010.
|
|
19 |
*/
|
|
20 |
|
3891
|
21 |
|
3884
|
22 |
#import "SupportViewController.h"
|
|
23 |
#import "CommodityFunctions.h"
|
|
24 |
|
|
25 |
@implementation SupportViewController
|
4115
|
26 |
@synthesize waysToSupport;
|
3884
|
27 |
|
4115
|
28 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
3884
|
29 |
return rotationManager(interfaceOrientation);
|
|
30 |
}
|
|
31 |
|
4115
|
32 |
#pragma mark -
|
|
33 |
#pragma mark View lifecycle
|
|
34 |
-(void) viewDidLoad {
|
|
35 |
[super viewDidLoad];
|
|
36 |
|
|
37 |
NSArray *array = [[NSArray alloc] initWithObjects:
|
|
38 |
NSLocalizedString(@"Leave a positive review on iTunes!",@""),
|
|
39 |
NSLocalizedString(@"Join us on Facebook",@""),
|
|
40 |
NSLocalizedString(@"Follow on Twitter",@""),
|
|
41 |
NSLocalizedString(@"Visit website",@""),
|
4341
|
42 |
NSLocalizedString(@"Chat with us in IRC",@""),
|
4115
|
43 |
nil];
|
|
44 |
self.waysToSupport = array;
|
|
45 |
[array release];
|
|
46 |
|
|
47 |
self.tableView.rowHeight = 50;
|
|
48 |
}
|
|
49 |
|
|
50 |
#pragma mark -
|
|
51 |
#pragma mark Table view data source
|
|
52 |
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
53 |
return 2;
|
|
54 |
}
|
|
55 |
|
|
56 |
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
57 |
if (section == 0)
|
|
58 |
return 1;
|
|
59 |
else
|
|
60 |
return [self.waysToSupport count] - 1;
|
|
61 |
}
|
|
62 |
|
|
63 |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
64 |
static NSString *CellIdentifier = @"Cell";
|
|
65 |
NSInteger row = [indexPath row];
|
|
66 |
NSInteger section = [indexPath section];
|
|
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) {
|
|
76 |
cell.textLabel.textAlignment = UITextAlignmentCenter;
|
|
77 |
cell.imageView.image = nil;
|
|
78 |
} else {
|
|
79 |
cell.textLabel.textAlignment = UITextAlignmentLeft;
|
|
80 |
NSString *imgString = nil;
|
|
81 |
switch (row) {
|
|
82 |
case 0:
|
|
83 |
imgString = @"fb.png";
|
|
84 |
break;
|
|
85 |
case 1:
|
|
86 |
imgString = @"tw.png";
|
|
87 |
break;
|
|
88 |
case 2:
|
|
89 |
imgString = @"Icon-Small.png";
|
|
90 |
break;
|
4341
|
91 |
case 3:
|
|
92 |
imgString = @"irc.png";
|
|
93 |
break;
|
4115
|
94 |
default:
|
|
95 |
DLog(@"No way");
|
|
96 |
break;
|
|
97 |
}
|
|
98 |
|
|
99 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgString];
|
|
100 |
cell.imageView.image = img;
|
|
101 |
[img release];
|
|
102 |
}
|
|
103 |
|
|
104 |
return cell;
|
|
105 |
}
|
|
106 |
|
|
107 |
#pragma mark -
|
|
108 |
#pragma mark Table view delegate
|
|
109 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
110 |
NSString *urlString = nil;
|
|
111 |
if ([indexPath section] == 0)
|
|
112 |
urlString = @"http://itunes.apple.com/us/app/hedgewars/id391234866?affC=QQABAAAAHgAFasEiWjVwUGZOc3k1VGctQkRJazlacXhUclpBTVpiU2xteVdfUQ%3D%3D#&mt=8";
|
|
113 |
else
|
|
114 |
switch ([indexPath row]) {
|
|
115 |
case 0:
|
|
116 |
urlString = @"http://www.facebook.com/Hedgewars";
|
|
117 |
break;
|
|
118 |
case 1:
|
|
119 |
urlString = @"http://twitter.com/hedgewars";
|
|
120 |
break;
|
|
121 |
case 2:
|
|
122 |
urlString = @"http://www.hedgewars.org";
|
|
123 |
break;
|
4341
|
124 |
case 3:
|
|
125 |
urlString = @"http://webchat.freenode.net/?channels=hedgewars";
|
|
126 |
break;
|
4115
|
127 |
default:
|
|
128 |
DLog(@"No way");
|
|
129 |
break;
|
|
130 |
}
|
|
131 |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
|
|
132 |
}
|
|
133 |
|
|
134 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
|
|
135 |
if (section == 1) {
|
|
136 |
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 240)];
|
|
137 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"];
|
|
138 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img];
|
|
139 |
[img release];
|
|
140 |
imgView.center = CGPointMake(self.tableView.frame.size.width/2, 120);
|
|
141 |
[footer addSubview:imgView];
|
|
142 |
[imgView release];
|
|
143 |
|
|
144 |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];
|
|
145 |
label.textAlignment = UITextAlignmentCenter;
|
|
146 |
label.text = @" ♥ THANK YOU ♥ ";
|
|
147 |
label.backgroundColor = [UIColor clearColor];
|
|
148 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 250);
|
|
149 |
[footer addSubview:label];
|
|
150 |
[label release];
|
|
151 |
|
|
152 |
return [footer autorelease];
|
|
153 |
} else
|
|
154 |
return nil;
|
|
155 |
}
|
|
156 |
|
|
157 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
|
158 |
// image height + label height
|
|
159 |
return 265;
|
|
160 |
}
|
|
161 |
|
|
162 |
#pragma mark -
|
|
163 |
#pragma mark Memory management
|
|
164 |
-(void)didReceiveMemoryWarning {
|
3884
|
165 |
[super didReceiveMemoryWarning];
|
|
166 |
}
|
|
167 |
|
|
168 |
-(void) viewDidUnload {
|
4115
|
169 |
self.waysToSupport = nil;
|
|
170 |
MSG_DIDUNLOAD();
|
3884
|
171 |
[super viewDidUnload];
|
|
172 |
}
|
|
173 |
|
|
174 |
-(void) dealloc {
|
4115
|
175 |
[self.waysToSupport release];
|
3884
|
176 |
[super dealloc];
|
|
177 |
}
|
|
178 |
|
|
179 |
@end
|