3621
|
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
|
3624
|
13 |
@synthesize delegate, weaponName, weaponIcon, initialQt, probability, delay, crateQt;
|
3621
|
14 |
|
|
15 |
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
16 |
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
|
3624
|
17 |
delegate = nil;
|
|
18 |
|
3621
|
19 |
weaponName = [[UILabel alloc] init];
|
|
20 |
weaponName.backgroundColor = [UIColor clearColor];
|
|
21 |
weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
|
|
22 |
weaponIcon = [[UIImageView alloc] init];
|
|
23 |
|
|
24 |
NSString *imgStr;
|
|
25 |
initialQt = [[UIButton alloc] init];
|
|
26 |
imgStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
|
3624
|
27 |
[initialQt setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
|
3621
|
28 |
[initialQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
|
3624
|
29 |
[initialQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
3621
|
30 |
|
|
31 |
probability = [[UIButton alloc] init];
|
|
32 |
imgStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
|
|
33 |
[probability setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
|
3624
|
34 |
[probability addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
35 |
|
3621
|
36 |
delay = [[UIButton alloc] init];
|
|
37 |
imgStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
|
|
38 |
[delay setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
|
3624
|
39 |
[delay addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
40 |
|
3621
|
41 |
crateQt = [[UIButton alloc] init];
|
|
42 |
imgStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
|
|
43 |
[crateQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
|
3624
|
44 |
[crateQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
45 |
|
3621
|
46 |
[self.contentView addSubview:weaponName];
|
|
47 |
[self.contentView addSubview:weaponIcon];
|
|
48 |
[self.contentView addSubview:initialQt];
|
|
49 |
[self.contentView addSubview:probability];
|
|
50 |
[self.contentView addSubview:delay];
|
|
51 |
[self.contentView addSubview:crateQt];
|
|
52 |
}
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
-(void) layoutSubviews {
|
|
57 |
[super layoutSubviews];
|
|
58 |
|
|
59 |
CGRect contentRect = self.contentView.bounds;
|
|
60 |
CGFloat boundsX = contentRect.origin.x;
|
|
61 |
CGRect frame;
|
|
62 |
|
3624
|
63 |
frame = CGRectMake(boundsX+5, 5, 32, 32);
|
3621
|
64 |
weaponIcon.frame = frame;
|
|
65 |
|
3624
|
66 |
frame = CGRectMake(boundsX+45, 8, 200, 25);
|
3621
|
67 |
weaponName.frame = frame;
|
|
68 |
|
|
69 |
// second line
|
|
70 |
frame = CGRectMake(boundsX+20, 40, 32, 32);
|
|
71 |
initialQt.frame = frame;
|
|
72 |
|
|
73 |
frame = CGRectMake(boundsX+60, 40, 32, 32);
|
|
74 |
probability.frame = frame;
|
|
75 |
|
|
76 |
frame = CGRectMake(boundsX+100, 40, 32, 32);
|
|
77 |
delay.frame = frame;
|
|
78 |
|
|
79 |
frame = CGRectMake(boundsX+140, 40, 32, 32);
|
|
80 |
crateQt.frame = frame;
|
|
81 |
}
|
|
82 |
|
|
83 |
/*
|
|
84 |
-(void) setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
85 |
[super setSelected:selected animated:animated];
|
|
86 |
// Configure the view for the selected state
|
|
87 |
}
|
|
88 |
*/
|
|
89 |
|
3624
|
90 |
-(void) buttonPressed:(id) sender {
|
|
91 |
if (self.delegate != nil) {
|
|
92 |
[(UIButton *)sender setTag:self.tag];
|
|
93 |
[delegate buttonPressed:sender];
|
|
94 |
} else
|
|
95 |
DLog(@"error - delegate = nil!");
|
|
96 |
}
|
|
97 |
|
3621
|
98 |
-(void) dealloc {
|
|
99 |
[weaponName release];
|
|
100 |
[weaponIcon release];
|
|
101 |
[initialQt release];
|
|
102 |
[probability release];
|
|
103 |
[delay release];
|
|
104 |
[crateQt release];
|
|
105 |
[super dealloc];
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
@end
|