finished ammo configuration (which is the last page missing in config \o/)
authorkoda
Thu, 15 Jul 2010 04:31:25 +0200
changeset 3644 42c5684289ae
parent 3643 858b20bafb6e
child 3645 c0b3f1bb9316
child 3646 a3271158d93b
finished ammo configuration (which is the last page missing in config \o/)
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/SingleWeaponViewController.m	Thu Jul 15 03:28:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Thu Jul 15 04:31:25 2010 +0200
@@ -74,10 +74,10 @@
     self.ammoNames = array;
     [array release];
 
-    quantity = (char *)malloc(sizeof(char)*CURRENT_AMMOSIZE);
-    probability = (char *)malloc(sizeof(char)*CURRENT_AMMOSIZE);
-    delay = (char *)malloc(sizeof(char)*CURRENT_AMMOSIZE);
-    crateness = (char *)malloc(sizeof(char)*CURRENT_AMMOSIZE);
+    quantity = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
+    probability = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
+    delay = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
+    crateness = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
     
     NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()];
     UIImage *img = [[UIImage alloc] initWithContentsOfFile:str];
@@ -122,6 +122,11 @@
 -(void) viewWillDisappear:(BOOL) animated {
     [super viewWillDisappear:animated];
     
+    quantity[CURRENT_AMMOSIZE] = '\0';
+    probability[CURRENT_AMMOSIZE] = '\0';
+    delay[CURRENT_AMMOSIZE] = '\0';
+    crateness[CURRENT_AMMOSIZE] = '\0';
+    
     NSString *quantityStr = [NSString stringWithUTF8String:quantity];
     NSString *probabilityStr = [NSString stringWithUTF8String:probability];
     NSString *delayStr = [NSString stringWithUTF8String:delay];
@@ -172,7 +177,7 @@
     [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.crateQt setValue:[[NSString stringWithFormat:@"%c", crateness[row]] intValue] animated:NO];
     
     cell.selectionStyle = UITableViewCellSelectionStyleNone;
     return cell;
@@ -194,9 +199,11 @@
 
 #pragma mark -
 #pragma mark WeaponButtonControllerDelegate
--(void) valueChanged:(id) sender {
-   // UIButton *button = (UIButton *)sender;
-   // DLog(@"%@ %d", button.titleLabel.text, button.tag);
+-(void) updateValues:(NSArray *)withArray atIndex:(NSInteger) index {
+    quantity[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:0] intValue]] characterAtIndex:0];
+    probability[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:1] intValue]] characterAtIndex:0];
+    delay[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:2] intValue]] characterAtIndex:0];
+    crateness[index] = [[NSString stringWithFormat:@"%d",[[withArray objectAtIndex:3] intValue]] characterAtIndex:0];
 }
 
 #pragma mark -
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Thu Jul 15 03:28:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.h	Thu Jul 15 04:31:25 2010 +0200
@@ -10,7 +10,7 @@
 
 @protocol WeaponButtonControllerDelegate <NSObject>
 
--(void) valueChanged:(id) sender;
+-(void) updateValues:(NSArray *)withArray atIndex:(NSInteger) index;
 
 @end
 
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m	Thu Jul 15 03:28:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m	Thu Jul 15 04:31:25 2010 +0200
@@ -144,8 +144,12 @@
         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];
+        [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] 
+                       atIndex:self.tag];
     } else
         DLog(@"error - delegate = nil!");
 }
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 15 03:28:29 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 15 04:31:25 2010 +0200
@@ -121,7 +121,6 @@
 		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 */; };
@@ -382,7 +381,6 @@
 		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; };
@@ -634,7 +632,6 @@
 				616591FF11CA9BA200D6E256 /* SingleSchemeViewController.m */,
 				61F904D511DF7DA30068B24D /* WeaponCellView.h */,
 				61F904D611DF7DA30068B24D /* WeaponCellView.m */,
-				61B3B77511EE8C500094F77E /* WeaponCellView.xib */,
 			);
 			name = "Second Level";
 			sourceTree = "<group>";
@@ -1059,7 +1056,6 @@
 				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;
 		};