add a little explanation when modifying weaponset in ifrontend
authorkoda
Wed, 25 Aug 2010 01:30:25 +0200
changeset 3766 36b625111609
parent 3765 ebfe7c9b3085
child 3767 2416a3f51c77
add a little explanation when modifying weaponset in ifrontend
project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
project_files/HedgewarsMobile/Classes/WeaponCellView.h
project_files/HedgewarsMobile/Classes/WeaponCellView.m
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Wed Aug 25 00:17:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Wed Aug 25 01:30:25 2010 +0200
@@ -199,10 +199,10 @@
         customCell.weaponName.text = [ammoNames objectAtIndex:row];
         customCell.tag = row;
 
-        [customCell.initialQt setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
-        [customCell.probabilityQt setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO];
-        [customCell.delayQt setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO];
-        [customCell.crateQt setValue:[[NSString stringWithFormat:@"%c", crateness[row]] intValue] animated:NO];
+        [customCell.initialSli setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
+        [customCell.probabilitySli setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO];
+        [customCell.delaySli setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO];
+        [customCell.crateSli setValue:[[NSString stringWithFormat:@"%c", crateness[row]] intValue] animated:NO];
         cell = customCell;
     }
 
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Wed Aug 25 00:17:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Wed Aug 25 01:30:25 2010 +0200
@@ -19,21 +19,23 @@
     UILabel *weaponName;
     UIImageView *weaponIcon;
 
-    UISlider *initialQt;
-    UISlider *probabilityQt;
-    UISlider *delayQt;
-    UISlider *crateQt;
+    UISlider *initialSli;
+    UISlider *probabilitySli;
+    UISlider *delaySli;
+    UISlider *crateSli;
 
 @private
     UIImageView *initialImg;
-    UIImageView *probabImg;
+    UIImageView *probabilityImg;
     UIImageView *delayImg;
     UIImageView *crateImg;
 
     UILabel *initialLab;
-    UILabel *probLab;
-    UILabel *delLab;
-    UILabel *craLab;
+    UILabel *probabilityLab;
+    UILabel *delayLab;
+    UILabel *crateLab;
+
+    UILabel *helpLabel;
 }
 
 @property (nonatomic,assign) id<WeaponButtonControllerDelegate> delegate;
@@ -41,19 +43,21 @@
 @property (nonatomic,retain) UILabel *weaponName;
 @property (nonatomic,retain) UIImageView *weaponIcon;
 
-@property (nonatomic,retain) UISlider *initialQt;
-@property (nonatomic,retain) UISlider *probabilityQt;
-@property (nonatomic,retain) UISlider *delayQt;
-@property (nonatomic,retain) UISlider *crateQt;
+@property (nonatomic,retain) UISlider *initialSli;
+@property (nonatomic,retain) UISlider *probabilitySli;
+@property (nonatomic,retain) UISlider *delaySli;
+@property (nonatomic,retain) UISlider *crateSli;
 
 @property (nonatomic,retain) UIImageView *initialImg;
-@property (nonatomic,retain) UIImageView *probabImg;
+@property (nonatomic,retain) UIImageView *probabilityImg;
 @property (nonatomic,retain) UIImageView *delayImg;
 @property (nonatomic,retain) UIImageView *crateImg;
 
 @property (nonatomic,retain) UILabel *initialLab;
-@property (nonatomic,retain) UILabel *probLab;
-@property (nonatomic,retain) UILabel *delLab;
-@property (nonatomic,retain) UILabel *craLab;
+@property (nonatomic,retain) UILabel *probabilityLab;
+@property (nonatomic,retain) UILabel *delayLab;
+@property (nonatomic,retain) UILabel *crateLab;
+
+@property (nonatomic,retain) UILabel *helpLabel;
 
 @end
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m	Wed Aug 25 00:17:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m	Wed Aug 25 01:30:25 2010 +0200
@@ -10,8 +10,8 @@
 #import "CommodityFunctions.h"
 
 @implementation WeaponCellView
