480 begin |
481 begin |
481 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
482 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
482 AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; |
483 AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; |
483 if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining |
484 if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining |
484 begin |
485 begin |
485 DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, |
486 DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, |
486 y + AMSlotPadding, AMFrame); |
487 y + AMSlotPadding, AMFrame); |
487 if STurns < 100 then |
488 if STurns < 100 then |
488 DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, |
489 DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, |
489 x + AMSlotSize-16, |
490 x + AMSlotSize-16, |
490 y + AMSlotSize + 1 - 16, STurns); |
491 y + AMSlotSize + 1 - 16, STurns); |
491 end |
492 end |
492 else //draw colored version |
493 else //draw colored version |
493 begin |
494 begin |
494 DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, |
495 DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, |
495 y + AMSlotPadding, AMFrame); |
496 y + AMSlotPadding, AMFrame); |
496 end; |
497 end; |
497 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
498 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
498 inc(y, AMSlotSize + 1); //the plus one is for the border |
499 inc(y, AMSlotSize + 1); //the plus one is for the border |
499 {$ELSE} |
500 {$ELSE} |
500 inc(x, AMSlotSize + 1); |
501 inc(x, AMSlotSize + 1); |
501 {$ENDIF} |
502 {$ENDIF} |
502 end; |
503 end; |
503 end; |
504 end; |
504 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
505 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
505 inc(x, AMSlotSize + 1); |
506 inc(x, AMSlotSize + 1); |
506 {$ELSE} |
507 {$ELSE} |
507 inc(y, AMSlotSize + 1); |
508 inc(y, AMSlotSize + 1); |
508 {$ENDIF} |
509 {$ENDIF} |
509 end; |
510 end; |
510 |
511 |
511 for i:= 1 to SlotsNumX -1 do |
512 for i:= 1 to SlotsNumX -1 do |
512 DrawLine2Surf(amSurface, i * (AMSlotSize+1)+1, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.h + BORDERSIZE - AMSlotSize - 2,160,160,160); |
513 DrawLine2Surf(amSurface, i * (AMSlotSize+1)+1, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.h + BORDERSIZE - AMSlotSize - 2,160,160,160); |
513 for i:= 1 to SlotsNumY -1 do |
514 for i:= 1 to SlotsNumY -1 do |
514 DrawLine2Surf(amSurface, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.w + BORDERSIZE, i * (AMSlotSize+1)+1,160,160,160); |
515 DrawLine2Surf(amSurface, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.w + BORDERSIZE, i * (AMSlotSize+1)+1,160,160,160); |
515 |
516 |
516 //draw outer border |
517 //draw outer border |
517 DrawSpriteFrame2Surf(sprAMCorners, amSurface, 0 , 0 , 0); |
518 DrawSpriteFrame2Surf(sprAMCorners, amSurface, 0 , 0 , 0); |
762 exit |
763 exit |
763 end; |
764 end; |
764 end |
765 end |
765 end |
766 end |
766 else |
767 else |
767 FreeWeaponTooltip; |
768 FreeAndNilTexture(WeaponTooltipTex); |
768 |
769 |
769 if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then |
770 if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then |
770 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
771 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
771 if not isPhone() then |
772 if (not isPhone()) then |
772 ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize); |
773 ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize); |
773 {$ELSE} |
774 {$ELSE} |
774 ShowWeaponTooltip(AmmoRect.x - WeaponTooltipTex^.w - 3, Min(AmmoRect.y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); |
775 ShowWeaponTooltip(AmmoRect.x - WeaponTooltipTex^.w - 3, Min(AmmoRect.y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); |
775 {$ENDIF} |
776 {$ENDIF} |
776 |
777 |
777 bSelected:= false; |
778 bSelected:= false; |
778 {$IFNDEF USE_TOUCH_INTERFACE} |
779 {$IFNDEF USE_TOUCH_INTERFACE} |
779 if (AMShiftX = 0) and (AMShiftY = 0) then |
780 if (AMShiftX = 0) and (AMShiftY = 0) then |
780 DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); |
781 DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); |
781 {$ENDIF} |
782 {$ENDIF} |
782 end; |
|
783 |
|
784 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
|
785 var VertexBuffer: array [0..3] of TVertex2f; |
|
786 r: TSDL_Rect; |
|
787 lw, lh: GLfloat; |
|
788 begin |
|
789 if SuddenDeathDmg then |
|
790 begin |
|
791 SDWaterColorArray[0].a := Alpha; |
|
792 SDWaterColorArray[1].a := Alpha; |
|
793 SDWaterColorArray[2].a := Alpha; |
|
794 SDWaterColorArray[3].a := Alpha |
|
795 end |
|
796 else |
|
797 begin |
|
798 WaterColorArray[0].a := Alpha; |
|
799 WaterColorArray[1].a := Alpha; |
|
800 WaterColorArray[2].a := Alpha; |
|
801 WaterColorArray[3].a := Alpha |
|
802 end; |
|
803 |
|
804 lw:= cScreenWidth / cScaleFactor; |
|
805 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; |
|
806 |
|
807 // Water |
|
808 r.y:= OffsetY + WorldDy + cWaterLine; |
|
809 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then |
|
810 begin |
|
811 if r.y < 0 then |
|
812 r.y:= 0; |
|
813 |
|
814 glDisable(GL_TEXTURE_2D); |
|
815 VertexBuffer[0].X:= -lw; |
|
816 VertexBuffer[0].Y:= r.y; |
|
817 VertexBuffer[1].X:= lw; |
|
818 VertexBuffer[1].Y:= r.y; |
|
819 VertexBuffer[2].X:= lw; |
|
820 VertexBuffer[2].Y:= lh; |
|
821 VertexBuffer[3].X:= -lw; |
|
822 VertexBuffer[3].Y:= lh; |
|
823 |
|
824 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
|
825 glEnableClientState(GL_COLOR_ARRAY); |
|
826 if SuddenDeathDmg then |
|
827 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @SDWaterColorArray[0]) |
|
828 else |
|
829 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
|
830 |
|
831 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
832 |
|
833 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
834 |
|
835 glDisableClientState(GL_COLOR_ARRAY); |
|
836 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
837 glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required |
|
838 glEnable(GL_TEXTURE_2D); |
|
839 end; |
|
840 end; |
|
841 |
|
842 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
|
843 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
844 lw, waves, shift: GLfloat; |
|
845 sprite: TSprite; |
|
846 begin |
|
847 if SuddenDeathDmg then |
|
848 sprite:= sprSDWater |
|
849 else |
|
850 sprite:= sprWater; |
|
851 |
|
852 cWaveWidth:= SpritesData[sprite].Width; |
|
853 |
|
854 lw:= cScreenWidth / cScaleFactor; |
|
855 waves:= lw * 2 / cWaveWidth; |
|
856 |
|
857 if SuddenDeathDmg then |
|
858 Tint(LongInt(tnt) * SDWaterColorArray[2].r div 255 + 255 - tnt, |
|
859 LongInt(tnt) * SDWaterColorArray[2].g div 255 + 255 - tnt, |
|
860 LongInt(tnt) * SDWaterColorArray[2].b div 255 + 255 - tnt, |
|
861 255 |
|
862 ) |
|
863 else |
|
864 Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt, |
|
865 LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt, |
|
866 LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt, |
|
867 255 |
|
868 ); |
|
869 |
|
870 glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id); |
|
871 |
|
872 VertexBuffer[0].X:= -lw; |
|
873 VertexBuffer[0].Y:= cWaterLine + WorldDy + dY; |
|
874 VertexBuffer[1].X:= lw; |
|
875 VertexBuffer[1].Y:= VertexBuffer[0].Y; |
|
876 VertexBuffer[2].X:= lw; |
|
877 VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprite].Height; |
|
878 VertexBuffer[3].X:= -lw; |
|
879 VertexBuffer[3].Y:= VertexBuffer[2].Y; |
|
880 |
|
881 shift:= - lw / cWaveWidth; |
|
882 TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1); |
|
883 TextureBuffer[0].Y:= 0; |
|
884 TextureBuffer[1].X:= TextureBuffer[0].X + waves; |
|
885 TextureBuffer[1].Y:= TextureBuffer[0].Y; |
|
886 TextureBuffer[2].X:= TextureBuffer[1].X; |
|
887 TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry; |
|
888 TextureBuffer[3].X:= TextureBuffer[0].X; |
|
889 TextureBuffer[3].Y:= TextureBuffer[2].Y; |
|
890 |
|
891 |
|
892 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
893 glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
|
894 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
895 |
|
896 untint; |
|
897 |
|
898 {for i:= -1 to cWaterSprCount do |
|
899 DrawSprite(sprWater, |
|
900 i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2), |
|
901 cWaterLine + WorldDy + dY, |
|
902 0)} |
|
903 end; |
783 end; |
904 |
784 |
905 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt); |
785 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt); |
906 var i, w, h, lw, lh, rw, rh, sw: LongInt; |
786 var i, w, h, lw, lh, rw, rh, sw: LongInt; |
907 begin |
787 begin |
973 zoom:= ZoomValue |
853 zoom:= ZoomValue |
974 end |
854 end |
975 else |
855 else |
976 ZoomValue:= zoom; |
856 ZoomValue:= zoom; |
977 |
857 |
978 // Sky |
|
979 glClear(GL_COLOR_BUFFER_BIT); |
|
980 //glPushMatrix; |
|
981 //glScalef(1.0, 1.0, 1.0); |
|
982 |
|
983 if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then |
858 if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then |
984 MoveCamera; |
859 MoveCamera; |
985 |
860 |
986 if cStereoMode = smNone then |
861 if cStereoMode = smNone then |
987 begin |
862 begin |
988 glClear(GL_COLOR_BUFFER_BIT); |
863 RenderClear(); |
989 DrawWorldStereo(Lag, rmDefault) |
864 DrawWorldStereo(Lag, rmDefault) |
990 end |
|
991 {$IFDEF USE_S3D_RENDERING} |
865 {$IFDEF USE_S3D_RENDERING} |
992 else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
|
993 begin |
|
994 // create left fb |
|
995 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); |
|
996 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
|
997 DrawWorldStereo(Lag, rmLeftEye); |
|
998 |
|
999 // create right fb |
|
1000 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer); |
|
1001 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
|
1002 DrawWorldStereo(0, rmRightEye); |
|
1003 |
|
1004 // detatch drawing from fbs |
|
1005 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); |
|
1006 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
|
1007 SetScale(cDefaultZoomLevel); |
|
1008 |
|
1009 // draw left frame |
|
1010 glBindTexture(GL_TEXTURE_2D, texl); |
|
1011 glBegin(GL_QUADS); |
|
1012 if cStereoMode = smHorizontal then |
|
1013 begin |
|
1014 glTexCoord2f(0.0, 0.0); |
|
1015 glVertex2d(cScreenWidth / -2, cScreenHeight); |
|
1016 glTexCoord2f(1.0, 0.0); |
|
1017 glVertex2d(0, cScreenHeight); |
|
1018 glTexCoord2f(1.0, 1.0); |
|
1019 glVertex2d(0, 0); |
|
1020 glTexCoord2f(0.0, 1.0); |
|
1021 glVertex2d(cScreenWidth / -2, 0); |
|
1022 end |
|
1023 else |
|
1024 begin |
|
1025 glTexCoord2f(0.0, 0.0); |
|
1026 glVertex2d(cScreenWidth / -2, cScreenHeight / 2); |
|
1027 glTexCoord2f(1.0, 0.0); |
|
1028 glVertex2d(cScreenWidth / 2, cScreenHeight / 2); |
|
1029 glTexCoord2f(1.0, 1.0); |
|
1030 glVertex2d(cScreenWidth / 2, 0); |
|
1031 glTexCoord2f(0.0, 1.0); |
|
1032 glVertex2d(cScreenWidth / -2, 0); |
|
1033 end; |
|
1034 glEnd(); |
|
1035 |
|
1036 // draw right frame |
|
1037 glBindTexture(GL_TEXTURE_2D, texr); |
|
1038 glBegin(GL_QUADS); |
|
1039 if cStereoMode = smHorizontal then |
|
1040 begin |
|
1041 glTexCoord2f(0.0, 0.0); |
|
1042 glVertex2d(0, cScreenHeight); |
|
1043 glTexCoord2f(1.0, 0.0); |
|
1044 glVertex2d(cScreenWidth / 2, cScreenHeight); |
|
1045 glTexCoord2f(1.0, 1.0); |
|
1046 glVertex2d(cScreenWidth / 2, 0); |
|
1047 glTexCoord2f(0.0, 1.0); |
|
1048 glVertex2d(0, 0); |
|
1049 end |
|
1050 else |
|
1051 begin |
|
1052 glTexCoord2f(0.0, 0.0); |
|
1053 glVertex2d(cScreenWidth / -2, cScreenHeight); |
|
1054 glTexCoord2f(1.0, 0.0); |
|
1055 glVertex2d(cScreenWidth / 2, cScreenHeight); |
|
1056 glTexCoord2f(1.0, 1.0); |
|
1057 glVertex2d(cScreenWidth / 2, cScreenHeight / 2); |
|
1058 glTexCoord2f(0.0, 1.0); |
|
1059 glVertex2d(cScreenWidth / -2, cScreenHeight / 2); |
|
1060 end; |
|
1061 glEnd(); |
|
1062 SetScale(zoom); |
|
1063 end |
866 end |
1064 else |
867 else |
1065 begin |
868 begin |
1066 // clear scene |
869 // draw frame for left eye |
1067 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
870 RenderClear(rmLeftEye); |
1068 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); |
|
1069 // draw left eye in red channel only |
|
1070 if cStereoMode = smGreenRed then |
|
1071 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE) |
|
1072 else if cStereoMode = smBlueRed then |
|
1073 glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE) |
|
1074 else if cStereoMode = smCyanRed then |
|
1075 glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE) |
|
1076 else |
|
1077 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); |
|
1078 DrawWorldStereo(Lag, rmLeftEye); |
871 DrawWorldStereo(Lag, rmLeftEye); |
1079 // draw right eye in selected channel(s) only |
872 |
1080 if cStereoMode = smRedGreen then |
873 // draw frame for right eye |
1081 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE) |
874 RenderClear(rmRightEye); |
1082 else if cStereoMode = smRedBlue then |
875 DrawWorldStereo(0, rmRightEye); |
1083 glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE) |
876 {$ENDIF} |
1084 else if cStereoMode = smRedCyan then |
877 end; |
1085 glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE) |
878 |
1086 else |
879 FinishRender(); |
1087 glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE); |
880 end; |
1088 DrawWorldStereo(Lag, rmRightEye); |
881 |
1089 end |
882 procedure RenderWorldEdge; |
1090 {$ENDIF} |
|
1091 end; |
|
1092 |
|
1093 procedure ChangeDepth(rm: TRenderMode; d: GLfloat); |
|
1094 begin |
|
1095 {$IFNDEF USE_S3D_RENDERING} |
|
1096 rm:= rm; d:= d; // avoid hint |
|
1097 exit; |
|
1098 {$ELSE} |
|
1099 d:= d / 5; |
|
1100 if rm = rmDefault then |
|
1101 exit |
|
1102 else if rm = rmLeftEye then |
|
1103 d:= -d; |
|
1104 stereoDepth:= stereoDepth + d; |
|
1105 glMatrixMode(GL_PROJECTION); |
|
1106 glTranslatef(d, 0, 0); |
|
1107 glMatrixMode(GL_MODELVIEW); |
|
1108 {$ENDIF} |
|
1109 end; |
|
1110 |
|
1111 procedure ResetDepth(rm: TRenderMode); |
|
1112 begin |
|
1113 {$IFNDEF USE_S3D_RENDERING} |
|
1114 rm:= rm; // avoid hint |
|
1115 exit; |
|
1116 {$ELSE} |
|
1117 if rm = rmDefault then |
|
1118 exit; |
|
1119 glMatrixMode(GL_PROJECTION); |
|
1120 glTranslatef(-stereoDepth, 0, 0); |
|
1121 glMatrixMode(GL_MODELVIEW); |
|
1122 stereoDepth:= 0; |
|
1123 {$ENDIF} |
|
1124 end; |
|
1125 |
|
1126 |
|
1127 procedure RenderWorldEdge(Lag: Longword); |
|
1128 var |
883 var |
1129 VertexBuffer: array [0..3] of TVertex2f; |
884 //VertexBuffer: array [0..3] of TVertex2f; |
1130 c1, c2: LongWord; // couple of colours for edges |
885 tmp, w: LongInt; |
1131 begin |
886 rect: TSDL_Rect; |
1132 if WorldEdge <> weNone then |
887 //c1, c2: LongWord; // couple of colours for edges |
|
888 begin |
|
889 if (WorldEdge <> weNone) and (WorldEdge <> weSea) then |
1133 begin |
890 begin |
1134 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type. Prob also, say, trigger a border animation timer on an impact. *) |
891 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type. Prob also, say, trigger a border animation timer on an impact. *) |
|
892 |
|
893 rect.y:= ViewTopY; |
|
894 rect.h:= ViewHeight; |
|
895 tmp:= LongInt(leftX) + WorldDx; |
|
896 w:= tmp - ViewLeftX; |
|
897 |
|
898 if w > 0 then |
|
899 begin |
|
900 rect.w:= w; |
|
901 rect.x:= ViewLeftX; |
|
902 DrawRect(rect, $10, $10, $10, $80, true); |
|
903 if WorldEdge = weBounce then |
|
904 DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF); |
|
905 end; |
|
906 |
|
907 tmp:= LongInt(rightX) + WorldDx; |
|
908 w:= ViewRightX - tmp; |
|
909 |
|
910 if w > 0 then |
|
911 begin |
|
912 rect.w:= w; |
|
913 rect.x:= tmp; |
|
914 DrawRect(rect, $10, $10, $10, $80, true); |
|
915 if WorldEdge = weBounce then |
|
916 DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF); |
|
917 end; |
|
918 |
|
919 (* |
|
920 WARNING: the following render code is outdated and does not work with |
|
921 current Render.pas ! - don't just uncomment without fixing it first |
1135 |
922 |
1136 glDisable(GL_TEXTURE_2D); |
923 glDisable(GL_TEXTURE_2D); |
1137 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
924 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
1138 glEnableClientState(GL_COLOR_ARRAY); |
925 if (WorldEdge = weWrap) or (worldEdge = weBounce) then |
|
926 glColor4ub($00, $00, $00, $40) |
|
927 else |
|
928 begin |
|
929 glEnableClientState(GL_COLOR_ARRAY); |
|
930 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]); |
|
931 end; |
1139 |
932 |
1140 glPushMatrix; |
933 glPushMatrix; |
1141 glTranslatef(WorldDx, WorldDy, 0); |
934 glTranslatef(WorldDx, WorldDy, 0); |
1142 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]); |
|
1143 |
935 |
1144 VertexBuffer[0].X:= leftX-20; |
936 VertexBuffer[0].X:= leftX-20; |
1145 VertexBuffer[0].Y:= -3000; |
937 VertexBuffer[0].Y:= -3500; |
1146 VertexBuffer[1].X:= leftX-20; |
938 VertexBuffer[1].X:= leftX-20; |
1147 VertexBuffer[1].Y:= cWaterLine+cVisibleWater; |
939 VertexBuffer[1].Y:= cWaterLine+cVisibleWater; |
1148 VertexBuffer[2].X:= leftX+30; |
940 VertexBuffer[2].X:= leftX+30; |
1149 VertexBuffer[2].Y:= cWaterLine+cVisibleWater; |
941 VertexBuffer[2].Y:= cWaterLine+cVisibleWater; |
1150 VertexBuffer[3].X:= leftX+30; |
942 VertexBuffer[3].X:= leftX+30; |
1151 VertexBuffer[3].Y:= -3000; |
943 VertexBuffer[3].Y:= -3500; |
1152 |
944 |
1153 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
945 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
1154 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
946 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
1155 |
947 |
1156 VertexBuffer[0].X:= rightX+20; |
948 VertexBuffer[0].X:= rightX+20; |
1310 r.x:= 2; |
1103 r.x:= 2; |
1311 r.y:= 2; |
1104 r.y:= 2; |
1312 r.w:= NameTagTex^.w - 4; |
1105 r.w:= NameTagTex^.w - 4; |
1313 r.h:= NameTagTex^.h - 4; |
1106 r.h:= NameTagTex^.h - 4; |
1314 DrawTextureFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex); |
1107 DrawTextureFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex); |
|
1108 |
|
1109 if OwnerTex <> nil then |
|
1110 begin |
|
1111 r.w:= OwnerTex^.w - 4; |
|
1112 r.h:= OwnerTex^.h - 4; |
|
1113 DrawTextureFromRect(-OwnerTex^.w - NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, OwnerTex) |
|
1114 end; |
|
1115 |
|
1116 if (GameFlags and gfAISurvival) <> 0 then |
|
1117 begin |
|
1118 r.w:= AIKillsTex^.w - 4; |
|
1119 r.h:= AIKillsTex^.h - 4; |
|
1120 DrawTextureFromRect(TeamHealthBarWidth + 24, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, AIKillsTex); |
|
1121 end; |
|
1122 |
1315 // draw flag |
1123 // draw flag |
1316 r.w:= 22; |
1124 r.w:= 22; |
1317 r.h:= 15; |
1125 r.h:= 15; |
1318 DrawTextureFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex); |
1126 DrawTextureFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex); |
|
1127 end |
|
1128 // draw an arrow next to active team |
|
1129 else if (CurrentTeam = TeamsArray[t]) and (TurnTimeLeft > 0) then |
|
1130 begin |
|
1131 h:= -NameTagTex^.w - 24; |
|
1132 if OwnerTex <> nil then |
|
1133 h:= h - OwnerTex^.w - 4; |
|
1134 DrawSpriteRotatedF(sprFinger, h, cScreenHeight + DrawHealthY + smallScreenOffset + 2 + SpritesData[sprFinger].Width div 4, 0, 1, -90); |
1319 end; |
1135 end; |
1320 end; |
1136 end; |
1321 if smallScreenOffset <> 0 then |
1137 if smallScreenOffset <> 0 then |
1322 begin |
1138 begin |
1323 SetScale(cDefaultZoomLevel); |
1139 SetScale(cDefaultZoomLevel); |
1324 if TeamsCount * 20 > Longword(cScreenHeight) div 5 then |
1140 if TeamsCount * 20 > Longword(cScreenHeight) div 5 then |
1325 Tint($FF,$FF,$FF,$FF); |
1141 untint; |
1326 end; |
1142 end; |
1327 end; |
1143 end; |
1328 |
1144 |
|
1145 |
|
1146 var preShiftWorldDx: LongInt; |
|
1147 |
|
1148 procedure ShiftWorld(Dir: LongInt); inline; |
|
1149 begin |
|
1150 preShiftWorldDx:= WorldDx; |
|
1151 WorldDx:= WorldDx + LongInt(Dir * LongInt(playWidth)); |
|
1152 |
|
1153 end; |
|
1154 |
|
1155 procedure UnshiftWorld(); inline; |
|
1156 begin |
|
1157 WorldDx:= preShiftWorldDx; |
|
1158 end; |
1329 |
1159 |
1330 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); |
1160 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); |
1331 var i, t: LongInt; |
1161 var i, t: LongInt; |
1332 r: TSDL_Rect; |
1162 r: TSDL_Rect; |
1333 tdx, tdy: Double; |
1163 tdx, tdy: Double; |
1334 s: shortstring; |
1164 s: shortstring; |
1335 offsetX, offsetY, screenBottom: LongInt; |
1165 offsetX, offsetY, screenBottom: LongInt; |
1336 VertexBuffer: array [0..3] of TVertex2f; |
1166 replicateToLeft, replicateToRight, tmp: boolean; |
1337 begin |
1167 a: Byte; |
|
1168 begin |
|
1169 if WorldEdge <> weWrap then |
|
1170 begin |
|
1171 replicateToLeft := false; |
|
1172 replicateToRight:= false; |
|
1173 end |
|
1174 else |
|
1175 begin |
|
1176 replicateToLeft := (LongInt(leftX) + WorldDx > ViewLeftX); |
|
1177 replicateToRight:= (LongInt(rightX) + WorldDx < ViewRightX); |
|
1178 end; |
|
1179 |
|
1180 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine); |
|
1181 |
|
1182 // note: offsetY is negative! |
|
1183 offsetY:= 10 * Min(0, -145 - ScreenBottom); // TODO limit this in the other direction too |
|
1184 |
1338 if (cReducedQuality and rqNoBackground) = 0 then |
1185 if (cReducedQuality and rqNoBackground) = 0 then |
1339 begin |
1186 begin |
1340 // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway |
1187 // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway |
1341 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine); |
|
1342 offsetY:= 10 * Min(0, -145 - ScreenBottom); |
|
1343 SkyOffset:= offsetY div 35 + cWaveHeight; |
1188 SkyOffset:= offsetY div 35 + cWaveHeight; |
1344 HorizontOffset:= SkyOffset; |
1189 HorizontOffset:= SkyOffset; |
1345 if ScreenBottom > SkyOffset then |
1190 if ScreenBottom > SkyOffset then |
1346 HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20); |
1191 HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20); |
1347 |
1192 |
1361 DrawVisualGears(4); |
1206 DrawVisualGears(4); |
1362 |
1207 |
1363 if (cReducedQuality and rq2DWater) = 0 then |
1208 if (cReducedQuality and rq2DWater) = 0 then |
1364 begin |
1209 begin |
1365 // Waves |
1210 // Waves |
1366 DrawWater(255, SkyOffset); |
1211 DrawWater(255, SkyOffset, 0); |
1367 ChangeDepth(RM, -cStereo_Water_distant); |
1212 ChangeDepth(RM, -cStereo_Water_distant); |
1368 DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); |
1213 DrawWaves( 1, 0 - WorldDx div 32, offsetY div 35, -49, 64); |
1369 ChangeDepth(RM, -cStereo_Water_distant); |
1214 ChangeDepth(RM, -cStereo_Water_distant); |
1370 DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48); |
1215 DrawWaves( -1, 25 + WorldDx div 25, offsetY div 38, -37, 48); |
1371 ChangeDepth(RM, -cStereo_Water_distant); |
1216 ChangeDepth(RM, -cStereo_Water_distant); |
1372 DrawWaves( 1, 75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32); |
1217 DrawWaves( 1, 75 - WorldDx div 19, offsetY div 45, -23, 32); |
1373 ChangeDepth(RM, -cStereo_Water_distant); |
1218 ChangeDepth(RM, -cStereo_Water_distant); |
1374 DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24); |
1219 DrawWaves(-1, 100 + WorldDx div 14, offsetY div 70, -7, 24); |
1375 end |
1220 end |
1376 else |
1221 else |
1377 DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0); |
1222 DrawWaves(-1, 100, - cWaveHeight div 2, - cWaveHeight div 2, 0); |
1378 |
1223 |
1379 changeDepth(RM, cStereo_Land); |
1224 ChangeDepth(RM, cStereo_Land); |
1380 DrawVisualGears(5); |
1225 DrawVisualGears(5); |
|
1226 DrawLand(WorldDx, WorldDy); |
|
1227 |
|
1228 if replicateToLeft then |
|
1229 begin |
|
1230 ShiftWorld(-1); |
1381 DrawLand(WorldDx, WorldDy); |
1231 DrawLand(WorldDx, WorldDy); |
1382 |
1232 UnshiftWorld(); |
1383 DrawWater(255, 0); |
1233 end; |
|
1234 |
|
1235 if replicateToRight then |
|
1236 begin |
|
1237 ShiftWorld(1); |
|
1238 DrawLand(WorldDx, WorldDy); |
|
1239 UnshiftWorld(); |
|
1240 end; |
|
1241 |
|
1242 DrawWater(255, 0, 0); |
|
1243 |
|
1244 (* |
|
1245 // Attack bar |
|
1246 if CurrentTeam <> nil then |
|
1247 case AttackBar of |
|
1248 //1: begin |
|
1249 //r:= StuffPoz[sPowerBar]; |
|
1250 //{$WARNINGS OFF} |
|
1251 //r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; |
|
1252 //{$WARNINGS ON} |
|
1253 //DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
|
1254 //end; |
|
1255 2: with CurrentHedgehog^ do |
|
1256 begin |
|
1257 tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); |
|
1258 tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); |
|
1259 for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do |
|
1260 DrawSprite(sprPower, |
|
1261 hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16, |
|
1262 hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16, |
|
1263 i) |
|
1264 end |
|
1265 end; |
|
1266 *) |
|
1267 |
|
1268 tmp:= bShowFinger; |
|
1269 bShowFinger:= false; |
|
1270 |
|
1271 if replicateToLeft then |
|
1272 begin |
|
1273 ShiftWorld(-1); |
|
1274 DrawVisualGears(1); |
|
1275 DrawGears(); |
|
1276 DrawVisualGears(6); |
|
1277 UnshiftWorld(); |
|
1278 end; |
|
1279 |
|
1280 if replicateToRight then |
|
1281 begin |
|
1282 ShiftWorld(1); |
|
1283 DrawVisualGears(1); |
|
1284 DrawGears(); |
|
1285 DrawVisualGears(6); |
|
1286 UnshiftWorld(); |
|
1287 end; |
|
1288 |
|
1289 bShowFinger:= tmp; |
1384 |
1290 |
1385 DrawVisualGears(1); |
1291 DrawVisualGears(1); |
1386 DrawGears; |
1292 DrawGears; |
1387 DrawVisualGears(6); |
1293 DrawVisualGears(6); |
1388 |
1294 |
|
1295 |
1389 if SuddenDeathDmg then |
1296 if SuddenDeathDmg then |
1390 DrawWater(SDWaterOpacity, 0) |
1297 DrawWater(SDWaterOpacity, 0, 0) |
1391 else |
1298 else |
1392 DrawWater(WaterOpacity, 0); |
1299 DrawWater(WaterOpacity, 0, 0); |
1393 |
1300 |
1394 // Waves |
1301 // Waves |
1395 ChangeDepth(RM, cStereo_Water_near); |
1302 ChangeDepth(RM, cStereo_Water_near); |
1396 DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12); |
1303 DrawWaves( 1, 25 - WorldDx div 9, 0, 0, 12); |
1397 |
1304 |
1398 if (cReducedQuality and rq2DWater) = 0 then |
1305 if (cReducedQuality and rq2DWater) = 0 then |
1399 begin |
1306 begin |
1400 //DrawWater(WaterOpacity, - offsetY div 40); |
1307 //DrawWater(WaterOpacity, - offsetY div 40); |
1401 ChangeDepth(RM, cStereo_Water_near); |
1308 ChangeDepth(RM, cStereo_Water_near); |
1402 DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8); |
1309 DrawWaves(-1, 50 + WorldDx div 6, - offsetY div 40, 23, 8); |
1403 if SuddenDeathDmg then |
1310 if SuddenDeathDmg then |
1404 DrawWater(SDWaterOpacity, - offsetY div 20) |
1311 DrawWater(SDWaterOpacity, - offsetY div 20, 23) |
1405 else |
1312 else |
1406 DrawWater(WaterOpacity, - offsetY div 20); |
1313 DrawWater(WaterOpacity, - offsetY div 20, 23); |
1407 ChangeDepth(RM, cStereo_Water_near); |
1314 ChangeDepth(RM, cStereo_Water_near); |
1408 DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2); |
1315 DrawWaves( 1, 75 - WorldDx div 4, - offsetY div 20, 37, 2); |
1409 if SuddenDeathDmg then |
1316 if SuddenDeathDmg then |
1410 DrawWater(SDWaterOpacity, - offsetY div 10) |
1317 DrawWater(SDWaterOpacity, - offsetY div 10, 47) |
1411 else |
1318 else |
1412 DrawWater(WaterOpacity, - offsetY div 10); |
1319 DrawWater(WaterOpacity, - offsetY div 10, 47); |
1413 ChangeDepth(RM, cStereo_Water_near); |
1320 ChangeDepth(RM, cStereo_Water_near); |
1414 DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0); |
1321 DrawWaves( -1, 25 + WorldDx div 3, - offsetY div 10, 59, 0); |
1415 end |
1322 end |
1416 else |
1323 else |
1417 DrawWaves(-1, 50, - (cWaveHeight shr 1), 0); |
1324 DrawWaves(-1, 50, cWaveHeight div 2, cWaveHeight div 2, 0); |
1418 |
1325 |
1419 // everything after this ChangeDepth will be drawn outside the screen |
1326 // everything after this ChangeDepth will be drawn outside the screen |
1420 // note: negative parallax gears should last very little for a smooth stereo effect |
1327 // note: negative parallax gears should last very little for a smooth stereo effect |
1421 ChangeDepth(RM, cStereo_Outside); |
1328 ChangeDepth(RM, cStereo_Outside); |
|
1329 |
|
1330 if replicateToLeft then |
|
1331 begin |
|
1332 ShiftWorld(-1); |
|
1333 DrawVisualGears(2); |
|
1334 UnshiftWorld(); |
|
1335 end; |
|
1336 |
|
1337 if replicateToRight then |
|
1338 begin |
|
1339 ShiftWorld(1); |
|
1340 DrawVisualGears(2); |
|
1341 UnshiftWorld(); |
|
1342 end; |
|
1343 |
1422 DrawVisualGears(2); |
1344 DrawVisualGears(2); |
1423 |
1345 |
1424 // everything after this ResetDepth will be drawn at screen level (depth = 0) |
1346 // everything after this ResetDepth will be drawn at screen level (depth = 0) |
1425 // note: everything that needs to be readable should be on this level |
1347 // note: everything that needs to be readable should be on this level |
1426 ResetDepth(RM); |
1348 ResetDepth(RM); |
|
1349 |
|
1350 if replicateToLeft then |
|
1351 begin |
|
1352 ShiftWorld(-1); |
|
1353 DrawVisualGears(3); |
|
1354 UnshiftWorld(); |
|
1355 end; |
|
1356 |
|
1357 if replicateToRight then |
|
1358 begin |
|
1359 ShiftWorld(1); |
|
1360 DrawVisualGears(3); |
|
1361 UnshiftWorld(); |
|
1362 end; |
|
1363 |
1427 DrawVisualGears(3); |
1364 DrawVisualGears(3); |
1428 |
1365 |
1429 {$WARNINGS OFF} |
1366 {$WARNINGS OFF} |
1430 // Target |
1367 // Target |
1431 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then |
1368 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then |
1734 end |
1657 end |
1735 end; |
1658 end; |
1736 |
1659 |
1737 |
1660 |
1738 // Cursor |
1661 // Cursor |
1739 if isCursorVisible then |
1662 if isCursorVisible and (not bShowAmmoMenu) then |
1740 begin |
1663 begin |
1741 if not bShowAmmoMenu then |
1664 if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint; |
1742 begin |
1665 with CurrentHedgehog^ do |
1743 if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint; |
1666 if (Gear <> nil) and ((Gear^.State and gstChooseTarget) <> 0) then |
1744 with CurrentHedgehog^ do |
1667 begin |
1745 if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then |
1668 if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) or (((GameFlags and gfMoreWind) <> 0) and ((CurAmmoType = amDrillStrike) or (CurAmmoType = amAirAttack))) then |
|
1669 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); |
|
1670 i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos; |
|
1671 with Ammoz[CurAmmoType] do |
|
1672 if PosCount > 1 then |
1746 begin |
1673 begin |
1747 if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then |
1674 if (CurAmmoType = amGirder) or (CurAmmoType = amTeleport) then |
1748 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); |
1675 begin |
1749 i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos; |
1676 // pulsating transparency |
1750 with Ammoz[CurAmmoType] do |
1677 if ((GameTicks div 16) mod $80) >= $40 then |
1751 if PosCount > 1 then |
1678 Tint($FF, $FF, $FF, $C0 - (GameTicks div 16) mod $40) |
1752 DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
1679 else |
|
1680 Tint($FF, $FF, $FF, $80 + (GameTicks div 16) mod $40); |
|
1681 end; |
|
1682 DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
|
1683 Untint(); |
1753 end; |
1684 end; |
1754 DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8) |
1685 end; |
1755 end |
1686 //DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8) |
1756 end; |
1687 DrawTextureF(SpritesData[sprArrow].Texture, cDefaultZoomLevel / cScaleFactor, TargetCursorPoint.X + round(SpritesData[sprArrow].Width / cScaleFactor), cScreenHeight + round(SpritesData[sprArrow].Height / cScaleFactor) - TargetCursorPoint.Y, (RealTicks shr 6) mod 8, 1, SpritesData[sprArrow].Width, SpritesData[sprArrow].Height); |
1757 isFirstFrame:= false; |
1688 end; |
|
1689 |
|
1690 // debug stuff |
|
1691 if cViewLimitsDebug then |
|
1692 begin |
|
1693 r.x:= ViewLeftX; |
|
1694 r.y:= ViewTopY; |
|
1695 r.w:= ViewWidth; |
|
1696 r.h:= ViewHeight; |
|
1697 DrawRect(r, 255, 0, 0, 128, false); |
|
1698 end; |
|
1699 |
|
1700 isFirstFrame:= false |
1758 end; |
1701 end; |
1759 |
1702 |
1760 var PrevSentPointTime: LongWord = 0; |
1703 var PrevSentPointTime: LongWord = 0; |
1761 |
1704 |
1762 procedure MoveCamera; |
1705 procedure MoveCamera; |
1763 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt; |
1706 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY, dstX: LongInt; |
1764 inbtwnTrgtAttks: Boolean; |
1707 inbtwnTrgtAttks: Boolean; |
1765 begin |
1708 begin |
1766 {$IFNDEF MOBILE} |
1709 {$IFNDEF MOBILE} |
1767 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then |
1710 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then |
1768 uCursor.updatePosition(); |
1711 uCursor.updatePosition(); |
1769 {$ENDIF} |
1712 {$ENDIF} |
1770 z:= round(200/zoom); |
1713 z:= round(200/zoom); |
1771 inbtwnTrgtAttks := (CurrentHedgehog <> nil) and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) <> 0) and ((GameFlags and gfInfAttack) <> 0); |
1714 inbtwnTrgtAttks := ((GameFlags and gfInfAttack) <> 0) and (CurrentHedgehog <> nil) and ((CurrentHedgehog^.Gear = nil) or (CurrentHedgehog^.Gear <> FollowGear)) and ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) <> 0); |
1772 if autoCameraOn and not PlacingHogs and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and not inbtwnTrgtAttks then |
1715 if autoCameraOn and (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and (not inbtwnTrgtAttks) then |
1773 if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then |
1716 if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then |
1774 begin |
1717 begin |
1775 FollowGear:= nil; |
1718 FollowGear:= nil; |
1776 prevPoint:= CursorPoint; |
1719 prevPoint:= CursorPoint; |
1777 exit |
1720 exit |
1778 end |
1721 end |
1779 else |
1722 else |
1780 begin |
1723 begin |
1781 CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx) div 8; |
1724 dstX:= hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx; |
1782 if isPhone() or (cScreenHeight < 600) or ((hwSign(FollowGear^.dY) * z) < 10) then |
1725 |
|
1726 if (WorldEdge = weWrap) then |
|
1727 begin |
|
1728 if dstX - prevPoint.X < (LongInt(leftX) - rightX) div 2 then |
|
1729 CursorPoint.X:= (prevPoint.X * 7 + dstX - (leftX - rightX)) div 8 |
|
1730 else if dstX - prevPoint.X > (LongInt(rightX) - leftX) div 2 then |
|
1731 CursorPoint.X:= (prevPoint.X * 7 + dstX - (rightX - leftX)) div 8 |
|
1732 else |
|
1733 CursorPoint.X:= (prevPoint.X * 7 + dstX) div 8; |
|
1734 end |
|
1735 else // usual camera movement routine |
|
1736 begin |
|
1737 CursorPoint.X:= (prevPoint.X * 7 + dstX) div 8; |
|
1738 end; |
|
1739 |
|
1740 if isPhone() or (cScreenHeight < 600) or (hwFloat(FollowGear^.dY * z).Round < 10) then |
1783 CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
1741 CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
1784 else |
1742 else |
1785 CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8; |
1743 CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8; |
1786 end; |
1744 end; |
|
1745 |
|
1746 if (WorldEdge = weWrap) then |
|
1747 begin |
|
1748 if -WorldDx < leftX then |
|
1749 WorldDx:= WorldDx - LongInt(rightX) + leftX |
|
1750 else if -WorldDx > rightX then |
|
1751 WorldDx:= WorldDx + LongInt(rightX) - leftX; |
|
1752 end; |
1787 |
1753 |
1788 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; |
1754 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; |
1789 if WorldDy < wdy then |
1755 if WorldDy < wdy then |
1790 WorldDy:= wdy; |
1756 WorldDy:= wdy; |
1791 |
1757 |
1937 exit; |
1905 exit; |
1938 {$ENDIF} |
1906 {$ENDIF} |
1939 |
1907 |
1940 {$IFDEF USE_VIDEO_RECORDING} |
1908 {$IFDEF USE_VIDEO_RECORDING} |
1941 // do not change volume during prerecording as it will affect sound in video file |
1909 // do not change volume during prerecording as it will affect sound in video file |
1942 if not flagPrerecording then |
1910 if (not flagPrerecording) then |
1943 {$ENDIF} |
1911 {$ENDIF} |
1944 begin |
1912 begin |
1945 if not cHasFocus then DampenAudio() |
1913 if (not cHasFocus) then DampenAudio() |
1946 else UndampenAudio(); |
1914 else UndampenAudio(); |
1947 end; |
1915 end; |
|
1916 end; |
|
1917 |
|
1918 procedure updateCursorVisibility; |
|
1919 begin |
|
1920 if isPaused or isAFK then |
|
1921 SDL_ShowCursor(1) |
|
1922 else |
|
1923 SDL_ShowCursor(ord(GameState = gsConfirm)) |
1948 end; |
1924 end; |
1949 |
1925 |
1950 procedure SetUtilityWidgetState(ammoType: TAmmoType); |
1926 procedure SetUtilityWidgetState(ammoType: TAmmoType); |
1951 begin |
1927 begin |
1952 {$IFDEF USE_TOUCH_INTERFACE} |
1928 {$IFDEF USE_TOUCH_INTERFACE} |
1953 if(ammoType = amNothing)then |
1929 if(ammoType = amNothing)then |
1954 ammoType:= CurrentHedgehog^.CurAmmoType; |
1930 ammoType:= CurrentHedgehog^.CurAmmoType; |
1955 |
1931 |
1956 if(CurrentHedgehog <> nil)then |
1932 if(CurrentHedgehog <> nil)then |
1957 if (Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0 then |
1933 if ((Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0) and (ammoType <> amDrillStrike) then |
1958 begin |
1934 begin |
1959 utilityWidget.sprite:= sprTimerButton; |
1935 utilityWidget.sprite:= sprTimerButton; |
1960 animateWidget(@utilityWidget, true, true); |
1936 animateWidget(@utilityWidget, true, true); |
1961 end |
1937 end |
1962 else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then |
1938 else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then |
1963 begin |
1939 begin |
1964 utilityWidget.sprite:= sprTargetButton; |
1940 utilityWidget.sprite:= sprTargetButton; |
1965 animateWidget(@utilityWidget, true, true); |
1941 animateWidget(@utilityWidget, true, true); |
1966 end |
1942 end |
1967 else if ammoType = amSwitch then |
1943 else if ammoType = amSwitch then |
1968 begin |
1944 begin |
1969 utilityWidget.sprite:= sprTargetButton; |
1945 utilityWidget.sprite:= sprSwitchButton; |
1970 animateWidget(@utilityWidget, true, true); |
1946 animateWidget(@utilityWidget, true, true); |
1971 end |
1947 end |
1972 else if utilityWidget.show then |
1948 else if utilityWidget.show then |
1973 animateWidget(@utilityWidget, true, false); |
1949 animateWidget(@utilityWidget, true, false); |
1974 {$ELSE} |
1950 {$ELSE} |