--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m Thu Jul 15 01:18:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m Thu Jul 15 03:28:29 2010 +0200
@@ -10,7 +10,8 @@
#import "CommodityFunctions.h"
@implementation WeaponCellView
-@synthesize delegate, weaponName, weaponIcon, initialQt, probability, delay, crateQt;
+@synthesize delegate, weaponName, weaponIcon, initialQt, probabilityQt, delayQt, crateQt,
+ initialImg, probabImg, delayImg, crateImg, initialLab, probLab, delLab, craLab;
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
@@ -21,34 +22,73 @@
weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
weaponIcon = [[UIImageView alloc] init];
- NSString *imgStr;
- initialQt = [[UIButton alloc] init];
- imgStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
- [initialQt setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
- [initialQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
- [initialQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
+ initialQt = [[UISlider alloc] init];
+ [initialQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+ initialQt.maximumValue = 9;
+ initialQt.minimumValue = 0;
+
+ probabilityQt = [[UISlider alloc] init];
+ [probabilityQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+ probabilityQt.maximumValue = 9;
+ probabilityQt.minimumValue = 0;
- probability = [[UIButton alloc] init];
- imgStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
- [probability setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
- [probability addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
+ delayQt = [[UISlider alloc] init];
+ [delayQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+ delayQt.maximumValue = 9;
+ delayQt.minimumValue = 0;
+
+ crateQt = [[UISlider alloc] init];
+ [crateQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+ crateQt.maximumValue = 9;
+ crateQt.minimumValue = 0;
+
+ NSString *imgAmmoStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
+ NSString *imgDamageStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
+ NSString *imgTimeStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
+ NSString *imgBoxStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
- delay = [[UIButton alloc] init];
- imgStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
- [delay setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
- [delay addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
+ initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]];
+ probabImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]];
+ delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]];
+ crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]];
+
+ initialLab = [[UILabel alloc] init];
+ initialLab.backgroundColor = [UIColor clearColor];
+ initialLab.textColor = [UIColor grayColor];
+ initialLab.textAlignment = UITextAlignmentCenter;
+
+ probLab = [[UILabel alloc] init];
+ probLab.backgroundColor = [UIColor clearColor];
+ probLab.textColor = [UIColor grayColor];
+ probLab.textAlignment = UITextAlignmentCenter;
+
+ delLab = [[UILabel alloc] init];
+ delLab.backgroundColor = [UIColor clearColor];
+ delLab.textColor = [UIColor grayColor];
+ delLab.textAlignment = UITextAlignmentCenter;
+
+ craLab = [[UILabel alloc] init];
+ craLab.backgroundColor = [UIColor clearColor];
+ craLab.textColor = [UIColor grayColor];
+ craLab.textAlignment = UITextAlignmentCenter;
+
+ [self.contentView addSubview:weaponName]; [weaponName release];
+ [self.contentView addSubview:weaponIcon]; [weaponIcon release];
+
+ [self.contentView addSubview:initialQt]; [initialQt release];
+ [self.contentView addSubview:probabilityQt]; [probabilityQt release];
+ [self.contentView addSubview:delayQt]; [delayQt release];
+ [self.contentView addSubview:crateQt]; [crateQt release];
+
+ [self.contentView addSubview:initialImg]; [initialImg release];
+ [self.contentView addSubview:probabImg]; [probabImg release];
+ [self.contentView addSubview:delayImg]; [delayImg release];
+ [self.contentView addSubview:crateImg]; [crateImg release];
- crateQt = [[UIButton alloc] init];
- imgStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
- [crateQt setBackgroundImage:[UIImage imageWithContentsOfFile:imgStr] forState:UIControlStateNormal];
- [crateQt addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
-
- [self.contentView addSubview:weaponName];
- [self.contentView addSubview:weaponIcon];
- [self.contentView addSubview:initialQt];
- [self.contentView addSubview:probability];
- [self.contentView addSubview:delay];
- [self.contentView addSubview:crateQt];
+ [self.contentView addSubview:initialLab]; [initialLab release];
+ [self.contentView addSubview:probLab]; [probLab release];
+ [self.contentView addSubview:delLab]; [delLab release];
+ [self.contentView addSubview:craLab]; [craLab release];
}
return self;
}
@@ -58,26 +98,36 @@
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
- CGRect frame;
- frame = CGRectMake(boundsX+5, 5, 32, 32);
- weaponIcon.frame = frame;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
+ boundsX += 65;
+ else
+ boundsX -= 9;
- frame = CGRectMake(boundsX+45, 8, 200, 25);
- weaponName.frame = frame;
+ weaponIcon.frame = CGRectMake(5, 5, 32, 32);
+ weaponName.frame = CGRectMake(45, 8, 200, 25);
// second line
- frame = CGRectMake(boundsX+20, 40, 32, 32);
- initialQt.frame = frame;
+ initialImg.frame = CGRectMake(boundsX+20, 40, 32, 32);
+ initialLab.frame = CGRectMake(boundsX+56, 40, 20, 32);
+ initialLab.text = ((int)initialQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialQt.value];
+ initialQt.frame = CGRectMake(boundsX+80, 40, 150, 32);
- frame = CGRectMake(boundsX+60, 40, 32, 32);
- probability.frame = frame;
+ probabImg.frame = CGRectMake(boundsX+255, 40, 32, 32);
+ probLab.frame = CGRectMake(boundsX+291, 40, 20, 32);
+ probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value];
+ probabilityQt.frame = CGRectMake(boundsX+314, 40, 150, 32);
- frame = CGRectMake(boundsX+100, 40, 32, 32);
- delay.frame = frame;
+ // third line
+ delayImg.frame = CGRectMake(boundsX+20, 80, 32, 32);
+ delLab.frame = CGRectMake(boundsX+56, 80, 20, 32);
+ delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value];
+ delayQt.frame = CGRectMake(boundsX+80, 80, 150, 32);
- frame = CGRectMake(boundsX+140, 40, 32, 32);
- crateQt.frame = frame;
+ crateImg.frame = CGRectMake(boundsX+255, 80, 32, 32);
+ craLab.frame = CGRectMake(boundsX+291, 80, 20, 32);
+ craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value];
+ crateQt.frame = CGRectMake(boundsX+314, 80, 150, 32);
}
/*
@@ -87,10 +137,15 @@
}
*/
--(void) buttonPressed:(id) sender {
+-(void) valueChanged:(id) sender {
if (self.delegate != nil) {
- [(UIButton *)sender setTag:self.tag];
- [delegate buttonPressed:sender];
+ initialLab.text = ((int)initialQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialQt.value];
+ probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value];
+ delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value];
+ craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value];
+
+ [(UISlider *)sender setTag:self.tag];
+ [delegate valueChanged:sender];
} else
DLog(@"error - delegate = nil!");
}
@@ -99,8 +154,8 @@
[weaponName release];
[weaponIcon release];
[initialQt release];
- [probability release];
- [delay release];
+ [probabilityQt release];
+ [delayQt release];
[crateQt release];
[super dealloc];
}