equal
deleted
inserted
replaced
26 |
26 |
27 // load all the hat file names and store them into hatArray |
27 // load all the hat file names and store them into hatArray |
28 NSString *hatsDirectory = HATS_DIRECTORY(); |
28 NSString *hatsDirectory = HATS_DIRECTORY(); |
29 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL]; |
29 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL]; |
30 self.hatArray = array; |
30 self.hatArray = array; |
31 |
31 [array release]; |
|
32 |
32 // load all the hat images from the previous array but save only the first sprite and store it in hatSprites |
33 // load all the hat images from the previous array but save only the first sprite and store it in hatSprites |
33 NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[hatArray count]]; |
34 NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[hatArray count]]; |
34 for (int i=0; i < [hatArray count]; i++) { |
35 for (int i=0; i < [hatArray count]; i++) { |
35 NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", hatsDirectory,[hatArray objectAtIndex:i]]; |
36 NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", hatsDirectory,[hatArray objectAtIndex:i]]; |
36 |
37 |
159 int newRow = [indexPath row]; |
160 int newRow = [indexPath row]; |
160 int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
161 int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1; |
161 |
162 |
162 if (newRow != oldRow) { |
163 if (newRow != oldRow) { |
163 // if the two selected rows differ update data on the hog dictionary and reload table content |
164 // if the two selected rows differ update data on the hog dictionary and reload table content |
|
165 // TODO: maybe this section could be cleaned up |
164 NSDictionary *oldHog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog]; |
166 NSDictionary *oldHog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog]; |
165 |
167 |
166 NSMutableDictionary *newHog = [[NSMutableDictionary alloc] initWithDictionary: oldHog]; |
168 NSMutableDictionary *newHog = [[NSMutableDictionary alloc] initWithDictionary: oldHog]; |
167 [newHog setObject:[[hatArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"hat"]; |
169 [newHog setObject:[[hatArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"hat"]; |
168 [[teamDictionary objectForKey:@"hedgehogs"] replaceObjectAtIndex:selectedHog withObject:newHog]; |
170 [[teamDictionary objectForKey:@"hedgehogs"] replaceObjectAtIndex:selectedHog withObject:newHog]; |