cocoaTouch/iPad/MasterViewController.m
author smxx
Tue, 30 Mar 2010 13:20:04 +0000
changeset 3172 ae5c7f97df44
parent 3165 3ec07a7d8456
child 3250 d5cd1a617123
permissions -rw-r--r--
Engine: * Lowered the number of feathers spawned by Birdy * Made hogs caugh/moan once they lose health due to poison - no longer random Frontend: * Modified game scheme editor to lookup the number of default ammoschemes (no longer hardcoded) * Added new default game schemes: Barrel Mayhem, Tunnel Hogs * Added new default weapon scheme: Tunnel Hogs
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];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    26
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    27
    // Uncomment the following line to preserve selection between presentations.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    28
    //self.clearsSelectionOnViewWillAppear = NO;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    29
    // 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
    30
    //self.navigationItem.rightBarButtonItem = self.editButtonItem;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    31
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    32
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    33
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    34
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    35
}
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
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    39
#pragma mark Table view data source
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    40
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    41
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    42
    return 1;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    43
}
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
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    47
    return [optionList count];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    48
}
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
// Customize the appearance of table view cells.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    52
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    53
    static NSString *CellIdentifier = @"Cell";
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    54
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    55
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    56
    if (cell == nil) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    57
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    58
        cell.textLabel.text = [optionList objectAtIndex:[indexPath row]];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    59
    }
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    60
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    61
    return cell;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    62
}
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
// Override to support editing the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    66
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    67
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    68
    if (editingStyle == UITableViewCellEditingStyleDelete) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    69
        // Delete the row from the data source
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    70
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    71
    }   
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    72
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    73
        // 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
    74
    }   
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
// Override to support rearranging the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    80
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    81
}
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
// Override to support conditional rearranging of the table view.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    86
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    87
    // Return NO if you do not want the item to be re-orderable.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    88
    return YES;
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    89
}
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
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    93
#pragma mark Table view delegate
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    94
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    95
    // Navigation logic may go here. Create and push another view controller.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
    96
	/*
3165
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
    97
	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
    98
    // 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
    99
	[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
   100
	[detailViewController release];
3ec07a7d8456 just some very sane stuff for the iphone port (plus some macro on pascal files)
koda
parents: 3113
diff changeset
   101
	*/
3113
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   102
    detailViewController.detailItem = [[NSString alloc] initWithFormat:@"%d", [indexPath row]];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   103
}
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
#pragma mark -
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   107
#pragma mark Memory management
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   108
-(void) didReceiveMemoryWarning {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   109
    // Releases the view if it doesn't have a superview.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   110
    [super didReceiveMemoryWarning];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   111
    
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   112
    // Relinquish ownership any cached data, images, etc that aren't in use.
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   113
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   114
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   115
- (void)dealloc {
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   116
    [optionList release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   117
    [detailViewController release];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   118
    [super dealloc];
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   119
}
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   120
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   121
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   122
@end
2829ea0dd47c * port fadeout to opengles
koda
parents:
diff changeset
   123