# HG changeset patch # User koda # Date 1329616339 -3600 # Node ID d2afc6b2d88e6bd7ef324f681b629351be8e0837 # Parent 686ebfd50f56dec19c67f219666e81ecfe87645e added one button play feature, like in desktop frontend; need to make sure that the hardcoded stuff never gets deleted diff -r 686ebfd50f56 -r d2afc6b2d88e project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h --- 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; diff -r 686ebfd50f56 -r d2afc6b2d88e project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m --- 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 diff -r 686ebfd50f56 -r d2afc6b2d88e project_files/HedgewarsMobile/Classes/MainMenuViewController-iPad.xib --- 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 @@ 269 - {{468, 686}, {89, 37}} + {{565, 686}, {89, 37}} NO 5 @@ -187,6 +187,26 @@ + + + 269 + {{383, 686}, {89, 37}} + + NO + 6 + IBIPadFramework + 0 + 0 + + 1 + Simple + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + {1024, 768} @@ -256,6 +276,15 @@ 92 + + + switchViews: + + + 7 + + 94 + @@ -276,8 +305,9 @@ + - + @@ -328,6 +358,11 @@ + + 93 + + + @@ -350,6 +385,8 @@ 90.IBViewBoundsToFrameTransform 91.IBPluginDependency 91.IBViewBoundsToFrameTransform + 93.IBPluginDependency + 93.IBViewBoundsToFrameTransform YES @@ -377,7 +414,11 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin - AUPqAABEK4AAA + P4AAAL+AAABD6gAAxDRAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABDuYAAxDRAAA @@ -397,7 +438,7 @@ - 92 + 94 @@ -421,6 +462,13 @@ Classes/MainMenuViewController.h + + UIButton + + IBProjectSource + Classes/ExtraCategories.h + + YES diff -r 686ebfd50f56 -r d2afc6b2d88e project_files/HedgewarsMobile/Classes/MainMenuViewController-iPhone.xib --- 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 @@ YES - + YES @@ -196,6 +196,25 @@ + + + 292 + {{439, 68}, {29, 31}} + + NO + 6 + IBCocoaTouchFramework + 0 + 0 + + 2 + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + {480, 320} @@ -265,6 +284,15 @@ 47 + + + switchViews: + + + 7 + + 49 + @@ -287,6 +315,7 @@ + @@ -336,6 +365,11 @@ + + 48 + + + @@ -360,6 +394,8 @@ 43.IBViewBoundsToFrameTransform 46.IBPluginDependency 46.IBViewBoundsToFrameTransform + 48.IBPluginDependency + 48.IBViewBoundsToFrameTransform YES @@ -393,7 +429,11 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin - P4AAAL+AAABD0YAAwmgAAA + AUPbgABBUAAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + P4AAAL+AAABD3gAAwjwAAA @@ -413,7 +453,7 @@ - 47 + 49 @@ -437,6 +477,13 @@ Classes/MainMenuViewController.h + + UIButton + + IBProjectSource + Classes/ExtraCategories.h + + YES diff -r 686ebfd50f56 -r d2afc6b2d88e project_files/HedgewarsMobile/Classes/MainMenuViewController.m --- 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"