initial support for game modifiers (schemes)
authorkoda
Sun, 23 May 2010 22:05:59 +0000
changeset 3479 972ae3ec178a
parent 3478 cbf71e938164
child 3480 c4c3f3512404
initial support for game modifiers (schemes)
cocoaTouch/GameSetup.h
cocoaTouch/GameSetup.m
cocoaTouch/MainMenuViewController.m
cocoaTouch/OverlayViewController.m
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
cocoaTouch/SchemeSettingsViewController.h
cocoaTouch/SchemeSettingsViewController.m
cocoaTouch/SingleSchemeViewController.h
cocoaTouch/SingleSchemeViewController.m
cocoaTouch/SingleTeamViewController.m
cocoaTouch/TeamSettingsViewController.m
cocoaTouch/otherSrc/CommodityFunctions.h
cocoaTouch/otherSrc/CommodityFunctions.m
cocoaTouch/otherSrc/SquareButtonView.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/cocoaTouch/GameSetup.h	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/GameSetup.h	Sun May 23 22:05:59 2010 +0000
@@ -21,10 +21,11 @@
 @property (nonatomic, retain) NSDictionary *gameConfig;
 
 -(void) engineProtocol;
--(void) startThread: (NSString *)selector;
--(int)  sendToEngine: (NSString *)string;
--(void) sendTeamData:(NSString *)fileName withPlayingHogs:(NSInteger) playingHogs ofColor:(NSNumber *)color;
--(void) sendAmmoData:(NSDictionary *)ammoData forTeams: (NSInteger)numberPlaying;
+-(void) startThread:(NSString *)selector;
+-(int)  sendToEngine:(NSString *)string;
+-(void) provideTeamData:(NSString *)teamName forHogs:(NSInteger) numberOfPlayingHogs withHealth:(NSInteger) initialHealth ofColor:(NSNumber *)teamColor;
+-(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams;
+-(NSInteger) provideScheme:(NSString *)schemeName;
 
 -(const char **)getSettings;
 
--- a/cocoaTouch/GameSetup.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Sun May 23 22:05:59 2010 +0000
@@ -58,19 +58,26 @@
 
 // wrapper that computes the length of the message and then sends the command string
 -(int) sendToEngine: (NSString *)string {
-	unsigned char length = [string length];
+	uint8_t length = [string length];
 	
 	SDLNet_TCP_Send(csd, &length , 1);
 	return SDLNet_TCP_Send(csd, [string UTF8String], length);
 }
 
-// unpacks team data from the team.plist to a sequence of commands for engine
--(void) sendTeamData:(NSString *)fileName withPlayingHogs:(NSInteger) playingHogs ofColor:(NSNumber *)color{    
-    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@", TEAMS_DIRECTORY(), fileName];
+// unpacks team data from the selected team.plist to a sequence of engine commands
+-(void) provideTeamData:(NSString *)teamName forHogs:(NSInteger) numberOfPlayingHogs withHealth:(NSInteger) initialHealth ofColor:(NSNumber *)teamColor {
+    /*
+     addteam <32charsMD5hash> <color> <team name>
+     addhh <level> <health> <hedgehog name>
+     <level> is 0 for human, 1-5 for bots (5 is the most stupid)
+    */
+    
+    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@", TEAMS_DIRECTORY(), teamName];
     NSDictionary *teamData = [[NSDictionary alloc] initWithContentsOfFile:teamFile];
     [teamFile release];
     
-    NSString *teamHashColorAndName = [[NSString alloc] initWithFormat:@"eaddteam %@ %@ %@", [teamData objectForKey:@"hash"], [color stringValue], [teamData objectForKey:@"teamname"]];
+    NSString *teamHashColorAndName = [[NSString alloc] initWithFormat:@"eaddteam %@ %@ %@", 
+                                      [teamData objectForKey:@"hash"], [teamColor stringValue], [teamData objectForKey:@"teamname"]];
     [self sendToEngine: teamHashColorAndName];
     [teamHashColorAndName release];
     
@@ -91,10 +98,11 @@
     [flag release];
     
     NSArray *hogs = [teamData objectForKey:@"hedgehogs"];
-    for (int i = 0; i < playingHogs; i++) {
+    for (int i = 0; i < numberOfPlayingHogs; i++) {
         NSDictionary *hog = [hogs objectAtIndex:i];
         
-        NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %@ %@", [hog objectForKey:@"level"], [hog objectForKey:@"health"], [hog objectForKey:@"hogname"]];
+        NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %d %@", 
+                                           [hog objectForKey:@"level"], initialHealth, [hog objectForKey:@"hogname"]];
         [self sendToEngine: hogLevelHealthAndName];
         [hogLevelHealthAndName release];
         
@@ -106,29 +114,124 @@
     [teamData release];
 }
 
-// unpacks ammodata from the ammo.plist to a sequence of commands for engine
--(void) sendAmmoData:(NSDictionary *)ammoData forTeams: (NSInteger)numberPlaying {
+// unpacks ammostore data from the selected ammo.plist to a sequence of engine commands
+-(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams {
+    
+    //NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:ammoDataFile];
+    NSDictionary *ammoData = [[NSDictionary alloc] initWithObjectsAndKeys:
+                              @"9391929422199121032235111001201000000211190911",@"ammostore_initialqt",
+                              @"0405040541600655546554464776576666666155501000",@"ammostore_probability",
+                              @"0000000000000205500000040007004000000000200000",@"ammostore_delay",
+                              @"1311110312111111123114111111111111111211101111",@"ammostore_crate", nil];
+    
+    
     NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@", [ammoData objectForKey:@"ammostore_initialqt"]];
     [self sendToEngine: ammloadt];
     [ammloadt release];
     
-    NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammprob %@", [ammoData objectForKey:@"ammostore_probability"]];
+    NSString *ammprob = [[NSString alloc] initWithFormat:@"eammprob %@", [ammoData objectForKey:@"ammostore_probability"]];
+    [self sendToEngine: ammprob];
+    [ammprob release];
+    
+    NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammdelay %@", [ammoData objectForKey:@"ammostore_delay"]];
     [self sendToEngine: ammdelay];
     [ammdelay release];
     
-    NSString *ammprob = [[NSString alloc] initWithFormat:@"eammdelay %@", [ammoData objectForKey:@"ammostore_delay"]];
-    [self sendToEngine: ammprob];
-    [ammprob release];
-    
     NSString *ammreinf = [[NSString alloc] initWithFormat:@"eammreinf %@", [ammoData objectForKey:@"ammostore_crate"]];
     [self sendToEngine: ammreinf];
     [ammreinf release];
     
     // sent twice so it applies to both teams
     NSString *ammstore = [[NSString alloc] initWithString:@"eammstore"];
-    for (int i = 0; i < numberPlaying; i++)
+    for (int i = 0; i < numberOfTeams; i++)
         [self sendToEngine: ammstore];
     [ammstore release];
+    
+    [ammoData release];
+}
+
+// unpacks scheme data from the selected scheme.plist to a sequence of engine commands
+-(NSInteger) provideScheme:(NSString *)schemeName {
+    NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),schemeName];
+    NSArray *scheme = [[NSArray alloc] initWithContentsOfFile:schemePath];
+    int result = 0;
+    int i = 0;
+    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x01;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x10;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x04;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x08;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x20;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x40;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x80;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x100;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x200;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x400;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x800;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x2000;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x4000;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x8000;    
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x10000;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x20000;
+    if ([[scheme objectAtIndex:i++] boolValue])
+        result |= 0x80000;    
+
+    NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result];
+    [self sendToEngine:flags];
+    [flags release];
+    
+    NSString *dmgMod = [[NSString alloc] initWithFormat:@"e$damagepct %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:dmgMod];
+    [dmgMod release];
+    
+    NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
+    [self sendToEngine:turnTime];
+    [turnTime release];
+    
+    result = [[scheme objectAtIndex:i++] intValue]; // initial health
+    
+    NSString *sdTime = [[NSString alloc] initWithFormat:@"e$sd_turns %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:sdTime];
+    [sdTime release];
+    
+    NSString *crateDrops = [[NSString alloc] initWithFormat:@"e$casefreq %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:crateDrops];
+    [crateDrops release];
+    
+    NSString *minesTime = [[NSString alloc] initWithFormat:@"e$minestime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
+    [self sendToEngine:minesTime];
+    [minesTime release];
+    
+    NSString *minesNumber = [[NSString alloc] initWithFormat:@"e$landadds %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:minesNumber];
+    [minesNumber release];
+    
+
+    NSString *dudMines = [[NSString alloc] initWithFormat:@"e$minedudpct %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:dudMines];
+    [dudMines release];
+    
+    NSString *explosives = [[NSString alloc] initWithFormat:@"e$explosives %d",[[scheme objectAtIndex:i++] intValue]];
+    [self sendToEngine:explosives];
+    [explosives release];
+    
+    return result;
 }
 
 // method that handles net setup with engine and keeps connection alive
@@ -138,8 +241,8 @@
 	int eProto;
 	BOOL clientQuit, serverQuit;
 	char buffer[BUFFER_SIZE], string[BUFFER_SIZE];
-	Uint8 msgSize;
-	Uint16 gameTicks;
+	uint8_t msgSize;
+	uint16_t gameTicks;
 
     serverQuit = NO;
 
@@ -162,7 +265,6 @@
 	
 	NSLog(@"engineProtocol - Waiting for a client on port %d", ipcPort);
 	while (!serverQuit) {
-		
 		// This check the sd if there is a pending connection.
         // If there is one, accept that, and open a new socket for communicating
 		csd = SDLNet_TCP_Accept(sd);
@@ -172,7 +274,7 @@
 			NSLog(@"engineProtocol - Client found");
 			
 			//first byte of the command alwayas contain the size of the command
-			SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8));
+			SDLNet_TCP_Recv(csd, &msgSize, sizeof(uint8_t));
 			
 			SDLNet_TCP_Recv(csd, buffer, msgSize);
 			gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
@@ -181,29 +283,14 @@
 			if ('C' == buffer[0]) {
 				NSLog(@"engineProtocol - sending game config");
                 
-				// send config data data
-				/*
-				seed is arbitrary string
-				addteam <32charsMD5hash> <color> <team name>
-				addhh <level> <health> <hedgehog name>
-				  <level> is 0 for human, 1-5 for bots (5 is the most stupid)
-				*/
 				// local game
 				[self sendToEngine:@"TL"];
 				
 				// seed info
 				[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
 				
-				// various flags
-				[self sendToEngine:@"e$gmflags 256"]; 
-				[self sendToEngine:@"e$damagepct 100"];
-				[self sendToEngine:@"e$turntime 45000"];
-				[self sendToEngine:@"e$minestime 3000"];
-				[self sendToEngine:@"e$landadds 4"];
-				[self sendToEngine:@"e$sd_turns 15"];
-				[self sendToEngine:@"e$casefreq 5"];
-				[self sendToEngine:@"e$explosives 2"];
-				[self sendToEngine:@"e$minedudpct 0"];
+                // scheme (returns initial health)
+                NSInteger health = [self provideScheme:@"testing"];
 
 				// dimension of the map
 				[self sendToEngine:[self.gameConfig objectForKey:@"templatefilter_command"]];
@@ -215,18 +302,13 @@
 				
                 NSArray *teamsConfig = [self.gameConfig objectForKey:@"teams_list"];
                 for (NSDictionary *teamData in teamsConfig) {
-                    [self sendTeamData:[teamData objectForKey:@"team"] 
-                       withPlayingHogs:[[teamData objectForKey:@"number"] intValue]
-                               ofColor:[teamData objectForKey:@"color"]];
+                    [self provideTeamData:[teamData objectForKey:@"team"] 
+                                  forHogs:[[teamData objectForKey:@"number"] intValue]
+                               withHealth:health
+                                  ofColor:[teamData objectForKey:@"color"]];
                 }
                 
-                NSDictionary *ammoData = [[NSDictionary alloc] initWithObjectsAndKeys:
-                                          @"939192942219912103223511100120100000021119091",@"ammostore_initialqt",
-                                          @"040504054160065554655446477657666666615550100",@"ammostore_probability",
-                                          @"000000000000020550000004000700400000000020000",@"ammostore_delay",
-                                          @"131111031211111112311411111111111111121110111",@"ammostore_crate", nil];
-                [self sendAmmoData:ammoData forTeams:[teamsConfig count]];
-                [ammoData release];
+                [self provideAmmoData:nil forPlayingTeams:[teamsConfig count]];
                 
                 clientQuit = NO;
 			} else {
@@ -238,7 +320,7 @@
 				msgSize = 0;
 				memset(buffer, 0, BUFFER_SIZE);
 				memset(string, 0, BUFFER_SIZE);
-				if (SDLNet_TCP_Recv(csd, &msgSize, sizeof(Uint8)) <= 0)
+				if (SDLNet_TCP_Recv(csd, &msgSize, sizeof(uint8_t)) <= 0)
 					clientQuit = YES;
 				if (SDLNet_TCP_Recv(csd, buffer, msgSize) <=0)
 					clientQuit = YES;
--- a/cocoaTouch/MainMenuViewController.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/MainMenuViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -69,6 +69,8 @@
     // create a team
     createTeamNamed(@"Default Team");
     
+    createSchemeNamed(@"testing ftw");
+    
     // create settings.plist
     NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init];
 
--- a/cocoaTouch/OverlayViewController.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/OverlayViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -48,30 +48,24 @@
             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
             [self chatDisappear];
-            [dimTimer setFireDate:HIDING_TIME_DEFAULT];
             HW_setLandscape(YES);
             break;
         case UIDeviceOrientationLandscapeRight:
             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
             [self chatDisappear];
-            [dimTimer setFireDate:HIDING_TIME_DEFAULT];
             HW_setLandscape(YES);
             break;
         case UIDeviceOrientationPortrait:
             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(270));
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
             [self chatAppear];
-            [self activateOverlay];
-            [dimTimer setFireDate:HIDING_TIME_NEVER];
             HW_setLandscape(NO);
             break;
         case UIDeviceOrientationPortraitUpsideDown:
             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
             [self chatAppear];
-            [self activateOverlay];
-            [dimTimer setFireDate:HIDING_TIME_NEVER];
             HW_setLandscape(NO);
             break;
         default:
@@ -98,7 +92,8 @@
         [self.view addSubview:writeChatTextField];
     }
     writeChatTextField.alpha = 1;
-    //[self activateOverlay];
+    [self activateOverlay];
+    [dimTimer setFireDate:HIDING_TIME_NEVER];
 }
 
 -(void) chatDisappear {
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h	Sun May 23 22:05:59 2010 +0000
@@ -30,8 +30,10 @@
     MainMenuViewController *mainViewController;
     BOOL isInGame;
 }
+
 +(SDLUIKitDelegate *)sharedAppDelegate;
 -(void) startSDLgame;
+-(void) displayOverlayLater;
 
 @end
 
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Sun May 23 22:05:59 2010 +0000
@@ -88,9 +88,8 @@
 	const char **gameArgs = [setup getSettings];
 	[setup release];
 
-    //NSLog(@"%@",[[[UIApplication sharedApplication] windows]);
     // since the sdlwindow is not yet created, we add the overlayController with a delay
-    [self performSelector:@selector(later) withObject:nil afterDelay:4];
+    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:4];
     
     // this is the pascal fuction that starts the game (wrapped around isInGame)
     isInGame = YES;
@@ -98,7 +97,6 @@
     isInGame = NO;
     
     free(gameArgs);
-    //[overlayController.view removeFromSuperview];
     
     [UIView beginAnimations:@"inserting main controller" context:NULL];
 	[UIView setAnimationDuration:1];
@@ -106,7 +104,7 @@
 	[UIView commitAnimations];
 }
 
--(void) later {
+-(void) displayOverlayLater {
     // overlay with controls, become visible after 4 seconds, with a transparency effect
     OverlayViewController *overlayController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
     
--- a/cocoaTouch/SchemeSettingsViewController.h	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/SchemeSettingsViewController.h	Sun May 23 22:05:59 2010 +0000
@@ -7,10 +7,13 @@
 //
 
 #import <UIKit/UIKit.h>
-
+@class SingleSchemeViewController;
 
 @interface SchemeSettingsViewController : UITableViewController {
-
+    NSMutableArray *listOfSchemes;
+    SingleSchemeViewController *childController;
 }
 
+@property (nonatomic, retain) NSMutableArray *listOfSchemes;
+
 @end
--- a/cocoaTouch/SchemeSettingsViewController.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/SchemeSettingsViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -7,85 +7,88 @@
 //
 
 #import "SchemeSettingsViewController.h"
-
+#import "CommodityFunctions.h"
+#import "SingleSchemeViewController.h"
 
 @implementation SchemeSettingsViewController
-
-
-#pragma mark -
-#pragma mark Initialization
+@synthesize listOfSchemes;
 
-/*
-- (id)initWithStyle:(UITableViewStyle)style {
-    // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-    if ((self = [super initWithStyle:style])) {
-    }
-    return self;
+-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+    return rotationManager(interfaceOrientation);
 }
-*/
 
 
 #pragma mark -
 #pragma mark View lifecycle
-
-/*
-- (void)viewDidLoad {
+-(void) viewDidLoad {
     [super viewDidLoad];
-
-    // Uncomment the following line to preserve selection between presentations.
-    self.clearsSelectionOnViewWillAppear = NO;
- 
-    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
-    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
-}
-*/
-
-/*
-- (void)viewWillAppear:(BOOL)animated {
-    [super viewWillAppear:animated];
+    
+    UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the scheme panel")
+                                                                   style:UIBarButtonItemStyleBordered
+                                                                  target:self
+                                                                  action:@selector(toggleEdit:)];
+    self.navigationItem.rightBarButtonItem = editButton;
+    [editButton release];
+    
 }
-*/
-/*
-- (void)viewDidAppear:(BOOL)animated {
-    [super viewDidAppear:animated];
-}
-*/
-/*
-- (void)viewWillDisappear:(BOOL)animated {
-    [super viewWillDisappear:animated];
-}
-*/
-/*
-- (void)viewDidDisappear:(BOOL)animated {
-    [super viewDidDisappear:animated];
-}
-*/
 
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
-    // Override to allow orientations other than the default portrait orientation.
-    return YES;
+-(void) viewWillAppear:(BOOL) animated {
+    [super viewWillAppear:animated];
+    
+    NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCHEMES_DIRECTORY() error:NULL];
+    NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES];
+    self.listOfSchemes = array;
+    [array release];
+    
+    [self.tableView reloadData];
 }
 
+// modifies the navigation bar to add the "Add" and "Done" buttons
+-(void) toggleEdit:(id) sender {
+    BOOL isEditing = self.tableView.editing;
+    [self.tableView setEditing:!isEditing animated:YES];
+    
+    if (isEditing) {
+        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the scheme panel")];
+        [self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered];
+        self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
+    } else {
+        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the scheme panel")];
+        [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
+        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the scheme panel")
+                                                                      style:UIBarButtonItemStyleBordered
+                                                                     target:self
+                                                                     action:@selector(addScheme:)];
+        self.navigationItem.leftBarButtonItem = addButton;
+        [addButton release];
+    }
+}
+
+-(void) addScheme:(id) sender {
+    NSString *fileName = [[NSString alloc] initWithFormat:@"Scheme %u.plist", [self.listOfSchemes count]];
+    
+    createSchemeNamed([fileName stringByDeletingPathExtension]);
+    
+    [self.listOfSchemes addObject:fileName];
+    [fileName release];
+    
+    // order the array alphabetically, so schemes will keep their position
+    [self.listOfSchemes sortUsingSelector:@selector(compare:)];
+    
+    [self.tableView reloadData];
+}
 
 #pragma mark -
 #pragma mark Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-    // Return the number of sections.
+-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     return 1;
 }
 
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    // Return the number of rows in the section.
-    return 1;
+-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return [self.listOfSchemes count];
 }
 
-
-// Customize the appearance of table view cells.
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-    
+-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *CellIdentifier = @"Cell";
     
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
@@ -93,84 +96,60 @@
         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
     }
     
