project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m
changeset 4349 8efa91f98274
parent 4287 7dbdc862097c
child 4356 d1d26f8963a3
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m	Tue Nov 16 20:04:20 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m	Sun Nov 21 04:10:39 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 {