project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
author Wuzzy <Wuzzy2@mail.ru>
Fri, 16 Feb 2018 19:49:46 +0100
changeset 13020 d1e7f2420f00
parent 11549 893722a2a1f9
child 12872 00215a7ec5f5
permissions -rw-r--r--
Lua API: Add functons: GetTeamIndex and GetTeamClan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
6700
e04da46ee43c the most important commit of the year
koda
parents: 6636
diff changeset
     3
 * Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 8441
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    17
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3814
diff changeset
    18
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    19
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    20
#import "TeamConfigViewController.h"
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    21
#import <QuartzCore/QuartzCore.h>
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    22
#import "SquareButtonView.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    23
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
    24
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    25
@implementation TeamConfigViewController
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    26
@synthesize tableView, selectedTeamsCount, allTeamsCount, listOfAllTeams, listOfSelectedTeams, cachedContentsOfDir;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    27
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    28
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    29
    return rotationManager(interfaceOrientation);
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    30
}
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    31
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    32
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    33
#pragma mark View lifecycle
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    34
-(void) viewDidLoad {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    35
    UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    36
                                                           style:UITableViewStyleGrouped];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    37
    aTableView.delegate = self;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    38
    aTableView.dataSource = self;
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    39
    if (IS_IPAD()) {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    40
        [aTableView setBackgroundColorForAnyTable:[UIColor darkBlueColorTransparent]];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    41
        aTableView.layer.borderColor = [[UIColor darkYellowColor] CGColor];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    42
        aTableView.layer.borderWidth = 2.7f;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    43
        aTableView.layer.cornerRadius = 8;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    44
        aTableView.contentInset = UIEdgeInsetsMake(10, 0, 10, 0);
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    45
    } else {
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    46
        UIImage *backgroundImage = [[UIImage alloc] initWithContentsOfFile:@"background~iphone.png"];
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    47
        UIImageView *background = [[UIImageView alloc] initWithImage:backgroundImage];
11146
f5e552f97eda - Fixes for cropped background image on iPhone
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    48
        background.contentMode = UIViewContentModeScaleAspectFill;
f5e552f97eda - Fixes for cropped background image on iPhone
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
    49
        background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    50
        [backgroundImage release];
6220
39782c4d9246 ok *this* brings ios 3.* runtime compatibility
koda
parents: 6219
diff changeset
    51
        [self.view addSubview:background];
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    52
        [background release];
6220
39782c4d9246 ok *this* brings ios 3.* runtime compatibility
koda
parents: 6219
diff changeset
    53
        [aTableView setBackgroundColorForAnyTable:[UIColor clearColor]];
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
    54
    }
4244
bf46b4bdf27d iphone interface
koda
parents: 4115
diff changeset
    55
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    56
    aTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    57
    aTableView.separatorColor = [UIColor whiteColor];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    58
    aTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