-    // Configure the cell...
+    NSUInteger row = [indexPath row]; 
+    NSString *rowString = [[self.listOfSchemes objectAtIndex:row] stringByDeletingPathExtension]; 
+    cell.textLabel.text = rowString; 
+    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
     
     return cell;
 }
 
-
-/*
-// Override to support conditional editing of the table view.
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
-    // Return NO if you do not want the specified item to be editable.
-    return YES;
-}
-*/
-
-
-/*
-// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+// delete the row and the file
+-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+    NSUInteger row = [indexPath row];
     
-    if (editingStyle == UITableViewCellEditingStyleDelete) {
-        // Delete the row from the data source
-        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
-    }   
-    else if (editingStyle == UITableViewCellEditingStyleInsert) {
-        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
-    }   
+    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),[self.listOfSchemes objectAtIndex:row]];
+    [[NSFileManager defaultManager] removeItemAtPath:schemeFile error:NULL];
+    [schemeFile release];
+    
+    [self.listOfSchemes removeObjectAtIndex:row];
+    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
 }
-*/
-
-
-/*
-// Override to support rearranging the table view.
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
-}
-*/
-
-
-/*
-// Override to support conditional rearranging of the table view.
-- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
-    // Return NO if you do not want the item to be re-orderable.
-    return YES;
-}
-*/
-
 
 #pragma mark -
 #pragma mark Table view delegate
 
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    // Navigation logic may go here. Create and push another view controller.
-	/*
-	 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
-     // ...
-     // Pass the selected object to the new view controller.
-	 [self.navigationController pushViewController:detailViewController animated:YES];
-	 [detailViewController release];
-	 */
+-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    if (childController == nil) {
+        childController = [[SingleSchemeViewController alloc] initWithStyle:UITableViewStyleGrouped];
+    }
+    
+    NSInteger row = [indexPath row];
+    NSString *selectedSchemeFile = [self.listOfSchemes objectAtIndex:row];
+    
+    // this must be set so childController can load the correct plist
+    childController.title = [selectedSchemeFile stringByDeletingPathExtension];
+    [childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
+
+    [self.navigationController pushViewController:childController animated:YES];
 }
 
 
 #pragma mark -
 #pragma mark Memory management
