project_files/HedgewarsMobile/Classes/AboutViewController.m
author smaxx
Thu, 02 Sep 2010 19:21:41 +0200
changeset 3811 967363197f01
parent 3787 6e84339eefee
child 3829 81db3c85784b
permissions -rw-r--r--
Engine: * Enabled zoom in ready time
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     1
    //
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     2
//  AboutViewController.m
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     3
//  Hedgewars
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     4
//
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     5
//  Created by Vittorio on 01/08/10.
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     7
//
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     8
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
     9
#import "AboutViewController.h"
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    10
#import "CommodityFunctions.h"
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    11
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    12
@implementation AboutViewController
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    13
@synthesize tableView, segmentedControl, people;
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    14
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    15
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    16
    return rotationManager(interfaceOrientation);
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    17
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    18
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    19
-(void) viewDidLoad {
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    20
    self.tableView.backgroundView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    21
    self.tableView.allowsSelection = NO;
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    22
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    23
    NSString *strPath = [NSString stringWithFormat:@"%@/Settings/credits.plist",[[NSBundle mainBundle] resourcePath]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    24
    NSArray *array = [[NSArray alloc] initWithContentsOfFile:strPath];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    25
    self.people = array;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    26
    [array release];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    27
    
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    28
    [super viewDidLoad];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    29
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    30
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    31
-(IBAction) buttonPressed:(id) sender {
3783
8e9daf967406 X&Y buttons, sounds for some buttons, cleanup
koda
parents: 3753
diff changeset
    32
    playSound(@"backSound");
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    33
    [[self parentViewController] dismissModalViewControllerAnimated:YES];
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    34
}
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    35
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    36
-(IBAction) segmentedControlChanged:(id) sender {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    37
    playSound(@"clickSound");
6e84339eefee about page done
koda
parents: 3783
diff changeset
    38
    [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    39
    [self.tableView reloadData];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    40
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    41
6e84339eefee about page done
koda
parents: 3783
diff changeset
    42
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    43
#pragma mark Table view data source
6e84339eefee about page done
koda
parents: 3783
diff changeset
    44
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    45
    return 1;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    46
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    47
6e84339eefee about page done
koda
parents: 3783
diff changeset
    48
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    49
    return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    50
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    51
6e84339eefee about page done
koda
parents: 3783
diff changeset
    52
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    53
    static NSString *CellIdentifier = @"Cell";
6e84339eefee about page done
koda
parents: 3783
diff changeset
    54
6e84339eefee about page done
koda
parents: 3783
diff changeset
    55
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    56
    if (cell == nil)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    57
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    58
6e84339eefee about page done
koda
parents: 3783
diff changeset
    59
    // first all the names, then the title (which is offset 5)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    60
    cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    61
    cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    62
6e84339eefee about page done
koda
parents: 3783
diff changeset
    63
    return cell;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    64
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    65
6e84339eefee about page done
koda
parents: 3783
diff changeset
    66
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    67
#pragma mark Table view delegate
6e84339eefee about page done
koda
parents: 3783
diff changeset
    68
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    69
    // do nothing
6e84339eefee about page done
koda
parents: 3783
diff changeset
    70
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    71
6e84339eefee about page done
koda
parents: 3783
diff changeset
    72
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    73
#pragma mark Memory Management
6e84339eefee about page done
koda
parents: 3783
diff changeset
    74
-(void) didReceiveMemoryWarning {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    75
    [super didReceiveMemoryWarning];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    76
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    77
6e84339eefee about page done
koda
parents: 3783
diff changeset
    78
-(void) viewDidUnload {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    79
    self.tableView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    80
    self.segmentedControl = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    81
    self.people = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    82
    [super viewDidUnload];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    83
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    84
6e84339eefee about page done
koda
parents: 3783
diff changeset
    85
-(void) dealloc {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    86
    [tableView release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    87
    [segmentedControl release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    88
    [people release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    89
    [super dealloc];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    90
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    91
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    92
@end