remove weapons and schemes selection for missions from ifrontend
authorkoda
Wed, 17 Nov 2010 01:42:51 +0100
changeset 4351 9d155da5b417
parent 4348 d4f659e96a4a
child 4353 671d66ba3af6
remove weapons and schemes selection for missions from ifrontend
hedgewars/uAmmos.pas
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/MapConfigViewController.h
project_files/HedgewarsMobile/Classes/MapConfigViewController.m
project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.h
project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m
--- a/hedgewars/uAmmos.pas	Tue Nov 16 20:04:20 2010 +0100
+++ b/hedgewars/uAmmos.pas	Wed Nov 17 01:42:51 2010 +0100
@@ -20,7 +20,7 @@
 
 unit uAmmos;
 interface
-uses uConsts, uTeams, uStats;
+uses uConsts, uTeams;
 
 procedure initModule;
 procedure freeModule;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Wed Nov 17 01:42:51 2010 +0100
@@ -157,7 +157,6 @@
     int hogs = 0;
     for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
         hogs += [[teamData objectForKey:@"number"] intValue];
-    
     if (hogs > self.mapConfigViewController.maxHogs) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"")
                                                         message:NSLocalizedString(@"The map is too small for that many hogs",@"")
@@ -193,7 +192,7 @@
         return NO;
     }
 
-    // play if the gameflags are set correctly (divideteam works only with 2 teams
+    // play if the gameflags are set correctly (divideteam works only with 2 teams)
     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),self.schemeWeaponConfigViewController.selectedScheme];
     NSArray *gameFlags = [[NSDictionary dictionaryWithContentsOfFile:schemePath] objectForKey:@"gamemod"];
     [schemePath release];
@@ -367,6 +366,7 @@
         [self.view addSubview:self.schemeWeaponConfigViewController.view];
     }
     [self.view addSubview:self.mapConfigViewController.view];
+    self.mapConfigViewController.externalController = schemeWeaponConfigViewController;
 
     [super viewDidLoad];
 }
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.h	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.h	Wed Nov 17 01:42:51 2010 +0100
@@ -22,10 +22,12 @@
 #import <UIKit/UIKit.h>
 #import "MapPreviewButtonView.h"
 
+@class SchemeWeaponConfigViewController;
+
 @interface MapConfigViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, MapPreviewViewDelegate> {
-    NSInteger oldValue;  //slider
-    NSInteger oldPage;   //segmented control
-    BOOL busy;
+    NSInteger oldValue;     // for the slider
+    NSInteger oldPage;      // for the segmented control
+    BOOL busy;              // for the preview button
 
     // objects read (mostly) by parent view
     NSInteger maxHogs;
@@ -48,6 +50,9 @@
     // internal objects
     NSIndexPath *lastIndexPath;
     NSArray *dataSourceArray;
+
+    // controller for mission state
+    SchemeWeaponConfigViewController *externalController;
 }
 
 
@@ -71,6 +76,9 @@
 @property (nonatomic,retain) NSIndexPath *lastIndexPath;
 @property (nonatomic,retain) NSArray *dataSourceArray;
 
+@property (nonatomic,assign) SchemeWeaponConfigViewController *externalController;
+
+
 -(IBAction) buttonPressed:(id) sender;
 
 -(IBAction) mapButtonPressed;
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m	Wed Nov 17 01:42:51 2010 +0100
@@ -23,13 +23,14 @@
 #import "PascalImports.h"
 #import "CommodityFunctions.h"
 #import "UIImageExtra.h"
+#import "SchemeWeaponConfigViewController.h"
 
 #define scIndex         self.segmentedControl.selectedSegmentIndex
 #define isRandomness()  (segmentedControl.selectedSegmentIndex == 0 || segmentedControl.selectedSegmentIndex == 2)
 
 @implementation MapConfigViewController
 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand, staticMapCommand,
