26 @implementation SavedGamesViewController |
26 @implementation SavedGamesViewController |
27 @synthesize tableView, listOfSavegames; |
27 @synthesize tableView, listOfSavegames; |
28 |
28 |
29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
29 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
30 return rotationManager(interfaceOrientation); |
30 return rotationManager(interfaceOrientation); |
|
31 } |
|
32 |
|
33 -(void) updateTable { |
|
34 NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SAVES_DIRECTORY() error:NULL]; |
|
35 NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES]; |
|
36 self.listOfSavegames = array; |
|
37 [array release]; |
|
38 |
|
39 [self.tableView reloadData]; |
31 } |
40 } |
32 |
41 |
33 -(void) viewDidLoad { |
42 -(void) viewDidLoad { |
34 self.tableView.backgroundView = nil; |
43 self.tableView.backgroundView = nil; |
35 [[NSNotificationCenter defaultCenter] addObserver:self |
44 [[NSNotificationCenter defaultCenter] addObserver:self |
39 [super viewDidLoad]; |
48 [super viewDidLoad]; |
40 } |
49 } |
41 |
50 |
42 -(void) viewWillAppear:(BOOL)animated { |
51 -(void) viewWillAppear:(BOOL)animated { |
43 [super viewWillAppear:animated]; |
52 [super viewWillAppear:animated]; |
44 |
53 [self updateTable]; |
45 NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SAVES_DIRECTORY() error:NULL]; |
54 } |
46 NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES]; |
55 |
47 self.listOfSavegames = array; |
56 #pragma mark - |
48 [array release]; |
57 #pragma mark button functions |
49 |
|
50 [self.tableView reloadData]; |
|
51 } |
|
52 |
|
53 -(IBAction) buttonPressed:(id) sender { |
58 -(IBAction) buttonPressed:(id) sender { |
54 playSound(@"backSound"); |
59 playSound(@"backSound"); |
55 [self.tableView setEditing:NO animated:YES]; |
60 [self.tableView setEditing:NO animated:YES]; |
56 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
61 [[self parentViewController] dismissModalViewControllerAnimated:YES]; |
57 } |
62 } |
58 |
63 |
59 -(IBAction) toggleEdit:(id) sender { |
64 -(IBAction) toggleEdit:(id) sender { |
60 BOOL isEditing = self.tableView.editing; |
65 BOOL isEditing = self.tableView.editing; |
61 [self.tableView setEditing:!isEditing animated:YES]; |
66 [self.tableView setEditing:!isEditing animated:YES]; |
|
67 UIToolbar *toolbar = (UIToolbar *)[self.view viewWithTag:458912]; |
|
68 for (UIBarButtonItem *item in toolbar.items) |
|
69 if (item.tag == 452198) |
|
70 item.enabled = !isEditing; |
|
71 } |
|
72 |
|
73 -(IBAction) clearAll:(id) sender { |
|
74 [[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
75 [[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() withIntermediateDirectories:NO attributes:nil error:NULL]; |
|
76 [self updateTable]; |
62 } |
77 } |
63 |
78 |
64 #pragma mark - |
79 #pragma mark - |
65 #pragma mark Table view data source |
80 #pragma mark Table view data source |
66 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |
81 -(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { |