project_files/HedgewarsMobile/Classes/SingleTeamViewController.m
author antonc27 <antonc27@mail.ru>
Fri, 16 Oct 2015 02:54:03 +0200
branchios-revival
changeset 11217 6e5fd5ea5acb
parent 11187 b2112ed988cb
child 11221 e68b3e392091
permissions -rw-r--r--
- Fix for autorotation of table view of StatsPageVC - Adjustment for header's height
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
6700
e04da46ee43c the most important commit of the year
koda
parents: 6104
diff changeset
     3
 * Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3825
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: 3825
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3825
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3825
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: 3825
diff changeset
    17
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3825
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 "SingleTeamViewController.h"
4478
05029b4d8490 code cleanup
koda
parents: 3948
diff changeset
    21
#import <QuartzCore/QuartzCore.h>
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    22
#import "HogHatViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    23
#import "GravesViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    24
#import "VoicesViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    25
#import "FortsViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    26
#import "FlagsViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    27
#import "LevelViewController.h"
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: 5983
diff changeset
    28
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    29
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    30
#define TEAMNAME_TAG 78789
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    31
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    32
@implementation SingleTeamViewController
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    33
@synthesize teamDictionary, normalHogSprite, secondaryItems, moreSecondaryItems, teamName;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    34
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    35
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    36
    return rotationManager(interfaceOrientation);
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    37
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    38
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    39
#pragma mark -
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    40
#pragma mark editableCellViewDelegate methods
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    41
// set the new value
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    42
-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    43
    if (TEAMNAME_TAG == tagValue) {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    44
        // delete old file
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    45
        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName] error:NULL];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    46
        // update filename
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    47
        self.teamName = textString;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    48
        // save new file
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    49
        [self writeFile];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    50
    } else {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    51
        // replace the old value with the new one
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    52
        NSMutableDictionary *hog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:tagValue];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    53
        [hog setObject:textString forKey:@"hogname"];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    54
        isWriteNeeded = YES;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    55
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    56
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    57
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    58
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    59
#pragma mark View lifecycle
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    60
-(void) viewDidLoad {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    61
    [super viewDidLoad];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    62
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    63
    // labels for the entries
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    64
    NSArray *array = [[NSArray alloc] initWithObjects:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    65
                      NSLocalizedString(@"Grave",@""),
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    66
                      NSLocalizedString(@"Voice",@""),
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    67
                      NSLocalizedString(@"Fort",@""),
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    68
                      NSLocalizedString(@"Flag",@""),
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    69
                      NSLocalizedString(@"Level",@""),nil];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    70
    self.secondaryItems = array;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    71
    [array release];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
    72
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    73
    // labels for the subtitles
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    74
    NSArray *moreArray = [[NSArray alloc] initWithObjects:
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    75
                          NSLocalizedString(@"Mark the death of your fallen warriors",@""),
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    76
                          NSLocalizedString(@"Pick a slang your hogs will speak",@""),
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    77
                          NSLocalizedString(@"Select the team invincible fortress (only valid for fort games)",@""),
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    78
                          NSLocalizedString(@"Choose a charismatic symbol for your team",@""),
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    79
                          NSLocalizedString(@"Opt for controlling the team or let the AI lead",@""),nil];
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    80
    self.moreSecondaryItems = moreArray;
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
    81
    [moreArray release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    82
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    83
    // load the base hog image, drawing will occure in cellForRow...
5983
f0925204f50e retina images, again
koda
parents: 5982
diff changeset
    84
    NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/basehat-hedgehog.png",[[NSBundle mainBundle] resourcePath]];
f0925204f50e retina images, again
koda
parents: 5982
diff changeset
    85
    UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    86
    [normalHogFile release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    87
    self.normalHogSprite = hogSprite;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    88
    [hogSprite release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    89
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    90
    // listen if any childController modifies the plist and write it if needed
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    91
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    92
    isWriteNeeded = NO;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    93
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
    94
    self.title = NSLocalizedString(@"Edit team settings",@"");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    95
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    96
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    97
-(void) viewWillAppear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    98
    [super viewWillAppear:animated];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    99
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   100
    // load data about the team and write if there has been a change from other childControllers
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   101
    if (isWriteNeeded)
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   102
        [self writeFile];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   103
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   104
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   105
    NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   106
    self.teamDictionary = teamDict;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   107
    [teamDict release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   108
    [teamFile release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   109
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   110
    [self.tableView reloadData];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   111
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   112
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   113
// write on file if there has been a change
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   114
-(void) viewWillDisappear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   115
    [super viewWillDisappear:animated];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   116
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   117
    if (isWriteNeeded)
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   118
        [self writeFile];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   119
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   121
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   122
// needed by other classes to warn about a user change
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   123
-(void) setWriteNeeded {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   124
    isWriteNeeded = YES;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   125
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   126
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   127
-(void) writeFile {
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   128
    NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   129
    [self.teamDictionary writeToFile:teamFile atomically:YES];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   130
    [teamFile release];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   131
3789
c3eb56754e92 added a smaller version of forts, fixed a couple of regressions
koda
parents: 3783
diff changeset
   132
    //DLog(@"%@",teamDictionary);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   133
    isWriteNeeded = NO;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   134
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   135
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   136
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   137
#pragma mark Table view data source
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   138
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   139
    return 3;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   140
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   141
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   142
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   143
    NSInteger rows = 0;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   144
    switch (section) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   145
        case 0: // team name
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   146
            rows = 1;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   147
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   148
        case 1: // team members
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   149
            rows = HW_getMaxNumberOfHogs() + 1; // one for 'Select one hat for all hogs' cell
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   150
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   151
        case 2: // team details
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   152
            rows = [self.secondaryItems count];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   153
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   154
        default:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   155
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   156
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   157
    return rows;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   158
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   159
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   160
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   161
    NSString *sectionTitle = nil;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   162
    switch (section) {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   163
        case 0:
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   164
            sectionTitle = NSLocalizedString(@"Team Name", @"");
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   165
            break;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   166
        case 1:
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   167
            sectionTitle = NSLocalizedString(@"Names and Hats", @"");
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   168
            break;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   169
        case 2:
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   170
            sectionTitle = NSLocalizedString(@"Team Preferences", @"");
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   171
            break;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   172
        default:
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   173
            DLog(@"Nope");
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   174
            break;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   175
    }
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   176
    return sectionTitle;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   177
}
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   178
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   179
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   180
    static NSString *CellIdentifier0 = @"Cell0";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   181
    static NSString *CellIdentifier1 = @"Cell1";
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   182
    static NSString *CellIdentifier2 = @"Cell2";
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   183
    static NSString *CellIdentifierDefault = @"CellDefault";
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   184
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   185
    NSArray *hogArray;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   186
    UITableViewCell *cell = nil;
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   187
    EditableCellView *editableCell = nil;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   188
    NSInteger row = [indexPath row];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   189
    UIImage *accessoryImage;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   190
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   191
    switch ([indexPath section]) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   192
        case 0:
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   193
            editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   194
            if (editableCell == nil) {
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   195
                editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   196
                                               reuseIdentifier:CellIdentifier0] autorelease];
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   197
                editableCell.delegate = self;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   198
                editableCell.tag = TEAMNAME_TAG;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   199
            }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   200
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   201
            editableCell.imageView.image = nil;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   202
            editableCell.accessoryType = UITableViewCellAccessoryNone;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   203
            editableCell.textField.text = self.teamName;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   204
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   205
            cell = editableCell;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   206
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   207
        case 1:
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   208
            if ([indexPath row] == HW_getMaxNumberOfHogs())
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   209
            {
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   210
                cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierDefault];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   211
                if (cell == nil)
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   212
                {
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   213
                    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   214
                                                   reuseIdentifier:CellIdentifierDefault] autorelease];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   215
                    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   216
                }
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   217
                
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   218
                cell.textLabel.text = NSLocalizedString(@"Select one hat for all hogs", nil);
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   219
                
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   220
                break;
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   221
            }
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   222
            
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   223
            editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   224
            if (editableCell == nil) {
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   225
                editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   226
                                               reuseIdentifier:CellIdentifier1] autorelease];
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   227
                editableCell.delegate = self;
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   228
                editableCell.tag = [indexPath row];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   229
            }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   230
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   231
            hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   232
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   233
            // draw the hat on top of the hog
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   234
            NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   235
            UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   236
            [hatFile release];
