73 tmpSurface: PSDL_Surface; |
72 tmpSurface: PSDL_Surface; |
74 fpsTexture: PTexture; |
73 fpsTexture: PTexture; |
75 timeTexture: PTexture; |
74 timeTexture: PTexture; |
76 FPS: Longword; |
75 FPS: Longword; |
77 CountTicks: Longword; |
76 CountTicks: Longword; |
78 SoundTimerTicks: Longword; |
77 prevPoint, prevTargetPoint: TPoint; |
79 prevPoint: TPoint; |
|
80 amSel: TAmmoType = amNothing; |
78 amSel: TAmmoType = amNothing; |
81 missionTex: PTexture; |
79 missionTex: PTexture; |
82 missionTimer: LongInt; |
80 missionTimer: LongInt; |
83 stereoDepth: GLfloat; |
81 stereoDepth: GLfloat; |
84 isFirstFrame: boolean; |
82 isFirstFrame: boolean; |
85 AMAnimType: LongInt; |
83 AMAnimType: LongInt; |
86 recTexture: PTexture; |
84 recTexture: PTexture; |
|
85 AmmoMenuTex : PTexture; |
|
86 HorizontOffset: LongInt; |
|
87 cOffsetY: LongInt; |
87 |
88 |
88 const cStereo_Sky = 0.0500; |
89 const cStereo_Sky = 0.0500; |
89 cStereo_Horizon = 0.0250; |
90 cStereo_Horizon = 0.0250; |
90 cStereo_MidDistance = 0.0175; |
91 cStereo_MidDistance = 0.0175; |
91 cStereo_Water_distant = 0.0125; |
92 cStereo_Water_distant = 0.0125; |
92 cStereo_Land = 0.0075; |
93 cStereo_Land = 0.0075; |
93 cStereo_Water_near = 0.0025; |
94 cStereo_Water_near = 0.0025; |
94 cStereo_Outside = -0.0400; |
95 cStereo_Outside = -0.0400; |
|
96 |
|
97 AMAnimDuration = 200; |
|
98 AMHidden = 0;//AMState values |
|
99 AMShowingUp = 1; |
|
100 AMShowing = 2; |
|
101 AMHiding = 3; |
|
102 |
|
103 AMTypeMaskX = $00000001; |
|
104 AMTypeMaskY = $00000002; |
|
105 AMTypeMaskAlpha = $00000004; |
|
106 //AMTypeMaskSlide = $00000008; |
|
107 |
|
108 {$IFDEF MOBILE} |
|
109 AMSlotSize = 48; |
|
110 {$ELSE} |
|
111 AMSlotSize = 32; |
|
112 {$ENDIF} |
|
113 AMSlotPadding = (AMSlotSize - 32) shr 1; |
|
114 |
|
115 cSendCursorPosTime = 50; |
|
116 cCursorEdgesDist = 100; |
95 |
117 |
96 // helper functions to create the goal/game mode string |
118 // helper functions to create the goal/game mode string |
97 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; |
119 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; |
98 var t: ansistring; |
120 var t: ansistring; |
99 begin |
121 begin |
197 |
219 |
198 InitCameraBorders(); |
220 InitCameraBorders(); |
199 uCursor.init(); |
221 uCursor.init(); |
200 prevPoint.X:= 0; |
222 prevPoint.X:= 0; |
201 prevPoint.Y:= cScreenHeight div 2; |
223 prevPoint.Y:= cScreenHeight div 2; |
|
224 prevTargetPoint.X:= 0; |
|
225 prevTargetPoint.Y:= 0; |
202 WorldDx:= -(LAND_WIDTH div 2) + cScreenWidth div 2; |
226 WorldDx:= -(LAND_WIDTH div 2) + cScreenWidth div 2; |
203 WorldDy:= -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2); |
227 WorldDy:= -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2); |
204 |
228 |
205 //aligns it to the bottom of the screen, minus the border |
229 //aligns it to the bottom of the screen, minus the border |
206 SkyOffset:= 0; |
230 SkyOffset:= 0; |
616 else |
640 else |
617 begin |
641 begin |
618 AMShiftX:= AMShiftTargetX; |
642 AMShiftX:= AMShiftTargetX; |
619 AMShiftY:= AMShiftTargetY; |
643 AMShiftY:= AMShiftTargetY; |
620 prevPoint:= CursorPoint; |
644 prevPoint:= CursorPoint; |
|
645 prevTargetPoint:= TargetCursorPoint; |
621 AMState:= AMHidden; |
646 AMState:= AMHidden; |
622 end; |
647 end; |
623 end; |
648 end; |
624 |
649 |
625 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); |
650 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); |
959 if cStereoMode = smNone then |
984 if cStereoMode = smNone then |
960 begin |
985 begin |
961 glClear(GL_COLOR_BUFFER_BIT); |
986 glClear(GL_COLOR_BUFFER_BIT); |
962 DrawWorldStereo(Lag, rmDefault) |
987 DrawWorldStereo(Lag, rmDefault) |
963 end |
988 end |
964 {$IFNDEF S3D_DISABLED} |
989 {$IFDEF USE_S3D_RENDERING} |
965 else if (cStereoMode = smAFR) then |
|
966 begin |
|
967 AFRToggle:= not AFRToggle; |
|
968 glClear(GL_COLOR_BUFFER_BIT); |
|
969 if AFRToggle then |
|
970 DrawWorldStereo(Lag, rmLeftEye) |
|
971 else |
|
972 DrawWorldStereo(Lag, rmRightEye) |
|
973 end |
|
974 else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
990 else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
975 begin |
991 begin |
976 // create left fb |
992 // create left fb |
977 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); |
993 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); |
978 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
994 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
1495 SDL_FreeSurface(tmpSurface) |
1511 SDL_FreeSurface(tmpSurface) |
1496 end; |
1512 end; |
1497 if fpsTexture <> nil then |
1513 if fpsTexture <> nil then |
1498 DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); |
1514 DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); |
1499 end; |
1515 end; |
1500 |
1516 end; |
1501 // lag warning (?) |
1517 |
1502 inc(SoundTimerTicks, Lag); |
|
1503 end; |
|
1504 |
|
1505 if SoundTimerTicks >= 50 then |
|
1506 begin |
|
1507 SoundTimerTicks:= 0; |
|
1508 if cVolumeDelta <> 0 then |
|
1509 begin |
|
1510 str(ChangeVolume(cVolumeDelta), s); |
|
1511 AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume); |
|
1512 end; |
|
1513 if isAudioMuted then |
|
1514 AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume) |
|
1515 end; |
|
1516 |
1518 |
1517 if GameState = gsConfirm then |
1519 if GameState = gsConfirm then |
1518 DrawTextureCentered(0, (cScreenHeight shr 1), ConfirmTexture); |
1520 DrawTextureCentered(0, (cScreenHeight shr 1), ConfirmTexture); |
1519 |
1521 |
1520 if ScreenFade <> sfNone then |
1522 if ScreenFade <> sfNone then |
1613 // Cursor |
1615 // Cursor |
1614 if isCursorVisible then |
1616 if isCursorVisible then |
1615 begin |
1617 begin |
1616 if not bShowAmmoMenu then |
1618 if not bShowAmmoMenu then |
1617 begin |
1619 begin |
|
1620 if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint; |
1618 with CurrentHedgehog^ do |
1621 with CurrentHedgehog^ do |
1619 if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then |
1622 if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then |
1620 begin |
1623 begin |
1621 if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then |
1624 if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then |
1622 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF); |
1625 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF); |
1623 i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos; |
1626 i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos; |
1624 with Ammoz[CurAmmoType] do |
1627 with Ammoz[CurAmmoType] do |
1625 if PosCount > 1 then |
1628 if PosCount > 1 then |
1626 DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
1629 DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
1627 end; |
1630 end; |
1628 DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
1631 DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8) |
1629 end |
1632 end |
1630 end; |
1633 end; |
1631 isFirstFrame:= false |
1634 isFirstFrame:= false |
1632 end; |
1635 end; |
1633 |
1636 |
1635 |
1638 |
1636 procedure MoveCamera; |
1639 procedure MoveCamera; |
1637 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt; |
1640 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt; |
1638 begin |
1641 begin |
1639 {$IFNDEF MOBILE} |
1642 {$IFNDEF MOBILE} |
1640 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu))) and cHasFocus and (GameState <> gsConfirm) then |
1643 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then |
1641 uCursor.updatePosition(); |
1644 uCursor.updatePosition(); |
1642 {$ENDIF} |
1645 {$ENDIF} |
1643 z:= round(200/zoom); |
1646 z:= round(200/zoom); |
1644 if not PlacingHogs and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and autoCameraOn then |
1647 if not PlacingHogs and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and autoCameraOn then |
1645 if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then |
1648 if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then |
1706 end |
1709 end |
1707 else |
1710 else |
1708 EdgesDist:= cGearScrEdgesDist; |
1711 EdgesDist:= cGearScrEdgesDist; |
1709 |
1712 |
1710 // this generates the border around the screen that moves the camera when cursor is near it |
1713 // this generates the border around the screen that moves the camera when cursor is near it |
1711 if isCursorVisible or ((FollowGear <> nil) and autoCameraOn) then |
1714 if (CurrentTeam^.ExtDriven and isCursorVisible and autoCameraOn) or |
|
1715 (not CurrentTeam^.ExtDriven and isCursorVisible) or ((FollowGear <> nil) and autoCameraOn) then |
1712 begin |
1716 begin |
1713 if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then |
1717 if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then |
1714 begin |
1718 begin |
1715 WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; |
1719 WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; |
1716 CursorPoint.X:= - cScreenWidth div 2 + EdgesDist |
1720 CursorPoint.X:= - cScreenWidth div 2 + EdgesDist |