-
-- (void)didReceiveMemoryWarning {
-    // Releases the view if it doesn't have a superview.
+-(void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
-    
-    // Relinquish ownership any cached data, images, etc that aren't in use.
 }
 
-- (void)viewDidUnload {
-    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
-    // For example: self.myOutlet = nil;
+-(void) viewDidUnload {
+    self.listOfSchemes = nil;
+    childController = nil;
 }
 
 
-- (void)dealloc {
+-(void) dealloc {
+    [self.listOfSchemes release];
+    [childController release];
     [super dealloc];
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/SingleSchemeViewController.h	Sun May 23 22:05:59 2010 +0000
@@ -0,0 +1,25 @@
+//
+//  SingleSchemeViewController.h
+//  Hedgewars
+//
+//  Created by Vittorio on 23/05/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface SingleSchemeViewController : UITableViewController <UITextFieldDelegate> {
+    UITextField *textFieldBeingEdited;
+    NSMutableArray *schemeArray;
+    
+    NSArray *basicSettingList;
+    NSArray *gameModifierArray;
+}
+
+@property (nonatomic, retain) UITextField *textFieldBeingEdited;
+@property (nonatomic, retain) NSMutableArray *schemeArray;
+@property (nonatomic, retain) NSArray *basicSettingList;
+@property (nonatomic, retain) NSArray *gameModifierArray;
+
+@end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/SingleSchemeViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -0,0 +1,317 @@
+//
+//  SingleSchemeViewController.m
+//  Hedgewars
+//
+//  Created by Vittorio on 23/05/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "SingleSchemeViewController.h"
+#import <QuartzCore/QuartzCore.h>
+#import "CommodityFunctions.h"
+#import "UIImageExtra.h"
+
+@implementation SingleSchemeViewController
+@synthesize textFieldBeingEdited, schemeArray, basicSettingList, gameModifierArray;
+
+-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
+	return rotationManager(interfaceOrientation);
+}
+
+#pragma mark -
+#pragma mark View lifecycle
+-(void) viewDidLoad {
+    [super viewDidLoad];
+
+    NSArray *mods = [[NSArray alloc] initWithObjects:
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Fort Mode",@""),@"title",
+                      NSLocalizedString(@"Defend your fort and destroy the opponents (two team colours max)",@""),@"description",
+                      @"Forts",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Divide Team",@""),@"title",
+                      NSLocalizedString(@"Teams will start on opposite sides of the terrain (two team colours max)",@""),@"description",
+                      @"TeamsDivide",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Solid Land",@""),@"title",
+                      NSLocalizedString(@"Land can not be destroyed",@""),@"description",
+                      @"Solid",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Border",@""),@"title",
+                      NSLocalizedString(@"Add an indestructable border around the terrain",@""),@"description",
+                      @"Border",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Low Gravity",@""),@"title",
+                      NSLocalizedString(@"Lower gravity",@""),@"description",
+                      @"LowGravity",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Laser Sight",@""),@"title",
+                      NSLocalizedString(@"Assisted aiming with laser sight",@""),@"description",
+                      @"LaserSight",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Invulnerable",@""),@"title",
+                      NSLocalizedString(@"All hogs have a personal forcefield",@""),@"description",
+                      @"Invulnerable",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Add Mines",@""),@"title",
+                      NSLocalizedString(@"Enable random mines",@""),@"description",
+                      @"Mines",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Vampirism Mode",@""),@"title",
+                      NSLocalizedString(@"Gain 80% of the damage you do back in health",@""),@"description",
+                      @"Vampiric",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Karma Mode",@""),@"title",
+                      NSLocalizedString(@"Share your opponents pain, share their damage",@""),@"description",
+                      @"Karma",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Artillery Mode",@""),@"title",
+                      NSLocalizedString(@"Your hogs are unable to move, test your aim",@""),@"description",
+                      @"Artillery",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Random Order",@""),@"title",
+                      NSLocalizedString(@"Order of play is random instead of in room order",@""),@"description",
+                      @"RandomOrder",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"King Mode",@""),@"title",
+                      NSLocalizedString(@"Play with a King. If he dies, your side loses",@""),@"description",
+                      @"King",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Place Hedgehogs",@""),@"title",
+                      NSLocalizedString(@"Take turns placing your hedgehogs pre-game",@""),@"description",
+                      @"PlaceHog",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Clan Shares Ammo",@""),@"title",
+                      NSLocalizedString(@"Ammo is shared between all clan teams",@""),@"description",
+                      @"SharedAmmo",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Girders",@""),@"title",
+                      NSLocalizedString(@"Disable girders when generating random maps",@""),@"description",
+                      @"DisableGirders",@"image",nil],
+                     [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Disable Land Objects",@""),@"title",
+                      NSLocalizedString(@"Disable land objects when generating maps",@""),@"description",
+                      @"DisableLandObjects",@"image",nil],
+                     nil];
+    self.gameModifierArray = mods;
+    [mods release];
+    
+    NSArray *basicSettings = [[NSArray alloc] initWithObjects:
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Damage Modifier",@""),@"title",@"Damage",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Turn Time",@""),@"title",@"Time",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Initial Health",@""),@"title",@"Health",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Sudden Death Timeout",@""),@"title",@"SuddenDeath",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Crate Drops",@""),@"title",@"Box",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Time",@""),@"title",@"Time",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Mines Number",@""),@"title",@"Mine",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Dud Mines Probability",@""),@"title",@"Dud",@"image",nil],
+                              [NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Explosives",@""),@"title",@"Damage",@"image",nil],
+                              nil];
+    self.basicSettingList = basicSettings;
+    [basicSettings release];
+}
+
+// load from file
+-(void) viewWillAppear:(BOOL) animated {
+    [super viewWillAppear:animated];
+    
+    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
+	NSMutableArray *scheme = [[NSMutableArray alloc] initWithContentsOfFile:schemeFile];
+    self.schemeArray = scheme;
+    [scheme release];
+	[schemeFile release];
+}
+
+// save to file
+-(void) viewWillDisappear:(BOOL) animated {
+    [super viewWillDisappear:animated];
+    
+    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title];
+    [self.schemeArray writeToFile:schemeFile atomically:YES];
+    [schemeFile release];
+}
+
+#pragma mark -
+#pragma mark textfield methods
+-(void) cancel:(id) sender {
+    if (textFieldBeingEdited != nil)
+        [self.textFieldBeingEdited resignFirstResponder];
+}
+
+// set the new value
+-(BOOL) save:(id) sender {    
+    if (textFieldBeingEdited != nil) {
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] error:NULL];
+        self.title = self.textFieldBeingEdited.text;
+        [self.schemeArray writeToFile:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.title] atomically:YES];
+        [self.textFieldBeingEdited resignFirstResponder];
+        return YES;
+    }
+    return NO;
+}
+
+// the textfield is being modified, update the navigation controller
+-(void) textFieldDidBeginEditing:(UITextField *)aTextField{   
+    self.textFieldBeingEdited = aTextField;
+
+    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"from schemes table")
+                                                                     style:UIBarButtonItemStylePlain
+                                                                    target:self
+                                                                    action:@selector(cancel:)];
+    self.navigationItem.leftBarButtonItem = cancelButton;
+    [cancelButton release];
+    
+    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"from schemes table")
+                                                                     style:UIBarButtonItemStyleDone
+                                                                    target:self
+                                                                    action:@selector(save:)];
+    self.navigationItem.rightBarButtonItem = saveButton;
+    [saveButton release];
+}
+
+// the textfield has been modified, check for empty strings and restore original navigation bar
+-(void) textFieldDidEndEditing:(UITextField *)aTextField{
+    if ([textFieldBeingEdited.text length] == 0) 
+        textFieldBeingEdited.text = [NSString stringWithFormat:@"New Scheme"];
+
+    self.textFieldBeingEdited = nil;
+    self.navigationItem.rightBarButtonItem = self.navigationItem.backBarButtonItem;
+    self.navigationItem.leftBarButtonItem = nil;
+}
+
+// limit the size of the field to 64 characters like in original frontend
+-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    int limit = 64;
+    return !([textField.text length] > limit && [string length] > range.length);
+}
+
+
+#pragma mark -
+#pragma mark Table view data source
+-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
+    return 3;
+}
+
+-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    switch (section) {
+        case 0:
+            return 1;
+            break;
+        case 1:
+            return [self.basicSettingList count];
+            break;
+        case 2:
+            return [self.gameModifierArray count];
+        default:
+            break;
+    }
+    return 0;
+}
+
+-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    static NSString *CellIdentifier0 = @"Cell0";
+    static NSString *CellIdentifier1 = @"Cell1";
+    static NSString *CellIdentifier2 = @"Cell2";
+    
+    UITableViewCell *cell = nil;
+    NSInteger row = [indexPath row];
+    
+    switch ([indexPath section]) {
+        case 0:
+            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
+            if (cell == nil) {
+                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
+                                               reuseIdentifier:CellIdentifier0] autorelease];
+                // create a uitextfield for each row, expand it to take the maximum size
+                UITextField *aTextField = [[UITextField alloc] 
+                                           initWithFrame:CGRectMake(5, 12, (cell.frame.size.width + cell.frame.size.width/3) - 42, 25)];
+                aTextField.clearsOnBeginEditing = NO;
+                aTextField.returnKeyType = UIReturnKeyDone;
+                aTextField.adjustsFontSizeToFitWidth = YES;
+                aTextField.delegate = self;
+                aTextField.tag = [indexPath row];
+                aTextField.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
+                aTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
+                [aTextField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
+                [cell.contentView addSubview:aTextField];
+                [aTextField release];
+            }
+            
+            for (UIView *oneView in cell.contentView.subviews) {
+                if ([oneView isMemberOfClass:[UITextField class]]) {
+                    // we find the uitextfied and we'll use its tag to understand which one is being edited
+                    UITextField *textFieldFound = (UITextField *)oneView;
+                    textFieldFound.text = self.title;
+                }
+            }
+            cell.detailTextLabel.text = nil;
+            cell.imageView.image = nil;
+            break;
+        case 1:
+            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
+            if (cell == nil) {
+                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
+                                               reuseIdentifier:CellIdentifier1] autorelease];
+            }
+            
+            UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]];
+            cell.imageView.image = [img scaleToSize:CGSizeMake(40, 40)];
+            [img release];
+            cell.textLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
+            cell.detailTextLabel.text = nil;
+            break;
+        case 2:
+            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
+            if (cell == nil) {
+                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
+                                               reuseIdentifier:CellIdentifier2] autorelease];
+                UISwitch *onOff = [[UISwitch alloc] init];
+                onOff.tag = row;
+                [onOff addTarget:self action:@selector(toggleSwitch:) forControlEvents:UIControlEventValueChanged];
+                cell.accessoryView = onOff;
+                [onOff release];
+            }
+            
+            UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
+            cell.imageView.image = image;
+            [image release];
+            [cell.imageView.layer setCornerRadius:7.0f];
+            [cell.imageView.layer setMasksToBounds:YES];
+            cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
+            cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
+            [(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
+        }
+    
+    return cell;
+}
+
+-(void) toggleSwitch:(id) sender {
+    UISwitch *theSwitch = (UISwitch *)sender;
+    [self.schemeArray replaceObjectAtIndex:theSwitch.tag withObject:[NSNumber numberWithBool:theSwitch.on]];
+}
+
+
+#pragma mark -
+#pragma mark Table view delegate
+-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    if ([indexPath section] == 0) {
+        UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
+        for (UIView *oneView in cell.contentView.subviews) {
+            if ([oneView isMemberOfClass:[UITextField class]]) {
+                textFieldBeingEdited = (UITextField *)oneView;
+                [textFieldBeingEdited becomeFirstResponder];
+            }
+        }
+    }
+    [aTableView deselectRowAtIndexPath:indexPath animated:YES];
+}
+
+
+#pragma mark -
+#pragma mark Memory management
+-(void) didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+}
+
+-(void) viewDidUnload {
+    self.textFieldBeingEdited = nil;
+    self.schemeArray = nil;
+    self.basicSettingList = nil;
+    self.gameModifierArray = nil;
+}
+
+-(void) dealloc {
+    [textFieldBeingEdited release];
+    [schemeArray release];
+    [basicSettingList release];
+    [gameModifierArray release];
+    [super dealloc];
+}
+
+
+@end
+
--- a/cocoaTouch/SingleTeamViewController.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/SingleTeamViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -29,7 +29,6 @@
 
 #pragma mark -
 #pragma mark textfield methods
