project_files/HedgewarsMobile/Classes/AboutViewController.m
author sheepluva
Tue, 05 Sep 2017 20:46:40 +0200
changeset 12452 e18cfe90e4e2
parent 11549 893722a2a1f9
child 12872 00215a7ec5f5
permissions -rw-r--r--
fix physfs using inflateCopy() (not part of miniz)
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
6700
e04da46ee43c the most important commit of the year
koda
parents: 6673
diff changeset
     3
 * Copyright (c) 2009-2012 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
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 6869
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
3829
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
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    19
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    20
#import "AboutViewController.h"
6078
8c0cc07731e5 headers cleanup, converted some function-only sources into proper class method files, more use of OOP power, removed some 'respondsToSelector' calls, moved defines into their own header, more use of objc categories
koda
parents: 6000
diff changeset
    21
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    22
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    23
@implementation AboutViewController
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    24
@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
    25
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    26
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    27
    return rotationManager(interfaceOrientation);
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    28
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    29
11308
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    30
-(void) viewDidLoad
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    31
{
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    32
    [super viewDidLoad];
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    33
    
6673
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    34
    [self.tableView setBackgroundColorForAnyTable:[UIColor clearColor]];
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];
6673
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    47
    UIImageView *background = [[UIImageView alloc] initWithImage:img];
4030
adbb37b8c487 fix background for the about and saves controller
koda
parents: 4000
diff changeset
    48
    [img release];
6673
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    49
    background.frame = self.view.frame;
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    50
    background.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    51
    [self.view insertSubview:background atIndex:0];
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    52
    [background release];
1ee72dcea263 colorWithPatternImage uses too much memory
koda
parents: 6078
diff changeset
    53
11308
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    54
    [self localizeSegmentedControl];
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    55
}
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    56
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    57
-(IBAction) buttonPressed:(id) sender {
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
    58
    [[AudioManagerController mainManager] playBackSound];
11116
102684240fe8 - Interscreen transitions fixed
Anton Malmygin <antonc27@mail.ru>
parents: 10108
diff changeset
    59
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
3753
bb5a0252fb56 small update for the about page
koda
parents: 3703
diff changeset
    60
}
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
    61
11308
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    62
#pragma mark - Segmented Control
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    63
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    64
- (void)localizeSegmentedControl
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    65
{
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    66
    for (NSUInteger i = 0; i < self.segmentedControl.numberOfSegments; i++)
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    67
    {
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    68
        NSString *oldTitle = [self.segmentedControl titleForSegmentAtIndex:i];
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    69
        [self.segmentedControl setTitle:NSLocalizedStringFromTable(oldTitle, @"About", nil) forSegmentAtIndex:i];
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    70
    }
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    71
}
92b023095153 - Update rus localization for 'About' screen
antonc27 <antonc27@mail.ru>
parents: 11307
diff changeset
    72
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    73
-(IBAction) segmentedControlChanged:(id) sender {
6869
a187c280dd3d ios: convert audio operation from class to instance, plays better with memory
koda
parents: 6832
diff changeset
    74
    [[AudioManagerController mainManager] playClickSound];
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
    75
    [self.tableView setContentOffset:CGPointMake(0, 0) animated:NO];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    76
    [self.tableView reloadData];
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 data source
6e84339eefee about page done
koda
parents: 3783
diff changeset
    81
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    82
    return 1;
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
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    86
    return [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] count];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    87
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
    88
6e84339eefee about page done
koda
parents: 3783
diff changeset
    89
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
    90
    static NSString *CellIdentifier = @"Cell";
6e84339eefee about page done
koda
parents: 3783
diff changeset
    91
6e84339eefee about page done
koda
parents: 3783
diff changeset
    92
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    93
    if (cell == nil)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    94
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
6e84339eefee about page done
koda
parents: 3783
diff changeset
    95
6e84339eefee about page done
koda
parents: 3783
diff changeset
    96
    // first all the names, then the title (which is offset 5)
6e84339eefee about page done
koda
parents: 3783
diff changeset
    97
    cell.textLabel.text = [[self.people objectAtIndex:self.segmentedControl.selectedSegmentIndex] objectAtIndex:[indexPath row]];
5985
d276be65b745 aligned credits and game modes to main release
koda
parents: 5208
diff changeset
    98
    cell.textLabel.adjustsFontSizeToFitWidth = YES;
