project_files/HedgewarsMobile/Classes/AboutViewController.m
author koda
Sat, 04 Sep 2010 16:24:00 +0200
changeset 3829 81db3c85784b
parent 3787 6e84339eefee
child 3971 5c82ee165ed5
permissions -rw-r--r--
headers ftw, also right project file
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     3
 * Copyright (c) 2009-2010 Vittorio Giovara <vittorio.giovara@gmail.com>
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    15
 * along with this program; if not, write to the Free Software
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    17
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    18
 * File created on 01/08/2010.
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    19
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3787
diff changeset
    20
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    21
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    22
#import "AboutViewController.h"
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    23
#import "CommodityFunctions.h"
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    24
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    25
@implementation AboutViewController
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    26
@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
    27
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    28
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    29
    return rotationManager(interfaceOrientation);
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    30
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    31
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    32
-(void) viewDidLoad {
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    33
    self.tableView.backgroundView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    34
    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
    35
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    36
    NSString *strPath = [NSString stringWithFormat:@"%@/Settings/credits.plist",[[NSBundle mainBundle] resourcePath]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    37
    NSArray *array = [[NSArray alloc] initWithContentsOfFile:strPath];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    38
    self.people = array;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    39
    [array release];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    40
    
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    41
    [super viewDidLoad];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    42
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    43
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    44
-(IBAction) buttonPressed:(id) sender {
3783
8e9daf967406 X&Y buttons, sounds for some buttons, cleanup
koda
parents: 3753
diff changeset
    45
    playSound(@"backSound");
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    46
    [[self parentViewController] dismissModalViewControllerAnimated:YES];
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    47
}
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    48
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    49
-(IBAction) segmentedControlChanged:(id) sender {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    50
    playSound(@"clickSound");
6e84339eefee about page done
koda
parents: 3783
diff changeset
    51
    [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    52
    [self.tableView reloadData];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    53
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    54
6e84339eefee about page done
koda
parents: 3783
diff changeset
    55
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    56
#pragma mark Table view data source
6e84339eefee about page done
koda
parents: 3783
diff changeset
    57
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    58
    return 1;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    59
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    60
6e84339eefee about page done
koda
parents: 3783
diff changeset
    61
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    62
    return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    63
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    64
6e84339eefee about page done
koda
parents: 3783
diff changeset
    65
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    66
    static NSString *CellIdentifier = @"Cell";
6e84339eefee about page done
koda
parents: 3783
diff changeset
    67
6e84339eefee about page done
koda
parents: 3783
diff changeset
    68
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    69
    if (cell == nil)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    70
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    71
6e84339eefee about page done
koda
parents: 3783
diff changeset
    72
    // first all the names, then the title (which is offset 5)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    73
    cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    74
    cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    75
6e84339eefee about page done
koda
parents: 3783
diff changeset
    76
    return cell;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    77
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    78
6e84339eefee about page done
koda
parents: 3783
diff changeset
    79
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    80
#pragma mark Table view delegate
6e84339eefee about page done
koda
parents: 3783
diff changeset
    81
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    82
    // do nothing
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
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    86
#pragma mark Memory Management
6e84339eefee about page done
koda
parents: 3783
diff changeset
    87
-(void) didReceiveMemoryWarning {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    88
    [super didReceiveMemoryWarning];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    89
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    90
6e84339eefee about page done
koda
parents: 3783
diff changeset
    91
-(void) viewDidUnload {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    92
    self.tableView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    93
    self.segmentedControl = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    94
    self.people = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    95
    [super viewDidUnload];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    96
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    97
6e84339eefee about page done
koda
parents: 3783
diff changeset
    98
-(void) dealloc {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    99
    [tableView release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   100
    [segmentedControl release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   101
    [people release];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   102
    [super dealloc];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   103
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   104
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
   105
@end