ios, one more grenade timer tweak
authorkoda
Mon, 26 Mar 2012 03:58:03 +0200
changeset 6825 aca4a6807ecc
parent 6824 617a861b7750
child 6826 8fadeefdd352
ios, one more grenade timer tweak
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/PascalImports.h
--- a/hedgewars/PascalExports.pas	Mon Mar 26 03:57:14 2012 +0200
+++ b/hedgewars/PascalExports.pas	Mon Mar 26 03:58:03 2012 +0200
@@ -270,6 +270,18 @@
     ParseCommand('/timer ' + inttostr(time), true);
 end;
 
+function HW_getGrenadeTime: LongInt; cdecl; export;
+var CurWeapon: PAmmo;
+    res: LongInt = 3;
+begin
+    if HW_isWeaponTimerable then
+    begin
+        CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
+        res:= CurWeapon^.Timer div 1000;
+    end;
+    exit(res);
+end;
+
 procedure HW_setPianoSound(snd: LongInt); cdecl; export;
 begin
     // this most likely won't work in network game
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Mon Mar 26 03:57:14 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Mon Mar 26 03:58:03 2012 +0200
@@ -45,7 +45,6 @@
     UIActivityIndicatorView *loadingIndicator;
     UIButton *confirmButton;
     UISegmentedControl *grenadeTimeSegment;
-    NSInteger cachedGrenadeTime;
 }
 
 @property (nonatomic,retain) id popoverController;
@@ -54,7 +53,6 @@
 @property (nonatomic,retain) UIActivityIndicatorView *loadingIndicator;
 @property (nonatomic,retain) UIButton *confirmButton;
 @property (nonatomic,retain) UISegmentedControl *grenadeTimeSegment;
-@property (assign) NSInteger cachedGrenadeTime;
 
 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Mon Mar 26 03:57:14 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Mon Mar 26 03:58:03 2012 +0200
@@ -32,7 +32,7 @@
 
 
 @implementation OverlayViewController
-@synthesize popoverController, popupMenu, helpPage, loadingIndicator, confirmButton, grenadeTimeSegment, cachedGrenadeTime;
+@synthesize popoverController, popupMenu, helpPage, loadingIndicator, confirmButton, grenadeTimeSegment;
 
 #pragma mark -
 #pragma mark rotation
@@ -259,11 +259,9 @@
 
 -(void) setGrenadeTime:(id) sender {
     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
-    NSInteger timeIndex = theSegment.selectedSegmentIndex;
-    if (self.cachedGrenadeTime != timeIndex) {
-        HW_setGrenadeTime(timeIndex + 1);
-        self.cachedGrenadeTime = timeIndex;
-    }
+    NSInteger timeIndex = theSegment.selectedSegmentIndex + 1;
+    if (HW_getGrenadeTime() != timeIndex)
+        HW_setGrenadeTime(timeIndex);
 }
 
 #pragma mark -
@@ -438,7 +436,7 @@
                                 [grenadeSegment release];
                             }
                             self.grenadeTimeSegment.frame = CGRectMake(screen.size.width / 2 - 125, screen.size.height, 250, 50);
-                            self.grenadeTimeSegment.selectedSegmentIndex = self.cachedGrenadeTime;
+                            self.grenadeTimeSegment.selectedSegmentIndex = HW_getGrenadeTime() - 1;
                             self.grenadeTimeSegment.alpha = 1;
                             self.grenadeTimeSegment.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
                                                                        UIViewAutoresizingFlexibleRightMargin |
--- a/project_files/HedgewarsMobile/Classes/PascalImports.h	Mon Mar 26 03:57:14 2012 +0200
+++ b/project_files/HedgewarsMobile/Classes/PascalImports.h	Mon Mar 26 03:58:03 2012 +0200
@@ -83,8 +83,9 @@
     BOOL HW_isWeaponRope(void);
 
     void HW_setGrenadeTime(int time);
+    int  HW_getGrenadeTime(void);
+
     void HW_setPianoSound(int snd);
-    
     void HW_setWeapon(int whichone);
     BOOL HW_isWeaponAnEffect(int whichone);
     char *HW_getWeaponNameByIndex(int whichone);