cocoaTouch/MapConfigViewController.m
author koda
Mon, 26 Apr 2010 01:55:26 +0000
changeset 3369 c7289e42f0ee
parent 3366 f0e5ff24fb72
child 3373 c1ff724a5c34
permissions -rw-r--r--
add other controls for map preview, also fix a bug in digest
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     1
//
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     2
//  MapConfigViewController.m
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     3
//  HedgewarsMobile
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     4
//
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     5
//  Created by Vittorio on 22/04/10.
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     7
//
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     8
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
     9
#import "MapConfigViewController.h"
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    10
#import "PascalImports.h"
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    11
#import "CommodityFunctions.h"
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    12
#import "UIImageExtra.h"
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    13
#import "SDL_net.h"
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    14
#import <pthread.h>
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    15
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    16
#define INDICATOR_TAG 7654
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    17
#define RANDOMSTR_LEN 36
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    18
@implementation MapConfigViewController
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    19
@synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand,
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    20
            tableView, maxLabel, sizeLabel, segmentedControl, slider;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    21
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    22
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    23
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    24
    return rotationManager(interfaceOrientation);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    25
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    26
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    27
#pragma mark -
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    28
#pragma mark Preview Handling
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    29
-(int) sendToEngine: (NSString *)string {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    30
	unsigned char length = [string length];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    31
	
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    32
	SDLNet_TCP_Send(csd, &length , 1);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    33
	return SDLNet_TCP_Send(csd, [string UTF8String], length);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    34
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    35
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    36
-(void) engineProtocol:(NSInteger) port {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    37
	IPaddress ip;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    38
	BOOL clientQuit, serverQuit;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    39
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    40
    serverQuit = NO;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    41
    clientQuit =NO;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    42
	if (SDLNet_Init() < 0) {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    43
		NSLog(@"SDLNet_Init: %s", SDLNet_GetError());
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    44
        serverQuit = YES;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    45
	}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    46
	
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    47
	/* Resolving the host using NULL make network interface to listen */
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    48
	if (SDLNet_ResolveHost(&ip, NULL, port) < 0) {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    49
		NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    50
        serverQuit = YES;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    51
	}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    52
	
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    53
	/* Open a connection with the IP provided (listen on the host's port) */
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    54
	if (!(sd = SDLNet_TCP_Open(&ip))) {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    55
		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), port);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    56
        serverQuit = YES;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    57
	}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    58
	
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    59
	NSLog(@"engineProtocol - Waiting for a client on port %d", port);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    60
	while (!serverQuit) {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    61
		/* This check the sd if there is a pending connection.
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    62
		 * If there is one, accept that, and open a new socket for communicating */
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    63
		csd = SDLNet_TCP_Accept(sd);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    64
		if (NULL != csd) {			
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    65
			NSLog(@"engineProtocol - Client found");
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    66
            
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    67
            [self sendToEngine:self.seedCommand];
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    68
            [self sendToEngine:self.templateFilterCommand];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    69
            [self sendToEngine:self.mapGenCommand];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    70
            [self sendToEngine:self.mazeSizeCommand];
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    71
            [self sendToEngine:@"!"];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    72
                
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    73
            memset(map, 0, 128*32);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    74
            SDLNet_TCP_Recv(csd, map, 128*32);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    75
            SDLNet_TCP_Recv(csd, &maxHogs, sizeof(Uint8));
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    76
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    77
			SDLNet_TCP_Close(csd);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    78
			serverQuit = YES;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    79
		}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    80
	}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    81
	
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    82
	SDLNet_TCP_Close(sd);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    83
	SDLNet_Quit();
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    84
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    85
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    86
-(void) drawingThread {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    87
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    88
    
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    89
    // select the port for IPC and launch the preview generation
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    90
    int port = randomPort();
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
    91
    pthread_t thread_id;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    92
    pthread_create(&thread_id, NULL, (void *)GenLandPreview, (void *)port);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    93
    [self engineProtocol:port];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    94
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    95
    // draw the buffer (1 pixel per component, 0= transparent 1= color)
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    96
    int xc = 0;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    97
    int yc = 0;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    98
    UIGraphicsBeginImageContext(CGSizeMake(256,128));      
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
    99
    CGContextRef context = UIGraphicsGetCurrentContext();       
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   100
    UIGraphicsPushContext(context);  
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   101
    for (int i = 0; i < 32*128; i++) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   102
        unsigned char byte = map[i];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   103
        for (int j = 0; j < 8; j++) {
3366
f0e5ff24fb72 rename the project from HedgewarsMobile to Hedgewars
koda
parents: 3365
diff changeset
   104
            // select the color based on the rightmost bit
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   105
            if ((byte & 0x00000001) != 0)
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   106
                CGContextSetRGBFillColor(context, 0.5, 0.5, 0.7, 1.0);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   107
            else
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   108
                CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.0);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   109
            
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   110
            // draw pixel
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   111
            CGContextFillRect(context,CGRectMake(xc,yc,1,1));
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   112
            // move coordinates
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   113
            xc = (xc + 1) % 256;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   114
            if (xc == 0) yc++;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   115
            
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   116
            // shift to next bit
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   117
            byte = byte >> 1;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   118
        }
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   119
    }
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   120
    UIGraphicsPopContext();
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   121
    UIImage *previewImage = UIGraphicsGetImageFromCurrentImageContext();
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   122
    UIGraphicsEndImageContext();
