project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
author koda
Sun, 19 Feb 2012 02:52:19 +0100
changeset 6719 d2afc6b2d88e
parent 6717 080e716e6990
child 6832 fae8fd118da9
permissions -rw-r--r--
added one button play feature, like in desktop frontend; need to make sure that the hardcoded stuff never gets deleted
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
    self.previewImage.layer.borderColor = [[UIColor darkYellowColor] CGColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    38
    self.previewImage.layer.borderWidth = 3.8f;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    39
    self.previewImage.layer.cornerRadius = 14;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    40
6210
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    41
    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
    42
        [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
    43
        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
    44
        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
    45
    } else {
923c8414e3af fix runtime compability with ios 3.* (hopefully) and fix a small glitch in turning off music/sounds
koda
parents: 6100
diff changeset
    46
        [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
    47
        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
    48
        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
    49
    }
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    50
    self.tableView.layer.borderWidth = 2.4f;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    51
    self.tableView.layer.cornerRadius = 8;
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    52
    self.tableView.separatorColor = [UIColor whiteColor];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    53
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    54
    self.descriptionLabel.textColor = [UIColor lightYellowColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    55
    [super viewDidLoad];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    56
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    57
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    58
-(void) viewWillAppear:(BOOL)animated {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    59
    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
    60
    [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
    61
    [self tableView:self.tableView didSelectRowAtIndexPath:indexPath];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    62
    [super viewWillAppear:animated];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    63
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    64
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    65
-(IBAction) buttonPressed:(id) sender {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    66
    UIButton *button = (UIButton *)sender;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    67
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    68
    if (button.tag == 0) {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    69
        [AudioManagerController playBackSound];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    70
        [[self parentViewController] dismissModalViewControllerAnimated:YES];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    71
    } 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
    72
        [GameInterfaceBridge registerCallingController:self];
6266
b02a1e92dba2 convert gameinterfacebridge in simple-to-use class methods
koda
parents: 6210
diff changeset
    73
        [GameInterfaceBridge startMissionGame:self.missionName];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    74
    }
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    75
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
    76
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    77
#pragma mark -
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    78
#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
    79
-(NSArray *)listOfMissions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    80
    if (listOfMissions == nil)
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    81
        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
    82
    return listOfMissions;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    83
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    84
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    85
-(NSArray *)listOfDescriptions {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    86
    if (listOfDescriptions == nil) {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    87
        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
    88
        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
    89
        [descLocation release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    90
        NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"];
6494
5e0595f41cde ios port working again, mono audio is missing
koda
parents: 6353
diff changeset
    91
        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
    92
        [descComplete release];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    93
        // 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
    94
        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
    95
            NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    96
            for (NSString *str in descArray)
6494
5e0595f41cde ios port working again, mono audio is missing
koda
parents: 6353
diff changeset
    97
                if ([str hasPrefix:desc] && [str hasSuffix:@"\""]) {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    98
                    NSArray *descriptionText = [str componentsSeparatedByString:@"\""];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
    99
                    [filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   100
                    break;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   101
                }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   102
        }
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   103
        self.listOfDescriptions = filteredArray;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   104
        [filteredArray release];
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
    return listOfDescriptions;
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
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   109
#pragma mark -
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   110
#pragma mark Table view data source
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   111
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   112
    return 1;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   113
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   114
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   115
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   116
    return [self.listOfMissions count];
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
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   119
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   120
    return (IS_IPAD()) ? self.tableView.rowHeight : 80;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   121
}
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   122
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   123
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   124
    static NSString *CellIdentifier = @"CellTr";
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   125
    NSInteger row = [indexPath row];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   126
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   127
    UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   128
    if (cell == nil)
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   129
        cell = [[[UITableViewCell alloc] initWithStyle:(IS_IPAD()) ? UITableViewCellStyleDefault : UITableViewCellStyleSubtitle
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   130
                                       reuseIdentifier:CellIdentifier] autorelease];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   131
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   132
    cell.textLabel.text = [[[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension]
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   133
                           stringByReplacingOccurrencesOfString:@"_" withString:@" "];
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   134
    cell.textLabel.textColor = [UIColor lightYellowColor];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   135
    //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
   136
    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
   137
    cell.textLabel.backgroundColor = [UIColor clearColor];
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   138
    cell.textLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   139
    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
   140
    cell.detailTextLabel.textColor = [UIColor whiteColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   141
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   142
    cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   143
    cell.detailTextLabel.numberOfLines = ([cell.detailTextLabel.text length] % 40);
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   144
    cell.detailTextLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   145
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   146
    cell.backgroundColor = [UIColor blackColorTransparent];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   147
    return cell;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   148
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   149
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   150
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   151
#pragma mark Table view delegate
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   152
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   153
    NSInteger row = [indexPath row];
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   154
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   155
    self.missionName = [[self.listOfMissions objectAtIndex:row] stringByDeletingPathExtension];
6100
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   156
    NSString *size = IS_IPAD() ? @"@2x" : @"";
e6426c6b2882 sed commands should be tested beforehand
koda
parents: 6094
diff changeset
   157
    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
   158
    UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   159
    [filePath release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   160
    [self.previewImage setImage:img];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   161
    [img release];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   162
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   163
    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
   164
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   165
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   166
#pragma mark -
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   167
#pragma mark Memory management
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   168
-(void) didReceiveMemoryWarning {
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   169
    self.previewImage = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   170
    self.missionName = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   171
    self.listOfMissions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   172
    self.listOfDescriptions = nil;
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   173
    // 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
   174
    //self.previewImage = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   175
    [super didReceiveMemoryWarning];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   176
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   177
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   178
-(void) viewDidUnload {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   179
    self.listOfMissions = nil;
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   180
    self.listOfDescriptions = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   181
    self.previewImage = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   182
    self.tableView = nil;
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   183
    self.descriptionLabel = nil;
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   184
    self.missionName = nil;
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   185
    MSG_DIDUNLOAD();
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   186
    [super viewDidUnload];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   187
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   188
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   189
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   190
-(void) dealloc {
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   191
    releaseAndNil(listOfMissions);
6094
16b12a6417d1 added iphone interface for missions/trainings page, setters/getters unlocked
koda
parents: 6084
diff changeset
   192
    releaseAndNil(listOfDescriptions);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   193
    releaseAndNil(previewImage);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   194
    releaseAndNil(tableView);
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   195
    releaseAndNil(descriptionLabel);
6084
e692c0348e74 make the missions/trainings start
koda
parents: 6083
diff changeset
   196
    releaseAndNil(missionName);
6083
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   197
    [super dealloc];
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   198
}
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   199
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   200
72c882c0fd0f first pass for implementing missions/training selection on ipad (not yet running)
koda
parents:
diff changeset
   201
@end