author | koda |
Sat, 08 Oct 2011 22:51:01 +0200 | |
changeset 6105 | 29bf0ca70af9 |
parent 6079 | c10767edcd58 |
child 6107 | 0741c0f0203e |
permissions | -rw-r--r-- |
3829 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
4976 | 3 |
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com> |
3829 | 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 22/04/2010. |
|
19 |
*/ |
|
20 |
||
3547 | 21 |
|
22 |
#import "MapConfigViewController.h" |
|
4349 | 23 |
#import "SchemeWeaponConfigViewController.h" |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4356
diff
changeset
|
24 |
#import "GameConfigViewController.h" |
3547 | 25 |
|
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:
6000
diff
changeset
|
26 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
27 |
#define scIndex self.segmentedControl.selectedSegmentIndex |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
28 |
#define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
3547 | 29 |
|
30 |
@implementation MapConfigViewController |
|
3642 | 31 |
@synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand, |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4356
diff
changeset
|
32 |
missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, |
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4356
diff
changeset
|
33 |
externalController, parentController; |
3547 | 34 |
|
35 |
||
36 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
37 |
return rotationManager(interfaceOrientation); |
|
38 |
} |
|
39 |
||
3783 | 40 |
-(IBAction) mapButtonPressed { |
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5483
diff
changeset
|
41 |
[AudioManagerController playClickSound]; |
3783 | 42 |
[self updatePreview]; |
43 |
} |
|
44 |
||
45 |
-(void) updatePreview { |
|
3547 | 46 |
// don't generate a new preview while it's already generating one |
47 |
if (busy) |
|
48 |
return; |
|
3697 | 49 |
|
3547 | 50 |
// generate a seed |
51 |
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); |
|
52 |
NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid); |
|
53 |
CFRelease(uuid); |
|
54 |
NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed]; |
|
55 |
self.seedCommand = seedCmd; |
|
56 |
[seedCmd release]; |
|
3697 | 57 |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
58 |
if (self.dataSourceArray == nil) |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
59 |
[self loadDataSourceArray]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
60 |
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex]; |
3547 | 61 |
NSIndexPath *theIndex; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
62 |
if (isRandomness()) { |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
63 |
// prevent other events and add an activity while the preview is beign generated |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
64 |
[self turnOffWidgets]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
65 |
[self.previewButton updatePreviewWithSeed:seed]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
66 |
theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0]; |
3547 | 67 |
} else { |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
68 |
theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0]; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
69 |
// the preview for static maps is loaded in didSelectRowAtIndexPath |
3547 | 70 |
} |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
71 |
[seed release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
72 |
|
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
73 |
// perform as if user clicked on an entry |
3547 | 74 |
[self tableView:self.tableView didSelectRowAtIndexPath:theIndex]; |
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:
6000
diff
changeset
|
75 |
if (IS_NOT_POWERFUL([HWUtils modelType]) == NO) |
4287 | 76 |
[self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; |
3547 | 77 |
} |
78 |
||
79 |
-(void) turnOffWidgets { |
|
80 |
busy = YES; |
|
81 |
self.previewButton.alpha = 0.5f; |
|
82 |
self.previewButton.enabled = NO; |
|
83 |
self.maxLabel.text = @"..."; |
|
84 |
self.segmentedControl.enabled = NO; |
|
85 |
self.slider.enabled = NO; |
|
86 |
} |
|
87 |
||
88 |
-(void) turnOnWidgets { |
|
89 |
self.previewButton.alpha = 1.0f; |
|
90 |
self.previewButton.enabled = YES; |
|
91 |
self.segmentedControl.enabled = YES; |
|
92 |
self.slider.enabled = YES; |
|
93 |
busy = NO; |
|
94 |
} |
|
3697 | 95 |
|
3547 | 96 |
-(void) setLabelText:(NSString *)str { |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
97 |
self.maxHogs = [str intValue]; |
3547 | 98 |
self.maxLabel.text = str; |
99 |
} |
|
100 |
||
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
101 |
-(NSDictionary *)getDataForEngine { |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
102 |
NSDictionary *dictForEngine = [NSDictionary dictionaryWithObjectsAndKeys: |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
103 |
self.seedCommand,@"seedCommand", |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
104 |
self.templateFilterCommand,@"templateFilterCommand", |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
105 |
self.mapGenCommand,@"mapGenCommand", |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
106 |
self.mazeSizeCommand,@"mazeSizeCommand", |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
107 |
nil]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
108 |
return dictForEngine; |
3547 | 109 |
} |
110 |
||
111 |
#pragma mark - |
|
112 |
#pragma mark Table view data source |
|
113 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
114 |
return 1; |
|
115 |
} |
|
116 |
||
117 |
-(NSInteger) tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger) section { |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
118 |
if (self.dataSourceArray == nil) |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
119 |
[self loadDataSourceArray]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
120 |
return [[self.dataSourceArray objectAtIndex:scIndex] count]; |
3547 | 121 |
} |
122 |
||
123 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
124 |
static NSString *CellIdentifier = @"Cell"; |
|
125 |
NSInteger row = [indexPath row]; |
|
3697 | 126 |
|
3547 | 127 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3697 | 128 |
if (cell == nil) |
3547 | 129 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3697 | 130 |
|
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
131 |
if (self.dataSourceArray == nil) |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
132 |
[self loadDataSourceArray]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
133 |
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
134 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
135 |
NSString *labelString = [source objectAtIndex:row]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
136 |
cell.textLabel.text = labelString; |
3996 | 137 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
138 |
cell.textLabel.minimumFontSize = 7; |
|
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:
6000
diff
changeset
|
139 |
cell.textLabel.textColor = [UIColor lightYellowColor]; |
4476
4bf74e158f44
team selection completely refactored, now has animation and more performance
koda
parents:
4362
diff
changeset
|
140 |
cell.textLabel.backgroundColor = [UIColor clearColor]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
141 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
142 |
if (isRandomness()) { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
143 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),labelString]]; |
3547 | 144 |
cell.imageView.image = image; |
145 |
[image release]; |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
146 |
} else |
3547 | 147 |
cell.imageView.image = nil; |
3697 | 148 |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
149 |
if (row == [self.lastIndexPath row]) { |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
150 |
UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]]; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
151 |
cell.accessoryView = checkbox; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
152 |
[checkbox release]; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
153 |
} else |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
154 |
cell.accessoryView = nil; |
3547 | 155 |
|
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:
6000
diff
changeset
|
156 |
cell.backgroundColor = [UIColor blackColorTransparent]; |
3547 | 157 |
return cell; |
158 |
} |
|
159 |
||
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
160 |
// this set details for a static map (called by didSelectRowAtIndexPath) |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
161 |
-(void) setDetailsForStaticMap:(NSInteger) index { |
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
162 |
if (self.dataSourceArray == nil) |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
163 |
[self loadDataSourceArray]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
164 |
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
165 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
166 |
NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg", |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
167 |
(scIndex == 1) ? MAPS_DIRECTORY() : MISSIONS_DIRECTORY(),[source objectAtIndex:index]]; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
168 |
NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
169 |
[fileCfg release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
170 |
NSArray *split = [contents componentsSeparatedByString:@"\n"]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
171 |
[contents release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
172 |
|
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
173 |
// if the number is not set we keep 18 standard; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
174 |
// sometimes it's not set but there are trailing characters, we get around them with the second equation |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
175 |
if ([split count] > 1 && [[split objectAtIndex:1] intValue] > 0) |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
176 |
maxHogs = [[split objectAtIndex:1] intValue]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
177 |
else |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
178 |
maxHogs = 18; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
179 |
NSString *max = [[NSString alloc] initWithFormat:@"%d",maxHogs]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
180 |
self.maxLabel.text = max; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
181 |
[max release]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
182 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
183 |
self.themeCommand = [NSString stringWithFormat:@"etheme %@", [split objectAtIndex:0]]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
184 |
self.staticMapCommand = [NSString stringWithFormat:@"emap %@", [source objectAtIndex:index]]; |
3912
e11df2de6af2
have engine try for a second position when map loading fails (in this way it's possible to move Missions data to any path)
koda
parents:
3911
diff
changeset
|
185 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
186 |
if (scIndex != 3) |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
187 |
self.missionCommand = @""; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
188 |
else |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
189 |
self.missionCommand = [NSString stringWithFormat:@"escript Missions/Maps/%@/map.lua",[source objectAtIndex:index]]; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
190 |
} |
3547 | 191 |
|
192 |
#pragma mark - |
|
193 |
#pragma mark Table view delegate |
|
194 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
195 |
int newRow = [indexPath row]; |
|
196 |
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
|
3697 | 197 |
|
3547 | 198 |
if (newRow != oldRow) { |
3926
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
199 |
if (self.dataSourceArray == nil) |
668b71f31e51
use dynamic data from engine instead of using hardcoded values
koda
parents:
3920
diff
changeset
|
200 |
[self loadDataSourceArray]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
201 |
NSArray *source = [self.dataSourceArray objectAtIndex:scIndex]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
202 |
if (isRandomness()) { |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
203 |
// just change the theme, don't update preview |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
204 |
self.themeCommand = [NSString stringWithFormat:@"etheme %@", [source objectAtIndex:newRow]]; |
3642 | 205 |
} else { |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
206 |
NSString *fileImage = [NSString stringWithFormat:@"%@/%@/preview.png", |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
207 |
(scIndex == 1) ? MAPS_DIRECTORY() : MISSIONS_DIRECTORY(),[source objectAtIndex:newRow]]; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
208 |
[self.previewButton updatePreviewWithFile:fileImage]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
209 |
[self setDetailsForStaticMap:newRow]; |
3642 | 210 |
} |
3697 | 211 |
|
212 |
UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath]; |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
213 |
UIImageView *checkbox = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"checkbox.png"]]; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
214 |
newCell.accessoryView = checkbox; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
215 |
[checkbox release]; |
3547 | 216 |
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:self.lastIndexPath]; |
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
217 |
oldCell.accessoryView = nil; |
3547 | 218 |
|
219 |
self.lastIndexPath = indexPath; |
|
220 |
[aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
|
221 |
} |
|
222 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
|
223 |
} |
|
224 |
||
225 |
#pragma mark - |
|
4082 | 226 |
#pragma mark slider & segmentedControl & button |
3547 | 227 |
// this updates the label and the command keys when the slider is moved, depending of the selection in segmentedControl |
228 |
// no methods are called by this routine and you can pass nil to it |
|
229 |
-(IBAction) sliderChanged:(id) sender { |
|
230 |
NSString *labelText; |
|
231 |
NSString *templateCommand; |
|
232 |
NSString *mazeCommand; |
|
3697 | 233 |
|
3547 | 234 |
switch ((int)(self.slider.value*100)) { |
235 |
case 0: |
|
236 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
237 |
labelText = NSLocalizedString(@"Wacky",@""); |
|
238 |
} else { |
|
239 |
labelText = NSLocalizedString(@"Large Floating Islands",@""); |
|
240 |
} |
|
241 |
templateCommand = @"e$template_filter 5"; |
|
242 |
mazeCommand = @"e$maze_size 5"; |
|
243 |
break; |
|
244 |
case 1: |
|
245 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
246 |
labelText = NSLocalizedString(@"Cavern",@""); |
|
247 |
} else { |
|
248 |
labelText = NSLocalizedString(@"Medium Floating Islands",@""); |
|
249 |
} |
|
250 |
templateCommand = @"e$template_filter 4"; |
|
251 |
mazeCommand = @"e$maze_size 4"; |
|
252 |
break; |
|
253 |
case 2: |
|
254 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
255 |
labelText = NSLocalizedString(@"Small",@""); |
|
256 |
} else { |
|
257 |
labelText = NSLocalizedString(@"Small Floating Islands",@""); |
|
258 |
} |
|
259 |
templateCommand = @"e$template_filter 1"; |
|
260 |
mazeCommand = @"e$maze_size 3"; |
|
261 |
break; |
|
262 |
case 3: |
|
263 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
264 |
labelText = NSLocalizedString(@"Medium",@""); |
|
265 |
} else { |
|
266 |
labelText = NSLocalizedString(@"Large Tunnels",@""); |
|
267 |
} |
|
268 |
templateCommand = @"e$template_filter 2"; |
|
269 |
mazeCommand = @"e$maze_size 2"; |
|
270 |
break; |
|
271 |
case 4: |
|
272 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
273 |
labelText = NSLocalizedString(@"Large",@""); |
|
274 |
} else { |
|
275 |
labelText = NSLocalizedString(@"Medium Tunnels",@""); |
|
276 |
} |
|
277 |
templateCommand = @"e$template_filter 3"; |
|
278 |
mazeCommand = @"e$maze_size 1"; |
|
279 |
break; |
|
280 |
case 5: |
|
281 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
282 |
labelText = NSLocalizedString(@"All",@""); |
|
283 |
} else { |
|
284 |
labelText = NSLocalizedString(@"Small Tunnels",@""); |
|
285 |
} |
|
286 |
templateCommand = @"e$template_filter 0"; |
|
287 |
mazeCommand = @"e$maze_size 0"; |
|
288 |
break; |
|
289 |
default: |
|
290 |
labelText = nil; |
|
291 |
templateCommand = nil; |
|
292 |
mazeCommand = nil; |
|
293 |
break; |
|
294 |
} |
|
3697 | 295 |
|
3547 | 296 |
self.sizeLabel.text = labelText; |
297 |
self.templateFilterCommand = templateCommand; |
|
298 |
self.mazeSizeCommand = mazeCommand; |
|
299 |
} |
|
300 |
||
301 |
// update preview (if not busy and if its value really changed) as soon as the user lifts its finger up |
|
302 |
-(IBAction) sliderEndedChanging:(id) sender { |
|
303 |
int num = (int) (self.slider.value * 100); |
|
304 |
if (oldValue != num) { |
|
305 |
[self updatePreview]; |
|
306 |
oldValue = num; |
|
307 |
} |
|
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5483
diff
changeset
|
308 |
[AudioManagerController playClickSound]; |
3547 | 309 |
} |
310 |
||
3697 | 311 |
// perform actions based on the activated section, then call updatePreview to visually update the selection |
3547 | 312 |
// and if necessary update the table with a slide animation |
313 |
-(IBAction) segmentedControlChanged:(id) sender { |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
314 |
NSString *mapgen, *staticmap, *mission; |
3547 | 315 |
NSInteger newPage = self.segmentedControl.selectedSegmentIndex; |
3697 | 316 |
|
6000
dbcebcd3d79f
ios frontend: sounds and music have their own class now (with caching\!) instead of being spread here and there (exploiting class methods like a true oop pro)
koda
parents:
5483
diff
changeset
|
317 |
[AudioManagerController playSelectSound]; |
3547 | 318 |
switch (newPage) { |
319 |
case 0: // Random |
|
320 |
mapgen = @"e$mapgen 0"; |
|
3642 | 321 |
staticmap = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
322 |
mission = @""; |
3547 | 323 |
[self sliderChanged:nil]; |
324 |
self.slider.enabled = YES; |
|
4349 | 325 |
[externalController fillSections]; |
3547 | 326 |
break; |
3697 | 327 |
|
3547 | 328 |
case 1: // Map |
329 |
mapgen = @"e$mapgen 0"; |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
330 |
// dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap |
3642 | 331 |
staticmap = @"map Bamboo"; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
332 |
mission = @""; |
3547 | 333 |
self.slider.enabled = NO; |
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
334 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
4349 | 335 |
[externalController fillSections]; |
3547 | 336 |
break; |
3697 | 337 |
|
3547 | 338 |
case 2: // Maze |
339 |
mapgen = @"e$mapgen 1"; |
|
3642 | 340 |
staticmap = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
341 |
mission = @""; |
3547 | 342 |
[self sliderChanged:nil]; |
343 |
self.slider.enabled = YES; |
|
4349 | 344 |
[externalController fillSections]; |
345 |
break; |
|
346 |
||
347 |
case 3: // Mission |
|
348 |
mapgen = @"e$mapgen 0"; |
|
349 |
// dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap |
|
350 |
staticmap = @"map Bamboo"; |
|
351 |
mission = @""; |
|
352 |
self.slider.enabled = NO; |
|
353 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
|
354 |
[externalController emptySections]; |
|
3547 | 355 |
break; |
3697 | 356 |
|
3547 | 357 |
default: |
358 |
mapgen = nil; |
|
3642 | 359 |
staticmap = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
360 |
mission = nil; |
3547 | 361 |
break; |
362 |
} |
|
363 |
self.mapGenCommand = mapgen; |
|
3642 | 364 |
self.staticMapCommand = staticmap; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
365 |
self.missionCommand = mission; |
3697 | 366 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
367 |
[self.tableView reloadData]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
368 |
[self updatePreview]; |
3547 | 369 |
oldPage = newPage; |
370 |
} |
|
371 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
372 |
-(IBAction) buttonPressed:(id) sender { |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4356
diff
changeset
|
373 |
[self.parentController buttonPressed:sender]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
374 |
} |
3697 | 375 |
|
4082 | 376 |
#pragma mark - |
377 |
#pragma mark view management |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
378 |
-(void) loadDataSourceArray { |
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:
6000
diff
changeset
|
379 |
NSString *model = [HWUtils modelType]; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
4976
diff
changeset
|
380 |
|
5281 | 381 |
// only folders containing icon.png are a valid theme |
382 |
NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL]; |
|
383 |
NSMutableArray *themeArray = [[NSMutableArray alloc] init]; |
|
384 |
for (NSString *themeName in themeArrayFull) { |
|
385 |
NSString *checkPath = [[NSString alloc] initWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),themeName]; |
|
386 |
if ([[NSFileManager defaultManager] fileExistsAtPath:checkPath]) |
|
387 |
[themeArray addObject:themeName]; |
|
5483
fc755bb8096d
ios: caught some leaks, merged two methods inside a fuction, postponed the rating popup
koda
parents:
5281
diff
changeset
|
388 |
[checkPath release]; |
5281 | 389 |
} |
4505
4a8f87eb67cb
disable large maps also on iphone3gs and ipodtouch3g, they fail to load sometimes
koda
parents:
4476
diff
changeset
|
390 |
|
4a8f87eb67cb
disable large maps also on iphone3gs and ipodtouch3g, they fail to load sometimes
koda
parents:
4476
diff
changeset
|
391 |
// remove images that are too big for certain devices without loading the whole image |
4290 | 392 |
NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL]; |
393 |
NSMutableArray *mapArray = [[NSMutableArray alloc] init]; |
|
394 |
for (NSString *str in mapArrayFull) { |
|
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:
6000
diff
changeset
|
395 |
CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
4976
diff
changeset
|
396 |
if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
4290 | 397 |
continue; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
4976
diff
changeset
|
398 |
if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
4290 | 399 |
continue; |
400 |
[mapArray addObject:str]; |
|
401 |
} |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
402 |
|
4290 | 403 |
NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
404 |
NSMutableArray *missionArray = [[NSMutableArray alloc] init]; |
|
405 |
for (NSString *str in missionArrayFull) { |
|
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:
6000
diff
changeset
|
406 |
CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
4976
diff
changeset
|
407 |
if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
4290 | 408 |
continue; |
5207
4c9ae0f484da
some general tweaks (more intelligent use of macros and more caching)
koda
parents:
4976
diff
changeset
|
409 |
if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
4290 | 410 |
continue; |
411 |
[missionArray addObject:str]; |
|
412 |
} |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
413 |
NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil]; |
4290 | 414 |
[missionArray release]; |
415 |
[themeArray release]; |
|
416 |
[mapArray release]; |
|
417 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
418 |
self.dataSourceArray = array; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
419 |
[array release]; |
3547 | 420 |
} |
421 |
||
422 |
-(void) viewDidLoad { |
|
423 |
[super viewDidLoad]; |
|
3697 | 424 |
|
3547 | 425 |
srandom(time(NULL)); |
3697 | 426 |
|
3547 | 427 |
CGSize screenSize = [[UIScreen mainScreen] bounds].size; |
428 |
self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
429 |
|
3547 | 430 |
// initialize some "default" values |
431 |
self.sizeLabel.text = NSLocalizedString(@"All",@""); |
|
432 |
self.slider.value = 0.05f; |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
433 |
oldValue = 5; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
434 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
435 |
busy = NO; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
436 |
[self loadDataSourceArray]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
437 |
self.lastIndexPath = [NSIndexPath indexPathForRow:-1 inSection:0]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
438 |
|
3789
c3eb56754e92
added a smaller version of forts, fixed a couple of regressions
koda
parents:
3783
diff
changeset
|
439 |
// select a map at first because it's faster - done in IB |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
440 |
oldPage = 1; |
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
441 |
if (self.segmentedControl.selectedSegmentIndex == 1) { |
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
442 |
self.slider.enabled = NO; |
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
443 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
6079 | 444 |
self.sizeLabel.textColor = [UIColor lightYellowColor]; |
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
445 |
} |
3547 | 446 |
|
447 |
self.templateFilterCommand = @"e$template_filter 0"; |
|
448 |
self.mazeSizeCommand = @"e$maze_size 0"; |
|
449 |
self.mapGenCommand = @"e$mapgen 0"; |
|
3642 | 450 |
self.staticMapCommand = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
451 |
self.missionCommand = @""; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
452 |
|
4244 | 453 |
if ([self.tableView respondsToSelector:@selector(setBackgroundView:)]) |
454 |
[self.tableView setBackgroundView:nil]; |
|
4356 | 455 |
self.tableView.backgroundColor = [UIColor clearColor]; |
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:
6000
diff
changeset
|
456 |
self.tableView.separatorColor = [UIColor darkYellowColor]; |
4244 | 457 |
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
3547 | 458 |
} |
459 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
460 |
-(void) viewWillAppear:(BOOL)animated { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
461 |
if (self.dataSourceArray == nil) |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
462 |
[self loadDataSourceArray]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
463 |
[super viewWillAppear:animated]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
464 |
} |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
465 |
|
3547 | 466 |
-(void) viewDidAppear:(BOOL) animated { |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
467 |
[self updatePreview]; |
3547 | 468 |
[super viewDidAppear:animated]; |
469 |
} |
|
470 |
||
471 |
-(void) viewDidUnload { |
|
472 |
self.previewButton = nil; |
|
473 |
self.seedCommand = nil; |
|
474 |
self.templateFilterCommand = nil; |
|
475 |
self.mapGenCommand = nil; |
|
476 |
self.mazeSizeCommand = nil; |
|
477 |
self.themeCommand = nil; |
|
3642 | 478 |
self.staticMapCommand = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
479 |
self.missionCommand = nil; |
3697 | 480 |
|
3547 | 481 |
self.previewButton = nil; |
482 |
self.tableView = nil; |
|
483 |
self.maxLabel = nil; |
|
484 |
self.sizeLabel = nil; |
|
485 |
self.segmentedControl = nil; |
|
486 |
self.slider = nil; |
|
3697 | 487 |
|
3547 | 488 |
self.lastIndexPath = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
489 |
self.dataSourceArray = nil; |
3697 | 490 |
|
3662
a44406f4369b
polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents:
3660
diff
changeset
|
491 |
MSG_DIDUNLOAD(); |
3547 | 492 |
[super viewDidUnload]; |
493 |
} |
|
494 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
495 |
-(void) didReceiveMemoryWarning { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
496 |
self.dataSourceArray = nil; |
4356 | 497 |
[super didReceiveMemoryWarning]; |
3984 | 498 |
|
4356 | 499 |
if (self.view.superview == nil) { |
500 |
self.tableView = nil; |
|
501 |
self.maxLabel = nil; |
|
502 |
self.sizeLabel = nil; |
|
503 |
self.slider = nil; |
|
504 |
} |
|
3971 | 505 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
506 |
MSG_MEMCLEAN(); |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
507 |
} |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
508 |
|
3547 | 509 |
-(void) dealloc { |
5208 | 510 |
releaseAndNil(seedCommand); |
511 |
releaseAndNil(templateFilterCommand); |
|
512 |
releaseAndNil(mapGenCommand); |
|
513 |
releaseAndNil(mazeSizeCommand); |
|
514 |
releaseAndNil(themeCommand); |
|
515 |
releaseAndNil(staticMapCommand); |
|
516 |
releaseAndNil(missionCommand); |
|
3697 | 517 |
|
5208 | 518 |
releaseAndNil(previewButton); |
519 |
releaseAndNil(tableView); |
|
520 |
releaseAndNil(maxLabel); |
|
521 |
releaseAndNil(sizeLabel); |
|
522 |
releaseAndNil(segmentedControl); |
|
523 |
releaseAndNil(slider); |
|
3697 | 524 |
|
5208 | 525 |
releaseAndNil(lastIndexPath); |
526 |
releaseAndNil(dataSourceArray); |
|
3697 | 527 |
|
3547 | 528 |
[super dealloc]; |
529 |
} |
|
530 |
||
531 |
@end |