author | koda |
Sat, 17 Jul 2010 16:35:14 +0200 | |
changeset 3649 | bc35f8fee587 |
parent 3644 | 42c5684289ae |
child 3659 | f8d5ac50e307 |
permissions | -rw-r--r-- |
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 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
13 |
@synthesize delegate, weaponName, weaponIcon, initialQt, probabilityQt, delayQt, crateQt, |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
14 |
initialImg, probabImg, delayImg, crateImg, initialLab, probLab, delLab, craLab; |
3621 | 15 |
|
16 |
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { |
|
17 |
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { |
|
3624 | 18 |
delegate = nil; |
19 |
||
3621 | 20 |
weaponName = [[UILabel alloc] init]; |
21 |
weaponName.backgroundColor = [UIColor clearColor]; |
|
22 |
weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
23 |
weaponIcon = [[UIImageView alloc] init]; |
|
24 |
||
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
25 |
initialQt = [[UISlider alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
26 |
[initialQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
27 |
initialQt.maximumValue = 9; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
28 |
initialQt.minimumValue = 0; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
29 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
30 |
probabilityQt = [[UISlider alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
31 |
[probabilityQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
32 |
probabilityQt.maximumValue = 9; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
33 |
probabilityQt.minimumValue = 0; |
3621 | 34 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
35 |
delayQt = [[UISlider alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
36 |
[delayQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
37 |
delayQt.maximumValue = 9; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
38 |
delayQt.minimumValue = 0; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
39 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
40 |
crateQt = [[UISlider alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
41 |
[crateQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
42 |
crateQt.maximumValue = 9; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
43 |
crateQt.minimumValue = 0; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
44 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
45 |
NSString *imgAmmoStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
46 |
NSString *imgDamageStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
47 |
NSString *imgTimeStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
48 |
NSString *imgBoxStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()]; |
3624 | 49 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
50 |
initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
51 |
probabImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
52 |
delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
53 |
crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
54 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
55 |
initialLab = [[UILabel alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
56 |
initialLab.backgroundColor = [UIColor clearColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
57 |
initialLab.textColor = [UIColor grayColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
58 |
initialLab.textAlignment = UITextAlignmentCenter; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
59 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
60 |
probLab = [[UILabel alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
61 |
probLab.backgroundColor = [UIColor clearColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
62 |
probLab.textColor = [UIColor grayColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
63 |
probLab.textAlignment = UITextAlignmentCenter; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
64 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
65 |
delLab = [[UILabel alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
66 |
delLab.backgroundColor = [UIColor clearColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
67 |
delLab.textColor = [UIColor grayColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
68 |
delLab.textAlignment = UITextAlignmentCenter; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
69 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
70 |
craLab = [[UILabel alloc] init]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
71 |
craLab.backgroundColor = [UIColor clearColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
72 |
craLab.textColor = [UIColor grayColor]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
73 |
craLab.textAlignment = UITextAlignmentCenter; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
74 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
75 |
[self.contentView addSubview:weaponName]; [weaponName release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
76 |
[self.contentView addSubview:weaponIcon]; [weaponIcon release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
77 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
78 |
[self.contentView addSubview:initialQt]; [initialQt release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
79 |
[self.contentView addSubview:probabilityQt]; [probabilityQt release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
80 |
[self.contentView addSubview:delayQt]; [delayQt release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
81 |
[self.contentView addSubview:crateQt]; [crateQt release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
82 |
|
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
83 |
[self.contentView addSubview:initialImg]; [initialImg release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
84 |
[self.contentView addSubview:probabImg]; [probabImg release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
85 |
[self.contentView addSubview:delayImg]; [delayImg release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
86 |
[self.contentView addSubview:crateImg]; [crateImg release]; |
3624 | 87 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
88 |
[self.contentView addSubview:initialLab]; [initialLab release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
89 |
[self.contentView addSubview:probLab]; [probLab release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
90 |
[self.contentView addSubview:delLab]; [delLab release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
91 |
[self.contentView addSubview:craLab]; [craLab release]; |
3621 | 92 |
} |
93 |
return self; |
|
94 |
} |
|
95 |
||
96 |
-(void) layoutSubviews { |
|
97 |
[super layoutSubviews]; |
|
98 |
||
99 |
CGRect contentRect = self.contentView.bounds; |
|
100 |
CGFloat boundsX = contentRect.origin.x; |
|
101 |
||
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
102 |
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
103 |
boundsX += 65; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
104 |
else |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
105 |
boundsX -= 9; |
3621 | 106 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
107 |
weaponIcon.frame = CGRectMake(5, 5, 32, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
108 |
weaponName.frame = CGRectMake(45, 8, 200, 25); |
3621 | 109 |
|
110 |
// second line |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
111 |
initialImg.frame = CGRectMake(boundsX+20, 40, 32, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
112 |
initialLab.frame = CGRectMake(boundsX+56, 40, 20, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
113 |
initialLab.text = ((int)initialQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
114 |
initialQt.frame = CGRectMake(boundsX+80, 40, 150, 32); |
3621 | 115 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
116 |
probabImg.frame = CGRectMake(boundsX+255, 40, 32, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
117 |
probLab.frame = CGRectMake(boundsX+291, 40, 20, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
118 |
probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
119 |
probabilityQt.frame = CGRectMake(boundsX+314, 40, 150, 32); |
3621 | 120 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
121 |
// third line |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
122 |
delayImg.frame = CGRectMake(boundsX+20, 80, 32, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
123 |
delLab.frame = CGRectMake(boundsX+56, 80, 20, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
124 |
delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
125 |
delayQt.frame = CGRectMake(boundsX+80, 80, 150, 32); |
3621 | 126 |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
127 |
crateImg.frame = CGRectMake(boundsX+255, 80, 32, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
128 |
craLab.frame = CGRectMake(boundsX+291, 80, 20, 32); |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
129 |
craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
130 |
crateQt.frame = CGRectMake(boundsX+314, 80, 150, 32); |
3621 | 131 |
} |
132 |
||
133 |
/* |
|
134 |
-(void) setSelected:(BOOL)selected animated:(BOOL)animated { |
|
135 |
[super setSelected:selected animated:animated]; |
|
136 |
// Configure the view for the selected state |
|
137 |
} |
|
138 |
*/ |
|
139 |
||
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
140 |
-(void) valueChanged:(id) sender { |
3624 | 141 |
if (self.delegate != nil) { |
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
142 |
initialLab.text = ((int)initialQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
143 |
probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
144 |
delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
145 |
craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
146 |
|
3644
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
147 |
[delegate updateValues:[NSArray arrayWithObjects: |
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
148 |
[NSNumber numberWithInt:(int)initialQt.value], |
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
149 |
[NSNumber numberWithInt:(int)probabilityQt.value], |
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
150 |
[NSNumber numberWithInt:(int)delayQt.value], |
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
151 |
[NSNumber numberWithInt:(int)crateQt.value], nil] |
42c5684289ae
finished ammo configuration (which is the last page missing in config \o/)
koda
parents:
3643
diff
changeset
|
152 |
atIndex:self.tag]; |
3624 | 153 |
} else |
154 |
DLog(@"error - delegate = nil!"); |
|
155 |
} |
|
156 |
||
3621 | 157 |
-(void) dealloc { |
158 |
[weaponName release]; |
|
159 |
[weaponIcon release]; |
|
160 |
[initialQt release]; |
|
3643
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
161 |
[probabilityQt release]; |
858b20bafb6e
reworked the ammunition configuration page (visually)
koda
parents:
3624
diff
changeset
|
162 |
[delayQt release]; |
3621 | 163 |
[crateQt release]; |
164 |
[super dealloc]; |
|
165 |
} |
|
166 |
||
167 |
||
168 |
@end |