cocoaTouch/TeamConfigViewController.m
author nemo
Wed, 19 May 2010 02:10:28 +0000
changeset 3476 1ec68b8d3bd1
parent 3377 a3f0849f26bc
child 3487 b1d00f1950c8
permissions -rw-r--r--
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
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
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
    33
    // integer representation of various color (defined in SquareButtonView)
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
    34
    NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    35
    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
    36
    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    37
    for (int i = 0; i < [contentsOfDir count]; i++) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    38
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    39
                                                                  [contentsOfDir objectAtIndex:i],@"team",
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    40
                                                                  [NSNumber numberWithInt:4],@"number",
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    41
                                                                  [NSNumber numberWithInt:colors[i%6]],@"color",nil];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    42
        [array addObject:dict];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    43
        [dict release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    44
    }
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    45
    self.listOfTeams = array;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    46
    [array release];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    47
    
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    48
    NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    49
    self.listOfSelectedTeams = emptyArray;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    50
    [emptyArray release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    51
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    52
    [self.tableView reloadData];
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
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    56
    return rotationManager(interfaceOrientation);
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
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    61
#pragma mark Table view data source
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    62
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    63
    return 2;
3361
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
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    66
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    67
    if (section == 0)
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    68
        return [listOfSelectedTeams count] ;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    69
    else
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    70
        return [listOfTeams count];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    71
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    72
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    73
-(NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    74
    if (section == 0)
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    75
        return NSLocalizedString(@"Playing Teams",@"");
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    76
    else
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    77
        return NSLocalizedString(@"Available Teams",@"");
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    78
}
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
// Customize the appearance of table view cells.
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
    81
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    82
    static NSString *CellIdentifier0 = @"Cell0";
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    83
    static NSString *CellIdentifier1 = @"Cell1";
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    84
    NSInteger section = [indexPath section];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    85
    UITableViewCell *cell;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
    86
    
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    87
    if (section == 0) {
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
    88
        cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    89
        if (cell == nil) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    90
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    91
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    92
            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
    93
            numberButton.tag = NUMBERBUTTON_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    94
            [cell addSubview:numberButton];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    95
            [numberButton release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    96
            
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    97
            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
    98
            squareButton.tag = SQUAREBUTTON_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
    99
            [cell addSubview:squareButton];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   100
            [squareButton release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   101
            
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   102
            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
   103
            label.textAlignment = UITextAlignmentLeft;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   104
            label.backgroundColor = [UIColor clearColor];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   105
            label.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize] + 2];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   106
            label.tag = LABEL_TAG;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   107
            [cell.contentView addSubview:label];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   108
            [label release];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   109
        }
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   110
        
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   111
        NSMutableDictionary *selectedRow = [listOfSelectedTeams objectAtIndex:[indexPath row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   112
        
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   113
        UILabel *cellLabel = (UILabel *)[cell viewWithTag:LABEL_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   114
        cellLabel.text = [[selectedRow objectForKey:@"team"] stringByDeletingPathExtension];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   115
        
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   116
        HogButtonView *numberButton = (HogButtonView *)[cell viewWithTag:NUMBERBUTTON_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   117
        [numberButton drawManyHogs:[[selectedRow objectForKey:@"number"] intValue]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   118
        numberButton.ownerDictionary = selectedRow;
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   119
        
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   120
        SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   121
        [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   122
        squareButton.ownerDictionary = selectedRow;
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   123
    } else {
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
   124
        cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   125
        if (cell == nil) 
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   126
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
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
        cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   129
    }
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   130
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   131
    return cell;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   132
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   133
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   134
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   135
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   136
// Override to support conditional editing of the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   137
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   138
    // 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
   139
    return YES;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   140
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   141
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   142
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   143
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   144
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   145
// Override to support editing the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   146
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
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
    if (editingStyle == UITableViewCellEditingStyleDelete) {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   149
        // Delete the row from the data source
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   150
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   151
    }   
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   152
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   153
        // 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
   154
    }   
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 rearranging the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   161
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
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
*/
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   164
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   165
/*
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   166
// Override to support conditional rearranging of the table view.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   167
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   168
    // 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
   169
    return YES;
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
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   174
#pragma mark Table view delegate
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
   175
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   176
    NSInteger row = [indexPath row];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   177
    NSInteger section = [indexPath section];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   178
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   179
    if (section == 0) {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   180
        [self.listOfTeams addObject:[self.listOfSelectedTeams objectAtIndex:row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   181
        [self.listOfSelectedTeams removeObjectAtIndex:row];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   182
    } else {
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   183
        [self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   184
        [self.listOfTeams removeObjectAtIndex:row];      
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3361
diff changeset
   185
    }
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
   186
    [aTableView reloadData];
3361
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
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   189
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   190
#pragma mark -
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   191
#pragma mark Memory management
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   192
-(void) didReceiveMemoryWarning {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   193
    // Releases the view if it doesn't have a superview.
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   194
    [super didReceiveMemoryWarning];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   195
    // 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
   196
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   197
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   198
-(void) viewDidUnload {
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   199
    self.listOfTeams = nil;
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   200
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   201
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
-(void) dealloc {
3374
0d522416d97f lazy loading for all the tables with images (might affect performance but ui feels much more responsive)
koda
parents: 3365
diff changeset
   204
    [self.listOfTeams release];
3361
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   205
    [super dealloc];
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   206
}
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   207
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   208
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   209
@end
cfc6cd502f85 buttons for number of hogs in game config
koda
parents:
diff changeset
   210