cocoaTouch/SettingsViewController.m
changeset 2723 eaa6ac1e95ea
parent 2720 a5111ec4d25f
child 2740 03df0573a9fd
equal deleted inserted replaced
2722:d891285e500f 2723:eaa6ac1e95ea
   161 }
   161 }
   162 
   162 
   163 #pragma mark -
   163 #pragma mark -
   164 #pragma mark UIActionSheet Methods
   164 #pragma mark UIActionSheet Methods
   165 -(IBAction) deleteData: (id)sender {
   165 -(IBAction) deleteData: (id)sender {
   166 	UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you reeeeeally sure?"
   166 	UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
   167 								 delegate:self
   167 								 delegate:self
   168 							cancelButtonTitle:@"Well, maybe not..."
   168 							cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
   169 						   destructiveButtonTitle:@"Sure, let's start over"
   169 						   destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"")
   170 							otherButtonTitles:nil];
   170 							otherButtonTitles:nil];
   171 	[actionSheet showInView:self.view];
   171 	[actionSheet showInView:self.view];
   172 	[actionSheet release];
   172 	[actionSheet release];
   173 }
   173 }
   174 
   174 
   175 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   175 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   176 	if ([actionSheet cancelButtonIndex] != buttonIndex) {
   176 	if ([actionSheet cancelButtonIndex] != buttonIndex) {
   177 		needsReset = YES;
   177 		needsReset = YES;
   178 		
   178 		
   179 		// get the document dirctory
   179 		// get the documents dirctory
   180 		NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   180 		NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   181 		NSString *documentsDirectory = [paths objectAtIndex:0];
   181 		NSString *documentsDirectory = [paths objectAtIndex:0];
   182 		
   182 		
   183 		// get the content of the directory
   183 		// get the content of the directory
   184 		NSFileManager *fm = [NSFileManager defaultManager];
   184 		NSFileManager *fm = [NSFileManager defaultManager];
   189 		for (NSString *fileName in dirContent) {
   189 		for (NSString *fileName in dirContent) {
   190 			[fm removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:fileName] error:&error];
   190 			[fm removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:fileName] error:&error];
   191 		}
   191 		}
   192 		
   192 		
   193 		// force resetting
   193 		// force resetting
   194 		UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:@"Hit Home Button to Exit" 
   194 		UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Hit Home Button to Exit", @"")
   195 								  message:@"\nEverything is gone!\nNow you need to restart the game..." 
   195 								  message:NSLocalizedString(@"\nEverything is gone!\nNow you need to restart the game...", @"")
   196 								 delegate:self
   196 								 delegate:self
   197 							cancelButtonTitle:nil
   197 							cancelButtonTitle:nil
   198 							otherButtonTitles:nil];
   198 							otherButtonTitles:nil];
   199 		[anAlert show];
   199 		[anAlert show];
   200 		[anAlert release];
   200 		[anAlert release];
   295 	headerLabel.font = [UIFont boldSystemFontOfSize:20];
   295 	headerLabel.font = [UIFont boldSystemFontOfSize:20];
   296 	headerLabel.backgroundColor = [UIColor clearColor];
   296 	headerLabel.backgroundColor = [UIColor clearColor];
   297 
   297 
   298 	switch (section) {
   298 	switch (section) {
   299 		case kNetworkFields:
   299 		case kNetworkFields:
   300 			headerLabel.text = NSLocalizedString(@"Network Configuration", @"Network Configuration");
   300 			headerLabel.text = NSLocalizedString(@"Network Configuration", @"");
   301 			break;
   301 			break;
   302 		case kAudioFields:
   302 		case kAudioFields:
   303 			headerLabel.text = NSLocalizedString(@"Audio Preferences", @"");
   303 			headerLabel.text = NSLocalizedString(@"Audio Preferences", @"");
   304 			break;
   304 			break;
   305 		case kOtherFields:
   305 		case kOtherFields:
   306 			headerLabel.text = NSLocalizedString(@"Other Settings", @"");
   306 			headerLabel.text = NSLocalizedString(@"Other Settings", @"");
   307 			break;
   307 			break;
   308 		default:
   308 		default:
   309 			NSLog(@"Warning: unset case value in titleForHeaderInSection!");
   309 			NSLog(@"Warning: unset case value in titleForHeaderInSection!");
   310 			headerLabel.text = @"!!!";
   310 			headerLabel.text = @"!";
   311 			break;
   311 			break;
   312 	}
   312 	}
   313 	
   313 	
   314 	[containerView addSubview:headerLabel];
   314 	[containerView addSubview:headerLabel];
   315 	return containerView;
   315 	return containerView;