# HG changeset patch # User antonc27 # Date 1456270390 -3600 # Node ID 28afdaa159cb3b9710335cef225ea52843d327a7 # Parent b709768e720c17571b8b94819279f50b9bac49e8 - Campaign for iOS: Finally can launch campaign's mission game from list! TODO: Customize UI TODO: Track user progress TODO: Localization TODO: Refactoring TODO: Get some sleep ^_ diff -r b709768e720c -r 28afdaa159cb project_files/HedgewarsMobile/Classes/CampaignViewController.m --- a/project_files/HedgewarsMobile/Classes/CampaignViewController.m Wed Feb 24 00:10:12 2016 +0100 +++ b/project_files/HedgewarsMobile/Classes/CampaignViewController.m Wed Feb 24 00:33:10 2016 +0100 @@ -18,6 +18,7 @@ #import "CampaignViewController.h" #import "IniParser.h" +#import "GameInterfaceBridge.h" @interface CampaignViewController () @property (nonatomic, retain) NSArray *campaignMissions; @@ -78,27 +79,19 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"campaignMissionCell" forIndexPath:indexPath]; - // Configure the cell... cell.textLabel.text = self.campaignMissions[indexPath.row][@"Name"]; return cell; } -/* #pragma mark - Table view delegate -// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - // Navigation logic may go here, for example: - // Create the next view controller. - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil]; + NSString *campaignMissionScript = self.campaignMissions[indexPath.row][@"Script"]; - // Pass the selected object to the new view controller. - - // Push the view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; + [GameInterfaceBridge registerCallingController:self]; + [GameInterfaceBridge startCampaignMissionGameWithScript:campaignMissionScript forCampaign:self.campaignName]; } -*/ #pragma mark - Dealloc diff -r b709768e720c -r 28afdaa159cb project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m --- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Wed Feb 24 00:10:12 2016 +0100 +++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m Wed Feb 24 00:33:10 2016 +0100 @@ -277,8 +277,9 @@ // seed info [self sendToEngine:[gameConfig objectForKey:@"seed_command"]]; - // missions/tranings only need the script configuration set and seed - if ([HWUtils gameType] == gtMission) + // missions/tranings/campaign only need the script configuration set and seed + TGameType currentGameType = [HWUtils gameType]; + if (currentGameType == gtMission || currentGameType == gtCampaign) break; // dimension of the map diff -r b709768e720c -r 28afdaa159cb project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h --- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h Wed Feb 24 00:10:12 2016 +0100 +++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.h Wed Feb 24 00:33:10 2016 +0100 @@ -34,6 +34,7 @@ +(void) startLocalGame:(NSDictionary *)withOptions; +(void) startSaveGame:(NSString *)atPath; +(void) startMissionGame:(NSString *)withScript; ++(void) startCampaignMissionGameWithScript:(NSString *)missionScriptName forCampaign:(NSString *)campaignName; +(void) startSimpleGame; +(void) registerCallingController:(UIViewController *)controller; diff -r b709768e720c -r 28afdaa159cb project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m --- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Wed Feb 24 00:10:12 2016 +0100 +++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m Wed Feb 24 00:33:10 2016 +0100 @@ -259,6 +259,17 @@ return seedCmd; } ++(void) startCampaignMissionGameWithScript:(NSString *)missionScriptName forCampaign:(NSString *)campaignName { + NSString *seedCmd = [self seedCommand]; + NSString *campaignMissionPath = [[NSString alloc] initWithFormat:@"escript Missions/Campaign/%@/%@", campaignName, missionScriptName]; + NSDictionary *campaignMissionDict = [[NSDictionary alloc] initWithObjectsAndKeys:campaignMissionPath, @"mission_command", seedCmd, @"seed_command", nil]; + [campaignMissionPath release]; + [seedCmd release]; + + [self startGame:gtCampaign atPath:nil withOptions:campaignMissionDict]; + [campaignMissionDict release]; +} + +(void) startSimpleGame { NSString *seedCmd = [self seedCommand]; diff -r b709768e720c -r 28afdaa159cb project_files/HedgewarsMobile/Classes/HWUtils.h --- a/project_files/HedgewarsMobile/Classes/HWUtils.h Wed Feb 24 00:10:12 2016 +0100 +++ b/project_files/HedgewarsMobile/Classes/HWUtils.h Wed Feb 24 00:33:10 2016 +0100 @@ -20,7 +20,7 @@ #import -typedef enum {gtNone, gtLocal, gtSave, gtMission, gtNet} TGameType; +typedef enum {gtNone, gtLocal, gtSave, gtMission, gtCampaign, gtNet} TGameType; typedef enum {gsNone, gsLoading, gsInGame, gsInterrupted, gsEnded} TGameStatus; @interface HWUtils : NSObject {