author | koda |
Sat, 31 Jul 2010 11:24:53 +0200 | |
changeset 3697 | d5b30d6373fc |
parent 3667 | 9359a70df013 |
child 3766 | 36b625111609 |
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; |
3697 | 19 |
|
3621 | 20 |
weaponName = [[UILabel alloc] init]; |
21 |
weaponName.backgroundColor = [UIColor clearColor]; |
|
22 |
weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
23 |
weaponIcon = [[UIImageView alloc] init]; |
|
3697 | 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; |
3697 | 29 |
|
3643
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; |
3697 | 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; |
3697 | 39 |
|
3643
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; |
3697 | 44 |
|
3643
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]]; |
3697 | 54 |
|
3643
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; |
3697 | 59 |
|
3643
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; |
3697 | 64 |
|
3643
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; |
3697 | 69 |
|
3643
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; |
3697 | 74 |
|
3667 | 75 |
[self.contentView addSubview:weaponName]; // [weaponName release]; |
76 |
[self.contentView addSubview:weaponIcon]; // [weaponIcon release]; |
|
3697 | 77 |
|
3667 | 78 |
[self.contentView addSubview:initialQt]; // [initialQt release]; |
79 |
[self.contentView addSubview:probabilityQt]; // [probabilityQt release]; |
|
80 |
[self.contentView addSubview:delayQt]; // [delayQt release]; |
|
81 |
[self.contentView addSubview:crateQt]; // [crateQt release]; |
|
3697 | 82 |
|
3667 | 83 |
[self.contentView addSubview:initialImg]; // [initialImg release]; |
84 |
[self.contentView addSubview:probabImg]; // [probabImg release]; |
|
85 |
[self.contentView addSubview:delayImg]; // [delayImg release]; |
|
86 |
[self.contentView addSubview:crateImg]; // [crateImg release]; |
|
3624 | 87 |
|
3667 | 88 |
[self.contentView addSubview:initialLab]; // [initialLab release]; |
89 |
[self.contentView addSubview:probLab]; // [probLab release]; |
|
90 |
[self.contentView addSubview:delLab]; // [delLab release]; |
|
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; |
|
3697 | 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); |
3697 | 109 |
|
3621 | 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); |
3697 | 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); |
3697 | 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); |
3697 | 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]; |
3697 | 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], |
3697 | 151 |
[NSNumber numberWithInt:(int)crateQt.value], nil] |
3644
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 { |
3667 | 158 |
self.delegate = nil; |
159 |
releaseAndNil(weaponName); |
|
160 |
releaseAndNil(weaponIcon); |
|
161 |
releaseAndNil(initialQt); |
|
162 |
releaseAndNil(probabilityQt); |
|
163 |
releaseAndNil(delayQt); |
|
164 |
releaseAndNil(crateQt); |
|
165 |
releaseAndNil(initialImg); |
|
166 |
releaseAndNil(probabImg); |
|
167 |
releaseAndNil(delayImg); |
|
168 |
releaseAndNil(crateImg); |
|
169 |
releaseAndNil(initialLab); |
|
170 |
releaseAndNil(probLab); |
|
171 |
releaseAndNil(delLab); |
|
172 |
releaseAndNil(craLab); |
|
3621 | 173 |
[super dealloc]; |
174 |
} |
|
175 |
||
176 |
@end |