-// return to previous table
 -(void) cancel:(id) sender {
     if (textFieldBeingEdited != nil)
         [self.textFieldBeingEdited resignFirstResponder];
--- a/cocoaTouch/TeamSettingsViewController.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/TeamSettingsViewController.m	Sun May 23 22:05:59 2010 +0000
@@ -25,7 +25,7 @@
 -(void) viewDidLoad {
     [super viewDidLoad];
 
-    UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the team navigation")
+    UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the team panel")
                                                                    style:UIBarButtonItemStyleBordered
                                                                   target:self
                                                                   action:@selector(toggleEdit:)];
@@ -51,13 +51,13 @@
     [self.tableView setEditing:!isEditing animated:YES];
     
     if (isEditing) {
-        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the team navigation")];
+        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the team panel")];
         [self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered];
         self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
     } else {
-        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the team navigation")];
+        [self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Done",@"from the team panel")];
         [self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
-        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the team navigation")
+        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Add",@"from the team panel")
                                                                       style:UIBarButtonItemStyleBordered
                                                                      target:self
                                                                      action:@selector(addTeam:)];
@@ -88,7 +88,7 @@
 }
 
 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return [listOfTeams count];
+    return [self.listOfTeams count];
 }
 
 // Customize the appearance of table view cells.
@@ -101,7 +101,7 @@
     }
     
     NSUInteger row = [indexPath row]; 
