add getawaytime and tagteam mode to ios
authorkoda
Wed, 27 Apr 2011 02:34:38 +0200
changeset 5181 102fef5ca5fc
parent 5180 a881cd3d3163
child 5182 7eb5e1268330
add getawaytime and tagteam mode to ios some tweaks to scheme creation
project_files/HedgewarsMobile/Classes/CreationChamber.m
project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
project_files/HedgewarsMobile/Resources/Settings/iFrontend/basicFlags_en.plist
project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist
--- a/project_files/HedgewarsMobile/Classes/CreationChamber.m	Wed Apr 27 02:10:22 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/CreationChamber.m	Wed Apr 27 02:34:38 2011 +0200
@@ -183,6 +183,7 @@
 
 void createSchemeNamed (NSString *nameWithoutExt) {
     NSString *schemesDirectory = SCHEMES_DIRECTORY();
+    NSString *path = nil;
 
     if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
         [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
@@ -191,53 +192,24 @@
                                                         error:NULL];
     }
 
-    int basicFlags[] = {100, 100, 45, 15, 47, 5, 100, 5, 35, 25, 3, 4, 0, 2};
-    BOOL gameFlags[] = {NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, YES, NO, NO, NO, NO,
-        NO, NO, NO, NO, NO, NO, NO};
-
-    NSMutableArray *basicArray  = [[NSMutableArray alloc] initWithObjects:
-                                   [NSNumber numberWithInt:basicFlags[0]],          //initialhealth
-                                   [NSNumber numberWithInt:basicFlags[1]],          //damagemodifier
-                                   [NSNumber numberWithInt:basicFlags[2]],          //turntime
-                                   [NSNumber numberWithInt:basicFlags[3]],          //suddendeathtimeout
-                                   [NSNumber numberWithInt:basicFlags[4]],          //waterrise
-                                   [NSNumber numberWithInt:basicFlags[5]],          //healthdecrease
-                                   [NSNumber numberWithInt:basicFlags[6]],          //ropelength
-                                   [NSNumber numberWithInt:basicFlags[7]],          //cratedrops
-                                   [NSNumber numberWithInt:basicFlags[8]],          //healthprob
-                                   [NSNumber numberWithInt:basicFlags[9]],          //healthamount
-                                   [NSNumber numberWithInt:basicFlags[10]],         //minestime
-                                   [NSNumber numberWithInt:basicFlags[11]],         //minesnumber
-                                   [NSNumber numberWithInt:basicFlags[12]],         //dudmines
-                                   [NSNumber numberWithInt:basicFlags[13]],         //explosives
-                                   nil];
+    // load data to get the size of the arrays and their default values
+    path = [NSString stringWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()];
+    NSArray *basicSettings = [[NSArray alloc] initWithContentsOfFile:path];
+    NSMutableArray *basicArray  = [[NSMutableArray alloc] initWithCapacity:[basicSettings count]];
+    for (NSDictionary *basicDict in basicSettings)
+        [basicArray addObject:[basicDict objectForKey:@"default"]];
+    [basicSettings release];
 
