make the missions/trainings start
authorkoda
Wed, 05 Oct 2011 01:06:58 +0200
changeset 6084 e692c0348e74
parent 6083 72c882c0fd0f
child 6085 252e9a7d260f
make the missions/trainings start
project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h
project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Wed Oct 05 00:18:54 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Wed Oct 05 01:06:58 2011 +0200
@@ -288,6 +288,9 @@
                 NSString *script = [gameConfig objectForKey:@"mission_command"];
                 if ([script length] != 0)
                     [self sendToEngine:script];
+                // missions/tranings only need the script configuration set
+                if ([gameConfig count] == 1)
+                    break;
 
                 // seed info
                 [self sendToEngine:[gameConfig objectForKey:@"seed_command"]];
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Oct 05 00:18:54 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Oct 05 01:06:58 2011 +0200
@@ -215,7 +215,9 @@
     self.gameType = gtMission;
     self.savePath = nil;
 
-    NSDictionary *config = [NSDictionary dictionaryWithObject:withScript forKey:@"mission_command"];
+    NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/Training/%@.lua",withScript];
+    NSDictionary *config = [NSDictionary dictionaryWithObject:missionPath forKey:@"mission_command"];
+    [missionPath release];
     [self.engineProtocol spawnThread:nil withOptions:config];
     [self prepareEngineLaunch];
 }
--- a/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h	Wed Oct 05 00:18:54 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h	Wed Oct 05 01:06:58 2011 +0200
@@ -26,14 +26,14 @@
     UIImageView *previewImage;
     UITableView *tableView;
     UILabel *descriptionLabel;
-    NSString *missionFile;
+    NSString *missionName;
 }
 
 @property (nonatomic, retain) NSArray *listOfMissions;
 @property (nonatomic, retain) IBOutlet UIImageView *previewImage;
 @property (nonatomic, retain) IBOutlet UITableView *tableView;
 @property (nonatomic, retain) IBOutlet UILabel *descriptionLabel;
-@property (nonatomic, retain) IBOutlet NSString *missionFile;
+@property (nonatomic, retain) IBOutlet NSString *missionName;
 
 -(IBAction) buttonPressed:(id) sender;
 
--- a/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Wed Oct 05 00:18:54 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Wed Oct 05 01:06:58 2011 +0200
@@ -23,7 +23,7 @@
 #import "GameInterfaceBridge.h"
 
 @implementation MissionTrainingViewController
-@synthesize listOfMissions, previewImage, tableView, descriptionLabel, missionFile;
+@synthesize listOfMissions, previewImage, tableView, descriptionLabel, missionName;
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
     return rotationManager(interfaceOrientation);
@@ -31,8 +31,6 @@
 
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 -(void) viewDidLoad {
-    srand(time(NULL));
-
     NSString *imgName = (IS_IPAD()) ? @"mediumBackground~ipad.png" : @"smallerBackground~iphone.png";
     UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName];
     self.view.backgroundColor = [UIColor colorWithPatternImage:img];
@@ -71,9 +69,9 @@
         [AudioManagerController playBackSound];
         [[self parentViewController] dismissModalViewControllerAnimated:YES];
     } else {
-/*        GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
-        [bridge startMissionGame:self.missionFile];
-        [bridge release];*/
+        GameInterfaceBridge *bridge = [[GameInterfaceBridge alloc] initWithController:self];
+        [bridge startMissionGame:self.missionName];
+        [bridge release];
     }
 }
 
@@ -105,8 +103,8 @@
 #pragma mark -
 #pragma mark Table view delegate
 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    NSString *missionName = [[self.listOfMissions objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
-    NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Missions/Training/%@@2x.png",GRAPHICS_DIRECTORY(),missionName];
+    self.missionName = [[self.listOfMissions objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
+    NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Missions/Training/%@@2x.png",GRAPHICS_DIRECTORY(),self.missionName];
     UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
     [filePath release];
     [self.previewImage setImage:img];
@@ -124,17 +122,13 @@
             self.descriptionLabel.text = [descriptionText objectAtIndex:1];
         }
     }
-
-    NSString *missionPath = [[NSString alloc] initWithFormat:@"%@/%@.lua",TRAININGS_DIRECTORY(),missionName];
-    self.missionFile = missionPath;
-    [missionPath release];
 }
 
 #pragma mark -
 #pragma mark Memory management
 -(void) didReceiveMemoryWarning {
     previewImage = nil;
-    missionFile = nil;
+    missionName = nil;
     [super didReceiveMemoryWarning];
 }
 
@@ -143,7 +137,7 @@
     self.previewImage = nil;
     self.tableView = nil;
     self.descriptionLabel = nil;
-    self.missionFile = nil;
+    self.missionName = nil;
     MSG_DIDUNLOAD();
     [super viewDidUnload];
 }
@@ -154,7 +148,7 @@
     releaseAndNil(previewImage);
     releaseAndNil(tableView);
     releaseAndNil(descriptionLabel);
-    releaseAndNil(missionFile);
+    releaseAndNil(missionName);
     [super dealloc];
 }