3948
24daa33a3114 some rethinking of initial menu presentation and initial orientation (also merging images should be threadsafe now)
koda
parents: 3926
diff changeset
   237
            editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, 5)];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   238
            [hatSprite release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   239
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   240
            editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   241
            editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   242
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   243
            cell = editableCell;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   244
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   245
        case 2:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   246
            cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   247
            if (cell == nil) {
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   248
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   249
                                               reuseIdentifier:CellIdentifier2] autorelease];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   250
            }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   251
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   252
            cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   253
            cell.detailTextLabel.text = [self.moreSecondaryItems objectAtIndex:row];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   254
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   255
            switch (row) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   256
                case 0: // grave
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   257
                    accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   258
                                                                              GRAVES_DIRECTORY(),[teamDictionary objectForKey:@"grave"]]
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   259
                                                                    andCutAt:CGRectMake(0,0,32,32)];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   260
                    cell.imageView.image = accessoryImage;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   261
                    [accessoryImage release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   262
                    break;
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   263
                case 1: // voice
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   264
                    accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/HellishBomb.png",
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   265
                                                                              GRAPHICS_DIRECTORY()]];
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   266
                    cell.imageView.image = accessoryImage;
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   267
                    [accessoryImage release];
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   268
                    break;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   269
                case 2: // fort
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   270
                    accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@-icon.png",
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   271
                                                                              FORTS_DIRECTORY(),[teamDictionary objectForKey:@"fort"]]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   272
                    cell.imageView.image = accessoryImage;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   273
                    [accessoryImage release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   274
                    break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   275
                case 3: // flags
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   276
                    accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   277
                                                                              FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]];
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   278
                    cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(26, 18)];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   279
                    [accessoryImage release];