6634
e00762923086 ios game configuration page supports rotation, with some enhancements (like the new slider); some glitches here and there
koda
parents: 6264
diff changeset
    59
    aTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    60
    self.tableView = aTableView;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    61
    [aTableView release];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    62
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    63
    [self.view addSubview:self.tableView];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    64
    [super viewDidLoad];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    65
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    66
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    67
-(void) viewWillAppear:(BOOL)animated {
3739
97cf933e5bd2 disable AI teleport
koda
parents: 3703
diff changeset
    68
    NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
3971
5c82ee165ed5 minor stuff
koda
parents: 3917
diff changeset
    69
    if ([self.cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    70
        self.cachedContentsOfDir = contentsOfDir;
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
    71
        NSArray *colors = [HWUtils teamColors];
3551
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    72
        NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
6908
896ed2afcfb8 ios: turn on more warning messages and start correcting them
koda
parents: 6832
diff changeset
    73
        for (NSUInteger i = 0; i < [contentsOfDir count]; i++) {
3551
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    74
            NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    75
                                         [contentsOfDir objectAtIndex:i],@"team",
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    76
                                         [NSNumber numberWithInt:4],@"number",
3917
4c243b1eac97 playing a bit with colors
koda
parents: 3829
diff changeset
    77
                                         [colors objectAtIndex:i%[colors count]],@"color",nil];
3551
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    78
            [array addObject:dict];
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    79
            [dict release];
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    80
        }
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    81
        self.listOfAllTeams = array;
3551
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    82
        [array release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    83
3551
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    84
        NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    85
        self.listOfSelectedTeams = emptyArray;
d4de36b3801a moar zoom, fixed fort mode, other glitches
koda
parents: 3547
diff changeset
    86
        [emptyArray release];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    87
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    88
        self.selectedTeamsCount = [self.listOfSelectedTeams count];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    89
        self.allTeamsCount = [self.listOfAllTeams count];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    90
        [self.tableView reloadData];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    91
    }
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    92
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
    93
    [super viewWillAppear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    94
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    95
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    96
-(NSInteger) filterNumberOfHogs:(NSInteger) hogs {
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    97
    NSInteger numberOfHogs;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    98
    if (hogs <= HW_getMaxNumberOfHogs() && hogs >= 1)
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
    99
        numberOfHogs = hogs;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   100
    else {
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   101
        if (hogs > HW_getMaxNumberOfHogs())
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   102
            numberOfHogs = 1;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   103
        else
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   104
            numberOfHogs = HW_getMaxNumberOfHogs();
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   105
    }
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   106
    return numberOfHogs;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   107
}
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   108
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   109
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   110
#pragma mark Table view data source
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   111
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   112
    return 2;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   113
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   114
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   115
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   116
    return (section == 0 ? self.selectedTeamsCount : self.allTeamsCount);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   117
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   118
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   119
// Customize the appearance of table view cells.
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   121
    static NSString *CellIdentifier0 = @"Cell0";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   122
    static NSString *CellIdentifier1 = @"Cell1";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   123
    NSInteger section = [indexPath section];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   124
    UITableViewCell *cell;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   125
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   126
    if (section == 0) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   127
        cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   128
        if (cell == nil) {
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   129
            cell = [[[HoldTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier0] autorelease];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   130
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   131
            SquareButtonView *squareButton = [[SquareButtonView alloc] initWithFrame:CGRectMake(0, 0, 36, 36)];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   132
            cell.accessoryView = squareButton;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   133
            [squareButton release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   134
        }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   135
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   136
        NSMutableDictionary *selectedRow = [listOfSelectedTeams objectAtIndex:[indexPath row]];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   137
        cell.textLabel.text = [[selectedRow objectForKey:@"team"] stringByDeletingPathExtension];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   138
        cell.textLabel.backgroundColor = [UIColor clearColor];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   139
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   140
        SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   141
        [squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   142
        NSNumber *hogNumber = [selectedRow objectForKey:@"number"];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   143
        [squareButton setTitle:[hogNumber stringValue] forState:UIControlStateNormal];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   144
        squareButton.ownerDictionary = selectedRow;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   145
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6115
diff changeset
   146
        cell.imageView.image = [UIImage drawHogsRepeated:[hogNumber intValue]];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   147
        ((HoldTableViewCell *)cell).delegate = self;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   148
    } else {
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   149
        cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   150
        if (cell == nil)
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   151
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   152
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   153
        cell.textLabel.text = [[[self.listOfAllTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   154
        cell.textLabel.backgroundColor = [UIColor clearColor];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   155
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   156
        NSString *teamPath = [NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),cell.textLabel.text];
3814
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   157
        NSDictionary *firstHog = [[[NSDictionary dictionaryWithContentsOfFile:teamPath] objectForKey:@"hedgehogs"] objectAtIndex:0];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   158
        if ([[firstHog objectForKey:@"level"] intValue] != 0) {
5976
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   159
            NSString *imgString = [[NSString alloc] initWithFormat:@"%@/robotBadge.png",[[NSBundle mainBundle] resourcePath]];
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   160
            UIImage *sprite = [[UIImage alloc] initWithContentsOfFile:imgString];
306cedbeb213 fixed several 'retina display' images and added a bunch more (though just from upscaling the normal ones; might be nice to have 'em redrawn at a real higher resolution)
koda
parents: 5208
diff changeset
   161
            [imgString release];
3814
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   162
            UIImageView *spriteView = [[UIImageView alloc] initWithImage:sprite];
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   163
            [sprite release];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6908
diff changeset
   164
3814
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   165
            cell.accessoryView = spriteView;
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   166
            [spriteView release];
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   167
        } else
7af568bc0710 discrimination between ai and humans
koda
parents: 3780
diff changeset
   168
            cell.accessoryView = nil;
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   169
    }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   170
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
   171
    cell.textLabel.textColor = [UIColor lightYellowColor];
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
   172
    cell.backgroundColor = [UIColor blackColorTransparent];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   173
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   174
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   175
    return cell;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   176
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   177
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   178
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
6108
7a8da11a6144 refreshed the ipad interface with some white
koda
parents: 6107
diff changeset
   179
    return 45.0;
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   180
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   181
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   182
-(UIView *)tableView:(UITableView *)aTableView viewForHeaderInSection:(NSInteger)section {
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   183
    CGRect frame = CGRectMake(0, 0, self.view.frame.size.width * 70/100, 30);
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
   184
    NSString *text = (section == 0) ? NSLocalizedString(@"Playing Teams",@"") : NSLocalizedString(@"Available Teams",@"");
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 5976
diff changeset
   185
    UILabel *theLabel = [[UILabel alloc] initWithFrame:frame andTitle:text];
3780
7c704e69242e fade in when returning from game, labels rewritten so that they are drawn at runtime (more flexibility with i18n and iphone support)
koda
parents: 3739
diff changeset
   186
    theLabel.center = CGPointMake(self.view.frame.size.width/2, 20);
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   187
    theLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   188
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   189
    UIView *theView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width, 30)];
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   190
    theView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
3780
7c704e69242e fade in when returning from game, labels rewritten so that they are drawn at runtime (more flexibility with i18n and iphone support)
koda
parents: 3739
diff changeset
   191
    [theView addSubview:theLabel];
7c704e69242e fade in when returning from game, labels rewritten so that they are drawn at runtime (more flexibility with i18n and iphone support)
koda
parents: 3739
diff changeset
   192
    [theLabel release];
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   193
    return [theView autorelease];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   194
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents: 3697
diff changeset
   195
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   196
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
11325
d98070707214 - Small size adjustments for footer labels on GameConfig screen
antonc27 <antonc27@mail.ru>
parents: 11148
diff changeset
   197
    return IS_IPAD() ? 40 : 30;
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   198
}
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   199
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   200
-(UIView *)tableView:(UITableView *)aTableView viewForFooterInSection:(NSInteger) section {
11325
d98070707214 - Small size adjustments for footer labels on GameConfig screen
antonc27 <antonc27@mail.ru>
parents: 11148
diff changeset
   201
    NSInteger height = IS_IPAD() ? 40 : 30;
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   202
    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width, height)];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   203
    footer.backgroundColor = [UIColor clearColor];
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   204
    footer.autoresizingMask = UIViewAutoresizingFlexibleWidth;
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   205
11325
d98070707214 - Small size adjustments for footer labels on GameConfig screen
antonc27 <antonc27@mail.ru>
parents: 11148
diff changeset
   206
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, aTableView.frame.size.width*90/100, height)];
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   207
    label.center = CGPointMake(aTableView.frame.size.width/2, height/2);
11549
893722a2a1f9 - Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents: 11327
diff changeset
   208
    label.textAlignment = NSTextAlignmentCenter;
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   209
    label.font = [UIFont italicSystemFontOfSize:12];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   210
    label.textColor = [UIColor whiteColor];
4538
4c2dc9d75742 add more space for this help message on ipad
koda
parents: 4504
diff changeset
   211
    label.numberOfLines = 2;
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   212
    label.backgroundColor = [UIColor clearColor];
11327
a0163b8302c5 - Fix for wrong footer labels size on autorotation on GameConfig screen
antonc27 <antonc27@mail.ru>
parents: 11325
diff changeset
   213
    label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
6636
4450e746dc34 ios game configuration page rotation gliches fix
koda
parents: 6634
diff changeset
   214
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   215
    if (section == 0)
4538
4c2dc9d75742 add more space for this help message on ipad
koda
parents: 4504
diff changeset
   216
        label.text = NSLocalizedString(@"Tap to add hogs or change color, touch and hold to remove a team.",@"");
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   217
    else
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   218
        label.text = NSLocalizedString(@"The robot badge indicates an AI-controlled team.",@"");
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   219
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   220
    [footer addSubview:label];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   221
    [label release];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   222
    return [footer autorelease];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   223
}
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   224
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   225
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   226
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   227
#pragma mark Table view delegate
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   228
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6908
896ed2afcfb8 ios: turn on more warning messages and start correcting them
koda
parents: 6832
diff changeset
   229
    NSUInteger row = [indexPath row];
896ed2afcfb8 ios: turn on more warning messages and start correcting them
koda
parents: 6832
diff changeset
   230
    NSUInteger section = [indexPath section];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   231
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   232
    if (section == 1 && [self.listOfAllTeams count] > row) {
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   233
        [self.listOfSelectedTeams addObject:[self.listOfAllTeams objectAtIndex:row]];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   234
        [self.listOfAllTeams removeObjectAtIndex:row];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   235
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   236
        NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:selectedTeamsCount inSection:0];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   237
        allTeamsCount--;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   238
        selectedTeamsCount++;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   239
        [aTableView beginUpdates];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   240
        [aTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationRight];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   241
        [aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   242
        [aTableView endUpdates];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   243
    }
4486
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   244
    if (section == 0 && [self.listOfSelectedTeams count] > row) {
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   245
        NSMutableDictionary *selectedRow = [self.listOfSelectedTeams objectAtIndex:row];
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   246
        UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   247
        SquareButtonView *squareButton = (SquareButtonView *)cell.accessoryView;
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   248
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   249
        NSInteger increaseNumber = [[selectedRow objectForKey:@"number"] intValue] + 1;
11148
064a53861759 - Refactoring in order to remove some warning related to using of int instead of NSInteger
antonc27 <antonc27@mail.ru>
parents: 11146
diff changeset
   250
        NSNumber *newNumber = [NSNumber numberWithInteger:[self filterNumberOfHogs:increaseNumber]];
4486
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   251
        [squareButton setTitle:[newNumber stringValue] forState:UIControlStateNormal];
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   252
        [selectedRow setObject:newNumber forKey:@"number"];
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   253
6209
074ab6ebcb3e restore runtime compatibility with ios 3.2
koda
parents: 6115
diff changeset
   254
        cell.imageView.image = [UIImage drawHogsRepeated:[newNumber intValue]];
4486
2c8e4d859d37 fix crasher (somehow, might be glitchy)
koda
parents: 4476
diff changeset
   255
    }
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   256
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   257
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   258
-(void) holdAction:(NSString *)content onTable:(UITableView *)aTableView {
6908
896ed2afcfb8 ios: turn on more warning messages and start correcting them
koda
parents: 6832
diff changeset
   259
    NSUInteger row;
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   260
    for (row = 0; row < [self.listOfSelectedTeams count]; row++) {
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   261
        NSDictionary *dict = [self.listOfSelectedTeams objectAtIndex:row];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   262
        if ([content isEqualToString:[[dict objectForKey:@"team"] stringByDeletingPathExtension]])
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   263
            break;
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   264
    }
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   265
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   266
    [self.listOfAllTeams addObject:[self.listOfSelectedTeams objectAtIndex:row]];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   267
    [self.listOfSelectedTeams removeObjectAtIndex:row];
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   268
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   269
    [aTableView beginUpdates];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   270
    [aTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:row inSection:0]] withRowAnimation:UITableViewRowAnimationLeft];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   271
    [aTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:allTeamsCount inSection:1]] withRowAnimation:UITableViewRowAnimationLeft];
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   272
    self.allTeamsCount++;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   273
    self.selectedTeamsCount--;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   274
    [aTableView endUpdates];
