add other controls for map preview, also fix a bug in digest
authorkoda
Mon, 26 Apr 2010 01:55:26 +0000
changeset 3369 c7289e42f0ee
parent 3368 791fa4664209
child 3370 37f4f83fedb1
add other controls for map preview, also fix a bug in digest
cocoaTouch/GameConfigViewController.m
cocoaTouch/GameSetup.m
cocoaTouch/MapConfigViewController.h
cocoaTouch/MapConfigViewController.m
cocoaTouch/xib/MapConfigViewController-iPhone.xib
hedgewars/hwengine.pas
hedgewars/uLand.pas
hedgewars/uRandom.pas
hedgewars/uSHA.pas
--- a/cocoaTouch/GameConfigViewController.m	Sun Apr 25 18:38:08 2010 +0000
+++ b/cocoaTouch/GameConfigViewController.m	Mon Apr 26 01:55:26 2010 +0000
@@ -38,7 +38,7 @@
 
 -(IBAction) segmentPressed:(id) sender {
     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
-    NSLog(@"%d", theSegment.selectedSegmentIndex);
+
     switch (theSegment.selectedSegmentIndex) {
         case 0:
             // this init here is just aestetic as this controller was already set up in viewDidLoad
@@ -91,8 +91,11 @@
         [alert show];
         [alert release];
         return;
-    } 
+    }
     NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
+                                                                      mapConfigViewController.templateFilterCommand,@"templatefilter_command",
+                                                                      mapConfigViewController.mapGenCommand,@"mapgen_command",
+                                                                      mapConfigViewController.mazeSizeCommand,@"mazesize_command",
                                                                       teamConfigViewController.listOfSelectedTeams,@"teams_list",nil];
     [dict writeToFile:GAMECONFIG_FILE() atomically:YES];
     [dict release];
@@ -104,7 +107,7 @@
     mapConfigViewController = [[MapConfigViewController alloc] initWithNibName:@"MapConfigViewController-iPhone" bundle:nil];
     activeController = mapConfigViewController;
     
-    [self.view insertSubview:mapConfigViewController.view atIndex:0];
+    [self.view addSubview:mapConfigViewController.view];
     
     [super viewDidLoad];
 }
--- a/cocoaTouch/GameSetup.m	Sun Apr 25 18:38:08 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Mon Apr 26 01:55:26 2010 +0000
@@ -198,7 +198,9 @@
 				[self sendToEngine:@"e$casefreq 5"];
 
 				// dimension of the map
-				[self sendToEngine:@"e$template_filter 1"];
+				[self sendToEngine:[self.gameConfig objectForKey:@"templatefilter_command"]];
+				[self sendToEngine:[self.gameConfig objectForKey:@"mapgen_command"]];
+				[self sendToEngine:[self.gameConfig objectForKey:@"mazesize_command"]];
 								
 				// theme info
 				[self sendToEngine:@"etheme Compost"];
@@ -290,6 +292,8 @@
 	SDLNet_TCP_Close(sd);
 	SDLNet_Quit();
 
+    [[NSFileManager defaultManager] removeItemAtPath:GAMECONFIG_FILE() error:NULL];
+    
 	[pool release];
 	[NSThread exit];
 }
@@ -302,7 +306,7 @@
     CGRect screenBounds = [[UIScreen mainScreen] bounds];
     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