6104
117bdf4e7af9 create teams programmatically
koda
parents: 6078
diff changeset
   280
                    cell.imageView.layer.borderWidth = 1;
117bdf4e7af9 create teams programmatically
koda
parents: 6078
diff changeset
   281
                    cell.imageView.layer.borderColor = [[UIColor blackColor] CGColor];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   282
                    break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   283
                case 4: // level
5982
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   284
                    accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/bot%d.png",
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   285
                                                                              [[NSBundle mainBundle] resourcePath],
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   286
                                                                              [[[[teamDictionary objectForKey:@"hedgehogs"]
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   287
                                                                                 objectAtIndex:0] objectForKey:@"level"]
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   288
                                                                               intValue]]];
283be2ca54a7 mad several updates to the resource copying phase in the ios project file, changed paths of some images and added some smaller forts version
koda
parents: 5208
diff changeset
   289
                    cell.imageView.image = accessoryImage;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   290
                    [accessoryImage release];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   291
                    break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   292
                default:
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   293
                    cell.imageView.image = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   294
                    break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   295
            }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   296
            break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   297
    }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   298
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   299
    return cell;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   300
}
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
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   304
#pragma mark Table view delegate
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   305
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   306
    NSInteger row = [indexPath row];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   307
    NSInteger section = [indexPath section];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   308
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   309
    if (2 == section) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   310
        switch (row) {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   311
            case 0: // grave
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   312
                if (nil == gravesViewController)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   313
                    gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
   314
3924
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   315
                [gravesViewController setTeamDictionary:teamDictionary];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   316
                [self.navigationController pushViewController:gravesViewController animated:YES];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   317
                break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   318
            case 1: // voice
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   319
                if (nil == voicesViewController)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   320
                    voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
   321
3924
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   322
                [voicesViewController setTeamDictionary:teamDictionary];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   323
                [self.navigationController pushViewController:voicesViewController animated:YES];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   324
                break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   325
            case 2: // fort
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   326
                if (nil == fortsViewController)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   327
                    fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
   328
3924
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   329
                [fortsViewController setTeamDictionary:teamDictionary];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   330
                [self.navigationController pushViewController:fortsViewController animated:YES];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   331
                break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   332
            case 3: // flag
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   333
                if (nil == flagsViewController)
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   334
                    flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
   335
3924
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   336
                [flagsViewController setTeamDictionary:teamDictionary];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   337
                [self.navigationController pushViewController:flagsViewController animated:YES];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   338
                break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   339
            case 4: // level
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   340
                if (nil == levelViewController)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   341
                    levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped];
