cocoaTouch/GeneralSettingsViewController.m
author koda
Sat, 10 Apr 2010 20:48:09 +0000
changeset 3332 3c90a923f156
parent 3312 6d8f1c76756d
child 3335 2520ee7a5484
permissions -rw-r--r--
simplify the general settings and review minor stuff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     1
//
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     2
//  SettingsViewController.m
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     3
//  hwengine
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     4
//
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     5
//  Created by Vittorio on 08/01/10.
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     7
//
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     8
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
     9
#import "GeneralSettingsViewController.h"
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    10
#import "SDL_uikitappdelegate.h"
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    11
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    12
@implementation GeneralSettingsViewController
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    13
@synthesize settingsDictionary, textFieldBeingEdited, musicSwitch, soundSwitch, altDamageSwitch;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    14
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    15
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    16
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    17
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    18
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    19
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    20
#pragma mark -
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    21
#pragma mark textfield methods
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    22
// return to previous table
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    23
-(void) cancel:(id) sender {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    24
    if (textFieldBeingEdited != nil)
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    25
        [self.textFieldBeingEdited resignFirstResponder];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    26
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    27
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    28
// set the new value
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    29
-(BOOL) save:(id) sender {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    30
    if (textFieldBeingEdited != nil) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    31
        if (textFieldBeingEdited.tag == 0) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    32
            [self.settingsDictionary setObject:textFieldBeingEdited.text forKey:@"username"];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    33
        } else {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    34
            [self.settingsDictionary setObject:textFieldBeingEdited.text forKey:@"password"];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    35
        }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    36
        
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    37
        isWriteNeeded = YES;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    38
        [self.textFieldBeingEdited resignFirstResponder];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    39
        return YES;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    40
    }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    41
    return NO;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    42
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    43
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    44
// the textfield is being modified, update the navigation controller
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    45
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{   
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    46
    self.textFieldBeingEdited = aTextField;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    47
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from the settings table")
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    48
                                                                     style:UIBarButtonItemStylePlain
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    49
                                                                    target:self
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    50
                                                                    action:@selector(cancel:)];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    51
    self.navigationItem.leftBarButtonItem = cancelButton;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    52
    [cancelButton release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    53
    
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    54
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from the settings table")
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    55
                                                                     style:UIBarButtonItemStyleDone
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    56
                                                                    target:self
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    57
                                                                    action:@selector(save:)];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    58
    self.navigationItem.rightBarButtonItem = saveButton;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    59
    [saveButton release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    60
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    61
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    62
// we save every time a textfield is edited, so we don't risk to update only the hogs or only the temname 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    63
-(BOOL) textFieldShouldEndEditing:(UITextField *)aTextField {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    64
    return [self save:nil];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    65
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    66
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    67
// the textfield has been modified, check for empty strings and restore original navigation bar
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    68
-(void) textFieldDidEndEditing:(UITextField *)aTextField{
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    69
    self.textFieldBeingEdited = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    70
    self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    71
    self.navigationItem.leftBarButtonItem = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    72
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    73
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    74
// limit the size of the field to 64 characters like in original frontend
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    75
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    76
    int limit = 64;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    77
    return !([textField.text length] > limit && [string length] > range.length);
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    78
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    79
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    80
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    81
#pragma mark -
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    82
#pragma mark View Lifecycle
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    83
-(void) viewDidLoad {
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    84
	[super viewDidLoad];
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    85
    self.musicSwitch = [[UISwitch alloc] init];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    86
	self.soundSwitch = [[UISwitch alloc] init];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    87
	self.altDamageSwitch = [[UISwitch alloc] init];
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    88
	[self.soundSwitch addTarget:self action:@selector(alsoTurnOffMusic:) forControlEvents:UIControlEventValueChanged];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    89
	[self.musicSwitch addTarget:self action:@selector(dontTurnOnMusic:) forControlEvents:UIControlEventValueChanged];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    90
	[self.altDamageSwitch addTarget:self action:@selector(justUpdateDictionary:) forControlEvents:UIControlEventValueChanged];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    91
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    92
    NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"];
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    93
    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    94
    self.settingsDictionary = dictionary;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    95
    [dictionary release];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    96
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    97
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
    98
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
    99
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   100
-(void) viewWillAppear:(BOOL)animated {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   101
    [self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   102
    isWriteNeeded = NO;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   103
    
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   104
    musicSwitch.on = [[settingsDictionary objectForKey:@"music"] boolValue];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   105
    soundSwitch.on = [[settingsDictionary objectForKey:@"sound"] boolValue];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   106
    altDamageSwitch.on = [[settingsDictionary objectForKey:@"alternate"] boolValue];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   107
    
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   108
    [super viewWillAppear:animated];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   109
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   110
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   111
-(void) viewWillDisappear:(BOOL)animated {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   112
    [super viewWillDisappear:animated];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   113
    
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   114
    if (isWriteNeeded) {
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   115
       	NSLog(@"writing preferences to file");
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   116
        [self.settingsDictionary writeToFile:[[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"] atomically:YES];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   117
        isWriteNeeded = NO;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   118
    }
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   119
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   120
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   121
#pragma mark -
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   122
// if the sound system is off, turn off also the background music 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   123
-(void) alsoTurnOffMusic:(id) sender {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   124
    [self.settingsDictionary setObject:[NSNumber numberWithBool:soundSwitch.on] forKey:@"sound"];
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   125
	if (YES == self.musicSwitch.on) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   126
		[musicSwitch setOn:NO animated:YES];
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   127
        [self.settingsDictionary setObject:[NSNumber numberWithBool:musicSwitch.on] forKey:@"music"];
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   128
	}
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   129
    isWriteNeeded = YES;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   130
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   131
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   132
// if the sound system is off, don't enable background music 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   133
-(void) dontTurnOnMusic:(id) sender {
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   134
	if (NO == self.soundSwitch.on) {
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   135
		[musicSwitch setOn:NO animated:YES];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   136
	} else {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   137
        [self.settingsDictionary setObject:[NSNumber numberWithBool:musicSwitch.on] forKey:@"music"];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   138
        isWriteNeeded = YES;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   139
    }
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   140
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   141
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   142
-(void) justUpdateDictionary:(id) sender {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   143
    UISwitch *theSwitch = (UISwitch *)sender;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   144
    [self.settingsDictionary setObject:[NSNumber numberWithBool:theSwitch.on] forKey:@"alternate"];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   145
    isWriteNeeded = YES;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   146
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   147
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   148
/*
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   149
#pragma mark -
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   150
#pragma mark UIActionSheet Methods
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   151
-(IBAction) deleteData: (id)sender {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   152
	UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you reeeeeally sure?", @"")
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   153
								 delegate:self
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   154
							cancelButtonTitle:NSLocalizedString(@"Well, maybe not...", @"")
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   155
						   destructiveButtonTitle:NSLocalizedString(@"As sure as I can be!", @"")
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   156
							otherButtonTitles:nil];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   157
	[actionSheet showInView:self.view];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   158
	[actionSheet release];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   159
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   160
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   161
-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   162
	if ([actionSheet cancelButtonIndex] != buttonIndex) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   163
		// get the documents dirctory
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   164
		NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   165
		NSString *documentsDirectory = [paths objectAtIndex:0];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   166
		
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   167
		// get the content of the directory
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   168
		NSFileManager *fm = [NSFileManager defaultManager];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   169
		NSArray *dirContent = [fm directoryContentsAtPath:documentsDirectory];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   170
		NSError *error;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   171
		
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   172
		// delete data
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   173
		for (NSString *fileName in dirContent) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   174
			[fm removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:fileName] error:&error];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   175
		}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   176
		
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   177
		// force resetting
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   178
		UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Hit Home Button to Exit", @"")
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   179
								  message:NSLocalizedString(@"\nEverything is gone!\nNow you need to restart the game...", @"")
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   180
								 delegate:self
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   181
							cancelButtonTitle:nil
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   182
							otherButtonTitles:nil];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   183
		[anAlert show];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   184
		[anAlert release];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   185
	}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   186
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   187
*/
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   188
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   189
#pragma mark -
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   190
#pragma mark TableView Methods
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   191
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   192
	return 3;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   193
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   194
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   195
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   196
	switch (section) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   197
		case kNetworkFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   198
			return 2;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   199
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   200
		case kAudioFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   201
			return 2;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   202
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   203
		case kOtherFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   204
			return 1;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   205
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   206
		default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   207
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   208
	}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   209
	return 0;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   210
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   211
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   212
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   213
	static NSString *cellIdentifier = @"systemSettingsCell";
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   214
	NSInteger row = [indexPath row];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   215
    NSInteger section = [indexPath section];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   216
    
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   217
	UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   218
    if (nil == cell) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   219
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   220
        if (section == kNetworkFields) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   221
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(-15, 10, 100, 25)];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   222
            label.textAlignment = UITextAlignmentRight;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   223
            label.backgroundColor = [UIColor clearColor];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   224
            label.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   225
            if (row == 0) 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   226
                label.text = NSLocalizedString(@"Nickname","from the settings table");
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   227
            else 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   228
                label.text = NSLocalizedString(@"Password","from the settings table");
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   229
            [cell.contentView addSubview:label];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   230
            [label release];
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   231
            
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   232
            UITextField *aTextField = [[UITextField alloc] initWithFrame:
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   233
                                       CGRectMake(110, 12, (cell.frame.size.width + cell.frame.size.width/3) - 90, 25)];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   234
            aTextField.clearsOnBeginEditing = NO;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   235
            aTextField.returnKeyType = UIReturnKeyDone;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   236
            aTextField.adjustsFontSizeToFitWidth = YES;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   237
            aTextField.delegate = self;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   238
            aTextField.tag = row;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   239
            aTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   240
            [aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   241
            [cell.contentView addSubview:aTextField];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   242
            [aTextField release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   243
        }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   244
    }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   245
    
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   246
    cell.accessoryType = UITableViewCellAccessoryNone;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   247
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   248
    cell.imageView.image = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   249
    
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   250
    UITextField *aTextField;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   251
    switch (section) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   252
        case kNetworkFields:
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   253
            for (UIView *oneView in cell.contentView.subviews) 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   254
                if ([oneView isMemberOfClass:[UITextField class]]) 
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   255
                    aTextField = (UITextField *)oneView;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   256
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   257
            switch (row) {
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   258
				case 0:                    
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   259
                    aTextField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"");
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   260
                    aTextField.text = [self.settingsDictionary objectForKey:@"username"];
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   261
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   262
				case 1:                    
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   263
                    aTextField.placeholder = NSLocalizedString(@"Insert your password",@"");
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   264
                    aTextField.text = [self.settingsDictionary objectForKey:@"password"];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   265
                    aTextField.secureTextEntry = YES;
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   266
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   267
				default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   268
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   269
			}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   270
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   271
            
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   272
		case kAudioFields:
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   273
			switch (row) {
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   274
				case 0:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   275
					cell.textLabel.text = NSLocalizedString(@"Sound", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   276
					cell.accessoryView = soundSwitch;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   277
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   278
				case 1:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   279
					cell.textLabel.text = NSLocalizedString(@"Music", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   280
					cell.accessoryView = musicSwitch;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   281
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   282
				default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   283
					break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   284
			}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   285
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   286
            
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   287
		case kOtherFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   288
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   289
			cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   290
			cell.accessoryView = altDamageSwitch;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   291
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   292
		default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   293
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   294
	}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   295
	return cell;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   296
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   297
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   298
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   299
    NSString *sectionTitle = nil;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   300
    switch (section) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   301
		case kNetworkFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   302
			sectionTitle = NSLocalizedString(@"Network Configuration", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   303
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   304
		case kAudioFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   305
			sectionTitle = NSLocalizedString(@"Audio Preferences", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   306
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   307
		case kOtherFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   308
			sectionTitle = NSLocalizedString(@"Other Settings", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   309
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   310
		default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   311
			NSLog(@"Nope");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   312
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   313
	}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   314
    return sectionTitle;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   315
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   316
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   317
/*
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   318
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   319
	UIView *containerView =	[[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)] autorelease];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   320
	UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 20, 300, 40)] autorelease];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   321
	headerLabel.textColor = [UIColor lightGrayColor];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   322
	headerLabel.shadowColor = [UIColor blackColor];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   323
	headerLabel.shadowOffset = CGSizeMake(0, 1);
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   324
	headerLabel.font = [UIFont boldSystemFontOfSize:20];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   325
	headerLabel.backgroundColor = [UIColor clearColor];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   326
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   327
	switch (section) {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   328
		case kNetworkFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   329
			headerLabel.text = NSLocalizedString(@"Network Configuration", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   330
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   331
		case kAudioFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   332
			headerLabel.text = NSLocalizedString(@"Audio Preferences", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   333
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   334
		case kOtherFields:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   335
			headerLabel.text = NSLocalizedString(@"Other Settings", @"");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   336
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   337
		default:
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   338
			NSLog(@"Warning: unset case value in titleForHeaderInSection!");
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   339
			headerLabel.text = @"!";
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   340
			break;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   341
	}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   342
	
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   343
	[containerView addSubview:headerLabel];
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   344
	return containerView;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   345
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   346
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   347
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   348
	if (kAudioFields == [indexPath section] && 2 == [indexPath row])
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   349
		return volumeCell.frame.size.height;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   350
	else
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   351
		return table.rowHeight;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   352
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   353
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   354
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   355
	return 57.0;
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   356
}
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   357
*/
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   358
3332
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   359
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   360
#pragma mark -
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   361
#pragma mark Table view delegate
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   362
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   363
    UITableViewCell *cell;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   364
    if (kNetworkFields == [indexPath section]) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   365
        cell = [aTableView cellForRowAtIndexPath:indexPath];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   366
        for (UIView *oneView in cell.contentView.subviews) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   367
            if ([oneView isMemberOfClass:[UITextField class]]) {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   368
                textFieldBeingEdited = (UITextField *)oneView;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   369
                [textFieldBeingEdited becomeFirstResponder];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   370
            }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   371
        }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   372
        [aTableView deselectRowAtIndexPath:indexPath animated:NO];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   373
    }
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   374
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   375
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   376
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   377
#pragma mark -
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   378
#pragma mark Memory management
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   379
-(void) didReceiveMemoryWarning {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   380
    // Releases the view if it doesn't have a superview.
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   381
    [super didReceiveMemoryWarning];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   382
    // Relinquish ownership any cached data, images, etc that aren't in use.
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   383
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   384
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   385
-(void) viewDidUnload {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   386
    self.settingsDictionary = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   387
	self.textFieldBeingEdited = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   388
	self.musicSwitch = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   389
	self.soundSwitch = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   390
	self.altDamageSwitch = nil;
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   391
	[super viewDidUnload];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   392
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   393
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   394
-(void) dealloc {
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   395
    [settingsDictionary release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   396
	[textFieldBeingEdited release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   397
	[musicSwitch release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   398
	[soundSwitch release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   399
	[altDamageSwitch release];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   400
	[super dealloc];
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   401
}
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   402
3c90a923f156 simplify the general settings and review minor stuff
koda
parents: 3312
diff changeset
   403
3312
6d8f1c76756d restore and update the old general settings
koda
parents:
diff changeset
   404
@end