project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
author koda
Thu, 03 Nov 2011 01:10:25 +0100
changeset 6266 b02a1e92dba2
parent 6210 923c8414e3af
child 6353 d8f62c805619
permissions -rw-r--r--
convert gameinterfacebridge in simple-to-use class methods
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
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
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
 *
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    18
 * File created on 03/10/2011.
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 {
6266
b02a1e92dba2 convert gameinterfacebridge in simple-to-use class methods
koda
parents: 6210
diff changeset
    77
        [GameInterfaceBridge startMissionGame:self.missionName];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    78
    }
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
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    81
#pragma mark -
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    82
#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
    83
-(NSArray *)listOfMissions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    84
    if (listOfMissions == nil)
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    85
        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
    86
    return listOfMissions;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    87
}
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
-(NSArray *)listOfDescriptions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    90
    if (listOfDescriptions == nil) {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    91
        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
    92
        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
    93
        [descLocation release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    94
        NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    95
        NSMutableArray *filteredArray = [[NSMutableArray alloc] initWithCapacity:[descArray count]];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    96
        [descComplete release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    97
        // 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
    98
        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
    99
            NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   100
            for (NSString *str in descArray)
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   101
                if ([str hasPrefix:desc]) {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   102
                    NSArray *descriptionText = [str componentsSeparatedByString:@"\""];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   103
                    [filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   104
                    break;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   105
                }
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
        self.listOfDescriptions = filteredArray;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   108
        [filteredArray release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   109
    }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   110
    return listOfDescriptions;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   111
}
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
#pragma mark -
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   114
#pragma mark Table view data source
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   115
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   116
    return 1;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   117
}
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
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   120
    return [self.listOfMissions count];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   121
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   122
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   123
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   124
    return (IS_IPAD()) ? self.tableView.rowHeight : 80;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   125
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   126
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   127
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   128
    static NSString *CellIdentifier = @"CellTr";
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   129
    NSInteger row = [indexPath row];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   130
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   131
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   132
    if (cell == nil)
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   133
        cell = [[[UITableViewCell alloc] initWithStyle:(IS_IPAD()) ? UITableViewCellStyleDefault : UITableViewCellStyleSubtitle
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   134
                                       reuseIdentifier:CellIdentifier] autorelease];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   135
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   136
    cell.textLabel.text = [[[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension]
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   137
                           stringByReplacingOccurrencesOfString:@"_" withString:@" "];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   138
    cell.textLabel.textColor = [UIColor lightYellowColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   139
    //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
   140
    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
   141
    cell.textLabel.backgroundColor = [UIColor clearColor];
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   142
    cell.textLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   143
    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
   144
    cell.detailTextLabel.textColor = [UIColor whiteColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   145
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   146
    cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   147
    cell.detailTextLabel.numberOfLines = ([cell.detailTextLabel.text length] % 40);
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   148
    cell.detailTextLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   149
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   150
    cell.backgroundColor = [UIColor blackColorTransparent];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   151
    return cell;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   152
}
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
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   155
#pragma mark Table view delegate
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   156
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   157
    NSInteger row = [indexPath row];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   158
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   159
    self.missionName = [[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension];
6100
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   160
    NSString *size = IS_IPAD() ? @"@2x" : @"";
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   161
    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
   162
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   163
    [filePath release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   164
    [self.previewImage setImage:img];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   165
    [img release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   166
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   167
    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
   168
}
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
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   171
#pragma mark Memory management
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   172
-(void) didReceiveMemoryWarning {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   173
    self.previewImage = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   174
    self.missionName = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   175
    self.listOfMissions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   176
    self.listOfDescriptions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   177
    // 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
   178
    //self.previewImage = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   179
    [super didReceiveMemoryWarning];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   180
}
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
-(void) viewDidUnload {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   183
    self.listOfMissions = nil;
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   184
    self.listOfDescriptions = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   185
    self.previewImage = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   186
    self.tableView = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   187
    self.descriptionLabel = nil;
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   188
    self.missionName = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   189
    MSG_DIDUNLOAD();
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   190
    [super viewDidUnload];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   191
}
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
-(void) dealloc {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   195
    releaseAndNil(listOfMissions);
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   196
    releaseAndNil(listOfDescriptions);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   197
    releaseAndNil(previewImage);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   198
    releaseAndNil(tableView);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   199
    releaseAndNil(descriptionLabel);
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   200
    releaseAndNil(missionName);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   201
    [super dealloc];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   202
}
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
@end