author | nemo |
Mon, 03 Dec 2018 12:43:39 -0500 | |
branch | 0.9.22 |
changeset 14361 | 21d556cddf93 |
parent 10108 | c68cf030eded |
child 11229 | b49dfdf628f6 |
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" |
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:
6074
diff
changeset
|
21 |
|
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"; |
4115 | 77 |
cell.textLabel.textAlignment = UITextAlignmentCenter; |
78 |
cell.imageView.image = nil; |
|
79 |
} else { |
|
80 |
cell.textLabel.textAlignment = UITextAlignmentLeft; |
|
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 |
} |
|
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]; |
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
|
102 |
[imgString release]; |
5700
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
103 |
cell.imageView.image = img; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
104 |
if (section == 0) { |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
105 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
106 |
cell.accessoryView = imgView; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
107 |
[imgView release]; |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
108 |
} |
f0960a88ab0e
savedgamesviewcontroller refactor, added icons to supportviewcontroller
koda
parents:
5208
diff
changeset
|
109 |
[img release]; |
8441 | 110 |
|
4115 | 111 |
return cell; |
112 |
} |
|
113 |
||
114 |
#pragma mark - |
|
115 |
#pragma mark Table view delegate |
|
116 |
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
117 |
NSString *urlString = nil; |
|
118 |
if ([indexPath section] == 0) |
|
119 |
urlString = @"http://itunes.apple.com/us/app/hedgewars/id391234866?affC=QQABAAAAHgAFasEiWjVwUGZOc3k1VGctQkRJazlacXhUclpBTVpiU2xteVdfUQ%3D%3D#&mt=8"; |
|
120 |
else |
|
121 |
switch ([indexPath row]) { |
|
122 |
case 0: |
|
123 |
urlString = @"http://www.facebook.com/Hedgewars"; |
|
124 |
break; |
|
125 |
case 1: |
|
126 |
urlString = @"http://twitter.com/hedgewars"; |
|
127 |
break; |
|
128 |
case 2: |
|
129 |
urlString = @"http://www.hedgewars.org"; |
|
130 |
break; |
|
4341 | 131 |
case 3: |
132 |
urlString = @"http://webchat.freenode.net/?channels=hedgewars"; |
|
133 |
break; |
|
4115 | 134 |
default: |
135 |
DLog(@"No way"); |
|
136 |
break; |
|
137 |
} |
|
138 |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; |
|
139 |
} |
|
140 |
||
141 |
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
|
142 |
if (section == 1) { |
|
143 |
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
|
144 |
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
|
145 |
|
4115 | 146 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"surprise.png"]; |
147 |
UIImageView *imgView = [[UIImageView alloc] initWithImage:img]; |
|
148 |
[img release]; |
|
149 |
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
|
150 |
imgView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
4115 | 151 |
[footer addSubview:imgView]; |
152 |
[imgView release]; |
|
8441 | 153 |
|
4115 | 154 |
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
|
155 |
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; |
4115 | 156 |
label.textAlignment = UITextAlignmentCenter; |
157 |
label.text = @" ♥ THANK YOU ♥ "; |
|
158 |
label.backgroundColor = [UIColor clearColor]; |
|
159 |
label.center = CGPointMake(self.tableView.frame.size.width/2, 250); |
|
160 |
[footer addSubview:label]; |
|
161 |
[label release]; |
|
8441 | 162 |
|
4115 | 163 |
return [footer autorelease]; |
164 |
} else |
|
165 |
return nil; |
|
166 |
} |
|
167 |
||
168 |
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { |
|
169 |
// image height + label height |
|
170 |
return 265; |
|
171 |
} |
|
172 |
||
173 |
#pragma mark - |
|
174 |
#pragma mark Memory management |
|
175 |
-(void)didReceiveMemoryWarning { |
|
3884 | 176 |
[super didReceiveMemoryWarning]; |
177 |
} |
|
178 |
||
179 |
-(void) viewDidUnload { |
|
4115 | 180 |
self.waysToSupport = nil; |
181 |
MSG_DIDUNLOAD(); |
|
3884 | 182 |
[super viewDidUnload]; |
183 |
} |
|
184 |
||
185 |
-(void) dealloc { |
|
5208 | 186 |
releaseAndNil(waysToSupport); |
3884 | 187 |
[super dealloc]; |
188 |
} |
|
189 |
||
190 |
@end |