--- a/project_files/HedgewarsMobile/Classes/CreationChamber.h Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CreationChamber.h Sat Oct 08 21:17:24 2011 +0200
@@ -21,7 +21,21 @@
#import <Foundation/Foundation.h>
-void createSettings (void);
-void createTeamNamed (NSString *nameWithoutExt);
-void createWeaponNamed (NSString *nameWithoutExt, int type);
-void createSchemeNamed (NSString *nameWithoutExt, int type);
+@interface CreationChamber : NSObject {
+
+}
+
++(void) createSettings;
+
++(void) createTeamNamed:(NSString *)nameWithoutExt;
++(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type;
++(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) flag;
+
++(void) createWeaponNamed:(NSString *)nameWithoutExt;
++(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type;
+
++(void) createSchemeNamed:(NSString *)nameWithoutExt;
++(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type;
+
+@end
+
--- a/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CreationChamber.m Sat Oct 08 21:17:24 2011 +0200
@@ -22,7 +22,11 @@
#import "CreationChamber.h"
#import "hwconsts.h"
-void createSettings () {
+
+@implementation CreationChamber
+
+#pragma mark Settings
++(void) createSettings {
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
[settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"];
[settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"];
@@ -39,7 +43,16 @@
[settings synchronize];
}
-void createTeamNamed (NSString *nameWithoutExt) {
+#pragma mark Teams
++(void) createTeamNamed:(NSString *)nameWithoutExt {
+ [CreationChamber createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO];
+}
+
++(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
+ [CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO];
+}
+
++(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) flag {
NSString *teamsDirectory = TEAMS_DIRECTORY();
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
@@ -80,7 +93,12 @@
[theTeam release];
}
-void createWeaponNamed (NSString *nameWithoutExt, int type) {
+#pragma mark Weapons
++(void) createWeaponNamed:(NSString *)nameWithoutExt {
+ [CreationChamber createWeaponNamed:nameWithoutExt ofType:0];
+}
+
++(void) createWeaponNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
NSString *weaponsDirectory = WEAPONS_DIRECTORY();
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
@@ -150,7 +168,12 @@
[theWeapon release];
}
-void createSchemeNamed (NSString *nameWithoutExt, int type) {
+#pragma mark Schemes
++(void) createSchemeNamed:(NSString *)nameWithoutExt {
+ [CreationChamber createSchemeNamed:nameWithoutExt ofType:0];
+}
+
++(void) createSchemeNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type {
NSString *schemesDirectory = SCHEMES_DIRECTORY();
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
@@ -287,3 +310,5 @@
[schemeFile release];
[theScheme release];
}
+
+@end
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Oct 08 21:17:24 2011 +0200
@@ -51,7 +51,7 @@
[[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() withIntermediateDirectories:NO attributes:nil error:NULL];
// SETTINGS - nsuserdefaults ftw
- createSettings();
+ [CreationChamber createSettings];
// TEAMS - update exisiting teams with new format
if ([[NSFileManager defaultManager] fileExistsAtPath:TEAMS_DIRECTORY()] == NO) {
@@ -74,27 +74,20 @@
// SCHEMES - always overwrite and delete custom ones
if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == YES)
[[NSFileManager defaultManager] removeItemAtPath:SCHEMES_DIRECTORY() error:NULL];
- createSchemeNamed(@"Default", 0);
- createSchemeNamed(@"Pro Mode", 1);
- createSchemeNamed(@"Shoppa", 2);
- createSchemeNamed(@"Clean Slate", 3);
- createSchemeNamed(@"Minefield", 4);
- createSchemeNamed(@"Barrel Mayhem", 5);
- createSchemeNamed(@"Tunnel Hogs", 6);
- createSchemeNamed(@"Fort Mode", 7);
- createSchemeNamed(@"Timeless", 8);
- createSchemeNamed(@"Thinking with Portals", 9);
- createSchemeNamed(@"King Mode", 10);
+ NSArray *schemeNames = [[NSArray alloc] initWithObjects:@"Default",@"Pro Mode",@"Shoppa",@"Clean Slate",@"Minefield",
+ @"Barrel Mayhem",@"Tunnel Hogs",@"Fort Mode",@"Timeless",@"Thinking with Portals",@"King Mode",nil];
+ NSInteger index = 0;
+ for (NSString *name in schemeNames)
+ [CreationChamber createSchemeNamed:name ofType:index++];
+ [schemeNames release];
- // WEAPONS - always overwrite
- createWeaponNamed(@"Default", 0);
- createWeaponNamed(@"Crazy", 1);
- createWeaponNamed(@"Pro Mode", 2);
- createWeaponNamed(@"Shoppa", 3);
- createWeaponNamed(@"Clean Slate", 4);
- createWeaponNamed(@"Minefield", 5);
- createWeaponNamed(@"Thinking with Portals", 6);
- // merge not needed because weapons not present in the set are 0ed by GameSetup
+ // WEAPONS - always overwrite as merge is not needed (missing weaps the set are 0ed automatically)
+ NSArray *weaponNames = [[NSArray alloc] initWithObjects:@"Default",@"Crazy",@"Pro Mode",@"Shoppa",@"Clean Slate",
+ @"Minefield",@"Thinking with Portals",nil];
+ index = 0;
+ for (NSString *name in weaponNames)
+ [CreationChamber createWeaponNamed:name ofType:index++];
+ [weaponNames release];
}
#pragma mark -
--- a/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Oct 08 21:17:24 2011 +0200
@@ -80,7 +80,7 @@
-(void) addScheme:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Scheme %u.plist", [self.listOfSchemes count]];
- createSchemeNamed([fileName stringByDeletingPathExtension], 0);
+ [CreationChamber createSchemeNamed:[fileName stringByDeletingPathExtension]];
[self.listOfSchemes addObject:fileName];
--- a/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Sat Oct 08 21:17:24 2011 +0200
@@ -84,7 +84,7 @@
-(void) addTeam:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Default Team %u.plist", [self.listOfTeams count]];
- createTeamNamed([fileName stringByDeletingPathExtension]);
+ [CreationChamber createTeamNamed:[fileName stringByDeletingPathExtension]];
[self.listOfTeams addObject:fileName];
--- a/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Sat Oct 08 17:22:06 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Sat Oct 08 21:17:24 2011 +0200
@@ -80,7 +80,7 @@
-(void) addWeapon:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Weapon %u.plist", [self.listOfWeapons count]];
- createWeaponNamed([fileName stringByDeletingPathExtension], 0);
+ [CreationChamber createWeaponNamed:[fileName stringByDeletingPathExtension]];
[self.listOfWeapons addObject:fileName];