project_files/HedgewarsMobile/Classes/WeaponCellView.m
author koda
Sun, 04 Jul 2010 00:33:59 +0200
changeset 3621 a8ddf681ba7d
child 3624 304c6d32383a
permissions -rw-r--r--
initial support for customizing weaponset
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     1
//
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     2
//  WeaponCellView.m
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     3
//  Hedgewars
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     4
//
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     5
//  Created by Vittorio on 03/07/10.
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     6
//  Copyright 2010 __MyCompanyName__. All rights reserved.
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     7
//
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     8
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
     9
#import "WeaponCellView.h"
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    10
#import "CommodityFunctions.h"
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    11
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    12
@implementation WeaponCellView
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    13
@synthesize weaponName, weaponIcon, initialQt, probability, delay, crateQt;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    14
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    15
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    16
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    17
        // Initialization code
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    18
        weaponName = [[UILabel alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    19
        weaponName.backgroundColor = [UIColor clearColor];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    20
        weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    21
        weaponIcon = [[UIImageView alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    22
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    23
        NSString *imgStr;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    24
        initialQt = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    25
        imgStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    26
        [initialQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    27
        
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    28
        probability = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    29
        imgStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    30
        [probability setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    31
        
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    32
        delay = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    33
        imgStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    34
        [delay setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    35
        
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    36
        crateQt = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    37
        imgStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    38
        [crateQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    39
        
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    40
        [self.contentView addSubview:weaponName];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    41
        [self.contentView addSubview:weaponIcon];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    42
        [self.contentView addSubview:initialQt];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    43
        [self.contentView addSubview:probability];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    44
        [self.contentView addSubview:delay];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    45
        [self.contentView addSubview:crateQt];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    46
    }
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    47
    return self;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    48
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    49
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    50
-(void) layoutSubviews {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    51
    [super layoutSubviews];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    52
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    53
    CGRect contentRect = self.contentView.bounds;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    54
    CGFloat boundsX = contentRect.origin.x;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    55
    CGRect frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    56
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    57
    frame = CGRectMake(boundsX+10, 5, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    58
    weaponIcon.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    59
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    60
    frame = CGRectMake(boundsX+50, 9, 200, 25);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    61
    weaponName.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    62
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    63
    // second line
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    64
    frame = CGRectMake(boundsX+20, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    65
    initialQt.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    66
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    67
    frame = CGRectMake(boundsX+60, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    68
    probability.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    69
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    70
    frame = CGRectMake(boundsX+100, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    71
    delay.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    72
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    73
    frame = CGRectMake(boundsX+140, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    74
    crateQt.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    75
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    76
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    77
/*
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    78
-(void) setSelected:(BOOL)selected animated:(BOOL)animated {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    79
    [super setSelected:selected animated:animated];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    80
    // Configure the view for the selected state
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    81
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    82
*/
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    83
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    84
-(void) dealloc {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    85
    [weaponName release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    86
    [weaponIcon release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    87
    [initialQt release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    88
    [probability release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    89
    [delay release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    90
    [crateQt release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    91
    [super dealloc];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    92
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    93
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    94
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    95
@end