30 return rotationManager(interfaceOrientation); |
30 return rotationManager(interfaceOrientation); |
31 } |
31 } |
32 |
32 |
33 -(void) viewDidLoad { |
33 -(void) viewDidLoad { |
34 self.tableView.backgroundView = nil; |
34 self.tableView.backgroundView = nil; |
35 |
35 [[NSNotificationCenter defaultCenter] addObserver:self |
|
36 selector:@selector(viewWillAppear:) |
|
37 name:@"removedSave" |
|
38 object:nil]; |
36 [super viewDidLoad]; |
39 [super viewDidLoad]; |
37 } |
40 } |
38 |
41 |
39 -(void) viewWillAppear:(BOOL)animated { |
42 -(void) viewWillAppear:(BOOL)animated { |
40 [super viewWillAppear:animated]; |
43 [super viewWillAppear:animated]; |
51 playSound(@"backSound"); |
54 playSound(@"backSound"); |
52 [self.tableView setEditing:NO animated:YES]; |
55 [self.tableView setEditing:NO animated:YES]; |
53 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
56 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
54 } |
57 } |
55 |
58 |
56 // modifies the navigation bar to add the "Add" and "Done" buttons |
|
57 -(IBAction) toggleEdit:(id) sender { |
59 -(IBAction) toggleEdit:(id) sender { |
58 BOOL isEditing = self.tableView.editing; |
60 BOOL isEditing = self.tableView.editing; |
59 [self.tableView setEditing:!isEditing animated:YES]; |
61 [self.tableView setEditing:!isEditing animated:YES]; |
60 |
|
61 UIBarButtonItem *barButton = (UIBarButtonItem *)sender; |
|
62 if (isEditing) |
|
63 [barButton setTitle:NSLocalizedString(@"Edit",@"")]; |
|
64 else |
|
65 [barButton setTitle:NSLocalizedString(@"Commit",@"")]; |
|
66 } |
62 } |
67 |
63 |
68 #pragma mark - |
64 #pragma mark - |
69 #pragma mark Table view data source |
65 #pragma mark Table view data source |
70 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
66 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
82 if (editableCell == nil) { |
78 if (editableCell == nil) { |
83 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
79 editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; |
84 editableCell.delegate = self; |
80 editableCell.delegate = self; |
85 } |
81 } |
86 editableCell.tag = [indexPath row]; |
82 editableCell.tag = [indexPath row]; |
87 |
83 editableCell.respectEditing = YES; |
88 editableCell.textField.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension]; |
84 editableCell.textField.text = [[self.listOfSavegames objectAtIndex:[indexPath row]] stringByDeletingPathExtension]; |
89 editableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
85 editableCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; |
90 |
86 |
91 UIImage *addImg = [UIImage imageWithContentsOfFile:@"plus.png"]; |
87 UIImage *addImg = [UIImage imageWithContentsOfFile:@"plus.png"]; |
92 UIButton *customButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; |
88 UIButton *customButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; |
95 [customButton addTarget:self action:@selector(duplicateEntry:) forControlEvents:UIControlEventTouchUpInside]; |
91 [customButton addTarget:self action:@selector(duplicateEntry:) forControlEvents:UIControlEventTouchUpInside]; |
96 editableCell.editingAccessoryView = customButton; |
92 editableCell.editingAccessoryView = customButton; |
97 |
93 |
98 return (UITableViewCell *)editableCell; |
94 return (UITableViewCell *)editableCell; |
99 } |
95 } |
100 /* |
96 |
101 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
97 -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section { |
102 UITableViewCellEditingStyleInsert |
98 UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)]; |
103 }*//* |
99 footer.backgroundColor = [UIColor clearColor]; |
104 -(UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { |
100 |
105 return UITableViewCellEditingStyleInsert; |
101 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width*80/100, 100)]; |
106 }*/ |
102 label.center = CGPointMake(self.tableView.frame.size.width/2,70); |
|
103 label.textAlignment = UITextAlignmentCenter; |
|
104 label.font = [UIFont systemFontOfSize:16]; |
|
105 label.textColor = [UIColor lightGrayColor]; |
|
106 label.numberOfLines = 5; |
|
107 label.text = NSLocalizedString(@"Games are automatically saved and can be resumed by selecting an entry above.\nYou can modify this list by pressing the 'Edit' button.\nNotice that completed games are deleted, so make backups.",@""); |
|
108 |
|
109 label.backgroundColor = [UIColor clearColor]; |
|
110 [footer addSubview:label]; |
|
111 [label release]; |
|
112 return [footer autorelease]; |
|
113 } |
107 |
114 |
108 -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
115 -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
109 NSUInteger row = [indexPath row]; |
116 NSUInteger row = [indexPath row]; |
110 [(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
117 [(EditableCellView *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0]] save:nil]; |
111 |
118 |