-    NSString *rowString = [[listOfTeams objectAtIndex:row] stringByDeletingPathExtension]; 
+    NSString *rowString = [[self.listOfTeams objectAtIndex:row] stringByDeletingPathExtension]; 
     cell.textLabel.text = rowString; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
     
@@ -120,20 +120,6 @@
     [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
 }
 
-/*
-// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
-    
-    if (editingStyle == UITableViewCellEditingStyleDelete) {
-        // Delete the row from the data source
-        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
-    }   
-    else if (editingStyle == UITableViewCellEditingStyleInsert) {
-        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
-    }   
-}
-*/
-
 
 #pragma mark -
 #pragma mark Table view delegate
@@ -144,7 +130,6 @@
     
     NSInteger row = [indexPath row];
     NSString *selectedTeamFile = [listOfTeams objectAtIndex:row];
-    NSLog(@"%@",selectedTeamFile);
     
     // this must be set so childController can load the correct plist
     childController.title = [selectedTeamFile stringByDeletingPathExtension];
@@ -169,7 +154,7 @@
 }
 
 -(void) dealloc {
-    [listOfTeams release];
+    [self.listOfTeams release];
     [childController release];
     [super dealloc];
 }
--- a/cocoaTouch/otherSrc/CommodityFunctions.h	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.h	Sun May 23 22:05:59 2010 +0000
@@ -20,11 +20,14 @@
 
 #define TEAMS_DIRECTORY()       [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \
                                  objectAtIndex:0] stringByAppendingString:@"/Teams/"]