-	const char **gameArgs = (const char**) malloc(sizeof(char*) * 8);
+	const char **gameArgs = (const char**) malloc(sizeof(char *) * 8);
 
     /*
     size_t size;
@@ -333,14 +337,14 @@
         username = [[NSString alloc] initWithString:originalUsername];
     }
     
-	gameArgs[0] = [username UTF8String];                                                    //UserNick
-	gameArgs[1] = [ipcString UTF8String];                                                   //ipcPort
-	gameArgs[2] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String];        //isSoundEnabled
-	gameArgs[3] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String];        //isMusicEnabled
-	gameArgs[4] = [localeString UTF8String];                                                //cLocaleFName
+	gameArgs[0] = [username UTF8String];                                                        //UserNick
+	gameArgs[1] = [ipcString UTF8String];                                                       //ipcPort
+	gameArgs[2] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String];       //isSoundEnabled
+	gameArgs[3] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String];       //isMusicEnabled
+	gameArgs[4] = [localeString UTF8String];                                                    //cLocaleFName
 	gameArgs[5] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String];	//cAltDamage
-	gameArgs[6] = [wSize UTF8String];                                                       //cScreenHeight
-    gameArgs[7] = [hSize UTF8String];                                                       //cScreenWidth
+	gameArgs[6] = [wSize UTF8String];                                                           //cScreenHeight
+    gameArgs[7] = [hSize UTF8String];                                                           //cScreenWidth
     
     [wSize release];
     [hSize release];
--- a/cocoaTouch/MapConfigViewController.h	Sun Apr 25 18:38:08 2010 +0000
+++ b/cocoaTouch/MapConfigViewController.h	Mon Apr 26 01:55:26 2010 +0000
@@ -9,20 +9,43 @@
 #import <UIKit/UIKit.h>
 #import "SDL_net.h"
 
-@interface MapConfigViewController : UIViewController {
+@interface MapConfigViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
     TCPsocket sd, csd;
-    NSInteger maxHogs;
     unsigned char map[128*32];
 
+    // objects read (mostly) by parent view
+    NSInteger maxHogs;
+    NSString *seedCommand;
+    NSString *templateFilterCommand;
+    NSString *mapGenCommand;
+    NSString *mazeSizeCommand;
+   
+    // various widgets in the view
     UIButton *previewButton;
-    NSString *seedCommand;
+    UITableView *tableView;
+    UILabel *maxLabel;
+    UILabel *sizeLabel;
+    UISegmentedControl *segmentedControl;
+    UISlider *slider;
 }
 
 @property (nonatomic) NSInteger maxHogs;
-@property (nonatomic,retain) UIButton *previewButton;
 @property (nonatomic,retain) NSString *seedCommand;
+@property (nonatomic,retain) NSString *templateFilterCommand;
+@property (nonatomic,retain) NSString *mapGenCommand;
+@property (nonatomic,retain) NSString *mazeSizeCommand;
+@property (nonatomic,retain) IBOutlet UIButton *previewButton;
+@property (nonatomic,retain) IBOutlet UITableView *tableView;
+@property (nonatomic,retain) IBOutlet UILabel *maxLabel;
+@property (nonatomic,retain) IBOutlet UILabel *sizeLabel;
+@property (nonatomic,retain) IBOutlet UISegmentedControl *segmentedControl;
+@property (nonatomic,retain) IBOutlet UISlider *slider;
 
 -(IBAction) updatePreview;
+-(IBAction) sliderChanged:(id) sender;
+-(IBAction) sliderEndedChanging:(id) sender;
+-(IBAction) segmentedControlChanged:(id) sender;
+
 -(void) engineProtocol:(NSInteger) port;
 
 @end
--- a/cocoaTouch/MapConfigViewController.m	Sun Apr 25 18:38:08 2010 +0000
+++ b/cocoaTouch/MapConfigViewController.m	Mon Apr 26 01:55:26 2010 +0000
@@ -13,8 +13,11 @@
 #import "SDL_net.h"
 #import <pthread.h>
 
+#define INDICATOR_TAG 7654
+#define RANDOMSTR_LEN 36
 @implementation MapConfigViewController
-@synthesize previewButton, maxHogs, seedCommand;
+@synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand,
+            tableView, maxLabel, sizeLabel, segmentedControl, slider;
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -62,9 +65,9 @@
 			NSLog(@"engineProtocol - Client found");
             
             [self sendToEngine:self.seedCommand];
-            [self sendToEngine:@"e$template_filter 1"];
-            [self sendToEngine:@"e$mapgen 0"];
-            [self sendToEngine:@"e$maze_size 1"];
+            [self sendToEngine:self.templateFilterCommand];
+            [self sendToEngine:self.mapGenCommand];
+            [self sendToEngine:self.mazeSizeCommand];
             [self sendToEngine:@"!"];
                 
             memset(map, 0, 128*32);
@@ -80,21 +83,12 @@
 	SDLNet_Quit();
 }
 
-
--(void) updatePreview {
-    pthread_t thread_id;
+-(void) drawingThread {
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     
-    // generate a seed
-    char randomStr[36];
-    for (int i = 0; i<36; i++) {
-         randomStr[i] = random()%255;
-    }
-    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%s}", randomStr];
-    self.seedCommand = seedCmd;
-    [seedCmd release];
-    
-    // select the port for IPC
+    // select the port for IPC and launch the preview generation
     int port = randomPort();
+    pthread_t thread_id;
     pthread_create(&thread_id, NULL, (void *)GenLandPreview, (void *)port);
     [self engineProtocol:port];
 
@@ -104,9 +98,9 @@
     UIGraphicsBeginImageContext(CGSizeMake(256,128));      
     CGContextRef context = UIGraphicsGetCurrentContext();       
     UIGraphicsPushContext(context);  
-    for (int x = 0; x < 32*128; x++) {
-        unsigned char byte = map[x];
-        for (int z = 0; z < 8; z++) {
+    for (int i = 0; i < 32*128; i++) {
+        unsigned char byte = map[i];
+        for (int j = 0; j < 8; j++) {
             // select the color based on the rightmost bit
             if ((byte & 0x00000001) != 0)
                 CGContextSetRGBFillColor(context, 0.5, 0.5, 0.7, 1.0);
@@ -116,7 +110,7 @@
             // draw pixel
             CGContextFillRect(context,CGRectMake(xc,yc,1,1));
             // move coordinates
-            xc = (xc+1)%256;
+            xc = (xc + 1) % 256;
             if (xc == 0) yc++;
             
             // shift to next bit
@@ -124,12 +118,23 @@
         }
     }
     UIGraphicsPopContext();
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIImage *previewImage = UIGraphicsGetImageFromCurrentImageContext();
     UIGraphicsEndImageContext();
     
-    // set the image in the button
-    [self.previewButton setImage:image forState:UIControlStateNormal];
+
+    // set the preview image (autoreleased) in the button and the maxhog label
+    [self.previewButton setBackgroundImage:previewImage forState:UIControlStateNormal];
+    self.maxLabel.text = [NSString stringWithFormat:@"%d", maxHogs];
     
+    // restore functionality of button and remove the spinning wheel
+    [self turnOnWidgets];
+    UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[self.previewButton viewWithTag:INDICATOR_TAG];
+    [indicator stopAnimating];
+    [indicator removeFromSuperview];
+    
+    [pool release];
+    [NSThread exit];
+
     /*
     // http://developer.apple.com/mac/library/qa/qa2001/qa1037.html
     CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
@@ -142,6 +147,180 @@
     */
 }
 
