cocoaTouch/SettingsViewController.m
author koda
Sat, 23 Jan 2010 13:15:27 +0000
changeset 2701 3a8560c00f78
parent 2698 90585aba87ad
child 2702 48fc46a922fd
permissions -rw-r--r--
settings tab has now a very nice iphone-like interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     1
//
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     2
//  SettingsViewController.m
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     3
//  hwengine
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     4
//
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     5
//  Created by Vittorio on 08/01/10.
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     7
//
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     8
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
     9
#import "SettingsViewController.h"
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    10
#import "SDL_uikitappdelegate.h"
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    11
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    12
@implementation SettingsViewController
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    13
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    14
@synthesize username, password, musicSwitch, effectsSwitch, altDamageSwitch, volumeSlider, volumeLabel, table, volumeCell;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    15
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    16
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    17
-(void) loadView {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    18
	self.musicSwitch = [[UISwitch alloc] init];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    19
	self.effectsSwitch = [[UISwitch alloc] init];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    20
	self.altDamageSwitch = [[UISwitch alloc] init];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    21
	[super loadView];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    22
}
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    23
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    24
-(void) viewDidLoad {
2698
90585aba87ad objc/pascal finally working
koda
parents: 2696
diff changeset
    25
	NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    26
	
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    27
	if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {	
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    28
		NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    29
		username.text = [data objectForKey:@"username"];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    30
		password.text = [data objectForKey:@"password"];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    31
		if (1 == [[data objectForKey:@"music"] intValue]) {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    32
			musicSwitch.on = YES;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    33
		} else {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    34
			musicSwitch.on = NO;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    35
		}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    36
		if (1 == [[data objectForKey:@"effects"] intValue]) {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    37
			effectsSwitch.on = YES;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    38
		} else {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    39
			effectsSwitch.on = NO;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    40
		}
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    41
		if (1 == [[data objectForKey:@"alternate"] intValue]) {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    42
			altDamageSwitch.on = YES;
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    43
		} else {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    44
			altDamageSwitch.on = NO;
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    45
		}		
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    46
		
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    47
		[volumeSlider setValue:[[data objectForKey:@"volume"] intValue] animated:NO];
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    48
		[data release];
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    49
	} else {
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    50
		[NSException raise:@"File NOT found" format:@"The file settings.plist was not found at %@", filePath];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    51
	}
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    52
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    53
	NSString *tmpVol = [[NSString alloc] initWithFormat:@"%d", (int) volumeSlider.value];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    54
	volumeLabel.text = tmpVol;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    55
	[tmpVol release];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    56
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    57
	username.textColor = [UIColor grayColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    58
	password.textColor = [UIColor grayColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    59
	volumeLabel.textColor = [UIColor grayColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    60
	table.backgroundColor = [UIColor clearColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    61
	table.allowsSelection = NO;
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
    62
	[super viewDidLoad];
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    63
}
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    64
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    65
-(void) viewDidUnload {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    66
	self.username = nil;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    67
	self.password = nil;
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    68
	self.musicSwitch = nil;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    69
	self.effectsSwitch = nil;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    70
	self.altDamageSwitch = nil;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    71
	self.volumeLabel = nil;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    72
	self.volumeSlider = nil;
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    73
	self.table = nil;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    74
	self.volumeCell = nil;
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    75
	[super viewDidUnload];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    76
}
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    77
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    78
//- (void)applicationWillTerminate:(NSNotification *)notification {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    79
-(void) viewWillDisappear:(BOOL)animated {
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    80
	NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    81
	NSString *tmpMus = (musicSwitch.on) ? @"1" : @"0";
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    82
	NSString *tmpEff = (effectsSwitch.on) ? @"1" : @"0";
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    83
	NSString *tmpAlt = (altDamageSwitch.on) ? @"1" : @"0";
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    84
	
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    85
	[saveDict setObject:username.text forKey:@"username"];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    86
	[saveDict setObject:password.text forKey:@"password"];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    87
	[saveDict setObject:tmpMus forKey:@"music"];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    88
	[saveDict setObject:tmpEff forKey:@"effects"];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    89
	[saveDict setObject:tmpAlt forKey:@"alternate"];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    90
	[saveDict setObject:volumeLabel.text forKey:@"volume"];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    91
	
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    92
	[saveDict writeToFile:[[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"] atomically:YES];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
    93
	[saveDict release];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    94
	[super viewWillDisappear:animated];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    95
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
    96
 
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    97
/*
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    98
// Override to allow orientations other than the default portrait orientation.
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
    99
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   100
    // Return YES for supported orientations
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   101
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   102
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   103
*/
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   104
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   105
// makes the keyboard go away when background is tapped
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   106
-(IBAction) backgroundTap: (id)sender {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   107
	[username resignFirstResponder];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   108
	[password resignFirstResponder];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   109
}
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   110
2696
41aa7b56c17b settings are applied to game launch
koda
parents: 2694
diff changeset
   111
// makes the keyboard go away when "Done" is tapped
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   112
-(IBAction) textFieldDoneEditing: (id)sender {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   113
	[sender resignFirstResponder];
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   114
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   115
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   116
-(IBAction) sliderChanged: (id) sender {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   117
	UISlider *slider = (UISlider *)sender;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   118
	int progress = slider.value;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   119
	NSString *newLabel = [[NSString alloc] initWithFormat:@"%d",progress];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   120
	self.volumeLabel.text = newLabel;
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   121
	[newLabel release];
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   122
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   123
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   124
-(void) dealloc {
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   125
	[username release];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   126
	[password release];
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   127
	[musicSwitch release];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   128
	[effectsSwitch release];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   129
	[altDamageSwitch release];
2694
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   130
	[volumeLabel release];
dcd248e04f3d can use latest sdlimage, work on setting panel and option when launching the game, minor fixes
koda
parents: 2687
diff changeset
   131
	[volumeSlider release];
2701
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   132
	[table release];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   133
	[volumeCell release];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   134
	[super dealloc];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   135
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   136
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   137
#pragma mark -
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   138
#pragma mark TableView Methods
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   139
#define kNetworkFields 0
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   140
#define kAudioFields 1
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   141
#define kOtherFields 2
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   142
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   143
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   144
	return 3;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   145
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   146
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   147
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   148
	switch (section) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   149
		case kNetworkFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   150
			return 2;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   151
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   152
		case kAudioFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   153
			return 3;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   154
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   155
		case kOtherFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   156
			return 1;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   157
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   158
		default:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   159
			NSLog(@"Warning: unset case value for numberOfRowsInSection!");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   160
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   161
	}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   162
	return 0;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   163
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   164
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   165
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   166
	static NSString *cellIdentifier = @"systemSettingsCell";
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   167
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   168
	UITableViewCell *cell;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   169
	if ( !(kAudioFields == [indexPath section] && 2 == [indexPath row]) ){
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   170
		cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   171
		if (nil == cell) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   172
			cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   173
						       reuseIdentifier:cellIdentifier] autorelease];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   174
		}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   175
	}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   176
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   177
	switch ([indexPath section]) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   178
		case kNetworkFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   179
			switch ([indexPath row]) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   180
				case 0:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   181
					cell.textLabel.text = NSLocalizedString(@"Nickname", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   182
					cell.accessoryView = username;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   183
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   184
				case 1:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   185
					cell.textLabel.text = NSLocalizedString(@"Password", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   186
					cell.accessoryView = password;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   187
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   188
				default:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   189
					NSLog(@"Warning: unset case value in kNetworkFields section!");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   190
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   191
			}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   192
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   193
		case kAudioFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   194
			switch ([indexPath row]) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   195
				case 0:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   196
					cell.accessoryView = musicSwitch;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   197
					cell.textLabel.text = NSLocalizedString(@"Music", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   198
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   199
				case 1:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   200
					cell.accessoryView = effectsSwitch;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   201
					cell.textLabel.text = NSLocalizedString(@"Sound Effects", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   202
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   203
				case 2:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   204
					cell = volumeCell;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   205
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   206
				default:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   207
					NSLog(@"Warning: unset case value in kAudioFields section!");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   208
					break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   209
			}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   210
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   211
		case kOtherFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   212
			cell.accessoryView = altDamageSwitch;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   213
			cell.textLabel.text = NSLocalizedString(@"Alternate Damage", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   214
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   215
		default:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   216
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   217
	}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   218
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   219
	return cell;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   220
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   221
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   222
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   223
	UIView *containerView =	[[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)] autorelease];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   224
	UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10, 20, 300, 40)] autorelease];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   225
	headerLabel.textColor = [UIColor lightGrayColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   226
	headerLabel.shadowColor = [UIColor blackColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   227
	headerLabel.shadowOffset = CGSizeMake(0, 1);
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   228
	headerLabel.font = [UIFont boldSystemFontOfSize:20];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   229
	headerLabel.backgroundColor = [UIColor clearColor];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   230
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   231
	switch (section) {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   232
		case kNetworkFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   233
			headerLabel.text = NSLocalizedString(@"Network Configuration", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   234
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   235
		case kAudioFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   236
			headerLabel.text = NSLocalizedString(@"Audio Preferences", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   237
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   238
		case kOtherFields:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   239
			headerLabel.text = NSLocalizedString(@"Other Settings", @"");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   240
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   241
		default:
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   242
			NSLog(@"Warning: unset case value in titleForHeaderInSection!");
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   243
			headerLabel.text = @"!!!";
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   244
			break;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   245
	}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   246
	
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   247
	[containerView addSubview:headerLabel];
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   248
	return containerView;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   249
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   250
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   251
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   252
	if (kAudioFields == [indexPath section] && 2 == [indexPath row])
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   253
		return volumeCell.frame.size.height;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   254
	else
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   255
		return table.rowHeight;
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   256
}
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   257
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   258
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
3a8560c00f78 settings tab has now a very nice iphone-like interface
koda
parents: 2698
diff changeset
   259
	return 57;
2687
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   260
}
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   261
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   262
28b8330b8af1 add stub files for other views and prevent useless crashes
koda
parents:
diff changeset
   263
@end