4476
4bf74e158f44 team selection completely refactored, now has animation and more performance
koda
parents: 4356
diff changeset
   275
}
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   276
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   277
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   278
#pragma mark Memory management
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   279
-(void) didReceiveMemoryWarning {
3739
97cf933e5bd2 disable AI teleport
koda
parents: 3703
diff changeset
   280
    self.cachedContentsOfDir = nil;
3971
5c82ee165ed5 minor stuff
koda
parents: 3917
diff changeset
   281
    MSG_MEMCLEAN();
5c82ee165ed5 minor stuff
koda
parents: 3917
diff changeset
   282
    [super didReceiveMemoryWarning];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   283
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   284
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   285
-(void) viewDidUnload {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   286
    self.tableView = nil;
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   287
    self.listOfAllTeams = nil;
3739
97cf933e5bd2 disable AI teleport
koda
parents: 3703
diff changeset
   288
    self.listOfSelectedTeams = nil;
97cf933e5bd2 disable AI teleport
koda
parents: 3703
diff changeset
   289
    self.cachedContentsOfDir = nil;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3659
diff changeset
   290
    MSG_DIDUNLOAD();
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   291
    [super viewDidUnload];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   292
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   293
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   294
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   295
-(void) dealloc {
6115
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   296
    releaseAndNil(tableView);
485cfecadc9a HUGE refactoring of the ipad interface, finally understood how to use interface builder with custom uiviewcontrollers, as well as converted some uitableviewcontrollers to uiviewcontrollers for simplicity
koda
parents: 6108
diff changeset
   297
    releaseAndNil(listOfAllTeams);
5208
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   298
    releaseAndNil(listOfSelectedTeams);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   299
    releaseAndNil(cachedContentsOfDir);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   300
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   301
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   302
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   303
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   304
@end
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   305