Ability to turn camera following gears off
authorunc0rr
Tue, 21 Jun 2011 16:43:05 +0400
changeset 5247 bf6d4bc531d2
parent 5244 1b408b965c01
child 5294 67278f1cba2c
Ability to turn camera following gears off
hedgewars/uCommandHandlers.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uCommandHandlers.pas	Tue Jun 21 16:42:04 2011 +0400
+++ b/hedgewars/uCommandHandlers.pas	Tue Jun 21 16:43:05 2011 +0400
@@ -26,7 +26,7 @@
 procedure freeModule;
 
 implementation
-uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom;
+uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions;
 
 procedure chGenCmd(var s: shortstring);
 begin
@@ -331,7 +331,7 @@
         FollowGear:= CurrentHedgehog^.Gear;
         if not CurrentTeam^.ExtDriven then SendIPC('A');
         Message:= Message or (gmAttack and InputMask);
-	ScriptCall('onAttack');
+        ScriptCall('onAttack');
         end
     end
 end;
@@ -411,7 +411,7 @@
     begin
         Message:= Message or (gmWeapon and InputMask);
         MsgParam:= byte(s[1]);
-	ScriptCall('onSetWeapon');
+    ScriptCall('onSetWeapon');
     end;
 end;
 
@@ -510,8 +510,18 @@
 begin
 s:= s; // avoid compiler hint
 if CheckNoTeamOrHH or isPaused then exit;
-bShowFinger:= true;
-FollowGear:= CurrentHedgehog^.Gear
+
+if FollowGear <> nil then
+    begin
+    AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume);
+    autoCameraOn:= false
+    end
+    else begin
+    AddCaption('Auto Camera On', $CCCCCC, capgrpVolume);
+    bShowFinger:= true;
+    FollowGear:= CurrentHedgehog^.Gear;
+    autoCameraOn:= true
+    end
 end;
 
 procedure chPause(var s: shortstring);
--- a/hedgewars/uVariables.pas	Tue Jun 21 16:42:04 2011 +0400
+++ b/hedgewars/uVariables.pas	Tue Jun 21 16:43:05 2011 +0400
@@ -62,6 +62,7 @@
     isFirstFrame    : boolean;
 
     fastUntilLag    : boolean;
+    autoCameraOn    : boolean;
 
     GameState       : TGameState;
     GameType        : TGameType;
@@ -2356,6 +2357,7 @@
     fastUntilLag    := false;
     isFirstFrame    := true;
     isSEBackup      := true;
+    autoCameraOn    := true;
     cSeed           := '';
     cVolumeDelta    := 0;
     cHasFocus       := true;
--- a/hedgewars/uWorld.pas	Tue Jun 21 16:42:04 2011 +0400
+++ b/hedgewars/uWorld.pas	Tue Jun 21 16:43:05 2011 +0400
@@ -1165,7 +1165,7 @@
 {$ENDIF}
 
 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
-    if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
+    if (not autoCameraOn) or (abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4) then
     begin
         FollowGear:= nil;
         prevPoint:= CursorPoint;