reworked the ammunition configuration page (visually)
authorkoda
Thu, 15 Jul 2010 03:28:29 +0200
changeset 3643 858b20bafb6e
parent 3642 fb39fecca350
child 3644 42c5684289ae
reworked the ammunition configuration page (visually)
project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m
project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
project_files/HedgewarsMobile/Classes/WeaponCellView.h
project_files/HedgewarsMobile/Classes/WeaponCellView.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Thu Jul 15 01:18:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m	Thu Jul 15 03:28:29 2010 +0200
@@ -256,7 +256,12 @@
             if (cell == nil) {
                 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 
                                                reuseIdentifier:CellIdentifier1] autorelease];
-                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(260, 12, 150, 23)];
+                
+                int offset = 0;
+                if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
+                    offset = 45;
+                
+                UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)];
                 slider.maximumValue = [[detail objectForKey:@"max"] floatValue];
                 slider.minimumValue = [[detail objectForKey:@"min"] floatValue];
                 slider.tag = row+gmSize;
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Thu Jul 15 01:18:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Thu Jul 15 03:28:29 2010 +0200
@@ -84,7 +84,7 @@
     self.ammoStoreImage = img;
     [img release];
     
-    self.tableView.rowHeight = 75;
+    self.tableView.rowHeight = 120;
 }
 
 -(void) viewWillAppear:(BOOL) animated {
@@ -146,12 +146,10 @@
     return 1;
 }
 
-
 -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
     return CURRENT_AMMOSIZE;
 }
 
-
 // Customize the appearance of table view cells.
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     static NSString *CellIdentifier = @"Cell";
@@ -171,10 +169,12 @@
     cell.weaponName.text = [ammoNames objectAtIndex:row];
     cell.tag = row;
     
-    [cell.initialQt setTitle:[NSString stringWithFormat:@"%c",quantity[row]] forState:UIControlStateNormal];
-    cell.probability.titleLabel.text = [NSString stringWithFormat:@"%c",probability[row]];
-    cell.delay.titleLabel.text = [NSString stringWithFormat:@"%c",delay[row]];
-    cell.crateQt.titleLabel.text = [NSString stringWithFormat:@"%c",crateness[row]];
+    [cell.initialQt setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
+    [cell.probabilityQt setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO];
+    [cell.delayQt setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO];
+    [cell.crateQt setValue:[[NSString stringWithFormat:@"%c",crateness[row]] intValue] animated:NO];
+    
+    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     return cell;
 }
 
@@ -194,9 +194,9 @@
 
 #pragma mark -
 #pragma mark WeaponButtonControllerDelegate
--(void) buttonPressed:(id) sender {
-    UIButton *button = (UIButton *)sender;
-    DLog(@"%@ %d", button.titleLabel.text, button.tag);
+-(void) valueChanged:(id) sender {
+   // UIButton *button = (UIButton *)sender;
+   // DLog(@"%@ %d", button.titleLabel.text, button.tag);
 }
 
 #pragma mark -
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Thu Jul 15 01:18:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Thu Jul 15 03:28:29 2010 +0200
@@ -10,7 +10,7 @@
 
 @protocol WeaponButtonControllerDelegate <NSObject>
 
--(void) buttonPressed:(id) sender;
+-(void) valueChanged:(id) sender;
 
 @end
 
@@ -19,10 +19,21 @@
     UILabel *weaponName;
     UIImageView *weaponIcon;
     
-    UIButton *initialQt;
-    UIButton *probability;
-    UIButton *delay;
-    UIButton *crateQt;
+    UISlider *initialQt;
+    UISlider *probabilityQt;
+    UISlider *delayQt;
+    UISlider *crateQt;
+    
+@private
+    UIImageView *initialImg;
+    UIImageView *probabImg;
+    UIImageView *delayImg;
+    UIImageView *crateImg;
+    
+    UILabel *initialLab;
+    UILabel *probLab;
+    UILabel *delLab;
+    UILabel *craLab;
 }
 
 @property (nonatomic,assign) id<WeaponButtonControllerDelegate> delegate;
@@ -30,9 +41,19 @@
 @property (nonatomic,retain) UILabel *weaponName;
 @property (nonatomic,retain) UIImageView *weaponIcon;
     
-@property (nonatomic,retain) UIButton *initialQt;
-@property (nonatomic,retain) UIButton *probability;
-@property (nonatomic,retain) UIButton *delay;
-@property (nonatomic,retain) UIButton *crateQt;
+@property (nonatomic,retain) UISlider *initialQt;
+@property (nonatomic,retain) UISlider *probabilityQt;
+@property (nonatomic,retain) UISlider *delayQt;
+@property (nonatomic,retain) UISlider *crateQt;
+
+@property (nonatomic,retain) UIImageView *initialImg;
+@property (nonatomic,retain) UIImageView *probabImg;
+@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;
 
 @end
--- 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];
 }
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 15 01:18:51 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 15 03:28:29 2010 +0200
@@ -121,6 +121,7 @@
 		619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */ = {isa = PBXBuildFile; fileRef = 619C09E911E8B8D600F1DF16 /* title_small.png */; };
 		61A1188511683A8C00359010 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61A117FE1168322700359010 /* CoreGraphics.framework */; };
 		61A118D311683CD100359010 /* HedgewarsTitle.png in Resources */ = {isa = PBXBuildFile; fileRef = 611FD9CB1155A28C00C2203D /* HedgewarsTitle.png */; };
+		61B3B77611EE8C500094F77E /* WeaponCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 61B3B77511EE8C500094F77E /* WeaponCellView.xib */; };
 		61B3D71C11EA6F2700EC7420 /* uKeys.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987FE114AA34C00BA94A9 /* uKeys.pas */; };
 		61C3255B1179A384001E70B1 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3255A1179A384001E70B1 /* OpenAL.framework */; };
 		61C325901179A732001E70B1 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3255A1179A384001E70B1 /* OpenAL.framework */; };
@@ -381,6 +382,7 @@
 		618736B8118CA28600123B23 /* GearDrawing.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = GearDrawing.inc; path = ../../hedgewars/GearDrawing.inc; sourceTree = SOURCE_ROOT; };
 		619C09E911E8B8D600F1DF16 /* title_small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = title_small.png; path = "Resources/Frontend-iPhone/title_small.png"; sourceTree = "<group>"; };
 		61A117FE1168322700359010 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+		61B3B77511EE8C500094F77E /* WeaponCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = WeaponCellView.xib; path = Resources/WeaponCellView.xib; sourceTree = SOURCE_ROOT; };
 		61C3251D1179A300001E70B1 /* libopenalbridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libopenalbridge.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		61C3255A1179A384001E70B1 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
 		61E1F4F711D004240016A5AA /* adler32.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = adler32.pas; path = ../../hedgewars/adler32.pas; sourceTree = SOURCE_ROOT; };
@@ -632,6 +634,7 @@
 				616591FF11CA9BA200D6E256 /* SingleSchemeViewController.m */,
 				61F904D511DF7DA30068B24D /* WeaponCellView.h */,
 				61F904D611DF7DA30068B24D /* WeaponCellView.m */,
+				61B3B77511EE8C500094F77E /* WeaponCellView.xib */,
 			);
 			name = "Second Level";
 			sourceTree = "<group>";
@@ -1056,6 +1059,7 @@
 				6183D83E11E2BCE200A88903 /* LI-ipad-Landscape.png in Resources */,
 				6183D83F11E2BCE200A88903 /* LI-iphone-Landscape.png in Resources */,
 				619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */,
+				61B3B77611EE8C500094F77E /* WeaponCellView.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};