cocoaTouch/MapConfigViewController.m
changeset 3490 016b3172b645
parent 3487 b1d00f1950c8
child 3492 07256e1ad559
equal deleted inserted replaced
3489:aedf289192f5 3490:016b3172b645
    15 
    15 
    16 #define INDICATOR_TAG 7654
    16 #define INDICATOR_TAG 7654
    17 
    17 
    18 @implementation MapConfigViewController
    18 @implementation MapConfigViewController
    19 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand,
    19 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand,
    20             tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, themeArray, mapArray;
    20             tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, themeArray, mapArray, busy;
    21 
    21 
    22 
    22 
    23 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    23 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    24     return rotationManager(interfaceOrientation);
    24     return rotationManager(interfaceOrientation);
    25 }
    25 }
    52 	if (!(sd = SDLNet_TCP_Open(&ip))) {
    52 	if (!(sd = SDLNet_TCP_Open(&ip))) {
    53 		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), port);
    53 		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), port);
    54         serverQuit = YES;
    54         serverQuit = YES;
    55 	}
    55 	}
    56 	
    56 	
    57 	NSLog(@"engineProtocol - Waiting for a client on port %d", port);
    57 	DLog(@"Waiting for a client on port %d", port);
    58 	while (!serverQuit) {
    58 	while (!serverQuit) {
    59 		/* This check the sd if there is a pending connection.
    59 		/* This check the sd if there is a pending connection.
    60 		 * If there is one, accept that, and open a new socket for communicating */
    60 		 * If there is one, accept that, and open a new socket for communicating */
    61 		csd = SDLNet_TCP_Accept(sd);
    61 		csd = SDLNet_TCP_Accept(sd);
    62 		if (NULL != csd) {			
    62 		if (NULL != csd) {			
    63 			NSLog(@"engineProtocol - Client found");
    63 			DLog(@"Client found");
    64             
    64             
    65             [self sendToEngine:self.seedCommand];
    65             [self sendToEngine:self.seedCommand];
    66             [self sendToEngine:self.templateFilterCommand];
    66             [self sendToEngine:self.templateFilterCommand];
    67             [self sendToEngine:self.mapGenCommand];
    67             [self sendToEngine:self.mapGenCommand];
    68             [self sendToEngine:self.mazeSizeCommand];
    68             [self sendToEngine:self.mazeSizeCommand];
    69             [self sendToEngine:@"!"];
    69             [self sendToEngine:@"!"];
    70                 
    70                 
    71             memset(map, 0, 128*32);
    71             memset(map, 0, 128*32);
    72             SDLNet_TCP_Recv(csd, map, 128*32);
    72             SDLNet_TCP_Recv(csd, map, 128*32);
    73             SDLNet_TCP_Recv(csd, &maxHogs, sizeof(Uint8));
    73             SDLNet_TCP_Recv(csd, &maxHogs, sizeof(uint8_t));
    74 
    74 
    75 			SDLNet_TCP_Close(csd);
    75 			SDLNet_TCP_Close(csd);
    76 			serverQuit = YES;
    76 			serverQuit = YES;
    77 		}
    77 		}
    78 	}
    78 	}
   216     busy = YES;
   216     busy = YES;
   217     self.previewButton.alpha = 0.5f;
   217     self.previewButton.alpha = 0.5f;
   218     self.previewButton.enabled = NO;
   218     self.previewButton.enabled = NO;
   219     self.maxLabel.text = @"...";
   219     self.maxLabel.text = @"...";
   220     self.segmentedControl.enabled = NO;
   220     self.segmentedControl.enabled = NO;
   221     self.tableView.allowsSelection = NO;
       
   222     self.slider.enabled = NO;
   221     self.slider.enabled = NO;
   223 }
   222 }
   224 
   223 
   225 -(void) turnOnWidgets {
   224 -(void) turnOnWidgets {
   226     self.previewButton.alpha = 1.0f;
   225     self.previewButton.alpha = 1.0f;
   227     self.previewButton.enabled = YES;
   226     self.previewButton.enabled = YES;
   228     self.segmentedControl.enabled = YES;
   227     self.segmentedControl.enabled = YES;
   229     self.tableView.allowsSelection = YES;
       
   230     self.slider.enabled = YES;
   228     self.slider.enabled = YES;
   231     busy = NO;
   229     busy = NO;
   232 }
   230 }
   233     
   231     
   234 #pragma mark -
   232 #pragma mark -
   503     self.lastIndexPath = nil;
   501     self.lastIndexPath = nil;
   504     self.themeArray = nil;
   502     self.themeArray = nil;
   505     self.mapArray = nil;
   503     self.mapArray = nil;
   506     
   504     
   507     [super viewDidUnload];
   505     [super viewDidUnload];
       
   506     MSG_DIDUNLOAD();
   508 }
   507 }
   509 
   508 
   510 -(void) dealloc {
   509 -(void) dealloc {
   511     [seedCommand release];
   510     [seedCommand release];
   512     [templateFilterCommand release];
   511     [templateFilterCommand release];