author | antonc27 <antonc27@mail.ru> |
Fri, 14 Aug 2015 02:10:53 +0200 | |
branch | ios-revival |
changeset 11119 | f08d5bb1d2b0 |
parent 11116 | 102684240fe8 |
child 11206 | 2e80c9861818 |
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 |
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:
6908
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6083
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]; |
11116
102684240fe8
- Interscreen transitions fixed
Anton Malmygin <antonc27@mail.ru>
parents:
10108
diff
changeset
|
68 |
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; |
6083
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) |
11119
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
95 |
{ |
6494 | 96 |
if ([str hasPrefix:desc] && [str hasSuffix:@"\""]) { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
97 |
NSArray *descriptionText = [str componentsSeparatedByString:@"\""]; |
11119
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
98 |
[filteredArray addObject:[descriptionText objectAtIndex:1]]; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
99 |
break; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
100 |
} |
11119
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
101 |
} |
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
102 |
|
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
103 |
if ([filteredArray count] == i) |
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
104 |
{ |
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
105 |
[filteredArray addObject:@""]; |
f08d5bb1d2b0
- Fix for loading missions descriptions
antonc27 <antonc27@mail.ru>
parents:
11116
diff
changeset
|
106 |
} |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
107 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
108 |
self.listOfDescriptions = filteredArray; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
109 |
[filteredArray release]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
110 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
111 |
return listOfDescriptions; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
112 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
113 |
|
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
114 |
#pragma mark - |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
115 |
#pragma mark Table view data source |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
116 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
117 |
return 1; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
118 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
119 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
120 |
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
121 |
return [self.listOfMissions count]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
122 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
123 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
124 |
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
125 |
return (IS_IPAD()) ? self.tableView.rowHeight : 80; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
126 |
} |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
127 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
128 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
129 |
static NSString *CellIdentifier = @"CellTr"; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
130 |
NSInteger row = [indexPath row]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
131 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
132 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
133 |
if (cell == nil) |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
134 |
cell = [[[UITableViewCell alloc] initWithStyle:(IS_IPAD()) ? UITableViewCellStyleDefault : UITableViewCellStyleSubtitle |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
135 |
reuseIdentifier:CellIdentifier] autorelease]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
136 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
137 |
cell.textLabel.text = [[[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension] |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
138 |
stringByReplacingOccurrencesOfString:@"_" withString:@" "]; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
139 |
cell.textLabel.textColor = [UIColor lightYellowColor]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
140 |
//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
|
141 |
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
|
142 |
cell.textLabel.backgroundColor = [UIColor clearColor]; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
143 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
144 |
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
|
145 |
cell.detailTextLabel.textColor = [UIColor whiteColor]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
146 |
cell.detailTextLabel.backgroundColor = [UIColor clearColor]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
147 |
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
148 |
cell.detailTextLabel.numberOfLines = ([cell.detailTextLabel.text length] % 40); |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
149 |
cell.detailTextLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
150 |
|
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
151 |
cell.backgroundColor = [UIColor blackColorTransparent]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
152 |
return cell; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
153 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
154 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
155 |
#pragma mark - |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
156 |
#pragma mark Table view delegate |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
157 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
158 |
NSInteger row = [indexPath row]; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
159 |
|
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
160 |
self.missionName = [[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension]; |
6100 | 161 |
NSString *size = IS_IPAD() ? @"@2x" : @""; |
162 |
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
|
163 |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
164 |
[filePath release]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
165 |
[self.previewImage setImage:img]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
166 |
[img release]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
167 |
|
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
168 |
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
|
169 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
170 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
171 |
#pragma mark - |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
172 |
#pragma mark Memory management |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
173 |
-(void) didReceiveMemoryWarning { |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
174 |
self.previewImage = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
175 |
self.missionName = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
176 |
self.listOfMissions = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
177 |
self.listOfDescriptions = nil; |
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
178 |
// 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
|
179 |
//self.previewImage = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
180 |
[super didReceiveMemoryWarning]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
181 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
182 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
183 |
-(void) viewDidUnload { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
184 |
self.listOfMissions = nil; |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
185 |
self.listOfDescriptions = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
186 |
self.previewImage = nil; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
187 |
self.tableView = nil; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
188 |
self.descriptionLabel = nil; |
6084 | 189 |
self.missionName = nil; |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
190 |
MSG_DIDUNLOAD(); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
191 |
[super viewDidUnload]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
192 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
193 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
194 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
195 |
-(void) dealloc { |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
196 |
releaseAndNil(listOfMissions); |
6094
16b12a6417d1
added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents:
6084
diff
changeset
|
197 |
releaseAndNil(listOfDescriptions); |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
198 |
releaseAndNil(previewImage); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
199 |
releaseAndNil(tableView); |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
200 |
releaseAndNil(descriptionLabel); |
6084 | 201 |
releaseAndNil(missionName); |
6083
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
202 |
[super dealloc]; |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
203 |
} |
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
204 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
205 |
|
72c882c0fd0f
first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff
changeset
|
206 |
@end |