Fix camera zooming out too far in pause mode (bug 773)
authorWuzzy <Wuzzy2@mail.ru>
Fri, 05 Jun 2020 01:30:03 +0200
changeset 15593 f0ac916a0608
parent 15592 46b7b2c821d0
child 15594 fdca2af677a9
Fix camera zooming out too far in pause mode (bug #773)
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Fri Jun 05 00:57:05 2020 +0200
+++ b/hedgewars/uWorld.pas	Fri Jun 05 01:30:03 2020 +0200
@@ -877,6 +877,13 @@
     end
 end;
 
+// Force the lower camera boundary to never be lower than a few pixels below the water line
+function LowerCameraBound: LongInt;
+begin
+LowerCameraBound:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - (cVisibleWater + trunc(CinematicBarH / (cScaleFactor / 2.0)));
+if WorldDy < LowerCameraBound then
+    WorldDy:= LowerCameraBound;
+end;
 
 procedure DrawWorld(Lag: LongInt);
 begin
@@ -897,7 +904,9 @@
         ZoomValue:= zoom;
 
     if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then
-        MoveCamera;
+        MoveCamera
+    else if (isPaused) then
+        LowerCameraBound;
 
     if cStereoMode = smNone then
         begin
@@ -1941,9 +1950,7 @@
             WorldDx:= WorldDx + rightX - leftX;
     end;
 
-wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - (cVisibleWater + trunc(CinematicBarH / (cScaleFactor / 2.0)));
-if WorldDy < wdy then
-    WorldDy:= wdy;
+wdy:= LowerCameraBound;
 
 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then
     exit;