+-(void) turnOffWidgets {
+    self.previewButton.alpha = 0.5f;
+    self.previewButton.enabled = NO;
+    self.maxLabel.text = @"...";
+    self.segmentedControl.enabled = NO;
+    self.tableView.allowsSelection = NO;
+    self.slider.enabled = NO;
+}
+
+-(void) turnOnWidgets {
+    self.previewButton.alpha = 1.0f;
+    self.previewButton.enabled = YES;
+    self.segmentedControl.enabled = YES;
+    self.tableView.allowsSelection = YES;
+    self.slider.enabled = YES;
+}
+
+-(IBAction) updatePreview {
+    // prevent other events and add an activity while the preview is beign generated
+    [self turnOffWidgets];
+    
+    // remove the current preview
+    [self.previewButton setImage:nil forState:UIControlStateNormal];
+    
+    // add a very nice spinning wheel
+    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] 
+                                          initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
+    indicator.center = CGPointMake(previewButton.bounds.size.width / 2, previewButton.bounds.size.height / 2);
+    indicator.tag = INDICATOR_TAG;
+    [indicator startAnimating];
+    [self.previewButton addSubview:indicator];
+    [indicator release];
+
+    // generate a seed
+    char randomStr[RANDOMSTR_LEN+1];
+    for (int i = 0; i < RANDOMSTR_LEN; ) {
+        randomStr[i] = random() % 255;
+        if (randomStr[i] >= '0' && randomStr[i] <= '9' || randomStr[i] >= 'a' && randomStr[i] <= 'z') 
+            i++;
+    }
+    randomStr[ 8] = '-';
+    randomStr[13] = '-';
+    randomStr[18] = '-';
+    randomStr[23] = '-';
+    randomStr[RANDOMSTR_LEN] = '\0';
+    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%s}", randomStr];
+    self.seedCommand = seedCmd;
+    [seedCmd release];
+    
+    // let's draw in a separate thread so the gui can work; also it restores the preview button
+    [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
+}
+
+#pragma mark -
+#pragma mark Table view data source
+-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
+    return 1;
+}
+
+-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return 1;
+}
+
+-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    static NSString *CellIdentifier = @"Cell";
+    
+    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
+    if (cell == nil) 
+        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+    
+    return cell;
+}
+
+#pragma mark -
+#pragma mark slider & segmentedControl
+-(IBAction) sliderChanged:(id) sender {
+    NSString *labelText;
+    NSString *templateCommand;
+    NSString *mazeCommand;
+    
+    switch ((int)(slider.value*100)) {
+        case 0:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"Wacky",@"");
+            } else {
+                labelText = NSLocalizedString(@"Large Floating Islands",@"");
+            }
+            templateCommand = @"e$template_filter 5";
+            mazeCommand = @"e$maze_size 5";
+            break;
+        case 1:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"Cavern",@"");
+            } else {
+                labelText = NSLocalizedString(@"Medium Floating Islands",@"");
+            }
+            templateCommand = @"e$template_filter 4";
+            mazeCommand = @"e$maze_size 4";
+            break;
+        case 2:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"Small",@"");
+            } else {
+                labelText = NSLocalizedString(@"Small Floating Islands",@"");
+            }
+            templateCommand = @"e$template_filter 1";
+            mazeCommand = @"e$maze_size 3";
+            break;
+        case 3:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"Medium",@"");
+            } else {
+                labelText = NSLocalizedString(@"Large Tunnels",@"");
+            }
+            templateCommand = @"e$template_filter 2";
+            mazeCommand = @"e$maze_size 2";
+            break;
+        case 4:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"Large",@"");
+            } else {
+                labelText = NSLocalizedString(@"Medium Tunnels",@"");
+            }
+            templateCommand = @"e$template_filter 3";
+            mazeCommand = @"e$maze_size 1";
+            break;
+        case 5:
+            if (self.segmentedControl.selectedSegmentIndex == 0) {
+                labelText = NSLocalizedString(@"All",@"");
+            } else {
+                labelText = NSLocalizedString(@"Small Tunnels",@"");
+            }
+            templateCommand = @"e$template_filter 0";
+            mazeCommand = @"e$maze_size 0";
+            break;
+        default:
+            break;
+    }
+    self.sizeLabel.text = labelText;
+    self.templateFilterCommand = templateCommand;
+    self.mazeSizeCommand = mazeCommand;
+}
+
+// update preview as soon as the user lifts its finger
+-(IBAction) sliderEndedChanging:(id) sender {
+    if (self.previewButton.enabled == YES)
+        [self updatePreview];
+}
+
+-(IBAction) segmentedControlChanged:(id) sender {
+    NSString *mapgen;
+    
+    switch (segmentedControl.selectedSegmentIndex) {
+        case 0: // Random
+            mapgen = @"e$mapgen 0";
+            [self sliderChanged:nil];
+            if (self.previewButton.enabled == YES)
+                [self updatePreview];
+            break;
+        case 1: // Map
+            mapgen = @"e$mapgen 0";
+            // other stuff
+            break;
+        case 2: // Maze
+            mapgen = @"e$mapgen 1";
+            [self sliderChanged:nil];
+            if (self.previewButton.enabled == YES)
+                [self updatePreview];
+
+            break;
+    }
+    self.mapGenCommand = mapgen;
+}
+
 #pragma mark -
 #pragma mark view management
 -(void) viewDidLoad {
@@ -150,13 +329,12 @@
 
     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
-    
-    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
-    button.frame = CGRectMake(32, 32, 256, 128);
-    [button addTarget:self action:@selector(updatePreview) forControlEvents:UIControlEventTouchUpInside];
-    self.previewButton = button;
-    [button release];
-    [self.view addSubview:self.previewButton];
+
+    self.sizeLabel.text = NSLocalizedString(@"All",@"");
+    self.templateFilterCommand = @"e$template_filter 0";
+    self.segmentedControl.selectedSegmentIndex == 0;
+    self.mazeSizeCommand = @"e$maze_size 0";
+    self.mapGenCommand = @"e$mapgen 0";
 }
 
 -(void) viewWillAppear:(BOOL)animated {
@@ -175,14 +353,30 @@
 -(void) viewDidUnload {
     self.previewButton = nil;
     self.seedCommand = nil;
+    self.seedCommand = nil;
+    self.templateFilterCommand = nil;
+    self.mapGenCommand = nil;
+    self.mazeSizeCommand = nil;
+    self.previewButton = nil;
+    self.tableView = nil;
+    self.maxLabel = nil;
+    self.sizeLabel = nil;
+    self.segmentedControl = nil;
+    self.slider = nil;
     [super viewDidUnload];
-    // Release any retained subviews of the main view.
-    // e.g. self.myOutlet = nil;
 }
 
 -(void) dealloc {
+    [seedCommand release];
+    [templateFilterCommand release];
+    [mapGenCommand release];
+    [mazeSizeCommand release];
     [previewButton release];
-    [seedCommand release];
+    [tableView release];
+    [maxLabel release];
+    [sizeLabel release];
+    [segmentedControl release];
+    [slider release];
     [super dealloc];
 }
 
--- a/cocoaTouch/xib/MapConfigViewController-iPhone.xib	Sun Apr 25 18:38:08 2010 +0000
+++ b/cocoaTouch/xib/MapConfigViewController-iPhone.xib	Mon Apr 26 01:55:26 2010 +0000
@@ -12,7 +12,7 @@
 		</object>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="8"/>
+			<integer value="1"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -42,27 +42,20 @@
 				<int key="NSvFlags">274</int>
 				<object class="NSMutableArray" key="NSSubviews">
 					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBUIPickerView" id="450385738">
-						<reference key="NSNextResponder" ref="191373211"/>
-						<int key="NSvFlags">290</int>
-						<string key="NSFrame">{{240, 60}, {240, 216}}</string>
-						<reference key="NSSuperview" ref="191373211"/>
-						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
-						<bool key="IBUIShowsSelectionIndicator">YES</bool>
-					</object>
 					<object class="IBUISegmentedControl" id="88728219">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{240, 9}, {240, 44}}</string>
