author | koda |
Fri, 04 Nov 2011 00:38:37 +0100 | |
changeset 6276 | 1e2f8da1860a |
parent 6115 | 485cfecadc9a |
child 6634 | e00762923086 |
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" |
|
6108 | 23 |
#import <QuartzCore/QuartzCore.h> |
4349 | 24 |
#import "SchemeWeaponConfigViewController.h" |
4362
8dae325dc625
added missing graphics and fixed some glitches/crashes/bugs
koda
parents:
4356
diff
changeset
|
25 |
#import "GameConfigViewController.h" |
3547 | 26 |
|
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
|
27 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
28 |
#define scIndex self.segmentedControl.selectedSegmentIndex |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
29 |
#define isRandomness() (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2) |
3547 | 30 |
|
31 |
@implementation MapConfigViewController |
|
3642 | 32 |
@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
|
33 |
missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
34 |
oldPage, oldValue; |
3547 | 35 |
|
36 |
||
37 |
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { |
|
38 |
return rotationManager(interfaceOrientation); |
|
39 |
} |
|
40 |
||
6109
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
41 |
-(IBAction) mapButtonPressed:(id) sender { |
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
|
42 |
[AudioManagerController playClickSound]; |
3783 | 43 |
[self updatePreview]; |
44 |
} |
|
45 |
||
46 |
-(void) updatePreview { |
|
3547 | 47 |
// don't generate a new preview while it's already generating one |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
48 |
if (self.busy) |
3547 | 49 |
return; |
3697 | 50 |
|
3547 | 51 |
// generate a seed |
52 |
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); |
|
53 |
NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid); |
|
54 |
CFRelease(uuid); |
|
55 |
NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed]; |
|
56 |
self.seedCommand = seedCmd; |
|
57 |
[seedCmd release]; |
|
3697 | 58 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
// 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
|
62 |
[self turnOffWidgets]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
63 |
[self.previewButton updatePreviewWithSeed:seed]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
64 |
// the preview for static maps is loaded in didSelectRowAtIndexPath |
3547 | 65 |
} |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
66 |
[seed release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
67 |
|
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
68 |
// perform as if user clicked on an entry |
6109
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
69 |
NSIndexPath *theIndex = [NSIndexPath indexPathForRow:(random()%[source count]) inSection:0]; |
3547 | 70 |
[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
|
71 |
if (IS_NOT_POWERFUL([HWUtils modelType]) == NO) |
4287 | 72 |
[self.tableView scrollToRowAtIndexPath:theIndex atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; |
3547 | 73 |
} |
74 |
||
75 |
-(void) turnOffWidgets { |
|
76 |
busy = YES; |
|
77 |
self.previewButton.alpha = 0.5f; |
|
78 |
self.previewButton.enabled = NO; |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
79 |
self.maxLabel.text = NSLocalizedString(@"Loading...",@"");; |
3547 | 80 |
self.segmentedControl.enabled = NO; |
81 |
self.slider.enabled = NO; |
|
82 |
} |
|
83 |
||
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
84 |
#pragma mark - |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
85 |
#pragma mark MapPreviewButtonView delegate methods |
3547 | 86 |
-(void) turnOnWidgets { |
87 |
self.previewButton.alpha = 1.0f; |
|
88 |
self.previewButton.enabled = YES; |
|
89 |
self.segmentedControl.enabled = YES; |
|
90 |
self.slider.enabled = YES; |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
91 |
self.busy = NO; |
3547 | 92 |
} |
3697 | 93 |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
94 |
-(void) setMaxLabelText:(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
|
95 |
self.maxHogs = [str intValue]; |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
96 |
self.maxLabel.text = [NSString stringWithFormat:@"%@ %@",NSLocalizedString(@"Max Hogs:",@""),str]; |
3547 | 97 |
} |
98 |
||
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
99 |
-(NSDictionary *)getDataForEngine { |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
nil]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
106 |
return dictForEngine; |
3547 | 107 |
} |
108 |
||
109 |
#pragma mark - |
|
110 |
#pragma mark Table view data source |
|
111 |
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
|
112 |
return 1; |
|
113 |
} |
|
114 |
||
115 |
-(NSInteger) tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger) section { |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
116 |
return [[self.dataSourceArray objectAtIndex:scIndex] count]; |
3547 | 117 |
} |
118 |
||
119 |
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
|
120 |
static NSString *CellIdentifier = @"Cell"; |
|
121 |
NSInteger row = [indexPath row]; |
|
3697 | 122 |
|
3547 | 123 |
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; |
3697 | 124 |
if (cell == nil) |
3547 | 125 |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
3697 | 126 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
127 |
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
|
128 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
129 |
NSString *labelString = [source objectAtIndex:row]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
130 |
cell.textLabel.text = labelString; |
3996 | 131 |
cell.textLabel.adjustsFontSizeToFitWidth = YES; |
132 |
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
|
133 |
cell.textLabel.textColor = [UIColor lightYellowColor]; |
4476
4bf74e158f44
team selection completely refactored, now has animation and more performance
koda
parents:
4362
diff
changeset
|
134 |
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
|
135 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
136 |
if (isRandomness()) { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
137 |
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),labelString]]; |
3547 | 138 |
cell.imageView.image = image; |
139 |
[image release]; |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
140 |
} else |
3547 | 141 |
cell.imageView.image = nil; |
3697 | 142 |
|
3703
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
cell.accessoryView = checkbox; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
146 |
[checkbox release]; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
147 |
} else |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
148 |
cell.accessoryView = nil; |
3547 | 149 |
|
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
|
150 |
cell.backgroundColor = [UIColor blackColorTransparent]; |
3547 | 151 |
return cell; |
152 |
} |
|
153 |
||
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
154 |
// 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
|
155 |
-(void) setDetailsForStaticMap:(NSInteger) index { |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
156 |
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
|
157 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
158 |
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
|
159 |
(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
|
160 |
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
|
161 |
[fileCfg release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
162 |
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
|
163 |
[contents release]; |
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
164 |
|
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
165 |
// 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
|
166 |
// sometimes it's not set but there are trailing characters, we get around them with the second equation |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
167 |
NSString *max; |
3910
dd47efbdec46
move all preview drawing code into its own class (for a simplified and more readable MapConfigViewController)
koda
parents:
3829
diff
changeset
|
168 |
if ([split count] > 1 && [[split objectAtIndex:1] intValue] > 0) |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
169 |
max = [split objectAtIndex:1]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
170 |
else |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
171 |
max = @"18"; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
172 |
[self setMaxLabelText:max]; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
173 |
|
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
174 |
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
|
175 |
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
|
176 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
177 |
if (scIndex != 3) |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
178 |
self.missionCommand = @""; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
179 |
else |
3920
a54ca6185307
updated lua loading in the ifrontend and also fixed masked maps
koda
parents:
3912
diff
changeset
|
180 |
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
|
181 |
} |
3547 | 182 |
|
183 |
#pragma mark - |
|
184 |
#pragma mark Table view delegate |
|
185 |
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
|
186 |
int newRow = [indexPath row]; |
|
187 |
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
|
3697 | 188 |
|
3547 | 189 |
if (newRow != oldRow) { |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
190 |
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
|
191 |
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
|
192 |
// 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
|
193 |
self.themeCommand = [NSString stringWithFormat:@"etheme %@", [source objectAtIndex:newRow]]; |
3642 | 194 |
} else { |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
195 |
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
|
196 |
(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
|
197 |
[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
|
198 |
[self setDetailsForStaticMap:newRow]; |
3642 | 199 |
} |
3697 | 200 |
|
201 |
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
|
202 |
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
|
203 |
newCell.accessoryView = checkbox; |
12d17c6e8855
halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
3697
diff
changeset
|
204 |
[checkbox release]; |
3547 | 205 |
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
|
206 |
oldCell.accessoryView = nil; |
3547 | 207 |
|
208 |
self.lastIndexPath = indexPath; |
|
209 |
[aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; |
|
210 |
} |
|
211 |
[aTableView deselectRowAtIndexPath:indexPath animated:YES]; |
|
212 |
} |
|
213 |
||
214 |
#pragma mark - |
|
4082 | 215 |
#pragma mark slider & segmentedControl & button |
3547 | 216 |
// this updates the label and the command keys when the slider is moved, depending of the selection in segmentedControl |
217 |
// no methods are called by this routine and you can pass nil to it |
|
218 |
-(IBAction) sliderChanged:(id) sender { |
|
219 |
NSString *labelText; |
|
220 |
NSString *templateCommand; |
|
221 |
NSString *mazeCommand; |
|
3697 | 222 |
|
3547 | 223 |
switch ((int)(self.slider.value*100)) { |
224 |
case 0: |
|
225 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
226 |
labelText = NSLocalizedString(@"Wacky",@""); |
|
227 |
} else { |
|
228 |
labelText = NSLocalizedString(@"Large Floating Islands",@""); |
|
229 |
} |
|
230 |
templateCommand = @"e$template_filter 5"; |
|
231 |
mazeCommand = @"e$maze_size 5"; |
|
232 |
break; |
|
233 |
case 1: |
|
234 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
235 |
labelText = NSLocalizedString(@"Cavern",@""); |
|
236 |
} else { |
|
237 |
labelText = NSLocalizedString(@"Medium Floating Islands",@""); |
|
238 |
} |
|
239 |
templateCommand = @"e$template_filter 4"; |
|
240 |
mazeCommand = @"e$maze_size 4"; |
|
241 |
break; |
|
242 |
case 2: |
|
243 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
244 |
labelText = NSLocalizedString(@"Small",@""); |
|
245 |
} else { |
|
246 |
labelText = NSLocalizedString(@"Small Floating Islands",@""); |
|
247 |
} |
|
248 |
templateCommand = @"e$template_filter 1"; |
|
249 |
mazeCommand = @"e$maze_size 3"; |
|
250 |
break; |
|
251 |
case 3: |
|
252 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
253 |
labelText = NSLocalizedString(@"Medium",@""); |
|
254 |
} else { |
|
255 |
labelText = NSLocalizedString(@"Large Tunnels",@""); |
|
256 |
} |
|
257 |
templateCommand = @"e$template_filter 2"; |
|
258 |
mazeCommand = @"e$maze_size 2"; |
|
259 |
break; |
|
260 |
case 4: |
|
261 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
262 |
labelText = NSLocalizedString(@"Large",@""); |
|
263 |
} else { |
|
264 |
labelText = NSLocalizedString(@"Medium Tunnels",@""); |
|
265 |
} |
|
266 |
templateCommand = @"e$template_filter 3"; |
|
267 |
mazeCommand = @"e$maze_size 1"; |
|
268 |
break; |
|
269 |
case 5: |
|
270 |
if (self.segmentedControl.selectedSegmentIndex == 0) { |
|
271 |
labelText = NSLocalizedString(@"All",@""); |
|
272 |
} else { |
|
273 |
labelText = NSLocalizedString(@"Small Tunnels",@""); |
|
274 |
} |
|
275 |
templateCommand = @"e$template_filter 0"; |
|
276 |
mazeCommand = @"e$maze_size 0"; |
|
277 |
break; |
|
278 |
default: |
|
279 |
labelText = nil; |
|
280 |
templateCommand = nil; |
|
281 |
mazeCommand = nil; |
|
282 |
break; |
|
283 |
} |
|
3697 | 284 |
|
3547 | 285 |
self.sizeLabel.text = labelText; |
286 |
self.templateFilterCommand = templateCommand; |
|
287 |
self.mazeSizeCommand = mazeCommand; |
|
288 |
} |
|
289 |
||
290 |
// update preview (if not busy and if its value really changed) as soon as the user lifts its finger up |
|
291 |
-(IBAction) sliderEndedChanging:(id) sender { |
|
292 |
int num = (int) (self.slider.value * 100); |
|
293 |
if (oldValue != num) { |
|
294 |
[self updatePreview]; |
|
295 |
oldValue = num; |
|
296 |
} |
|
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
|
297 |
[AudioManagerController playClickSound]; |
3547 | 298 |
} |
299 |
||
3697 | 300 |
// perform actions based on the activated section, then call updatePreview to visually update the selection |
3547 | 301 |
// and if necessary update the table with a slide animation |
302 |
-(IBAction) segmentedControlChanged:(id) sender { |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
303 |
NSString *mapgen, *staticmap, *mission; |
3547 | 304 |
NSInteger newPage = self.segmentedControl.selectedSegmentIndex; |
3697 | 305 |
|
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
|
306 |
[AudioManagerController playSelectSound]; |
3547 | 307 |
switch (newPage) { |
308 |
case 0: // Random |
|
309 |
mapgen = @"e$mapgen 0"; |
|
3642 | 310 |
staticmap = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
311 |
mission = @""; |
3547 | 312 |
[self sliderChanged:nil]; |
313 |
self.slider.enabled = YES; |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
314 |
[SchemeWeaponConfigViewController fillInstanceSections]; |
3547 | 315 |
break; |
3697 | 316 |
|
3547 | 317 |
case 1: // Map |
318 |
mapgen = @"e$mapgen 0"; |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
319 |
// dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap |
3642 | 320 |
staticmap = @"map Bamboo"; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
321 |
mission = @""; |
3547 | 322 |
self.slider.enabled = NO; |
3791
98072b3871c1
help page for ingame, some other fixes here and there
koda
parents:
3789
diff
changeset
|
323 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
324 |
[SchemeWeaponConfigViewController fillInstanceSections]; |
3547 | 325 |
break; |
3697 | 326 |
|
3547 | 327 |
case 2: // Maze |
328 |
mapgen = @"e$mapgen 1"; |
|
3642 | 329 |
staticmap = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
330 |
mission = @""; |
3547 | 331 |
[self sliderChanged:nil]; |
332 |
self.slider.enabled = YES; |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
333 |
[SchemeWeaponConfigViewController fillInstanceSections]; |
4349 | 334 |
break; |
335 |
||
336 |
case 3: // Mission |
|
337 |
mapgen = @"e$mapgen 0"; |
|
338 |
// dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap |
|
339 |
staticmap = @"map Bamboo"; |
|
340 |
mission = @""; |
|
341 |
self.slider.enabled = NO; |
|
342 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
343 |
[SchemeWeaponConfigViewController emptyInstanceSections]; |
3547 | 344 |
break; |
3697 | 345 |
|
3547 | 346 |
default: |
347 |
mapgen = nil; |
|
3642 | 348 |
staticmap = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
349 |
mission = nil; |
3547 | 350 |
break; |
351 |
} |
|
352 |
self.mapGenCommand = mapgen; |
|
3642 | 353 |
self.staticMapCommand = staticmap; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
354 |
self.missionCommand = mission; |
3697 | 355 |
|
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
356 |
[self.tableView reloadData]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
357 |
[self updatePreview]; |
3547 | 358 |
oldPage = newPage; |
359 |
} |
|
360 |
||
4082 | 361 |
#pragma mark - |
362 |
#pragma mark view management |
|
6107 | 363 |
-(NSArray *) dataSourceArray { |
364 |
if (dataSourceArray == nil) { |
|
365 |
NSString *model = [HWUtils modelType]; |
|
366 |
||
367 |
// only folders containing icon.png are a valid theme |
|
368 |
NSArray *themeArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:THEMES_DIRECTORY() error:NULL]; |
|
369 |
NSMutableArray *themeArray = [[NSMutableArray alloc] init]; |
|
370 |
for (NSString *themeName in themeArrayFull) { |
|
371 |
NSString *checkPath = [[NSString alloc] initWithFormat:@"%@/%@/icon.png",THEMES_DIRECTORY(),themeName]; |
|
372 |
if ([[NSFileManager defaultManager] fileExistsAtPath:checkPath]) |
|
373 |
[themeArray addObject:themeName]; |
|
374 |
[checkPath release]; |
|
375 |
} |
|
376 |
||
377 |
// remove images that are too big for certain devices without loading the whole image |
|
378 |
NSArray *mapArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL]; |
|
379 |
NSMutableArray *mapArray = [[NSMutableArray alloc] init]; |
|
380 |
for (NSString *str in mapArrayFull) { |
|
381 |
CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MAPS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
|
382 |
if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
|
383 |
continue; |
|
384 |
if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
|
385 |
continue; |
|
386 |
[mapArray addObject:str]; |
|
387 |
} |
|
388 |
||
389 |
NSArray *missionArrayFull = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MISSIONS_DIRECTORY() error:NULL]; |
|
390 |
NSMutableArray *missionArray = [[NSMutableArray alloc] init]; |
|
391 |
for (NSString *str in missionArrayFull) { |
|
392 |
CGSize imgSize = [UIImage imageSizeFromMetadataOf:[MISSIONS_DIRECTORY() stringByAppendingFormat:@"%@/map.png",str]]; |
|
393 |
if (IS_NOT_POWERFUL(model) && imgSize.height > 1024.0f) |
|
394 |
continue; |
|
395 |
if (IS_NOT_VERY_POWERFUL(model) && imgSize.height > 1280.0f) |
|
396 |
continue; |
|
397 |
[missionArray addObject:str]; |
|
398 |
} |
|
399 |
NSArray *array = [[NSArray alloc] initWithObjects:themeArray,mapArray,themeArray,missionArray,nil]; |
|
400 |
[missionArray release]; |
|
401 |
[themeArray release]; |
|
402 |
[mapArray release]; |
|
403 |
||
404 |
self.dataSourceArray = array; |
|
405 |
[array release]; |
|
5281 | 406 |
} |
6107 | 407 |
return dataSourceArray; |
3547 | 408 |
} |
409 |
||
6109
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
410 |
-(MapPreviewButtonView *)previewButton { |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
411 |
if (previewButton == nil) { |
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
412 |
MapPreviewButtonView *preview = [[MapPreviewButtonView alloc] initWithFrame:CGRectMake(32, 26, 256, 128)]; |
6109
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
413 |
preview.delegate = self; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
414 |
[preview addTarget:self action:@selector(mapButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
415 |
[self.view addSubview:preview]; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
416 |
self.previewButton = preview; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
417 |
[preview release]; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
418 |
} |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
419 |
return previewButton; |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
420 |
} |
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
421 |
|
3547 | 422 |
-(void) viewDidLoad { |
423 |
[super viewDidLoad]; |
|
3697 | 424 |
|
3547 | 425 |
srandom(time(NULL)); |
3697 | 426 |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
427 |
/* |
3547 | 428 |
CGSize screenSize = [[UIScreen mainScreen] bounds].size; |
429 |
self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44); |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
430 |
*/ |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
431 |
|
3547 | 432 |
// initialize some "default" values |
433 |
self.slider.value = 0.05f; |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
434 |
self.slider.enabled = NO; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
435 |
self.sizeLabel.text = NSLocalizedString(@"No filter",@""); |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
436 |
self.oldValue = 5; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
437 |
self.busy = NO; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
438 |
self.oldPage = self.segmentedControl.selectedSegmentIndex; |
3547 | 439 |
|
440 |
self.templateFilterCommand = @"e$template_filter 0"; |
|
441 |
self.mazeSizeCommand = @"e$maze_size 0"; |
|
442 |
self.mapGenCommand = @"e$mapgen 0"; |
|
3642 | 443 |
self.staticMapCommand = @""; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
444 |
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
|
445 |
|
6108 | 446 |
if (IS_IPAD()) { |
447 |
[self.tableView setBackgroundColorForAnyTable:[UIColor darkBlueColorTransparent]]; |
|
448 |
self.tableView.layer.borderColor = [[UIColor darkYellowColor] CGColor]; |
|
449 |
self.tableView.layer.borderWidth = 2.7f; |
|
450 |
self.tableView.layer.cornerRadius = 8; |
|
451 |
self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0); |
|
6115
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
452 |
|
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
453 |
UILabel *backLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 14, 300, 190) andTitle:nil withBorderWidth:2.3f]; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
454 |
[self.view insertSubview:backLabel belowSubview:self.segmentedControl]; |
485cfecadc9a
HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents:
6109
diff
changeset
|
455 |
[backLabel release]; |
6108 | 456 |
} |
457 |
self.tableView.separatorColor = [UIColor whiteColor]; |
|
4244 | 458 |
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; |
3547 | 459 |
} |
460 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
461 |
-(void) viewWillAppear:(BOOL)animated { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
462 |
[super viewWillAppear:animated]; |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
463 |
} |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
464 |
|
3547 | 465 |
-(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
|
466 |
[self updatePreview]; |
3547 | 467 |
[super viewDidAppear:animated]; |
468 |
} |
|
469 |
||
470 |
-(void) viewDidUnload { |
|
471 |
self.previewButton = nil; |
|
472 |
self.seedCommand = nil; |
|
473 |
self.templateFilterCommand = nil; |
|
474 |
self.mapGenCommand = nil; |
|
475 |
self.mazeSizeCommand = nil; |
|
476 |
self.themeCommand = nil; |
|
3642 | 477 |
self.staticMapCommand = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
478 |
self.missionCommand = nil; |
3697 | 479 |
|
3547 | 480 |
self.previewButton = nil; |
481 |
self.tableView = nil; |
|
482 |
self.maxLabel = nil; |
|
483 |
self.sizeLabel = nil; |
|
484 |
self.segmentedControl = nil; |
|
485 |
self.slider = nil; |
|
3697 | 486 |
|
3547 | 487 |
self.lastIndexPath = nil; |
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
488 |
self.dataSourceArray = nil; |
3697 | 489 |
|
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
|
490 |
MSG_DIDUNLOAD(); |
3547 | 491 |
[super viewDidUnload]; |
492 |
} |
|
493 |
||
3911
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
494 |
-(void) didReceiveMemoryWarning { |
46d7a5cf8ac6
further rework of MapConfigViewController, lists missions correctly (they don't load fine yet)
koda
parents:
3910
diff
changeset
|
495 |
self.dataSourceArray = nil; |
6109
f6726ec81e64
finally removed the white border glitch of the ipad preview map, moved initialization from IB to code
koda
parents:
6108
diff
changeset
|
496 |
self.previewButton = 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 |