author | Periklis Ntanasis <pntanasis@gmail.com> |
Mon, 29 Jul 2013 23:25:08 +0300 | |
branch | spacecampaign |
changeset 9388 | 790d4f7d57d1 |
parent 6908 | 896ed2afcfb8 |
child 10108 | c68cf030eded |
permissions | -rw-r--r-- |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
1 |
/* |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
4 |
* |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
8 |
* |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
13 |
* |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
17 |
*/ |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
18 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
19 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
20 |
#import "MissionTrainingViewController.h" |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
21 |
#import <QuartzCore/QuartzCore.h> |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
22 |
#import "GameInterfaceBridge.h" |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
23 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
24 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
25 |
@implementation MissionTrainingViewController |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
26 |
@synthesize listOfMissions, listOfDescriptions, previewImage, tableView, descriptionLabel, missionName; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
27 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
28 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
29 |
return rotationManager(interfaceOrientation); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
30 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
31 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
32 |
#pragma mark - |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
33 |
#pragma mark View management |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
34 |
-(void) viewDidLoad { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
35 |
self.previewImage.layer.borderColor = [[UIColor darkYellowColor] CGColor]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
36 |
self.previewImage.layer.borderWidth = 3.8f; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
37 |
self.previewImage.layer.cornerRadius = 14; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
38 |
|
6210
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
39 |
if (IS_IPAD()) { |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
40 |
[self.tableView setBackgroundColorForAnyTable:[UIColor darkBlueColorTransparent]]; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
41 |
self.tableView.layer.borderColor = [[UIColor darkYellowColor] CGColor]; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
42 |
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
43 |
} else { |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
44 |
[self.tableView setBackgroundColorForAnyTable:[UIColor blackColorTransparent]]; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
45 |
self.tableView.layer.borderColor = [[UIColor whiteColor] CGColor]; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
46 |
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; |
923c8414e3af
fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents:
6100
diff
changeset
|
47 |
} |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
48 |
self.tableView.layer.borderWidth = 2.4f; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
49 |
self.tableView.layer.cornerRadius = 8; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
50 |
self.tableView.separatorColor = [UIColor whiteColor]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
51 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
52 |
self.descriptionLabel.textColor = [UIColor lightYellowColor]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
53 |
[super viewDidLoad]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
54 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
55 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
56 |
-(void) viewWillAppear:(BOOL)animated { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
57 |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:random()%[self.listOfMissions count] inSection:0]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
58 |
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
59 |
[self tableView:self.tableView didSelectRowAtIndexPath:indexPath]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
60 |
[super viewWillAppear:animated]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
61 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
62 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
63 |
-(IBAction) buttonPressed:(id) sender { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
64 |
UIButton *button = (UIButton *)sender; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
65 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
66 |
if (button.tag == 0) { |
6869
a187c280dd3d
ios: convert audio operation from class to instance, plays better with memory
koda
parents:
6832
diff
changeset
|
67 |
[[AudioManagerController mainManager] playBackSound]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
68 |
[[self parentViewController] dismissModalViewControllerAnimated:YES]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
69 |
} else { |
6353
d8f62c805619
restore displaying statistics at the end of a game and restore warning lower views that they are going to appear
koda
parents:
6266
diff
changeset
|
70 |
[GameInterfaceBridge registerCallingController:self]; |
6266
b02a1e92dba2
convert gameinterfacebridge in simple-to-use class methods
koda
parents:
6210
diff
changeset
|
71 |
[GameInterfaceBridge startMissionGame:self.missionName]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
72 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
73 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
74 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
75 |
#pragma mark - |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
76 |
#pragma mark override setters/getters for better memory handling |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
77 |
-(NSArray *)listOfMissions { |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
78 |
if (listOfMissions == nil) |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
79 |
self.listOfMissions = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TRAININGS_DIRECTORY() error:NULL]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
80 |
return listOfMissions; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
81 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
82 |
|
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
83 |
-(NSArray *)listOfDescriptions { |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
84 |
if (listOfDescriptions == nil) { |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
85 |
NSString *descLocation = [[NSString alloc] initWithFormat:@"%@/missions_en.txt",LOCALE_DIRECTORY()]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
86 |
NSString *descComplete = [[NSString alloc] initWithContentsOfFile:descLocation encoding:NSUTF8StringEncoding error:NULL]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
87 |
[descLocation release]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
88 |
NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"]; |
6494 | 89 |
NSMutableArray *filteredArray = [[NSMutableArray alloc] initWithCapacity:[descArray count]/3]; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
90 |
[descComplete release]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
91 |
// sanity check to avoid having missions and descriptions conflicts |
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6869
diff
changeset
|
92 |
for (NSUInteger i = 0; i < [self.listOfMissions count]; i++) { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
93 |
NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
94 |
for (NSString *str in descArray) |
6494 | 95 |
if ([str hasPrefix:desc] && [str hasSuffix:@"\""]) { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
96 |
NSArray *descriptionText = [str componentsSeparatedByString:@"\""]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
97 |
[filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
98 |
break; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
99 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
100 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
101 |
self.listOfDescriptions = filteredArray; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
102 |
[filteredArray release]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
103 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
104 |
return listOfDescriptions; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
105 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
106 |
|
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
107 |
#pragma mark - |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
108 |
#pragma mark Table view data source |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
109 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
110 |
return 1; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
111 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
112 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
113 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
114 |
return [self.listOfMissions count]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
115 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
116 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
117 |
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
118 |
return (IS_IPAD()) ? self.tableView.rowHeight : 80; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
119 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
120 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
121 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
122 |
static NSString *CellIdentifier = @"CellTr"; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
123 |
NSInteger row = [indexPath row]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
124 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
125 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
126 |
if (cell == nil) |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
127 |
cell = [[[UITableViewCell alloc] initWithStyle:(IS_IPAD()) ? UITableViewCellStyleDefault : UITableViewCellStyleSubtitle |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
128 |
reuseIdentifier:CellIdentifier] autorelease]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
129 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
130 |
cell.textLabel.text = [[[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension] |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
131 |
stringByReplacingOccurrencesOfString:@"_" withString:@" "]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
132 |
cell.textLabel.textColor = [UIColor lightYellowColor]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
133 |
//cell.textLabel.font = [UIFont fontWithName:@"Bradley Hand Bold" size:[UIFont labelFontSize]]; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
134 |
cell.textLabel.textAlignment = (IS_IPAD()) ? UITextAlignmentCenter : UITextAlignmentLeft; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
135 |
cell.textLabel.backgroundColor = [UIColor clearColor]; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
136 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
137 |
cell.detailTextLabel.text = (IS_IPAD()) ? nil : [self.listOfDescriptions objectAtIndex:row]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
138 |
cell.detailTextLabel.textColor = [UIColor whiteColor]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
139 |
cell.detailTextLabel.backgroundColor = [UIColor clearColor]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
140 |
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
141 |
cell.detailTextLabel.numberOfLines = ([cell.detailTextLabel.text length] % 40); |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
142 |
cell.detailTextLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
143 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
144 |
cell.backgroundColor = [UIColor blackColorTransparent]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
145 |
return cell; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
146 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
147 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
148 |
#pragma mark - |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
149 |
#pragma mark Table view delegate |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
150 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
151 |
NSInteger row = [indexPath row]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
152 |
|
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
153 |
self.missionName = [[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension]; |
6100 | 154 |
NSString *size = IS_IPAD() ? @"@2x" : @""; |
155 |
NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Missions/Training/%@%@.png",GRAPHICS_DIRECTORY(),self.missionName,size]; |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
156 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
157 |
[filePath release]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
158 |
[self.previewImage setImage:img]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
159 |
[img release]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
160 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
161 |
self.descriptionLabel.text = [self.listOfDescriptions objectAtIndex:row]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
162 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
163 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
164 |
#pragma mark - |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
165 |
#pragma mark Memory management |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
166 |
-(void) didReceiveMemoryWarning { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
167 |
self.previewImage = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
168 |
self.missionName = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
169 |
self.listOfMissions = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
170 |
self.listOfDescriptions = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
171 |
// if you nil this one it won't get updated anymore |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
172 |
//self.previewImage = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
173 |
[super didReceiveMemoryWarning]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
174 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
175 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
176 |
-(void) viewDidUnload { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
177 |
self.listOfMissions = nil; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
178 |
self.listOfDescriptions = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
179 |
self.previewImage = nil; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
180 |
self.tableView = nil; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
181 |
self.descriptionLabel = nil; |
6084 | 182 |
self.missionName = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
183 |
MSG_DIDUNLOAD(); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
184 |
[super viewDidUnload]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
185 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
186 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
187 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
188 |
-(void) dealloc { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
189 |
releaseAndNil(listOfMissions); |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
190 |
releaseAndNil(listOfDescriptions); |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
191 |
releaseAndNil(previewImage); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
192 |
releaseAndNil(tableView); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
193 |
releaseAndNil(descriptionLabel); |
6084 | 194 |
releaseAndNil(missionName); |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
195 |
[super dealloc]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
196 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
197 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
198 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
199 |
@end |