22 |
22 |
23 @implementation WeaponCellView |
23 @implementation WeaponCellView |
24 @synthesize delegate, weaponName, weaponIcon, initialSli, probabilitySli, delaySli, crateSli, helpLabel, |
24 @synthesize delegate, weaponName, weaponIcon, initialSli, probabilitySli, delaySli, crateSli, helpLabel, |
25 initialImg, probabilityImg, delayImg, crateImg, initialLab, probabilityLab, delayLab, crateLab; |
25 initialImg, probabilityImg, delayImg, crateImg, initialLab, probabilityLab, delayLab, crateLab; |
26 |
26 |
27 -(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { |
27 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { |
28 if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { |
28 if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { |
29 delegate = nil; |
29 delegate = nil; |
30 |
30 |
31 weaponName = [[UILabel alloc] init]; |
31 weaponName = [[UILabel alloc] init]; |
32 weaponName.backgroundColor = [UIColor clearColor]; |
32 weaponName.backgroundColor = [UIColor clearColor]; |
65 crateSli.minimumValue = 0; |
65 crateSli.minimumValue = 0; |
66 crateSli.tag = 400; |
66 crateSli.tag = 400; |
67 |
67 |
68 NSString *imgAmmoStr = [[NSString alloc] initWithFormat:@"%@/ammopic.png",ICONS_DIRECTORY()]; |
68 NSString *imgAmmoStr = [[NSString alloc] initWithFormat:@"%@/ammopic.png",ICONS_DIRECTORY()]; |
69 initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]]; |
69 initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]]; |
70 [imgAmmoStr release]; |
|
71 NSString *imgDamageStr = [[NSString alloc] initWithFormat:@"%@/iconDamage.png",ICONS_DIRECTORY()]; |
70 NSString *imgDamageStr = [[NSString alloc] initWithFormat:@"%@/iconDamage.png",ICONS_DIRECTORY()]; |
72 probabilityImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]]; |
71 probabilityImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]]; |
73 [imgDamageStr release]; |
|
74 NSString *imgTimeStr = [[NSString alloc] initWithFormat:@"%@/iconTime.png",ICONS_DIRECTORY()]; |
72 NSString *imgTimeStr = [[NSString alloc] initWithFormat:@"%@/iconTime.png",ICONS_DIRECTORY()]; |
75 delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]]; |
73 delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]]; |
76 [imgTimeStr release]; |
|
77 NSString *imgBoxStr = [[NSString alloc] initWithFormat:@"%@/iconBox.png",ICONS_DIRECTORY()]; |
74 NSString *imgBoxStr = [[NSString alloc] initWithFormat:@"%@/iconBox.png",ICONS_DIRECTORY()]; |
78 crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]]; |
75 crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]]; |
79 [imgBoxStr release]; |
|
80 |
76 |
81 initialLab = [[UILabel alloc] init]; |
77 initialLab = [[UILabel alloc] init]; |
82 initialLab.backgroundColor = [UIColor clearColor]; |
78 initialLab.backgroundColor = [UIColor clearColor]; |
83 initialLab.textColor = [UIColor grayColor]; |
79 initialLab.textColor = [UIColor grayColor]; |
84 initialLab.textAlignment = NSTextAlignmentCenter; |
80 initialLab.textAlignment = NSTextAlignmentCenter; |
126 [self.contentView addSubview:helpLabel]; |
122 [self.contentView addSubview:helpLabel]; |
127 } |
123 } |
128 return self; |
124 return self; |
129 } |
125 } |
130 |
126 |
131 -(void) layoutSubviews { |
127 - (void)layoutSubviews { |
132 [super layoutSubviews]; |
128 [super layoutSubviews]; |
133 |
129 |
134 CGFloat hOffset = 80; |
130 CGFloat hOffset = 80; |
135 CGFloat hOffsetWhenLandscape = 234; |
131 CGFloat hOffsetWhenLandscape = 234; |
136 CGFloat vOffset = 40; |
132 CGFloat vOffset = 40; |
184 crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value]; |
180 crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value]; |
185 crateSli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + 40 + vOffsetWhenPortrait, sliderLength, 32); |
181 crateSli.frame = CGRectMake(hOffset + hOffsetWhenLandscape, vOffset + 40 + vOffsetWhenPortrait, sliderLength, 32); |
186 } |
182 } |
187 |
183 |
188 /* |
184 /* |
189 -(void) setSelected:(BOOL)selected animated:(BOOL)animated { |
185 - (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
190 [super setSelected:selected animated:animated]; |
186 [super setSelected:selected animated:animated]; |
191 // Configure the view for the selected state |
187 // Configure the view for the selected state |
192 } |
188 } |
193 */ |
189 */ |
194 |
190 |
195 -(void) valueChanged:(id) sender { |
191 - (void)valueChanged:(id)sender { |
196 if (self.delegate != nil) { |
192 if (self.delegate != nil) { |
197 initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value]; |
193 initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value]; |
198 probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value]; |
194 probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value]; |
199 delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value]; |
195 delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value]; |
200 crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value]; |
196 crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value]; |
240 break; |
236 break; |
241 } |
237 } |
242 self.helpLabel.text = str; |
238 self.helpLabel.text = str; |
243 } |
239 } |
244 |
240 |
245 -(void) stopDragging:(id) sender { |
241 - (void)stopDragging:(id)sender { |
246 self.helpLabel.text = @""; |
242 self.helpLabel.text = @""; |
247 } |
243 } |
248 |
244 |
249 -(void) dealloc { |
|
250 self.delegate = nil; |
|
251 releaseAndNil(weaponName); |
|
252 releaseAndNil(weaponIcon); |
|
253 releaseAndNil(initialSli); |
|
254 releaseAndNil(probabilitySli); |
|
255 releaseAndNil(delaySli); |
|
256 releaseAndNil(crateSli); |
|
257 releaseAndNil(initialImg); |
|
258 releaseAndNil(probabilityImg); |
|
259 releaseAndNil(delayImg); |
|
260 releaseAndNil(crateImg); |
|
261 releaseAndNil(initialLab); |
|
262 releaseAndNil(probabilityLab); |
|
263 releaseAndNil(delayLab); |
|
264 releaseAndNil(crateLab); |
|
265 releaseAndNil(helpLabel); |
|
266 [super dealloc]; |
|
267 } |
|
268 |
|
269 @end |
245 @end |