project_files/HedgewarsMobile/Classes/WeaponCellView.m
author koda
Mon, 05 Jul 2010 22:42:43 +0200
changeset 3624 304c6d32383a
parent 3621 a8ddf681ba7d
child 3643 858b20bafb6e
permissions -rw-r--r--
button to open ammomenu loading screen that fits launch orientation further work on weapon selection more savings for older idevices
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
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    13
@synthesize delegate, weaponName, weaponIcon, initialQt, probability, delay, crateQt;
3621
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])) {
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    17
        delegate = nil;
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    18
        
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    19
        weaponName = [[UILabel alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    20
        weaponName.backgroundColor = [UIColor clearColor];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    21
        weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    22
        weaponIcon = [[UIImageView alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    23
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    24
        NSString *imgStr;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    25
        initialQt = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    26
        imgStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    27
        [initialQt setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    28
        [initialQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    29
        [initialQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    30
        
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    31
        probability = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    32
        imgStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    33
        [probability setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    34
        [probability addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    35
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    36
        delay = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    37
        imgStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    38
        [delay setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    39
        [delay addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    40
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    41
        crateQt = [[UIButton alloc] init];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    42
        imgStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    43
        [crateQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    44
        [crateQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    45
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    46
        [self.contentView addSubview:weaponName];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    47
        [self.contentView addSubview:weaponIcon];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    48
        [self.contentView addSubview:initialQt];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    49
        [self.contentView addSubview:probability];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    50
        [self.contentView addSubview:delay];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    51
        [self.contentView addSubview:crateQt];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    52
    }
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    53
    return self;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    54
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    55
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    56
-(void) layoutSubviews {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    57
    [super layoutSubviews];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    58
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    59
    CGRect contentRect = self.contentView.bounds;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    60
    CGFloat boundsX = contentRect.origin.x;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    61
    CGRect frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    62
    
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    63
    frame = CGRectMake(boundsX+5, 5, 32, 32);
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    64
    weaponIcon.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    65
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    66
    frame = CGRectMake(boundsX+45, 8, 200, 25);
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    67
    weaponName.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    68
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    69
    // second line
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    70
    frame = CGRectMake(boundsX+20, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    71
    initialQt.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+60, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    74
    probability.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    75
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    76
    frame = CGRectMake(boundsX+100, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    77
    delay.frame = frame;
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    78
    
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    79
    frame = CGRectMake(boundsX+140, 40, 32, 32);
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    80
    crateQt.frame = frame;
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) setSelected:(BOOL)selected animated:(BOOL)animated {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    85
    [super setSelected:selected animated:animated];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    86
    // Configure the view for the selected state
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    87
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    88
*/
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    89
3624
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    90
-(void) buttonPressed:(id) sender {
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    91
    if (self.delegate != nil) {
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    92
        [(UIButton *)sender setTag:self.tag];
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    93
        [delegate buttonPressed:sender];
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    94
    } else
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    95
        DLog(@"error - delegate = nil!");
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    96
}
304c6d32383a button to open ammomenu
koda
parents: 3621
diff changeset
    97
3621
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    98
-(void) dealloc {
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
    99
    [weaponName release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   100
    [weaponIcon release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   101
    [initialQt release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   102
    [probability release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   103
    [delay release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   104
    [crateQt release];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   105
    [super dealloc];
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   106
}
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   107
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   108
a8ddf681ba7d initial support for customizing weaponset
koda
parents:
diff changeset
   109
@end