+						<string key="NSFrame">{{28, 166}, {240, 30}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBSegmentControlStyle">2</int>
 						<int key="IBNumberOfSegments">3</int>
 						<int key="IBSelectedSegmentIndex">0</int>
 						<object class="NSArray" key="IBSegmentTitles">
 							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>Random</string>
 							<string>Map</string>
-							<string>Random</string>
 							<string>Maze</string>
 						</object>
 						<object class="NSMutableArray" key="IBSegmentWidths">
@@ -93,7 +86,7 @@
 					<object class="IBUISlider" id="938256702">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{18.5, 234}, {150, 23}}</string>
+						<string key="NSFrame">{{121, 209}, {149, 23}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -102,13 +95,96 @@
 						<float key="IBUIValue">0.05000000074505806</float>
 						<float key="IBUIMaxValue">0.05000000074505806</float>
 					</object>
+					<object class="IBUIButton" id="326163764">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{20, 20}, {256, 128}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBUIContentHorizontalAlignment">0</int>
+						<int key="IBUIContentVerticalAlignment">0</int>
+						<object class="NSFont" key="IBUIFont">
+							<string key="NSName">Helvetica-Bold</string>
+							<double key="NSSize">15</double>
+							<int key="NSfFlags">16</int>
+						</object>
+						<int key="IBUIButtonType">1</int>
+						<object class="NSColor" key="IBUIHighlightedTitleColor" id="437070330">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MQA</bytes>
+						</object>
+						<object class="NSColor" key="IBUINormalTitleColor">
+							<int key="NSColorSpace">1</int>
+							<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+						</object>
+						<object class="NSColor" key="IBUINormalTitleShadowColor">
+							<int key="NSColorSpace">3</int>
+							<bytes key="NSWhite">MC41AA</bytes>
+						</object>
+					</object>
+					<object class="IBUITableView" id="565214171">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">274</int>
+						<string key="NSFrame">{{295, 0}, {185, 276}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<reference key="IBUIBackgroundColor" ref="437070330"/>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<bool key="IBUIBouncesZoom">NO</bool>
+						<int key="IBUISeparatorStyle">1</int>
+						<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
+						<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
+						<float key="IBUIRowHeight">44</float>
+						<float key="IBUISectionHeaderHeight">22</float>
+						<float key="IBUISectionFooterHeight">22</float>
+					</object>
+					<object class="IBUILabel" id="634417433">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{54, 234}, {42, 21}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<int key="IBUIContentMode">7</int>
+						<bool key="IBUIUserInteractionEnabled">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<string key="IBUIText">...</string>
+						<object class="NSColor" key="IBUITextColor" id="306081020">
+							<int key="NSColorSpace">1</int>
+							<bytes key="NSRGB">MCAwIDAAA</bytes>
+						</object>
+						<nil key="IBUIHighlightedColor"/>
+						<int key="IBUIBaselineAdjustment">1</int>
+						<float key="IBUIMinimumFontSize">10</float>
+						<int key="IBUITextAlignment">1</int>
+					</object>
+					<object class="IBUILabel" id="743202682">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{123, 239}, {145, 29}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<bool key="IBUIClipsSubviews">YES</bool>
+						<int key="IBUIContentMode">7</int>
+						<bool key="IBUIUserInteractionEnabled">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<string key="IBUIText">Label</string>
+						<object class="NSFont" key="IBUIFont">
+							<string key="NSName">Helvetica</string>
+							<double key="NSSize">24</double>
+							<int key="NSfFlags">16</int>
+						</object>
+						<reference key="IBUITextColor" ref="306081020"/>
+						<nil key="IBUIHighlightedColor"/>
+						<int key="IBUIBaselineAdjustment">1</int>
+						<float key="IBUIMinimumFontSize">10</float>
+						<int key="IBUITextAlignment">1</int>
+					</object>
 				</object>
 				<string key="NSFrameSize">{480, 276}</string>
 				<reference key="NSSuperview"/>
-				<object class="NSColor" key="IBUIBackgroundColor">
-					<int key="NSColorSpace">3</int>
-					<bytes key="NSWhite">MQA</bytes>
-				</object>
+				<reference key="IBUIBackgroundColor" ref="437070330"/>
 				<object class="IBUISimulatedToolbarMetrics" key="IBUISimulatedBottomBarMetrics"/>
 				<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
 					<int key="interfaceOrientation">3</int>
@@ -127,6 +203,98 @@
 					</object>
 					<int key="connectionID">3</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">updatePreview</string>
+						<reference key="source" ref="326163764"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">7</int>
+					</object>
+					<int key="connectionID">12</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">previewButton</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="326163764"/>
+					</object>
+					<int key="connectionID">13</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">dataSource</string>
+						<reference key="source" ref="565214171"/>
+						<reference key="destination" ref="372490531"/>
+					</object>
+					<int key="connectionID">14</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">delegate</string>
+						<reference key="source" ref="565214171"/>
+						<reference key="destination" ref="372490531"/>
+					</object>
+					<int key="connectionID">15</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">maxLabel</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="634417433"/>
+					</object>
+					<int key="connectionID">16</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">sizeLabel</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="743202682"/>
+					</object>
+					<int key="connectionID">18</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">sliderChanged:</string>
+						<reference key="source" ref="938256702"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">13</int>
+					</object>
+					<int key="connectionID">19</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">sliderEndedChanging:</string>
+						<reference key="source" ref="938256702"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">7</int>
+					</object>
+					<int key="connectionID">20</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">segmentedControl</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="88728219"/>
+					</object>
+					<int key="connectionID">21</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">segmentedControlChanged:</string>
+						<reference key="source" ref="88728219"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">13</int>
+					</object>
+					<int key="connectionID">22</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">slider</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="938256702"/>
+					</object>
+					<int key="connectionID">23</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -142,9 +310,12 @@
 						<reference key="object" ref="191373211"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="326163764"/>
+							<reference ref="565214171"/>
+							<reference ref="634417433"/>
 							<reference ref="88728219"/>
-							<reference ref="450385738"/>
 							<reference ref="938256702"/>
+							<reference ref="743202682"/>
 						</object>
 						<reference key="parent" ref="0"/>
 					</object>
@@ -160,11 +331,6 @@
 						<reference key="parent" ref="0"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">6</int>
-						<reference key="object" ref="450385738"/>
-						<reference key="parent" ref="191373211"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">7</int>
 						<reference key="object" ref="88728219"/>
 						<reference key="parent" ref="191373211"/>
@@ -174,6 +340,26 @@
 						<reference key="object" ref="938256702"/>
 						<reference key="parent" ref="191373211"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">9</int>
+						<reference key="object" ref="326163764"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">10</int>
+						<reference key="object" ref="565214171"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">11</int>
+						<reference key="object" ref="634417433"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">17</int>
+						<reference key="object" ref="743202682"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
@@ -184,15 +370,21 @@
 					<string>-2.CustomClassName</string>
 					<string>1.IBEditorWindowLastContentRect</string>
 					<string>1.IBPluginDependency</string>
-					<string>6.IBPluginDependency</string>
+					<string>10.IBPluginDependency</string>
+					<string>11.IBPluginDependency</string>
+					<string>17.IBPluginDependency</string>
 					<string>7.IBPluginDependency</string>
 					<string>8.IBPluginDependency</string>
+					<string>9.IBPluginDependency</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<string>MapConfigViewController</string>
 					<string>UIResponder</string>
-					<string>{{556, 572}, {480, 320}}</string>
+					<string>{{744, 568}, {480, 320}}</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -215,7 +407,7 @@
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">8</int>
+			<int key="maxID">23</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -223,6 +415,44 @@
 				<object class="IBPartialClassDescription">
 					<string key="className">MapConfigViewController</string>
 					<string key="superclassName">UIViewController</string>
+					<object class="NSMutableDictionary" key="actions">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>segmentedControlChanged:</string>
+							<string>sliderChanged:</string>
+							<string>sliderEndedChanging:</string>
+							<string>updatePreview</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>maxLabel</string>
+							<string>previewButton</string>
+							<string>segmentedControl</string>
+							<string>sizeLabel</string>
+							<string>slider</string>
+							<string>tableView</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>UILabel</string>
+							<string>UIButton</string>
+							<string>UISegmentedControl</string>
+							<string>UILabel</string>
+							<string>UISlider</string>
+							<string>UITableView</string>
+						</object>
+					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
 						<string key="majorKey">IBProjectSource</string>
 						<string key="minorKey">../../cocoaTouch/MapConfigViewController.h</string>
@@ -365,6 +595,14 @@
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
+					<string key="className">UIButton</string>
+					<string key="superclassName">UIControl</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIButton.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
 					<string key="className">UIControl</string>
 					<string key="superclassName">UIView</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -373,11 +611,11 @@
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
-					<string key="className">UIPickerView</string>
+					<string key="className">UILabel</string>
 					<string key="superclassName">UIView</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
 						<string key="majorKey">IBFrameworkSource</string>
-						<string key="minorKey">UIKit.framework/Headers/UIPickerView.h</string>
+						<string key="minorKey">UIKit.framework/Headers/UILabel.h</string>
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
@@ -386,6 +624,14 @@
 					<reference key="sourceIdentifier" ref="567455553"/>
 				</object>
 				<object class="IBPartialClassDescription">
+					<string key="className">UIScrollView</string>
+					<string key="superclassName">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIScrollView.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
 					<string key="className">UISearchBar</string>
 					<string key="superclassName">UIView</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -418,6 +664,14 @@
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
+					<string key="className">UITableView</string>
+					<string key="superclassName">UIScrollView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UITableView.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
 					<string key="className">UIView</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
 						<string key="majorKey">IBFrameworkSource</string>
@@ -481,7 +735,7 @@
 			<integer value="3000" key="NS.object.0"/>
 		</object>
 		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
-		<string key="IBDocument.LastKnownRelativeProjectPath">../project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj</string>
+		<string key="IBDocument.LastKnownRelativeProjectPath">../../project_files/HedgewarsMobile/Hedgewars.xcodeproj</string>
 		<int key="IBDocument.defaultPropertyAccessControl">3</int>
 		<string key="IBCocoaTouchPluginVersion">87</string>
 	</data>
--- a/hedgewars/hwengine.pas	Sun Apr 25 18:38:08 2010 +0000
+++ b/hedgewars/hwengine.pas	Mon Apr 26 01:55:26 2010 +0000
@@ -349,7 +349,7 @@
     //uLandTexture does not need initialization
     //uLocale does not need initialization
     uRandom.initModule; 
-    //uSHA does not need initialization
+    //uSHA is initialized internally
     uSound.initModule;
     uStats.initModule;
     uStore.initModule;
@@ -391,7 +391,7 @@
     uConsole.freeModule;
     uConsts.freeModule;         //stub
     uScript.freeModule;
-// uMisc closes the debug log.
+    // uMisc closes the debug log.
     uMisc.freeModule;
 
 end;
--- a/hedgewars/uLand.pas	Sun Apr 25 18:38:08 2010 +0000
+++ b/hedgewars/uLand.pas	Mon Apr 26 01:55:26 2010 +0000
@@ -35,6 +35,7 @@
     isMap: boolean;  
     playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
     LandBackSurface: PSDL_Surface;
+    digest: shortstring;
 
 type direction = record x, y: LongInt; end;
 const DIR_N: direction = (x: 0; y: -1);
@@ -80,15 +81,14 @@
 end;
 
 procedure CheckLandDigest(s: shortstring);
-const digest: shortstring = '';
 begin
 {$IFDEF DEBUGFILE}
-AddFileLog('CheckLandDigest: ' + s);
+    AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest);
 {$ENDIF}
-if digest = '' then
-   digest:= s
-else
-   TryDo(s = digest, 'Different maps generated, sorry', true)
+    if digest = '' then
+        digest:= s
+    else
+        TryDo(s = digest, 'Different maps generated, sorry', true);
 end;
 
 procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
@@ -1311,6 +1311,7 @@
 procedure initModule;
 begin
     LandBackSurface:= nil;
+    digest:= '';
     FillChar(LandPixels, sizeof(TLandArray), 0);
 end;
 
--- a/hedgewars/uRandom.pas	Sun Apr 25 18:38:08 2010 +0000
+++ b/hedgewars/uRandom.pas	Mon Apr 26 01:55:26 2010 +0000
@@ -99,6 +99,7 @@
 procedure initModule;
 begin
     n:= 54;
+    FillChar(cirbuf, 64*sizeof(Longword), 0);
 end;
 
 procedure freeModule;
--- a/hedgewars/uSHA.pas	Sun Apr 25 18:38:08 2010 +0000
+++ b/hedgewars/uSHA.pas	Mon Apr 26 01:55:26 2010 +0000
@@ -122,41 +122,43 @@
 procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
 var i: Longword;
 begin
-for i:= 0 to Pred(Length div 4) do
+    for i:= 0 to Pred(Length div 4) do
     begin
-    SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]);
-    inc(Context.CurrLength, 4);
-    if Context.CurrLength = 64 then
-       begin
-       SHA1Hash(Context);
-       inc(Context.Length, 512);
-       Context.CurrLength:= 0
-       end
+        SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]);
+        inc(Context.CurrLength, 4);
+        if Context.CurrLength = 64 then
+        begin
+            SHA1Hash(Context);
+            inc(Context.Length, 512);
+            Context.CurrLength:= 0
+        end
     end
 end;
 
 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
 var i: LongWord;
 begin