d276be65b745 aligned credits and game modes to main release
koda
parents: 5208
diff changeset
    99
    cell.textLabel.minimumFontSize = 8;
11128
344d523ab9bb - Fix for localization of detail labels at AboutViewController
antonc27 <antonc27@mail.ru>
parents: 11116
diff changeset
   100
    NSString *detailsKey = [[self.people objectAtIndex:(self.segmentedControl.selectedSegmentIndex + 5)] objectAtIndex:[indexPath row]];
344d523ab9bb - Fix for localization of detail labels at AboutViewController
antonc27 <antonc27@mail.ru>
parents: 11116
diff changeset
   101
    cell.detailTextLabel.text = NSLocalizedStringFromTable(detailsKey, @"About", nil);
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   102
6e84339eefee about page done
koda
parents: 3783
diff changeset
   103
    return cell;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   104
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   105
6e84339eefee about page done
koda
parents: 3783
diff changeset
   106
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
   107
#pragma mark Table view delegate
6e84339eefee about page done
koda
parents: 3783
diff changeset
   108
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6e84339eefee about page done
koda
parents: 3783
diff changeset
   109
    // do nothing
6e84339eefee about page done
koda
parents: 3783
diff changeset
   110
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   111
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   112
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   113
    return 95;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   114
}
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   115
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   116
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section {
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   117
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   118
    char *fullver;
4603
d362ab6c7f53 damn. it.
koda
parents: 4460
diff changeset
   119
    int proto;
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   120
    HW_versionInfo(&proto, &fullver);
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   121
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   122
    NSString *footerString = [[NSString alloc] initWithFormat:
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   123
                              @"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
   124
                              version, fullver, proto];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   125
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   126
    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
   127
    footer.backgroundColor = [UIColor clearColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   128
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   129
    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
   130
    label.center = CGPointMake(self.tableView.frame.size.width/2, 45);
11549
893722a2a1f9 - Some warnings fixed with text alignment on iOS front-end
antonc27 <antonc27@mail.ru>
parents: 11308
diff changeset
   131
    label.textAlignment = NSTextAlignmentCenter;
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   132
    label.font = [UIFont systemFontOfSize:16];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   133
    label.textColor = [UIColor lightGrayColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   134
    label.numberOfLines = 5;
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   135
    label.text = footerString;
11307
72c46b4923c4 - 'About' screen on iOS now is up-to-date with Qt front-end 'About'
antonc27 <antonc27@mail.ru>
parents: 11128
diff changeset
   136
    [footerString release];
4460
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   137
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   138
    label.backgroundColor = [UIColor clearColor];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   139
    [footer addSubview:label];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   140
    [label release];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   141
    return [footer autorelease];
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   142
}
bdace1e2f8aa write some version information inside the application
koda
parents: 4115
diff changeset
   143
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   144
#pragma mark -
6e84339eefee about page done
koda
parents: 3783
diff changeset
   145
#pragma mark Memory Management
6e84339eefee about page done
koda
parents: 3783
diff changeset
   146
-(void) didReceiveMemoryWarning {
3971
5c82ee165ed5 minor stuff
koda
parents: 3829
diff changeset
   147
    self.people = nil;
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   148
    [super didReceiveMemoryWarning];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   149
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   150
6e84339eefee about page done
koda
parents: 3783
diff changeset
   151
-(void) viewDidUnload {
6e84339eefee about page done
koda
parents: 3783
diff changeset
   152
    self.tableView = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   153
    self.segmentedControl = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   154
    self.people = nil;
6e84339eefee about page done
koda
parents: 3783
diff changeset
   155
    [super viewDidUnload];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   156
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   157
6e84339eefee about page done
koda
parents: 3783
diff changeset
   158
-(void) dealloc {
5208
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   159
    releaseAndNil(tableView);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   160
    releaseAndNil(segmentedControl);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 5185
diff changeset
   161
    releaseAndNil(people);
3787
6e84339eefee about page done
koda
parents: 3783
diff changeset
   162
    [super dealloc];
6e84339eefee about page done
koda
parents: 3783
diff changeset
   163
}
6e84339eefee about page done
koda
parents: 3783
diff changeset
   164
3703
12d17c6e8855 halfway-through finishing the frontend with new graphics by Tiy + initial 'About' page set up
koda
parents:
diff changeset
   165
@end