cocoaTouch/iPad/MasterViewController.m
author nemo
Sat, 03 Apr 2010 13:55:39 +0000
changeset 3287 4f7b57ed18b6
parent 3250 d5cd1a617123
permissions -rw-r--r--
New game scheme option to turn off land objects
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     1
//
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     2
//  MasterViewController.m
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     3
//  HedgewarsMobile
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     4
//
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     5
//  Created by Vittorio on 27/03/10.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     7
//
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     8
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
     9
#import "MasterViewController.h"
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    10
#import "DetailViewController.h"
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    11
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    12
@implementation MasterViewController
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    13
@synthesize detailViewController, optionList;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    14
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    15
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    16
#pragma mark View lifecycle
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    17
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    18
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    19
- (void)viewDidLoad {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    20
    [super viewDidLoad];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    21
    optionList = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    22
                                                  NSLocalizedString(@"Teams",@""),
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    23
                                                  NSLocalizedString(@"Weapons",@""),
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    24
                                                  NSLocalizedString(@"Schemes",@""),
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    25
                                                  nil];
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    26
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:0 target:self action:@selector(dismissSplitView)];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
    27
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    28
    // Uncomment the following line to preserve selection between presentations.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    29
    //self.clearsSelectionOnViewWillAppear = NO;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    30
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    31
    //self.navigationItem.rightBarButtonItem = self.editButtonItem;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    32
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    33
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    34
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    35
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    36
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    37
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    38
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    39
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    40
#pragma mark Table view data source
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    41
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    42
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    43
    return 1;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    44
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    45
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    46
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    47
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    48
    return [optionList count];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    49
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    50
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    51
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    52
// Customize the appearance of table view cells.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    53
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    54
    static NSString *CellIdentifier = @"Cell";
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    55
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    56
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    57
    if (cell == nil) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    58
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    59
        cell.textLabel.text = [optionList objectAtIndex:[indexPath row]];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    60
    }
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    61
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    62
    return cell;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    63
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    64
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    65
/*
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    66
// Override to support editing the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    67
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    68
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    69
    if (editingStyle == UITableViewCellEditingStyleDelete) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    70
        // Delete the row from the data source
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    71
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    72
    }   
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    73
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    74
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    75
    }   
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    76
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    77
*/
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    78
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    79
/*
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    80
// Override to support rearranging the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    81
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    82
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    83
*/
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    84
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    85
/*
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    86
// Override to support conditional rearranging of the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    87
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    88
    // Return NO if you do not want the item to be re-orderable.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    89
    return YES;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    90
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    91
*/
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    92
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    93
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    94
#pragma mark Table view delegate
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    95
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    96
    // Navigation logic may go here. Create and push another view controller.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    97
	/*
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    98
	DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    99
    // Pass the selected object to the new view controller.
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
   100
	[self.navigationController pushViewController:detailViewController animated:YES];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
   101
	[detailViewController release];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
   102
	*/
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   103
    detailViewController.detailItem = [[NSString alloc] initWithFormat:@"%d", [indexPath row]];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   104
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   105
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   106
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   107
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   108
#pragma mark Memory management
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   109
-(void) didReceiveMemoryWarning {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   110
    // Releases the view if it doesn't have a superview.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   111
    [super didReceiveMemoryWarning];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   112
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   113
    // Relinquish ownership any cached data, images, etc that aren't in use.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   114
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   115
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   116
- (void)dealloc {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   117
    [optionList release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   118
    [detailViewController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   119
    [super dealloc];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   120
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   121
3250
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
   122
-(IBAction) dismissSplitView {
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
   123
    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
d5cd1a617123 intial support for team configuration on the ifrontend
koda
parents: 3165
diff changeset
   124
}
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   125
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   126
@end
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   127