-Context.Length:= Context.Length + Context.CurrLength shl 3;
-Context.Buf[Context.CurrLength]:= $80;
-inc(Context.CurrLength);
+    Context.Length:= Context.Length + Context.CurrLength shl 3;
+    Context.Buf[Context.CurrLength]:= $80;
+    inc(Context.CurrLength);
 
-if Context.CurrLength > 56 then
-   begin
-   FillChar(Context.Buf[Context.CurrLength], 64 - Context.CurrLength, 0);
-   Context.CurrLength:= 64;
-   SHA1Hash(Context);
-   Context.CurrLength:=0
-   end;
+    if Context.CurrLength > 56 then
+    begin
+        FillChar(Context.Buf[Context.CurrLength], 64 - Context.CurrLength, 0);
+        Context.CurrLength:= 64;
+        SHA1Hash(Context);
+        Context.CurrLength:=0
+    end;
 
-FillChar(Context.Buf[Context.CurrLength], 56 - Context.CurrLength, 0);
+    FillChar(Context.Buf[Context.CurrLength], 56 - Context.CurrLength, 0);
 
-for i:= 56 to 63 do
-    Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
-SHA1Hash(Context);
-for i:= 0 to 4 do SHA1Final[i]:= Context.H[i];
-FillChar(Context, sizeof(Context), 0)
+    for i:= 56 to 63 do
+        Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
+    SHA1Hash(Context);
+    for i:= 0 to 4 do
+        SHA1Final[i]:= Context.H[i];
+    
+    FillChar(Context, sizeof(Context), 0)
 end;
 
 end.