project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
author koda
Sat, 18 Feb 2012 19:29:16 +0100
changeset 6711 76e96101a84f
parent 6700 e04da46ee43c
child 6717 080e716e6990
permissions -rw-r--r--
prepare a styled button
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     1
/*
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
6700
e04da46ee43c the most important commit of the year
koda
parents: 6494
diff changeset
     3
 * Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com>
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     4
 *
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     8
 *
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    12
 * GNU General Public License for more details.
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    13
 *
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    17
 *
6700
e04da46ee43c the most important commit of the year
koda
parents: 6494
diff changeset
    18
 * File created on 03/10/2012.
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    19
 */
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    20
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    21
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    22
#import "MissionTrainingViewController.h"
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    23
#import <QuartzCore/QuartzCore.h>
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    24
#import "GameInterfaceBridge.h"
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    25
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    26
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    27
@implementation MissionTrainingViewController
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    28
@synthesize listOfMissions, listOfDescriptions, previewImage, tableView, descriptionLabel, missionName;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    29
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    30
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    31
    return rotationManager(interfaceOrientation);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    32
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    33
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    34
#pragma mark -
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    35
#pragma mark View management
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    36
-(void) viewDidLoad {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    37
    NSString *imgName = (IS_IPAD()) ? @"mediumBackground~ipad.png" : @"smallerBackground~iphone.png";
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    38
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgName];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    39
    self.view.backgroundColor = [UIColor colorWithPatternImage:img];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    40
    [img release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    41
    
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    42
    self.previewImage.layer.borderColor = [[UIColor darkYellowColor] CGColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    43
    self.previewImage.layer.borderWidth = 3.8f;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    44
    self.previewImage.layer.cornerRadius = 14;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    45
6210
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    46
    if (IS_IPAD()) {
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    47
        [self.tableView setBackgroundColorForAnyTable:[UIColor darkBlueColorTransparent]];
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    48
        self.tableView.layer.borderColor = [[UIColor darkYellowColor] CGColor];
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    49
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    50
    } else {
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    51
        [self.tableView setBackgroundColorForAnyTable:[UIColor blackColorTransparent]];
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    52
        self.tableView.layer.borderColor = [[UIColor whiteColor] CGColor];
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    53
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    54
    }
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    55
    self.tableView.layer.borderWidth = 2.4f;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    56
    self.tableView.layer.cornerRadius = 8;
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    57
    self.tableView.separatorColor = [UIColor whiteColor];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    58
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    59
    self.descriptionLabel.textColor = [UIColor lightYellowColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    60
    [super viewDidLoad];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    61
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    62
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    63
-(void) viewWillAppear:(BOOL)animated {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    64
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:random()%[self.listOfMissions count] inSection:0];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    65
    [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    66
    [self tableView:self.tableView didSelectRowAtIndexPath:indexPath];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    67
    [super viewWillAppear:animated];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    68
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    69
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    70
-(IBAction) buttonPressed:(id) sender {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    71
    UIButton *button = (UIButton *)sender;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    72
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    73
    if (button.tag == 0) {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    74
        [AudioManagerController playBackSound];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    75
        [[self parentViewController] dismissModalViewControllerAnimated:YES];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    76
    } else {
6353
d8f62c805619 restore displaying statistics at the end of a game and restore warning lower views that they are going to appear
koda
parents: 6266
diff changeset
    77
        [GameInterfaceBridge registerCallingController:self];
6266
b02a1e92dba2 convert gameinterfacebridge in simple-to-use class methods
koda
parents: 6210
diff changeset
    78
        [GameInterfaceBridge startMissionGame:self.missionName];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    79
    }
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    80
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    81
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    82
#pragma mark -
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    83
#pragma mark override setters/getters for better memory handling
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    84
-(NSArray *)listOfMissions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    85
    if (listOfMissions == nil)
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    86
        self.listOfMissions = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TRAININGS_DIRECTORY() error:NULL];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    87
    return listOfMissions;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    88
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    89
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    90
-(NSArray *)listOfDescriptions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    91
    if (listOfDescriptions == nil) {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    92
        NSString *descLocation = [[NSString alloc] initWithFormat:@"%@/missions_en.txt",LOCALE_DIRECTORY()];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    93
        NSString *descComplete = [[NSString alloc] initWithContentsOfFile:descLocation encoding:NSUTF8StringEncoding error:NULL];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    94
        [descLocation release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    95
        NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"];
6494
5e0595f41cde ios port working again, mono audio is missing
koda
parents: 6353
diff changeset
    96
        NSMutableArray *filteredArray = [[NSMutableArray alloc] initWithCapacity:[descArray count]/3];
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    97
        [descComplete release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    98
        // sanity check to avoid having missions and descriptions conflicts
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    99
        for (int i = 0; i < [self.listOfMissions count]; i++) {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   100
            NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   101
            for (NSString *str in descArray)
6494
5e0595f41cde ios port working again, mono audio is missing
koda
parents: 6353
diff changeset
   102
                if ([str hasPrefix:desc] && [str hasSuffix:@"\""]) {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   103
                    NSArray *descriptionText = [str componentsSeparatedByString:@"\""];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   104
                    [filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   105
                    break;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   106
                }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   107
        }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   108
        self.listOfDescriptions = filteredArray;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   109
        [filteredArray release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   110
    }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   111
    return listOfDescriptions;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   112
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   113
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   114
#pragma mark -
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   115
#pragma mark Table view data source
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   116
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   117
    return 1;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   118
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   119
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   120
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   121
    return [self.listOfMissions count];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   122
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   123
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   124
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   125
    return (IS_IPAD()) ? self.tableView.rowHeight : 80;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   126
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   127
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   128
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   129
    static NSString *CellIdentifier = @"CellTr";
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   130
    NSInteger row = [indexPath row];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   131
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   132
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   133
    if (cell == nil)
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   134
        cell = [[[UITableViewCell alloc] initWithStyle:(IS_IPAD()) ? UITableViewCellStyleDefault : UITableViewCellStyleSubtitle
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   135
                                       reuseIdentifier:CellIdentifier] autorelease];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   136
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   137
    cell.textLabel.text = [[[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension]
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   138
                           stringByReplacingOccurrencesOfString:@"_" withString:@" "];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   139
    cell.textLabel.textColor = [UIColor lightYellowColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   140
    //cell.textLabel.font = [UIFont fontWithName:@"Bradley Hand Bold" size:[UIFont labelFontSize]];
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   141
    cell.textLabel.textAlignment = (IS_IPAD()) ? UITextAlignmentCenter : UITextAlignmentLeft;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   142
    cell.textLabel.backgroundColor = [UIColor clearColor];
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   143
    cell.textLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   144
    cell.detailTextLabel.text = (IS_IPAD()) ? nil : [self.listOfDescriptions objectAtIndex:row];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   145
    cell.detailTextLabel.textColor = [UIColor whiteColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   146
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   147
    cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   148
    cell.detailTextLabel.numberOfLines = ([cell.detailTextLabel.text length] % 40);
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   149
    cell.detailTextLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   150
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   151
    cell.backgroundColor = [UIColor blackColorTransparent];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   152
    return cell;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   153
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   154
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   155
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   156
#pragma mark Table view delegate
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   157
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   158
    NSInteger row = [indexPath row];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   159
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   160
    self.missionName = [[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension];
6100
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   161
    NSString *size = IS_IPAD() ? @"@2x" : @"";
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   162
    NSString *filePath = [[NSString alloc] initWithFormat:@"%@/Missions/Training/%@%@.png",GRAPHICS_DIRECTORY(),self.missionName,size];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   163
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   164
    [filePath release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   165
    [self.previewImage setImage:img];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   166
    [img release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   167
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   168
    self.descriptionLabel.text = [self.listOfDescriptions objectAtIndex:row];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   169
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   170
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   171
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   172
#pragma mark Memory management
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   173
-(void) didReceiveMemoryWarning {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   174
    self.previewImage = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   175
    self.missionName = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   176
    self.listOfMissions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   177
    self.listOfDescriptions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   178
    // if you nil this one it won't get updated anymore
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   179
    //self.previewImage = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   180
    [super didReceiveMemoryWarning];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   181
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   182
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   183
-(void) viewDidUnload {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   184
    self.listOfMissions = nil;
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   185
    self.listOfDescriptions = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   186
    self.previewImage = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   187
    self.tableView = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   188
    self.descriptionLabel = nil;
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   189
    self.missionName = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   190
    MSG_DIDUNLOAD();
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   191
    [super viewDidUnload];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   192
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   193
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   194
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   195
-(void) dealloc {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   196
    releaseAndNil(listOfMissions);
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   197
    releaseAndNil(listOfDescriptions);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   198
    releaseAndNil(previewImage);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   199
    releaseAndNil(tableView);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   200
    releaseAndNil(descriptionLabel);
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   201
    releaseAndNil(missionName);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   202
    [super dealloc];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   203
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   204
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   205
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   206
@end