project_files/HedgewarsMobile/Classes/AboutViewController.m
author koda
Tue, 23 Aug 2011 03:46:17 +0200
changeset 5662 99083392cd4f
parent 5208 878e551f0b4a
child 5985 d276be65b745
permissions -rw-r--r--
FREE AT LAST!!! SDL came around a (mostly) sane way for implementing rotation events, so we can scrap all the workaround code that has been added to workaround it!! Also this allows us to use proper (internal) multitasking handling and can simplify optional settings and other yet unexplored features. Yay!
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
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4603
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
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 {
4115
222b8016c773 make the support page more portable
koda
parents: 4082
diff changeset
    33
    if ([self.tableView respondsToSelector:@selector(setBackgroundView:)])
4082
bfe14b38dad1 better support for wimpier i-devices
koda
parents: 4030
diff changeset
    34
        self.tableView.backgroundView = nil;
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    35
    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
    36
5185
7607a64e1853 remove the trailing _en from scheme data and use the macros available instead of creating a string every time
koda
parents: 4976
diff changeset
    37
    NSArray *array = [[NSArray alloc] initWithContentsOfFile:CREDITS_FILE()];
3787
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];
4030
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    40
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    41
    NSString *imgName;
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    42
    if (IS_IPAD())
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    43
        imgName = @"smallerBackground~ipad.png";
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    44
    else
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    45
        imgName = @"smallerBackground~iphone.png";
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    46
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName];
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    47
    self.view.backgroundColor = [UIColor colorWithPatternImage:img];
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    48
    [img release];
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    49
    [super viewDidLoad];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    50
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    51
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    52
-(IBAction) buttonPressed:(id) sender {
3783
8e9daf967406 X&Y buttons, sounds for some buttons, cleanup
koda
parents: 3753
diff changeset
    53
    playSound(@"backSound");
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    54
    [[self parentViewController] dismissModalViewControllerAnimated:YES];
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    55
}
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    56
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    57
-(IBAction) segmentedControlChanged:(id) sender {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    58
    playSound(@"clickSound");
6e84339eefee about page done
koda
parents: 3783
diff changeset
    59
    [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    60
    [self.tableView reloadData];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    61
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    62
6e84339eefee about page done
koda
parents: 3783
diff changeset
    63
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    64
#pragma mark Table view data source
6e84339eefee about page done
koda
parents: 3783
diff changeset
    65
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    66
    return 1;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    67
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    68
6e84339eefee about page done
koda
parents: 3783
diff changeset
    69
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    70
    return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    71
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    72
6e84339eefee about page done
koda
parents: 3783
diff changeset
    73
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    74
    static NSString *CellIdentifier = @"Cell";
6e84339eefee about page done
koda
parents: 3783
diff changeset
    75
6e84339eefee about page done
koda
parents: 3783
diff changeset
    76
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    77
    if (cell == nil)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    78
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    79
6e84339eefee about page done
koda
parents: 3783
diff changeset
    80
    // first all the names, then the title (which is offset 5)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    81
    cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    82
    cell.detailTextLabel.text = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    83
6e84339eefee about page done
koda
parents: 3783
diff changeset
    84
    return cell;
6e84339eefee about page done
koda
parents: 3783
diff changeset
    85
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    86
6e84339eefee about page done
koda
parents: 3783
diff changeset
    87
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
    88
#pragma mark Table view delegate
6e84339eefee about page done
koda
parents: 3783
diff changeset
    89
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    90
    // do nothing
6e84339eefee about page done
koda
parents: 3783
diff changeset
    91
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    92
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    93
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    94
    return 95;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    95
}
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    96
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    97
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    98
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
    99
    char *fullver;
4603
d362ab6c7f53 damn. it.
koda
parents: 4460
diff changeset
   100
    int proto;
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   101
    HW_versionInfo(&proto, &fullver);
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   102
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   103
    NSString *footerString = [[NSString alloc] initWithFormat:
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   104
                              @"You are running Hedgewars-iOS %@ based on Hedgewars version %s (protocol %d)",
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   105
                              version, fullver, proto];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   106
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   107
    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 50)];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   108
    footer.backgroundColor = [UIColor clearColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   109
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   110
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width*80/100, 90)];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   111
    label.center = CGPointMake(self.tableView.frame.size.width/2, 45);
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   112
    label.textAlignment = UITextAlignmentCenter;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   113
    label.font = [UIFont systemFontOfSize:16];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   114
    label.textColor = [UIColor lightGrayColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   115
    label.numberOfLines = 5;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   116
    label.text = footerString;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   117
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   118
    label.backgroundColor = [UIColor clearColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   119
    [footer addSubview:label];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   120
    [label release];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   121
    return [footer autorelease];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   122
}
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   123
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   124
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
   125
#pragma mark Memory Management
6e84339eefee about page done
koda
parents: 3783
diff changeset
   126
-(void) didReceiveMemoryWarning {
3971
5c82ee165ed5 minor stuff
koda
parents: 3829
diff changeset
   127
    self.people = nil;
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   128
    [super didReceiveMemoryWarning];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   129
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   130
6e84339eefee about page done
koda
parents: 3783
diff changeset
   131
-(void) viewDidUnload {
6e84339eefee about page done
koda
parents: 3783
diff changeset
   132
    self.tableView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   133
    self.segmentedControl = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   134
    self.people = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   135
    [super viewDidUnload];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   136
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   137
6e84339eefee about page done
koda
parents: 3783
diff changeset
   138
-(void) dealloc {
5208
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   139
    releaseAndNil(tableView);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   140
    releaseAndNil(segmentedControl);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   141
    releaseAndNil(people);
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   142
    [super dealloc];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   143
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   144
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
   145
@end