--- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jan 26 23:56:10 2013 +0100
+++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jan 26 23:57:37 2013 +0100
@@ -48,19 +48,19 @@
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
if ([[[[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0] objectForKey:@"level"] intValue] == 0)
numberOfSections = 1;
else
numberOfSections = 2;
-
+
[self.tableView reloadData];
// this moves the tableview to the top
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
}
-(void) viewWillDisappear:(BOOL)animated {
- // stuff like checking that at least 1 field was selected
+ // stuff like checking that at least 1 field was selected
}
#pragma mark -
@@ -84,7 +84,7 @@
NSInteger row = [indexPath row];
NSInteger section = [indexPath section];
UITableViewCell *cell;
-
+
if (section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (cell == nil) {
@@ -104,7 +104,7 @@
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
-
+
cell.textLabel.text = [levelArray objectAtIndex:row];
NSDictionary *hog = [[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0];
if ([[hog objectForKey:@"level"] intValue] == row+1) {
@@ -113,14 +113,14 @@
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
-
+
NSString *botlevelPath = [[NSString alloc] initWithFormat:@"%@/bot%d.png",[[NSBundle mainBundle] resourcePath],row+1];
UIImage *levelImage = [[UIImage alloc] initWithContentsOfFile:botlevelPath];
[botlevelPath release];
cell.imageView.image = levelImage;
[levelImage release];
}
-
+
return cell;
}
@@ -129,7 +129,7 @@
NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:1];
NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"];
NSInteger level;
-
+
if (theSwitch.on) {
numberOfSections = 2;
[self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade];
@@ -156,19 +156,19 @@
int newRow = [indexPath row];
int oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1;
- if ([indexPath section] != 0) {
+ if ([indexPath section] != 0) {
if (newRow != oldRow) {
NSMutableArray *hogs = [self.teamDictionary objectForKey:@"hedgehogs"];
-
+
NSInteger level = newRow + 1;
for (NSMutableDictionary *hog in hogs)
[hog setObject:[NSNumber numberWithInt:level] forKey:@"level"];
DLog(@"New level is %d",level);
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
[self.tableView reloadData];
-
+
self.lastIndexPath = indexPath;
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}