875 inc(i, lw) |
875 inc(i, lw) |
876 end |
876 end |
877 end |
877 end |
878 end; |
878 end; |
879 |
879 |
880 // Force the lower camera boundary to never be lower than a few pixels below the water line |
880 // Force camera to stay within a certain area |
881 function LowerCameraBound: LongInt; |
881 procedure CameraBounds; |
882 begin |
882 var lowBound: LongInt; |
883 LowerCameraBound:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - (cVisibleWater + trunc(CinematicBarH / (cScaleFactor / 2.0))); |
883 begin |
884 if WorldDy < LowerCameraBound then |
884 if (not hasBorder) then |
885 WorldDy:= LowerCameraBound; |
885 begin |
|
886 if WorldDy > (-(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - TopY + cCamLimitY) then |
|
887 WorldDy:= (-trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - TopY + cCamLimitY); |
|
888 if (RightX - LeftX + cCamLimitX * 2) div 2 < cScreenWidth / cScaleFactor then |
|
889 WorldDx:= -((LeftX + RightX) div 2) |
|
890 else |
|
891 begin |
|
892 if WorldDx < -LAND_WIDTH - cCamLimitX + (cScreenWidth / cScaleFactor) then |
|
893 WorldDx:= -LAND_WIDTH - cCamLimitX + trunc(cScreenWidth / cScaleFactor); |
|
894 if WorldDx > cCamLimitX - (cScreenWidth / cScaleFactor) then |
|
895 WorldDx:= cCamLimitX - trunc(cScreenWidth / cScaleFactor); |
|
896 end; |
|
897 end |
|
898 else |
|
899 begin |
|
900 if WorldDy > (-(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - TopY + cCamLimitBorderY) then |
|
901 WorldDy:= (-trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - TopY + cCamLimitBorderY); |
|
902 if (RightX - LeftX + cCamLimitBorderX * 2) div 2 < cScreenWidth / cScaleFactor then |
|
903 WorldDx:= -((LeftX + RightX) div 2) |
|
904 else |
|
905 begin |
|
906 if WorldDx > -LeftX + cCamLimitBorderX - (cScreenWidth / cScaleFactor) then |
|
907 WorldDx:= -LeftX + cCamLimitBorderX - trunc(cScreenWidth / cScaleFactor); |
|
908 if WorldDx < -RightX - cCamLimitBorderX + (cScreenWidth / cScaleFactor) then |
|
909 WorldDx:= -RightX - cCamLimitBorderX + trunc(cScreenWidth / cScaleFactor); |
|
910 end; |
|
911 end; |
|
912 |
|
913 lowBound:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - (cVisibleWater + trunc(CinematicBarH / (cScaleFactor / 2.0))); |
|
914 if WorldDy < lowBound then |
|
915 WorldDy:= lowBound; |
886 end; |
916 end; |
887 |
917 |
888 procedure DrawWorld(Lag: LongInt); |
918 procedure DrawWorld(Lag: LongInt); |
889 begin |
919 begin |
890 if ZoomValue < zoom then |
920 if ZoomValue < zoom then |
1900 end; |
1930 end; |
1901 |
1931 |
1902 var PrevSentPointTime: LongWord = 0; |
1932 var PrevSentPointTime: LongWord = 0; |
1903 |
1933 |
1904 procedure MoveCamera; |
1934 procedure MoveCamera; |
1905 var EdgesDist, wdy, shs,z, dstX: LongInt; |
1935 var EdgesDist, shs,z, dstX: LongInt; |
1906 inbtwnTrgtAttks: Boolean; |
1936 inbtwnTrgtAttks: Boolean; |
1907 begin |
1937 begin |
1908 {$IFNDEF MOBILE} |
1938 {$IFNDEF MOBILE} |
1909 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then |
1939 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then |
1910 uCursor.updatePosition(); |
1940 uCursor.updatePosition(); |
1948 WorldDx:= WorldDx - rightX + leftX |
1978 WorldDx:= WorldDx - rightX + leftX |
1949 else if -WorldDx > rightX then |
1979 else if -WorldDx > rightX then |
1950 WorldDx:= WorldDx + rightX - leftX; |
1980 WorldDx:= WorldDx + rightX - leftX; |
1951 end; |
1981 end; |
1952 |
1982 |
1953 wdy:= LowerCameraBound; |
|
1954 |
|
1955 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then |
1983 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then |
|
1984 begin |
|
1985 CameraBounds; |
1956 exit; |
1986 exit; |
|
1987 end; |
1957 |
1988 |
1958 if (AMState = AMShowingUp) or (AMState = AMShowing) then |
1989 if (AMState = AMShowingUp) or (AMState = AMShowing) then |
1959 begin |
1990 begin |
1960 if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left |
1991 if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left |
1961 CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3; |
1992 CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3; |
1964 if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top |
1995 if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top |
1965 CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1; |
1996 CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1; |
1966 if CursorPoint.Y < cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5) then//check bottom |
1997 if CursorPoint.Y < cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5) then//check bottom |
1967 CursorPoint.Y:= cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5); |
1998 CursorPoint.Y:= cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5); |
1968 prevPoint:= CursorPoint; |
1999 prevPoint:= CursorPoint; |
|
2000 CameraBounds; |
1969 exit |
2001 exit |
1970 end; |
2002 end; |
1971 |
2003 |
1972 if isCursorVisible then |
2004 if isCursorVisible then |
1973 begin |
2005 begin |
2019 CursorPoint.Y:= cScreenHeight div 2; |
2051 CursorPoint.Y:= cScreenHeight div 2; |
2020 end; |
2052 end; |
2021 |
2053 |
2022 // this moves the camera according to CursorPoint X and Y |
2054 // this moves the camera according to CursorPoint X and Y |
2023 prevPoint:= CursorPoint; |
2055 prevPoint:= CursorPoint; |
2024 if WorldDy > LAND_HEIGHT + 1024 then |
2056 |
2025 WorldDy:= LAND_HEIGHT + 1024; |
2057 // enforce camera bounds |
2026 if WorldDy < wdy then |
2058 CameraBounds(); |
2027 WorldDy:= wdy; |
2059 |
2028 if WorldDx < - LAND_WIDTH - 1024 then |
|
2029 WorldDx:= - LAND_WIDTH - 1024; |
|
2030 if WorldDx > 1024 then |
|
2031 WorldDx:= 1024; |
|
2032 end; |
2060 end; |
2033 |
2061 |
2034 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); |
2062 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); |
2035 begin |
2063 begin |
2036 ShowMission(caption, subcaption, text, icon, time, false); |
2064 ShowMission(caption, subcaption, text, icon, time, false); |