cocoaTouch/TeamConfigViewController.m
author koda
Sun, 25 Apr 2010 02:30:42 +0000
changeset 3365 37ac593e9027
parent 3364 e5403e2bf02c
child 3374 0d522416d97f
permissions -rw-r--r--
wow all these files only for land preview and seed generation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     1
//
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     2
//  TeamConfigViewController.m
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     3
//  HedgewarsMobile
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     4
//
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     5
//  Created by Vittorio on 20/04/10.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     7
//
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     8
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
     9
#import "TeamConfigViewController.h"
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    10
#import "CommodityFunctions.h"
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    11
#import "HogButtonView.h"
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    12
#import "SquareButtonView.h"
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    13
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    14
@implementation TeamConfigViewController
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    15
@synthesize listOfTeams, listOfSelectedTeams;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    16
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    17
#define NUMBERBUTTON_TAG 123456
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    18
#define SQUAREBUTTON_TAG 654321
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    19
#define LABEL_TAG        456123
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    20
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    21
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    22
#pragma mark View lifecycle
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    23
-(void) viewDidLoad {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    24
    [super viewDidLoad];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    25
    
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    26
    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    27
    self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    28
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    29
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    30
-(void) viewWillAppear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    31
    [super viewWillAppear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    32
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    33
    unsigned int colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    34
    NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    35
    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    36
    for (int i = 0; i < [contentsOfDir count]; i++) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    37
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    38
                                                                  [contentsOfDir objectAtIndex:i],@"team",
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    39
                                                                  [NSNumber numberWithInt:4],@"number",
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    40
                                                                  [NSNumber numberWithInt:colors[i%6]],@"color",nil];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    41
        [array addObject:dict];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    42
        [dict release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    43
    }
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    44
    self.listOfTeams = array;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    45
    [array release];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    46
    
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    47
    NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    48
    self.listOfSelectedTeams = emptyArray;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    49
    [emptyArray release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    50
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    51
    [self.tableView reloadData];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    52
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    53
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    54
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    55
- (void)viewDidAppear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    56
    [super viewDidAppear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    57
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    58
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    59
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    60
- (void)viewWillDisappear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    61
    [super viewWillDisappear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    62
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    63
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    64
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    65
- (void)viewDidDisappear:(BOOL)animated {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    66
    [super viewDidDisappear:animated];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    67
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    68
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    69
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    70
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    71
    return rotationManager(interfaceOrientation);
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    72
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    73
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    74
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    75
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    76
#pragma mark Table view data source
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    77
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    78
    return 2;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    79
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    80
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    81
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    82
    if (section == 0)
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    83
        return [listOfSelectedTeams count] ;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    84
    else
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    85
        return [listOfTeams count];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    86
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    87
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    88
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    89
    if (section == 0)
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    90
        return NSLocalizedString(@"Playing Teams",@"");
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    91
    else
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    92
        return NSLocalizedString(@"Available Teams",@"");
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    93
}
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    94
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    95
// Customize the appearance of table view cells.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    96
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    97
    static NSString *CellIdentifier0 = @"Cell0";
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    98
    static NSString *CellIdentifier1 = @"Cell1";
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    99
    NSInteger section = [indexPath section];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   100
    UITableViewCell *cell;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   101
    
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   102
    if (section == 0) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   103
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   104
        if (cell == nil) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   105
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   106
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   107
            UIButton *numberButton = [[HogButtonView alloc] initWithFrame:CGRectMake(12, 5, 88, 32)];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   108
            numberButton.tag = NUMBERBUTTON_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   109
            [cell addSubview:numberButton];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   110
            [numberButton release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   111
            
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   112
            SquareButtonView *squareButton = [[SquareButtonView alloc] initWithFrame:CGRectMake(12+88+7, 5, 36, 36)];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   113
            squareButton.tag = SQUAREBUTTON_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   114
            [cell addSubview:squareButton];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   115
            [squareButton release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   116
            
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   117
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12+88+7+36+7, 10, 250, 25)];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   118
            label.textAlignment = UITextAlignmentLeft;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   119
            label.backgroundColor = [UIColor clearColor];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   120
            label.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   121
            label.tag = LABEL_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   122
            [cell.contentView addSubview:label];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   123
            [label release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   124
        }
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   125
        
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   126
        NSMutableDictionary *selectedRow = [listOfSelectedTeams objectAtIndex:[indexPath row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   127
        
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   128
        UILabel *cellLabel = (UILabel *)[cell viewWithTag:LABEL_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   129
        cellLabel.text = [[selectedRow objectForKey:@"team"] stringByDeletingPathExtension];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   130
        
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   131
        HogButtonView *numberButton = (HogButtonView *)[cell viewWithTag:NUMBERBUTTON_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   132
        [numberButton drawManyHogs:[[selectedRow objectForKey:@"number"] intValue]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   133
        numberButton.ownerDictionary = selectedRow;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   134
        
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   135
        SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   136
        [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   137
        squareButton.ownerDictionary = selectedRow;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   138
    } else {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   139
        cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   140
        if (cell == nil) 
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   141
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   142
        
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   143
        cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   144
    }
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   145
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   146
    return cell;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   147
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   148
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   149
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   150
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   151
// Override to support conditional editing of the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   152
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   153
    // Return NO if you do not want the specified item to be editable.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   154
    return YES;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   155
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   156
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   157
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   158
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   159
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   160
// Override to support editing the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   161
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   162
    
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   163
    if (editingStyle == UITableViewCellEditingStyleDelete) {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   164
        // Delete the row from the data source
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   165
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   166
    }   
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   167
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   168
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   169
    }   
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   170
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   171
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   172
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   173
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   174
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   175
// Override to support rearranging the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   176
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   177
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   178
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   179
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   180
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   181
// Override to support conditional rearranging of the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   182
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   183
    // Return NO if you do not want the item to be re-orderable.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   184
    return YES;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   185
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   186
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   187
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   188
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   189
#pragma mark Table view delegate
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   190
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   191
    NSInteger row = [indexPath row];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   192
    NSInteger section = [indexPath section];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   193
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   194
    if (section == 0) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   195
        [self.listOfTeams addObject:[self.listOfSelectedTeams objectAtIndex:row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   196
        [self.listOfSelectedTeams removeObjectAtIndex:row];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   197
    } else {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   198
        [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   199
        [self.listOfTeams removeObjectAtIndex:row];      
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   200
    }
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   201
    [self.tableView reloadData];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   202
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   203
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   204
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   205
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   206
#pragma mark Memory management
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   207
-(void) didReceiveMemoryWarning {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   208
    // Releases the view if it doesn't have a superview.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   209
    [super didReceiveMemoryWarning];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   210
    // Relinquish ownership any cached data, images, etc that aren't in use.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   211
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   212
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   213
-(void) viewDidUnload {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   214
    self.listOfTeams = nil;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   215
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   216
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   217
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   218
-(void) dealloc {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   219
    [listOfTeams release];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   220
    [super dealloc];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   221
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   222
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   223
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   224
@end
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   225