added one button play feature, like in desktop frontend; need to make sure that the hardcoded stuff never gets deleted
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h Sun Feb 19 01:22:59 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h Sun Feb 19 02:52:19 2012 +0100
@@ -36,6 +36,7 @@
+(void) startLocalGame:(NSDictionary *)withOptions;
+(void) startSaveGame:(NSString *)atPath;
+(void) startMissionGame:(NSString *)withScript;
++(void) startSimpleGame;
+(void) registerCallingController:(UIViewController *)controller;
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Sun Feb 19 01:22:59 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Sun Feb 19 02:52:19 2012 +0100
@@ -226,5 +226,67 @@
[missionLine release];
}
++(void) startSimpleGame {
+ srand(time(0));
+
+ // generate a seed
+ CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
+ NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
+ CFRelease(uuid);
+ NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%@}", seed];
+
+ // pick a random static map
+ NSArray *listOfMaps = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:MAPS_DIRECTORY() error:NULL];
+ NSString *mapName = [listOfMaps objectAtIndex:random()%[listOfMaps count]];
+ NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg",MAPS_DIRECTORY(),mapName];
+ NSString *contents = [[NSString alloc] initWithContentsOfFile:fileCfg encoding:NSUTF8StringEncoding error:NULL];
+ [fileCfg release];
+ NSArray *split = [contents componentsSeparatedByString:@"\n"];
+ [contents release];
+ NSString *themeCommand = [[NSString alloc] initWithFormat:@"etheme %@", [split objectAtIndex:0]];
+ NSString *staticMapCommand = [[NSString alloc] initWithFormat:@"emap %@", mapName];
+
+ // select teams with two different colors
+ NSArray *colorArray = [HWUtils teamColors];
+ NSInteger firstColorIndex, secondColorIndex;
+ do {
+ firstColorIndex = random()%[colorArray count];
+ secondColorIndex = random()%[colorArray count];
+ } while (firstColorIndex == secondColorIndex);
+ unsigned int firstColor = [[colorArray objectAtIndex:firstColorIndex] intValue];
+ unsigned int secondColor = [[colorArray objectAtIndex:secondColorIndex] intValue];
+
+ NSDictionary *firstTeam = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:4],@"number",
+ [NSNumber numberWithUnsignedInt:firstColor],@"color",
+ @"Ninjas.plist",@"team",nil];
+ NSDictionary *secondTeam = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:4],@"number",
+ [NSNumber numberWithUnsignedInt:secondColor],@"color",
+ @"Robots.plist",@"team",nil];
+ NSArray *listOfTeams = [[NSArray alloc] initWithObjects:firstTeam,secondTeam,nil];
+ [firstTeam release];
+ [secondTeam release];
+
+ // create the configuration
+ NSDictionary *gameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
+ seedCmd,@"seed_command",
+ @"e$template_filter 0",@"templatefilter_command",
+ @"e$mapgen 0",@"mapgen_command",
+ @"e$maze_size 0",@"mazesize_command",
+ themeCommand,@"theme_command",
+ staticMapCommand,@"staticmap_command",
+ listOfTeams,@"teams_list",
+ @"Default.plist",@"scheme",
+ @"Default.plist",@"weapon",
+ @"",@"mission_command",
+ nil];
+ [listOfTeams release];
+ [staticMapCommand release];
+ [themeCommand release];
+ [seedCmd release];
+
+ // launch game
+ [GameInterfaceBridge startLocalGame:gameDictionary];
+ [gameDictionary release];
+}
@end
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController-iPad.xib Sun Feb 19 01:22:59 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController-iPad.xib Sun Feb 19 02:52:19 2012 +0100
@@ -170,7 +170,7 @@
<object class="IBUIButton" id="357438048">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">269</int>
- <string key="NSFrame">{{468, 686}, {89, 37}}</string>
+ <string key="NSFrame">{{565, 686}, {89, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<int key="IBUITag">5</int>
@@ -187,6 +187,26 @@
</object>
<reference key="IBUINormalTitleShadowColor" ref="112471976"/>
</object>
+ <object class="IBUIButton" id="719094980">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">269</int>
+ <string key="NSFrame">{{383, 686}, {89, 37}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <int key="IBUITag">6</int>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <reference key="IBUIFont" ref="917635782"/>
+ <int key="IBUIButtonType">1</int>
+ <string key="IBUINormalTitle">Simple</string>
+ <reference key="IBUIHighlightedTitleColor" ref="918890028"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="112471976"/>
+ </object>
</object>
<string key="NSFrameSize">{1024, 768}</string>
<reference key="NSSuperview"/>
@@ -256,6 +276,15 @@
</object>
<int key="connectionID">92</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">switchViews:</string>
+ <reference key="source" ref="719094980"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">94</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -276,8 +305,9 @@
<reference ref="898948205"/>
<reference ref="894101036"/>
<reference ref="1019880682"/>
+ <reference ref="95106947"/>
<reference ref="357438048"/>
- <reference ref="95106947"/>
+ <reference ref="719094980"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -328,6 +358,11 @@
<reference key="object" ref="357438048"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">93</int>
+ <reference key="object" ref="719094980"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -350,6 +385,8 @@
<string>90.IBViewBoundsToFrameTransform</string>
<string>91.IBPluginDependency</string>
<string>91.IBViewBoundsToFrameTransform</string>
+ <string>93.IBPluginDependency</string>
+ <string>93.IBViewBoundsToFrameTransform</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -377,7 +414,11 @@
</object>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
- <bytes key="NSTransformStruct">AUPqAABEK4AAA</bytes>
+ <bytes key="NSTransformStruct">P4AAAL+AAABD6gAAxDRAAA</bytes>
+ </object>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABDuYAAxDRAAA</bytes>
</object>
</object>
</object>
@@ -397,7 +438,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">92</int>
+ <int key="maxID">94</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -421,6 +462,13 @@
<string key="minorKey">Classes/MainMenuViewController.h</string>
</object>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIButton</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Classes/ExtraCategories.h</string>
+ </object>
+ </object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController-iPhone.xib Sun Feb 19 01:22:59 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController-iPhone.xib Sun Feb 19 02:52:19 2012 +0100
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="1"/>
+ <integer value="48"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -196,6 +196,25 @@
</object>
<reference key="IBUINormalTitleShadowColor" ref="112471976"/>
</object>
+ <object class="IBUIButton" id="274540289">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{439, 68}, {29, 31}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <int key="IBUITag">6</int>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentHorizontalAlignment">0</int>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <reference key="IBUIFont" ref="917635782"/>
+ <int key="IBUIButtonType">2</int>
+ <reference key="IBUIHighlightedTitleColor" ref="918890028"/>
+ <object class="NSColor" key="IBUINormalTitleColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+ </object>
+ <reference key="IBUINormalTitleShadowColor" ref="112471976"/>
+ </object>
</object>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview"/>
@@ -265,6 +284,15 @@
</object>
<int key="connectionID">47</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">switchViews:</string>
+ <reference key="source" ref="274540289"/>
+ <reference key="destination" ref="372490531"/>
+ <int key="IBEventType">7</int>
+ </object>
+ <int key="connectionID">49</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -287,6 +315,7 @@
<reference ref="753723574"/>
<reference ref="124270424"/>
<reference ref="629390161"/>
+ <reference ref="274540289"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -336,6 +365,11 @@
<reference key="object" ref="629390161"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">48</int>
+ <reference key="object" ref="274540289"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -360,6 +394,8 @@
<string>43.IBViewBoundsToFrameTransform</string>
<string>46.IBPluginDependency</string>
<string>46.IBViewBoundsToFrameTransform</string>
+ <string>48.IBPluginDependency</string>
+ <string>48.IBViewBoundsToFrameTransform</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -393,7 +429,11 @@
</object>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAABD0YAAwmgAAA</bytes>
+ <bytes key="NSTransformStruct">AUPbgABBUAAAA</bytes>
+ </object>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <object class="NSAffineTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABD3gAAwjwAAA</bytes>
</object>
</object>
</object>
@@ -413,7 +453,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">47</int>
+ <int key="maxID">49</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -437,6 +477,13 @@
<string key="minorKey">Classes/MainMenuViewController.h</string>
</object>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIButton</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Classes/ExtraCategories.h</string>
+ </object>
+ </object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Feb 19 01:22:59 2012 +0100
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sun Feb 19 02:52:19 2012 +0100
@@ -29,6 +29,7 @@
#import "MissionTrainingViewController.h"
#import "Appirater.h"
#import "ServerProtocolNetwork.h"
+#import "GameInterfaceBridge.h"
@implementation MainMenuViewController
@@ -221,6 +222,10 @@
}
[self presentModalViewController:self.missionsViewController animated:YES];
break;
+ case 6:
+ [GameInterfaceBridge registerCallingController:self];
+ [GameInterfaceBridge startSimpleGame];
+ break;
default:
alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
message:@"Sorry, this feature is not yet implemented"