+#define SCHEMES_DIRECTORY()     [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) \
+                                 objectAtIndex:0] stringByAppendingString:@"/Schemes/"]
 
 #define GRAPHICS_DIRECTORY()    [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/"]
 #define HATS_DIRECTORY()        [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Hats/"]
 #define GRAVES_DIRECTORY()      [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Graves/"]
 #define BOTLEVELS_DIRECTORY()   [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Hedgehog/botlevels"]
+#define BTN_DIRECTORY()         [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Btn"]
 #define FLAGS_DIRECTORY()       [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Graphics/Flags/"]
 #define FORTS_DIRECTORY()       [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Forts/"]
 #define THEMES_DIRECTORY()      [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Themes/"]
@@ -32,6 +35,7 @@
 #define VOICES_DIRECTORY()      [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Sounds/voices/"]
 
 void createTeamNamed (NSString *nameWithoutExt);
+void createSchemeNamed (NSString *nameWithoutExt);
 BOOL rotationManager (UIInterfaceOrientation interfaceOrientation);
 NSInteger randomPort ();
 void popError (const char *title, const char *message);
--- a/cocoaTouch/otherSrc/CommodityFunctions.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.m	Sun May 23 22:05:59 2010 +0000
@@ -23,7 +23,7 @@
     
     for (int i = 0; i < MAX_HOGS; i++) {
         NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
-	NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys:@"100",@"health", [NSNumber numberWithInt:0],@"level",
+        NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level",
                              hogName,@"hogname", @"NoHat",@"hat", nil];
         [hogName release];
         [hedgehogs addObject:hog];