8441
a00b0fa0dbd7 some whitespaces from ios files
koda
parents: 6832
diff changeset
   342
3924
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   343
                [levelViewController setTeamDictionary:teamDictionary];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   344
                [self.navigationController pushViewController:levelViewController animated:YES];
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   345
                break;
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   346
            default:
2a9ace189288 WIP for an objc ammomenu implementation
koda
parents: 3829
diff changeset
   347
                DLog(@"Nope");
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   348
                break;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   349
        }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   350
    } else {
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   351
        if (section == 1 && row == HW_getMaxNumberOfHogs()) {
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   352
            // 'Select one hat for all hogs' selected
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   353
            [self showHogHatViewControllerForHogIndex:-1];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   354
        } else {
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   355
            EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   356
            [cell replyKeyboard];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   357
            [aTableView deselectRowAtIndexPath:indexPath animated:NO];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   358
        }
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   359
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   360
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   361
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   362
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   363
// action to perform when you want to change a hog hat
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   364
-(void) tableView:(UITableView *)aTableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   365
    // if we are editing the field undo any change before proceeding
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   366
    EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath];
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   367
    [cell cancel:nil];
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   368
    
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   369
    [self showHogHatViewControllerForHogIndex:[indexPath row]];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   370
}
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
   371
11187
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   372
- (void)showHogHatViewControllerForHogIndex:(NSInteger)hogIndex
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   373
{
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   374
    if (nil == hogHatViewController)
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   375
        hogHatViewController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   376
    
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   377
    // cache the dictionary file of the team, so that other controllers can modify it
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   378
    hogHatViewController.teamDictionary = self.teamDictionary;
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   379
    hogHatViewController.selectedHog = hogIndex;
b2112ed988cb - Added functionality to select one hat for all hogs at team settings
antonc27 <antonc27@mail.ru>
parents: 10108
diff changeset
   380
    
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   381
    [self.navigationController pushViewController:hogHatViewController animated:YES];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   382
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   383
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   384
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   385
#pragma mark Memory management
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   386
-(void) didReceiveMemoryWarning {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   387
    [super didReceiveMemoryWarning];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   388
    if (hogHatViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   389
        hogHatViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   390
    if (gravesViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   391
        gravesViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   392
    if (voicesViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   393
        voicesViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   394
    if (fortsViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   395
        fortsViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   396
    if (flagsViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   397
        flagsViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   398
    if (levelViewController.view.superview == nil)
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   399
        levelViewController = nil;
3660
bc125bea5849 complete settings page rework
koda
parents: 3659
diff changeset
   400
    MSG_MEMCLEAN();
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   401
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   402
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   403
-(void) viewDidUnload {
3783
8e9daf967406 X&Y buttons, sounds for some buttons, cleanup
koda
parents: 3697
diff changeset
   404
    [[NSNotificationCenter defaultCenter] removeObserver:self];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   405
    self.teamDictionary = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   406
    self.teamName = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   407
    self.normalHogSprite = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   408
    self.secondaryItems = nil;
3816
7b74aa003f52 a little more intuitive team editing
koda
parents: 3789
diff changeset
   409
    self.moreSecondaryItems = nil;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   410
    hogHatViewController = nil;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   411
    gravesViewController = nil;
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   412
    voicesViewController = nil;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   413
    flagsViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   414
    fortsViewController = nil;
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   415
    levelViewController = nil;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3660
diff changeset
   416
    MSG_DIDUNLOAD();
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   417
    [super viewDidUnload];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   418
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   419
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   420
-(void) dealloc {
5208
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   421
    releaseAndNil(teamDictionary);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   422
    releaseAndNil(teamName);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   423
    releaseAndNil(normalHogSprite);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   424
    releaseAndNil(secondaryItems);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   425
    releaseAndNil(moreSecondaryItems);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   426
    releaseAndNil(hogHatViewController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   427
    releaseAndNil(gravesViewController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   428
    releaseAndNil(fortsViewController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   429
    releaseAndNil(voicesViewController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   430
    releaseAndNil(flagsViewController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
   431
    releaseAndNil(levelViewController);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   432
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   433
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   434
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   435
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   436
@end
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   437