diff -r 7056284fd97c -r 6e84339eefee project_files/HedgewarsMobile/Classes/AboutViewController.m --- a/project_files/HedgewarsMobile/Classes/AboutViewController.m Sun Aug 29 16:55:58 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/AboutViewController.m Sun Aug 29 23:36:22 2010 +0200 @@ -10,32 +10,22 @@ #import "CommodityFunctions.h" @implementation AboutViewController - +@synthesize tableView, segmentedControl, people; -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { return rotationManager(interfaceOrientation); } -(void) viewDidLoad { - self.view.frame = CGRectMake(0, 0, 320, 480); - [super viewDidLoad]; -} + self.tableView.backgroundView = nil; + self.tableView.allowsSelection = NO; --(void) didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; + NSString *strPath = [NSString stringWithFormat:@"%@/Settings/credits.plist",[[NSBundle mainBundle] resourcePath]]; + NSArray *array = [[NSArray alloc] initWithContentsOfFile:strPath]; + self.people = array; + [array release]; - // Release any cached data, images, etc that aren't in use. -} - --(void) viewDidUnload { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - --(void) dealloc { - [super dealloc]; + [super viewDidLoad]; } -(IBAction) buttonPressed:(id) sender { @@ -43,4 +33,60 @@ [[self parentViewController] dismissModalViewControllerAnimated:YES]; } +-(IBAction) segmentedControlChanged:(id) sender { + playSound(@"clickSound"); + [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO]; + [self.tableView reloadData]; +} + +#pragma mark - +#pragma mark Table view data source +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count]; +} + +-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; + + // first all the names, then the title (which is offset 5) + cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]]; + cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]]; + + return cell; +} + +#pragma mark - +#pragma mark Table view delegate +-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + // do nothing +} + +#pragma mark - +#pragma mark Memory Management +-(void) didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +-(void) viewDidUnload { + self.tableView = nil; + self.segmentedControl = nil; + self.people = nil; + [super viewDidUnload]; +} + +-(void) dealloc { + [tableView release]; + [segmentedControl release]; + [people release]; + [super dealloc]; +} + @end