-            missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy;
+            missionCommand, tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, dataSourceArray, busy, externalController;
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -320,16 +321,17 @@
             mission = @"";
             [self sliderChanged:nil];
             self.slider.enabled = YES;
+            [externalController fillSections];
             break;
 
         case 1: // Map
-        case 3: // Mission
             mapgen = @"e$mapgen 0";
             // dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap
             staticmap = @"map Bamboo";
             mission = @"";
             self.slider.enabled = NO;
             self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
+            [externalController fillSections];
             break;
 
         case 2: // Maze
@@ -338,6 +340,17 @@
             mission = @"";
             [self sliderChanged:nil];
             self.slider.enabled = YES;
+            [externalController fillSections];
+            break;
+
+        case 3: // Mission
+            mapgen = @"e$mapgen 0";
+            // dummy values, these are set by -updatePreview -> -didSelectRowAtIndexPath -> -setDetailsForStaticMap
+            staticmap = @"map Bamboo";
+            mission = @"";
+            self.slider.enabled = NO;
+            self.sizeLabel.text = NSLocalizedString(@"No filter",@"");
+            [externalController emptySections];
             break;
 
         default:
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.h	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.h	Wed Nov 17 01:42:51 2010 +0100
@@ -33,6 +33,7 @@
     NSString *selectedWeapon;
 
     UISwitch *syncSwitch;
+    BOOL hideSections;
 }
 
 @property (nonatomic,retain) NSArray *listOfSchemes;
@@ -43,4 +44,7 @@
 @property (nonatomic,retain) NSString *selectedWeapon;
 @property (nonatomic,retain) UISwitch *syncSwitch;
 
+-(void) fillSections;
+-(void) emptySections;
+
 @end
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m	Wed Nov 17 01:42:51 2010 +0100
@@ -23,6 +23,8 @@
 #import "CommodityFunctions.h"
 #import "SDL_uikitappdelegate.h"
 
+#define LABEL_TAG 57423
+
 @implementation SchemeWeaponConfigViewController
 @synthesize listOfSchemes, listOfWeapons, lastIndexPath_sc, lastIndexPath_we, selectedScheme, selectedWeapon, syncSwitch;
 
@@ -81,7 +83,10 @@
 #pragma mark -
 #pragma mark Table view data source
 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
-    return 3;
+    if (hideSections)
+        return 0;
+    else
+        return 3;
 }
 
 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -215,6 +220,45 @@
     [aTableView deselectRowAtIndexPath:indexPath animated:YES];
 }
 
+-(void) fillSections {
+    if (hideSections == YES) {
+        hideSections = NO;
+        NSRange range;
+        range.location = 0;
+        range.length = 3;
+        NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range];
+        [self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade];
+        self.selectedScheme = @"Default.plist";
+        self.selectedWeapon = @"Default.plist";
+
+        self.tableView.scrollEnabled = YES;
+
+        [[self.view viewWithTag:LABEL_TAG] removeFromSuperview];
+    }
+}
+
+-(void) emptySections {
+    hideSections = YES;
+    NSRange range;
+    range.location = 0;
+    range.length = 3;
+    NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range];
+    [self.tableView deleteSections:sections withRowAnimation:UITableViewRowAnimationFade];
+    self.selectedScheme = @"Default.plist";
+    self.selectedWeapon = @"Default.plist";
+
+    self.tableView.scrollEnabled = NO;
+
+    CGRect frame = CGRectMake(0, 0, self.view.frame.size.width * 80/100, 60);
+    UILabel *theLabel = createBlueLabel(NSLocalizedString(@"Missions don't need further configuration",@""), frame);
+    theLabel.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
+    theLabel.numberOfLines = 2;
+    theLabel.tag = LABEL_TAG;
+
+    [self.view addSubview:theLabel];
+    [theLabel release];
+}
+
 #pragma mark -
 #pragma mark Memory management
 -(void) didReceiveMemoryWarning {