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