@@ -42,6 +42,52 @@
     [theTeam release];
 }
 
+void createSchemeNamed (NSString *nameWithoutExt) {
+    NSString *schemesDirectory = SCHEMES_DIRECTORY();
+    
+    if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
+        [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory 
+                                  withIntermediateDirectories:NO 
+                                                   attributes:nil 
+                                                        error:NULL];
+    }
+    
+    NSArray *theScheme = [[NSArray alloc] initWithObjects:
+                          [NSNumber numberWithBool:NO],    //fortmode
+                          [NSNumber numberWithBool:NO],    //divideteam
+                          [NSNumber numberWithBool:NO],    //solidland
+                          [NSNumber numberWithBool:NO],    //addborder
+                          [NSNumber numberWithBool:NO],    //lowgravity
+                          [NSNumber numberWithBool:NO],    //lasersight
+                          [NSNumber numberWithBool:NO],    //invulnerable
+                          [NSNumber numberWithBool:NO],    //addmines
+                          [NSNumber numberWithBool:NO],    //vampirism
+                          [NSNumber numberWithBool:NO],    //karma
+                          [NSNumber numberWithBool:NO],    //artillery
+                          [NSNumber numberWithBool:YES],   //randomorder
+                          [NSNumber numberWithBool:NO],    //king
+                          [NSNumber numberWithBool:NO],    //placehedgehogs
+                          [NSNumber numberWithBool:NO],    //clansharesammo
+                          [NSNumber numberWithBool:NO],    //disablegirders
+                          [NSNumber numberWithBool:NO],    //disablelandobjects
+                          [NSNumber numberWithInt:100],    //damagemodifier
+                          [NSNumber numberWithInt:45],     //turntime
+                          [NSNumber numberWithInt:100],    //initialhealth
+                          [NSNumber numberWithInt:15],     //suddendeathtimeout
+                          [NSNumber numberWithInt:5],      //cratedrops
+                          [NSNumber numberWithInt:3],      //minestime
+                          [NSNumber numberWithInt:4],      //mines
+                          [NSNumber numberWithInt:0],      //dudmines
+                          [NSNumber numberWithInt:2],      //explosives
+                          nil];
+    
+    NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt];
+
+    [theScheme writeToFile:schemeFile atomically:YES];
+    [schemeFile release];
+    [theScheme release];
+}
+
 BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) {
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
         return YES;
--- a/cocoaTouch/otherSrc/SquareButtonView.m	Sun May 23 19:37:31 2010 +0000
+++ b/cocoaTouch/otherSrc/SquareButtonView.m	Sun May 23 22:05:59 2010 +0000
@@ -7,9 +7,9 @@
 //
 
 #import "SquareButtonView.h"
+#import <QuartzCore/QuartzCore.h>
 #import "CommodityFunctions.h"
 #import "UIImageExtra.h"
-#import "QuartzCore/QuartzCore.h"
 
 @implementation SquareButtonView
 @synthesize colorArray, selectedColor, ownerDictionary;
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sun May 23 19:37:31 2010 +0000
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sun May 23 22:05:59 2010 +0000
@@ -41,6 +41,8 @@
 		6151347E116C2803001F16D1 /* Icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 6151347D116C2803001F16D1 /* Icon-iPad.png */; };
 		615134B1116C2C5F001F16D1 /* OverlayViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 615134B0116C2C5F001F16D1 /* OverlayViewController.xib */; };
 		615A92911183E31C006CA772 /* MapConfigViewController-iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 615A92901183E31C006CA772 /* MapConfigViewController-iPhone.xib */; };