-    NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects:
-                                   [NSNumber numberWithBool:gameFlags[0]],          //fortmode
-                                   [NSNumber numberWithBool:gameFlags[1]],          //divideteam
-                                   [NSNumber numberWithBool:gameFlags[2]],          //solidland
-                                   [NSNumber numberWithBool:gameFlags[3]],          //addborder
-                                   [NSNumber numberWithBool:gameFlags[4]],          //lowgravity
-                                   [NSNumber numberWithBool:gameFlags[5]],          //lasersight
-                                   [NSNumber numberWithBool:gameFlags[6]],          //invulnerable
-                                   [NSNumber numberWithBool:gameFlags[7]],          //resethealth
-                                   [NSNumber numberWithBool:gameFlags[8]],          //vampirism
-                                   [NSNumber numberWithBool:gameFlags[9]],          //karma
-                                   [NSNumber numberWithBool:gameFlags[10]],         //artillery
-                                   [NSNumber numberWithBool:gameFlags[11]],         //randomorder
-                                   [NSNumber numberWithBool:gameFlags[12]],         //king
-                                   [NSNumber numberWithBool:gameFlags[13]],         //placehedgehogs
-                                   [NSNumber numberWithBool:gameFlags[14]],         //clansharesammo
-                                   [NSNumber numberWithBool:gameFlags[15]],         //disablegirders
-                                   [NSNumber numberWithBool:gameFlags[16]],         //disablelandobjects
-                                   [NSNumber numberWithBool:gameFlags[17]],         //aisurvival
-                                   [NSNumber numberWithBool:gameFlags[18]],         //infattack
-                                   [NSNumber numberWithBool:gameFlags[19]],         //resetweaps
-                                   [NSNumber numberWithBool:gameFlags[20]],         //perhogammo
-                                   [NSNumber numberWithBool:gameFlags[21]],         //nowind
-                                   [NSNumber numberWithBool:gameFlags[22]],         //morewind
-                                   nil];
-    
+    path = [NSString stringWithFormat:@"%@/gameFlags_en.plist",IFRONTEND_DIRECTORY()];
+    NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path];
+    NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithCapacity:[mods count]];
+    for (int i = 0; i < [mods count]; i++)
+        [gamemodArray addObject:[NSNumber numberWithBool:NO]];
+    [mods release];
+
+    // workaround for randomorder that has to be set to YES
+    [gamemodArray replaceObjectAtIndex:11 withObject:[NSNumber numberWithBool:YES]];
+
     NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                       basicArray,@"basic",
                                       gamemodArray,@"gamemod",
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Wed Apr 27 02:10:22 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Wed Apr 27 02:34:38 2011 +0200
@@ -183,7 +183,7 @@
     [self sendToEngine:flags];
     [flags release];
 
-    /* basic game flags */
+    // game modifiers
     NSString *path = [[NSString alloc] initWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()];
     NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path];
     [path release];
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Wed Apr 27 02:10:22 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Wed Apr 27 02:34:38 2011 +0200
@@ -193,6 +193,7 @@
 
             UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG];
             cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
+            cellLabel.adjustsFontSizeToFitWidth = YES;
 
             // can't use the viewWithTag method because row is dynamic
             UISlider *cellSlider = nil;
--- a/project_files/HedgewarsMobile/Resources/Settings/iFrontend/basicFlags_en.plist	Wed Apr 27 02:10:22 2011 +0200
+++ b/project_files/HedgewarsMobile/Resources/Settings/iFrontend/basicFlags_en.plist	Wed Apr 27 02:34:38 2011 +0200
@@ -120,7 +120,7 @@
 		<key>min</key>
 		<integer>25</integer>
 		<key>title</key>
-		<string>Rope Length</string>
+		<string>Rope Length (%)</string>
 	</dict>
 	<dict>
 		<key>checkOverMax</key>
@@ -156,7 +156,7 @@
 		<key>min</key>
 		<integer>0</integer>
 		<key>title</key>
-		<string>Health Kit Probability</string>
+		<string>Health Kit Probability (%)</string>
 	</dict>
 	<dict>
 		<key>checkOverMax</key>
@@ -228,7 +228,7 @@
 		<key>min</key>
 		<integer>0</integer>
 		<key>title</key>
-		<string>Dud Mines Probability</string>
+		<string>Dud Mines Probability (%)</string>
 	</dict>
 	<dict>
 		<key>checkOverMax</key>
@@ -248,5 +248,23 @@
 		<key>title</key>
 		<string>Explosives</string>
 	</dict>
+	<dict>
+		<key>checkOverMax</key>
+		<false/>
+		<key>times1000</key>
+		<false/>
+		<key>command</key>
+		<string>e$getawaytime</string>
+		<key>default</key>
+		<integer>100</integer>
+		<key>image</key>
+		<string>Time</string>
+		<key>max</key>
+		<integer>999</integer>
+		<key>min</key>
+		<integer>0</integer>
+		<key>title</key>
+		<string>Get Away Time (%)</string>
+	</dict>
 </array>
 </plist>
--- a/project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist	Wed Apr 27 02:10:22 2011 +0200
+++ b/project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist	Wed Apr 27 02:34:38 2011 +0200
@@ -186,5 +186,13 @@
 		<key>title</key>
 		<string>More Wind</string>
 	</dict>
+	<dict>
+		<key>description</key>
+		<string>Clan teams take turns sharing their time</string>
+		<key>image</key>
+		<string>TagTeam</string>
+		<key>title</key>
+		<string>Tag Team</string>
+	</dict>
 </array>
 </plist>