3366
f0e5ff24fb72 rename the project from HedgewarsMobile to Hedgewars
koda
parents: 3365
diff changeset
   123
    
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   124
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   125
    // set the preview image (autoreleased) in the button and the maxhog label
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   126
    [self.previewButton setBackgroundImage:previewImage forState:UIControlStateNormal];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   127
    self.maxLabel.text = [NSString stringWithFormat:@"%d", maxHogs];
3366
f0e5ff24fb72 rename the project from HedgewarsMobile to Hedgewars
koda
parents: 3365
diff changeset
   128
    
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   129
    // restore functionality of button and remove the spinning wheel
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   130
    [self turnOnWidgets];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   131
    UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[self.previewButton viewWithTag:INDICATOR_TAG];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   132
    [indicator stopAnimating];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   133
    [indicator removeFromSuperview];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   134
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   135
    [pool release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   136
    [NSThread exit];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   137
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   138
    /*
3366
f0e5ff24fb72 rename the project from HedgewarsMobile to Hedgewars
koda
parents: 3365
diff changeset
   139
    // http://developer.apple.com/mac/library/qa/qa2001/qa1037.html
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   140
    CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   141
    CGContextRef bitmapImage = CGBitmapContextCreate(mapExp, 128, 32, 8, 128, colorspace, kCGImageAlphaNone);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   142
    CGColorSpaceRelease(colorspace);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   143
    
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   144
    CGImageRef previewCGImage = CGBitmapContextCreateImage(bitmapImage);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   145
    UIImage *previewImage = [[UIImage alloc] initWithCGImage:previewCGImage];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   146
    CGImageRelease(previewCGImage);
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   147
    */
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   148
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   149
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   150
-(void) turnOffWidgets {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   151
    self.previewButton.alpha = 0.5f;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   152
    self.previewButton.enabled = NO;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   153
    self.maxLabel.text = @"...";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   154
    self.segmentedControl.enabled = NO;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   155
    self.tableView.allowsSelection = NO;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   156
    self.slider.enabled = NO;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   157
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   158
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   159
-(void) turnOnWidgets {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   160
    self.previewButton.alpha = 1.0f;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   161
    self.previewButton.enabled = YES;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   162
    self.segmentedControl.enabled = YES;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   163
    self.tableView.allowsSelection = YES;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   164
    self.slider.enabled = YES;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   165
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   166
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   167
-(IBAction) updatePreview {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   168
    // prevent other events and add an activity while the preview is beign generated
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   169
    [self turnOffWidgets];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   170
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   171
    // remove the current preview
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   172
    [self.previewButton setImage:nil forState:UIControlStateNormal];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   173
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   174
    // add a very nice spinning wheel
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   175
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] 
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   176
                                          initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   177
    indicator.center = CGPointMake(previewButton.bounds.size.width / 2, previewButton.bounds.size.height / 2);
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   178
    indicator.tag = INDICATOR_TAG;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   179
    [indicator startAnimating];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   180
    [self.previewButton addSubview:indicator];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   181
    [indicator release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   182
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   183
    // generate a seed
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   184
    char randomStr[RANDOMSTR_LEN+1];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   185
    for (int i = 0; i < RANDOMSTR_LEN; ) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   186
        randomStr[i] = random() % 255;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   187
        if (randomStr[i] >= '0' && randomStr[i] <= '9' || randomStr[i] >= 'a' && randomStr[i] <= 'z') 
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   188
            i++;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   189
    }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   190
    randomStr[ 8] = '-';
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   191
    randomStr[13] = '-';
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   192
    randomStr[18] = '-';
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   193
    randomStr[23] = '-';
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   194
    randomStr[RANDOMSTR_LEN] = '\0';
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   195
    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%s}", randomStr];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   196
    self.seedCommand = seedCmd;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   197
    [seedCmd release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   198
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   199
    // let's draw in a separate thread so the gui can work; also it restores the preview button
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   200
    [NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   201
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   202
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   203
#pragma mark -
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   204
#pragma mark Table view data source
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   205
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   206
    return 1;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   207
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   208
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   209
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   210
    return 1;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   211
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   212
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   213
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   214
    static NSString *CellIdentifier = @"Cell";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   215
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   216
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   217
    if (cell == nil) 
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   218
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   219
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   220
    return cell;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   221
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   222
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   223
#pragma mark -
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   224
#pragma mark slider & segmentedControl
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   225
-(IBAction) sliderChanged:(id) sender {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   226
    NSString *labelText;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   227
    NSString *templateCommand;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   228
    NSString *mazeCommand;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   229
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   230
    switch ((int)(slider.value*100)) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   231
        case 0:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   232
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   233
                labelText = NSLocalizedString(@"Wacky",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   234
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   235
                labelText = NSLocalizedString(@"Large Floating Islands",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   236
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   237
            templateCommand = @"e$template_filter 5";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   238
            mazeCommand = @"e$maze_size 5";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   239
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   240
        case 1:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   241
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   242
                labelText = NSLocalizedString(@"Cavern",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   243
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   244
                labelText = NSLocalizedString(@"Medium Floating Islands",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   245
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   246
            templateCommand = @"e$template_filter 4";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   247
            mazeCommand = @"e$maze_size 4";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   248
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   249
        case 2:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   250
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   251
                labelText = NSLocalizedString(@"Small",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   252
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   253
                labelText = NSLocalizedString(@"Small Floating Islands",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   254
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   255
            templateCommand = @"e$template_filter 1";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   256
            mazeCommand = @"e$maze_size 3";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   257
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   258
        case 3:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   259
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   260
                labelText = NSLocalizedString(@"Medium",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   261
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   262
                labelText = NSLocalizedString(@"Large Tunnels",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   263
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   264
            templateCommand = @"e$template_filter 2";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   265
            mazeCommand = @"e$maze_size 2";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   266
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   267
        case 4:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   268
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   269
                labelText = NSLocalizedString(@"Large",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   270
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   271
                labelText = NSLocalizedString(@"Medium Tunnels",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   272
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   273
            templateCommand = @"e$template_filter 3";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   274
            mazeCommand = @"e$maze_size 1";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   275
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   276
        case 5:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   277
            if (self.segmentedControl.selectedSegmentIndex == 0) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   278
                labelText = NSLocalizedString(@"All",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   279
            } else {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   280
                labelText = NSLocalizedString(@"Small Tunnels",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   281
            }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   282
            templateCommand = @"e$template_filter 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   283
            mazeCommand = @"e$maze_size 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   284
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   285
        default:
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   286
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   287
    }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   288
    self.sizeLabel.text = labelText;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   289
    self.templateFilterCommand = templateCommand;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   290
    self.mazeSizeCommand = mazeCommand;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   291
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   292
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   293
// update preview as soon as the user lifts its finger
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   294
-(IBAction) sliderEndedChanging:(id) sender {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   295
    if (self.previewButton.enabled == YES)
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   296
        [self updatePreview];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   297
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   298
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   299
-(IBAction) segmentedControlChanged:(id) sender {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   300
    NSString *mapgen;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   301
    
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   302
    switch (segmentedControl.selectedSegmentIndex) {
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   303
        case 0: // Random
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   304
            mapgen = @"e$mapgen 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   305
            [self sliderChanged:nil];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   306
            if (self.previewButton.enabled == YES)
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   307
                [self updatePreview];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   308
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   309
        case 1: // Map
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   310
            mapgen = @"e$mapgen 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   311
            // other stuff
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   312
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   313
        case 2: // Maze
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   314
            mapgen = @"e$mapgen 1";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   315
            [self sliderChanged:nil];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   316
            if (self.previewButton.enabled == YES)
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   317
                [self updatePreview];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   318
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   319
            break;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   320
    }
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   321
    self.mapGenCommand = mapgen;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   322
}
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   323
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   324
#pragma mark -
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   325
#pragma mark view management
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   326
-(void) viewDidLoad {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   327
    srandom(time(NULL));
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   328
    [super viewDidLoad];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   329
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   330
    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   331
    self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   332
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   333
    self.sizeLabel.text = NSLocalizedString(@"All",@"");
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   334
    self.templateFilterCommand = @"e$template_filter 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   335
    self.segmentedControl.selectedSegmentIndex == 0;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   336
    self.mazeSizeCommand = @"e$maze_size 0";
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   337
    self.mapGenCommand = @"e$mapgen 0";
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   338
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   339
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   340
-(void) viewWillAppear:(BOOL)animated {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   341
    [super viewWillAppear:animated];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   342
    [self updatePreview];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   343
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   344
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   345
-(void) didReceiveMemoryWarning {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   346
    // Releases the view if it doesn't have a superview.
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   347
    [super didReceiveMemoryWarning];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   348
    // Release any cached data, images, etc that aren't in use.
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   349
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   350
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   351
#pragma mark -
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   352
#pragma mark memory
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   353
-(void) viewDidUnload {
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   354
    self.previewButton = nil;
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   355
    self.seedCommand = nil;
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   356
    self.seedCommand = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   357
    self.templateFilterCommand = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   358
    self.mapGenCommand = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   359
    self.mazeSizeCommand = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   360
    self.previewButton = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   361
    self.tableView = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   362
    self.maxLabel = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   363
    self.sizeLabel = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   364
    self.segmentedControl = nil;
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   365
    self.slider = nil;
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   366
    [super viewDidUnload];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   367
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   368
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   369
-(void) dealloc {
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   370
    [seedCommand release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   371
    [templateFilterCommand release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   372
    [mapGenCommand release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   373
    [mazeSizeCommand release];
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   374
    [previewButton release];
3369
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   375
    [tableView release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   376
    [maxLabel release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   377
    [sizeLabel release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   378
    [segmentedControl release];
c7289e42f0ee add other controls for map preview, also fix a bug in digest
koda
parents: 3366
diff changeset
   379
    [slider release];
3365
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   380
    [super dealloc];
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   381
}
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   382
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   383
37ac593e9027 wow all these files only for land preview and seed generation
koda
parents:
diff changeset
   384
@end