- Fix missions path, still needs refactoring... ios-develop
authorantonc27 <antonc27@mail.ru>
Wed, 14 Mar 2018 15:58:16 +0100
branchios-develop
changeset 13199 e17efd663125
parent 13192 d6aea85111c7
child 13223 915abf27ae5a
- Fix missions path, still needs refactoring...
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h
project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Mar 14 00:46:20 2018 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Wed Mar 14 15:58:16 2018 +0100
@@ -225,9 +225,9 @@
     [self startGame:gtSave atPath:atPath withOptions:nil];
 }
 
-+ (void)startMissionGame:(NSString *)withScript {
++ (void)startMissionGame:(NSString *)withSubPath {
     NSString *seedCmd = [self seedCommand];
-    NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/Training/%@.lua",withScript];
+    NSString *missionPath = [[NSString alloc] initWithFormat:@"escript Missions/%@.lua", withSubPath];
     NSDictionary *missionDict = [[NSDictionary alloc] initWithObjectsAndKeys:missionPath, @"mission_command", seedCmd, @"seed_command", nil];
 
     [self startGame:gtMission atPath:nil withOptions:missionDict];
--- a/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h	Wed Mar 14 00:46:20 2018 +0100
+++ b/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.h	Wed Mar 14 15:58:16 2018 +0100
@@ -25,7 +25,7 @@
 @property (nonatomic, strong) NSArray *missionsTypes;
 @property (nonatomic, strong) NSDictionary *dictOfAllMissions;
 
-@property (nonatomic, strong) NSString *missionName;
+@property (nonatomic, strong) NSString *missionSubPath;
 
 @property (nonatomic, strong) NSArray *listOfTrainingIDs;
 @property (nonatomic, strong) NSDictionary *dictOfTraining;
--- a/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Wed Mar 14 00:46:20 2018 +0100
+++ b/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Wed Mar 14 15:58:16 2018 +0100
@@ -77,7 +77,7 @@
         [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
     } else {
         [GameInterfaceBridge registerCallingController:self];
-        [GameInterfaceBridge startMissionGame:self.missionName];
+        [GameInterfaceBridge startMissionGame:self.missionSubPath];
     }
 }
 
@@ -362,14 +362,15 @@
     NSArray *listOfIDs = [self listOfMissionsIDsForType:type];
     
     NSInteger row = [indexPath row];
-    self.missionName = [listOfIDs objectAtIndex:row];
+    NSString *missionID = [listOfIDs objectAtIndex:row];
+    self.missionSubPath = [NSString stringWithFormat:@"%@/%@", type, missionID];
     NSString *size = IS_IPAD() ? @"@2x" : @"";
-    NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Missions/%@/%@%@.png",GRAPHICS_DIRECTORY(), type, self.missionName, size];
+    NSString *filePath = [NSString stringWithFormat:@"%@/Missions/%@%@.png",GRAPHICS_DIRECTORY(), self.missionSubPath, size];
     UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
     [self.previewImage setImage:img];
 
     NSDictionary *dict = [self dictOfMissionsForType:type];
-    self.descriptionLabel.text = dict[self.missionName][@"desc"];
+    self.descriptionLabel.text = dict[missionID][@"desc"];
 }
 
 #pragma mark -