-@synthesize delegate, weaponName, weaponIcon, initialQt, probabilityQt, delayQt, crateQt,
-            initialImg, probabImg, delayImg, crateImg, initialLab, probLab, delLab, craLab;
+@synthesize delegate, weaponName, weaponIcon, initialSli, probabilitySli, delaySli, crateSli, helpLabel,
+            initialImg, probabilityImg, delayImg, crateImg, initialLab, probabilityLab, delayLab, crateLab;
 
 -(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
@@ -22,25 +22,37 @@
         weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
         weaponIcon = [[UIImageView alloc] init];
 
-        initialQt = [[UISlider alloc] init];
-        [initialQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-        initialQt.maximumValue = 9;
-        initialQt.minimumValue = 0;
+        initialSli = [[UISlider alloc] init];
+        [initialSli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+        [initialSli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
+        [initialSli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
+        initialSli.maximumValue = 9;
+        initialSli.minimumValue = 0;
+        initialSli.tag = 100;
 
-        probabilityQt = [[UISlider alloc] init];
-        [probabilityQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-        probabilityQt.maximumValue = 9;
-        probabilityQt.minimumValue = 0;
+        probabilitySli = [[UISlider alloc] init];
+        [probabilitySli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+        [probabilitySli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
+        [probabilitySli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
+        probabilitySli.maximumValue = 9;
+        probabilitySli.minimumValue = 0;
+        probabilitySli.tag = 200;
 
-        delayQt = [[UISlider alloc] init];
-        [delayQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-        delayQt.maximumValue = 9;
-        delayQt.minimumValue = 0;
+        delaySli = [[UISlider alloc] init];
+        [delaySli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+        [delaySli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
+        [delaySli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
+        delaySli.maximumValue = 9;
+        delaySli.minimumValue = 0;
+        delaySli.tag = 300;
 
-        crateQt = [[UISlider alloc] init];
-        [crateQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-        crateQt.maximumValue = 9;
-        crateQt.minimumValue = 0;
+        crateSli = [[UISlider alloc] init];
+        [crateSli addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
+        [crateSli addTarget:self action:@selector(startDragging:) forControlEvents:UIControlEventTouchDown];
+        [crateSli addTarget:self action:@selector(stopDragging:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
+        crateSli.maximumValue = 9;
+        crateSli.minimumValue = 0;
+        crateSli.tag = 400;
 
         NSString *imgAmmoStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
         NSString *imgDamageStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
@@ -48,7 +60,7 @@
         NSString *imgBoxStr = [NSString stringWithFormat:@"%@/iconBox.png",BTN_DIRECTORY()];
 
         initialImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgAmmoStr]];
-        probabImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]];
+        probabilityImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]];
         delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]];
         crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]];
 
@@ -57,38 +69,46 @@
         initialLab.textColor = [UIColor grayColor];
         initialLab.textAlignment = UITextAlignmentCenter;
 
-        probLab = [[UILabel alloc] init];
-        probLab.backgroundColor = [UIColor clearColor];
-        probLab.textColor = [UIColor grayColor];
-        probLab.textAlignment = UITextAlignmentCenter;
+        probabilityLab = [[UILabel alloc] init];
+        probabilityLab.backgroundColor = [UIColor clearColor];
+        probabilityLab.textColor = [UIColor grayColor];
+        probabilityLab.textAlignment = UITextAlignmentCenter;
 
-        delLab = [[UILabel alloc] init];
-        delLab.backgroundColor = [UIColor clearColor];
-        delLab.textColor = [UIColor grayColor];
-        delLab.textAlignment = UITextAlignmentCenter;
+        delayLab = [[UILabel alloc] init];
+        delayLab.backgroundColor = [UIColor clearColor];
+        delayLab.textColor = [UIColor grayColor];
+        delayLab.textAlignment = UITextAlignmentCenter;
 
-        craLab = [[UILabel alloc] init];
-        craLab.backgroundColor = [UIColor clearColor];
-        craLab.textColor = [UIColor grayColor];
-        craLab.textAlignment = UITextAlignmentCenter;
+        crateLab = [[UILabel alloc] init];
+        crateLab.backgroundColor = [UIColor clearColor];
+        crateLab.textColor = [UIColor grayColor];
+        crateLab.textAlignment = UITextAlignmentCenter;
 
-        [self.contentView addSubview:weaponName]; // [weaponName release];
-        [self.contentView addSubview:weaponIcon]; // [weaponIcon release];
+        helpLabel = [[UILabel alloc] init];
+        helpLabel.backgroundColor = [UIColor clearColor];
+        helpLabel.textColor = [UIColor grayColor];
+        helpLabel.textAlignment = UITextAlignmentRight;
+        helpLabel.font = [UIFont italicSystemFontOfSize:[UIFont smallSystemFontSize]];
 
-        [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:weaponName];
+        [self.contentView addSubview:weaponIcon];
 
-        [self.contentView addSubview:initialImg]; // [initialImg release];
-        [self.contentView addSubview:probabImg];  // [probabImg release];
-        [self.contentView addSubview:delayImg];   // [delayImg release];
-        [self.contentView addSubview:crateImg];   // [crateImg release];
+        [self.contentView addSubview:initialSli];
+        [self.contentView addSubview:probabilitySli];
+        [self.contentView addSubview:delaySli];
+        [self.contentView addSubview:crateSli];
 
-        [self.contentView addSubview:initialLab]; // [initialLab release];
-        [self.contentView addSubview:probLab];    // [probLab release];
-        [self.contentView addSubview:delLab];     // [delLab release];
-        [self.contentView addSubview:craLab];     // [craLab release];
+        [self.contentView addSubview:initialImg];
+        [self.contentView addSubview:probabilityImg];
+        [self.contentView addSubview:delayImg];
+        [self.contentView addSubview:crateImg];
+
+        [self.contentView addSubview:initialLab];
+        [self.contentView addSubview:probabilityLab];
+        [self.contentView addSubview:delayLab];
+        [self.contentView addSubview:crateLab];
+
+        [self.contentView addSubview:helpLabel];
     }
     return self;
 }
@@ -97,37 +117,41 @@
     [super layoutSubviews];
 
     CGRect contentRect = self.contentView.bounds;
-    CGFloat boundsX = contentRect.origin.x;
+    CGFloat shiftSliders = contentRect.origin.x;
+    CGFloat shiftLabel = 0;
 
-    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-        boundsX += 65;
-    else
-        boundsX -= 9;
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+        shiftSliders += 65;
+        shiftLabel += 165;
+    } else
+        shiftSliders -= 13;
 
     weaponIcon.frame = CGRectMake(5, 5, 32, 32);
     weaponName.frame = CGRectMake(45, 8, 200, 25);
+    
+    helpLabel.frame = CGRectMake(shiftLabel + 200, 8, 250, 15);
 
     // second line
-    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);
+    initialImg.frame = CGRectMake(shiftSliders + 20, 40, 32, 32);
+    initialLab.frame = CGRectMake(shiftSliders + 56, 40, 20, 32);
+    initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
+    initialSli.frame = CGRectMake(shiftSliders + 80, 40, 150, 32);
 
-    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);
+    probabilityImg.frame = CGRectMake(shiftSliders + 255, 40, 32, 32);
+    probabilityLab.frame = CGRectMake(shiftSliders + 291, 40, 20, 32);
+    probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
+    probabilitySli.frame = CGRectMake(shiftSliders + 314, 40, 150, 32);
 
     // 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);
+    delayImg.frame = CGRectMake(shiftSliders + 20, 80, 32, 32);
+    delayLab.frame = CGRectMake(shiftSliders + 56, 80, 20, 32);
+    delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
+    delaySli.frame = CGRectMake(shiftSliders + 80, 80, 150, 32);
 
-    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);
+    crateImg.frame = CGRectMake(shiftSliders + 255, 80, 32, 32);
+    crateLab.frame = CGRectMake(shiftSliders + 291, 80, 20, 32);
+    crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
+    crateSli.frame = CGRectMake(shiftSliders + 314, 80, 150, 32);
 }
 
 /*
@@ -139,37 +163,65 @@
 
 -(void) valueChanged:(id) sender {
     if (self.delegate != nil) {
-        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];
+        initialLab.text = ((int)initialSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialSli.value];
+        probabilityLab.text = ((int)probabilitySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilitySli.value];
+        delayLab.text = ((int)delaySli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delaySli.value];
+        crateLab.text = ((int)crateSli.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateSli.value];
 
         [delegate updateValues:[NSArray arrayWithObjects:
-                                [NSNumber numberWithInt:(int)initialQt.value],
-                                [NSNumber numberWithInt:(int)probabilityQt.value],
-                                [NSNumber numberWithInt:(int)delayQt.value],
-                                [NSNumber numberWithInt:(int)crateQt.value], nil]
+                                [NSNumber numberWithInt:(int)initialSli.value],
+                                [NSNumber numberWithInt:(int)probabilitySli.value],
+                                [NSNumber numberWithInt:(int)delaySli.value],
+                                [NSNumber numberWithInt:(int)crateSli.value], nil]
                        atIndex:self.tag];
     } else
         DLog(@"error - delegate = nil!");
 }
 
+-(void) startDragging:(id) sender {
+    UISlider *slider = (UISlider *)sender;
+    NSString *str = nil;
+    
+    switch (slider.tag) {
+        case 100:
+            str = NSLocalizedString(@"Initial quantity ",@"ammo selection");
+            break;
+        case 200:
+            str = NSLocalizedString(@"Presence probability in crates ",@"ammo selection");
+            break;
+        case 300:
+            str = NSLocalizedString(@"Number of turns before you can use it ",@"ammo selection");
+            break;
+        case 400:
+            str = NSLocalizedString(@"Quantity that you will find in a crate ",@"ammo selection");
+            break;
+        default:
+            DLog(@"Nope");
+            break;
+    }
+    self.helpLabel.text = str;
+}
+
+-(void) stopDragging:(id) sender {
+    self.helpLabel.text =@"";
+}
+
 -(void) dealloc {
     self.delegate = nil;
     releaseAndNil(weaponName);
     releaseAndNil(weaponIcon);
-    releaseAndNil(initialQt);
-    releaseAndNil(probabilityQt);
-    releaseAndNil(delayQt);
-    releaseAndNil(crateQt);
+    releaseAndNil(initialSli);
+    releaseAndNil(probabilitySli);
+    releaseAndNil(delaySli);
+    releaseAndNil(crateSli);
     releaseAndNil(initialImg);
-    releaseAndNil(probabImg);
+    releaseAndNil(probabilityImg);
     releaseAndNil(delayImg);
     releaseAndNil(crateImg);
     releaseAndNil(initialLab);
-    releaseAndNil(probLab);
-    releaseAndNil(delLab);
-    releaseAndNil(craLab);
+    releaseAndNil(probabilityLab);
+    releaseAndNil(delayLab);
+    releaseAndNil(crateLab);
     [super dealloc];
 }