+		615FBA5511A93C9800B139F9 /* SingleSchemeViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 615FBA5311A93C9800B139F9 /* SingleSchemeViewController.h */; };
+		615FBA5811A93D6700B139F9 /* SingleSchemeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 615FBA5411A93C9800B139F9 /* SingleSchemeViewController.m */; };
 		617814E8118947A200C6A535 /* MapConfigViewController-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 617814E7118947A200C6A535 /* MapConfigViewController-iPad.xib */; };
 		61798816114AA34C00BA94A9 /* hwengine.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987E7114AA34C00BA94A9 /* hwengine.pas */; };
 		61798818114AA34C00BA94A9 /* hwLibrary.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987E9114AA34C00BA94A9 /* hwLibrary.pas */; };
@@ -245,6 +247,8 @@
 		6151347D116C2803001F16D1 /* Icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad.png"; path = "../../cocoaTouch/resources/Icon-iPad.png"; sourceTree = SOURCE_ROOT; };
 		615134B0116C2C5F001F16D1 /* OverlayViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = OverlayViewController.xib; path = ../../cocoaTouch/xib/OverlayViewController.xib; sourceTree = SOURCE_ROOT; };
 		615A92901183E31C006CA772 /* MapConfigViewController-iPhone.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MapConfigViewController-iPhone.xib"; path = "../../cocoaTouch/xib/MapConfigViewController-iPhone.xib"; sourceTree = SOURCE_ROOT; };
+		615FBA5311A93C9800B139F9 /* SingleSchemeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SingleSchemeViewController.h; path = ../../cocoaTouch/SingleSchemeViewController.h; sourceTree = SOURCE_ROOT; };
+		615FBA5411A93C9800B139F9 /* SingleSchemeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SingleSchemeViewController.m; path = ../../cocoaTouch/SingleSchemeViewController.m; sourceTree = SOURCE_ROOT; };
 		617814E7118947A200C6A535 /* MapConfigViewController-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MapConfigViewController-iPad.xib"; path = "../../cocoaTouch/xib/MapConfigViewController-iPad.xib"; sourceTree = SOURCE_ROOT; };
 		617987E1114AA34C00BA94A9 /* CCHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = CCHandlers.inc; path = ../../hedgewars/CCHandlers.inc; sourceTree = SOURCE_ROOT; };
 		617987E4114AA34C00BA94A9 /* GSHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = GSHandlers.inc; path = ../../hedgewars/GSHandlers.inc; sourceTree = SOURCE_ROOT; };
@@ -713,6 +717,8 @@
 			children = (
 				61A11ADF1168DC6E00359010 /* SingleTeamViewController.h */,
 				61A11AE01168DC6E00359010 /* SingleTeamViewController.m */,
+				615FBA5311A93C9800B139F9 /* SingleSchemeViewController.h */,
+				615FBA5411A93C9800B139F9 /* SingleSchemeViewController.m */,
 			);
 			name = "second level";
 			sourceTree = "<group>";
@@ -786,6 +792,7 @@
 				61C325491179A336001E70B1 /* openalbridge.h in Headers */,
 				61C3254B1179A336001E70B1 /* wrappers.h in Headers */,
 				61AA7ACA117FCC8200FDDD4D /* openalbridge_t.h in Headers */,
+				615FBA5511A93C9800B139F9 /* SingleSchemeViewController.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -986,7 +993,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\nsvn export --force ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels/.svn*\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\n\n#the following ones must be removed when their support is implemented\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Pirate,Robot,Russian,Singer,Surfer}\n\n#delete all names\nrm -rf ${PROJECT_DIR}/Data/Names/\n\n#delete all missions\nrm -rf ${PROJECT_DIR}/Data/Missions/\n\n#delete all reserved hats\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/";
+			shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\nsvn export --force ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels/.svn*\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\n\n#the following ones must be removed when their support is implemented\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Pirate,Robot,Russian,Singer,Surfer}\n\n#delete all names\nrm -rf ${PROJECT_DIR}/Data/Names/\n\n#delete all missions\nrm -rf ${PROJECT_DIR}/Data/Missions/\n\n#delete all reserved hats\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/";
 			showEnvVarsInLog = 0;
 		};
 		9283011B0F10CB2D00CC5A3C /* Build libfpc.a */ = {
@@ -1088,6 +1095,7 @@
 				61CF4971117E702F00BF05B7 /* SquareButtonView.m in Sources */,
 				61B22E0F1180FBF400B2FCE0 /* MapConfigViewController.m in Sources */,
 				61AE62C711A067FE008DC32E /* SplitViewRootController.m in Sources */,
+				615FBA5811A93D6700B139F9 /* SingleSchemeViewController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1169,7 +1177,7 @@
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;
-				FPC_SPECIFIC_OPTIONS = "-Ci- -Cr- -Co- -O-2 -Xs  -Cfvfpv2";
+				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -Ci- -Cr- -Co- -O-2 -Xs  -Cfvfpv2";
 				FPC_UNITS_PATH = "-Fu\"$(PROJECT_DIR)\"";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_DEBUGGING_SYMBOLS = default;