85 missionTimer: LongInt; |
84 missionTimer: LongInt; |
86 stereoDepth: GLfloat; |
85 stereoDepth: GLfloat; |
87 isFirstFrame: boolean; |
86 isFirstFrame: boolean; |
88 AMAnimType: LongInt; |
87 AMAnimType: LongInt; |
89 recTexture: PTexture; |
88 recTexture: PTexture; |
|
89 AmmoMenuTex : PTexture; |
|
90 HorizontOffset: LongInt; |
|
91 cOffsetY: LongInt; |
|
92 AFRToggle: Boolean; |
90 |
93 |
91 const cStereo_Sky = 0.0500; |
94 const cStereo_Sky = 0.0500; |
92 cStereo_Horizon = 0.0250; |
95 cStereo_Horizon = 0.0250; |
93 cStereo_MidDistance = 0.0175; |
96 cStereo_MidDistance = 0.0175; |
94 cStereo_Water_distant = 0.0125; |
97 cStereo_Water_distant = 0.0125; |
95 cStereo_Land = 0.0075; |
98 cStereo_Land = 0.0075; |
96 cStereo_Water_near = 0.0025; |
99 cStereo_Water_near = 0.0025; |
97 cStereo_Outside = -0.0400; |
100 cStereo_Outside = -0.0400; |
|
101 |
|
102 AMAnimDuration = 200; |
|
103 AMHidden = 0;//AMState values |
|
104 AMShowingUp = 1; |
|
105 AMShowing = 2; |
|
106 AMHiding = 3; |
|
107 |
|
108 AMTypeMaskX = $00000001; |
|
109 AMTypeMaskY = $00000002; |
|
110 AMTypeMaskAlpha = $00000004; |
|
111 AMTypeMaskSlide = $00000008; |
|
112 |
|
113 {$IFDEF MOBILE} |
|
114 AMSlotSize = 48; |
|
115 AMTITLE = 30; |
|
116 {$ELSE} |
|
117 AMSlotSize = 32; |
|
118 {$ENDIF} |
|
119 AMSlotPadding = (AMSlotSize - 32) shr 1; |
|
120 |
|
121 cSendCursorPosTime = 50; |
|
122 cCursorEdgesDist = 100; |
98 |
123 |
99 // helper functions to create the goal/game mode string |
124 // helper functions to create the goal/game mode string |
100 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; |
125 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; |
101 var t: ansistring; |
126 var t: ansistring; |
102 begin |
127 begin |
416 |
441 |
417 |
442 |
418 AmmoRect.w:= (BORDERSIZE*2) + (SlotsNumX * AMSlotSize) + (SlotsNumX-1); |
443 AmmoRect.w:= (BORDERSIZE*2) + (SlotsNumX * AMSlotSize) + (SlotsNumX-1); |
419 AmmoRect.h:= (BORDERSIZE*2) + (SlotsNumY * AMSlotSize) + (SlotsNumY-1); |
444 AmmoRect.h:= (BORDERSIZE*2) + (SlotsNumY * AMSlotSize) + (SlotsNumY-1); |
420 amSurface := SDL_CreateRGBSurface(SDL_SWSURFACE, AmmoRect.w, AmmoRect.h, 32, RMask, GMask, BMask, AMask); |
445 amSurface := SDL_CreateRGBSurface(SDL_SWSURFACE, AmmoRect.w, AmmoRect.h, 32, RMask, GMask, BMask, AMask); |
421 |
446 |
422 AMRect.x:= BORDERSIZE; |
447 AMRect.x:= BORDERSIZE; |
423 AMRect.y:= BORDERSIZE; |
448 AMRect.y:= BORDERSIZE; |
424 AMRect.w:= AmmoRect.w - (BORDERSIZE*2); |
449 AMRect.w:= AmmoRect.w - (BORDERSIZE*2); |
425 AMRect.h:= AmmoRect.h - (BORDERSIZE*2); |
450 AMRect.h:= AmmoRect.h - (BORDERSIZE*2); |
426 |
451 |
427 SDL_FillRect(amSurface, @AMRect, SDL_MapRGB(amSurface^.format, 0,0,0)); |
452 SDL_FillRect(amSurface, @AMRect, SDL_MapRGB(amSurface^.format, 0,0,0)); |
428 |
453 |
429 x:= AMRect.x; |
454 x:= AMRect.x; |
430 y:= AMRect.y; |
455 y:= AMRect.y; |
431 for i:= 0 to cMaxSlotIndex do |
456 for i:= 0 to cMaxSlotIndex do |
432 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
457 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
433 begin |
458 begin |
457 begin |
482 begin |
458 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
483 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
459 AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; |
484 AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; |
460 if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining |
485 if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining |
461 begin |
486 begin |
462 DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, |
487 DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, |
463 y + AMSlotPadding, AMFrame); |
488 y + AMSlotPadding, AMFrame); |
464 if STurns < 100 then |
489 if STurns < 100 then |
465 DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, |
490 DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, |
466 x + AMSlotSize-16, |
491 x + AMSlotSize-16, |
467 y + AMSlotSize + 1 - 16, STurns); |
492 y + AMSlotSize + 1 - 16, STurns); |
468 end |
493 end |
469 else //draw colored version |
494 else //draw colored version |
470 begin |
495 begin |
471 DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, |
496 DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, |
472 y + AMSlotPadding, AMFrame); |
497 y + AMSlotPadding, AMFrame); |
473 end; |
498 end; |
474 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
499 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
475 inc(y, AMSlotSize + 1); //the plus one is for the border |
500 inc(y, AMSlotSize + 1); //the plus one is for the border |
476 {$ELSE} |
501 {$ELSE} |
477 inc(x, AMSlotSize + 1); |
502 inc(x, AMSlotSize + 1); |
478 {$ENDIF} |
503 {$ENDIF} |
479 end; |
504 end; |
480 end; |
505 end; |
481 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
506 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
482 inc(x, AMSlotSize + 1); |
507 inc(x, AMSlotSize + 1); |
483 {$ELSE} |
508 {$ELSE} |
484 inc(y, AMSlotSize + 1); |
509 inc(y, AMSlotSize + 1); |
485 {$ENDIF} |
510 {$ENDIF} |
486 end; |
511 end; |
487 |
512 |
488 for i:= 1 to SlotsNumX -1 do |
513 for i:= 1 to SlotsNumX -1 do |
489 DrawLine2Surf(amSurface, i * (AMSlotSize+1)+1, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.h + BORDERSIZE - AMSlotSize - 2,160,160,160); |
514 DrawLine2Surf(amSurface, i * (AMSlotSize+1)+1, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.h + BORDERSIZE - AMSlotSize - 2,160,160,160); |
490 for i:= 1 to SlotsNumY -1 do |
515 for i:= 1 to SlotsNumY -1 do |
491 DrawLine2Surf(amSurface, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.w + BORDERSIZE, i * (AMSlotSize+1)+1,160,160,160); |
516 DrawLine2Surf(amSurface, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.w + BORDERSIZE, i * (AMSlotSize+1)+1,160,160,160); |
492 |
517 |
493 //draw outer border |
518 //draw outer border |
494 DrawSpriteFrame2Surf(sprAMCorners, amSurface, 0 , 0 , 0); |
519 DrawSpriteFrame2Surf(sprAMCorners, amSurface, 0 , 0 , 0); |
611 else |
636 else |
612 if AMAnimState < 1 then |
637 if AMAnimState < 1 then |
613 begin |
638 begin |
614 AMShiftX:= Round(AMShiftTargetX * AMAnimState); |
639 AMShiftX:= Round(AMShiftTargetX * AMAnimState); |
615 AMShiftY:= Round(AMShiftTargetY * AMAnimState); |
640 AMShiftY:= Round(AMShiftTargetY * AMAnimState); |
616 if (AMAnimType and AMTypeMaskAlpha) <> 0 then |
641 if (AMAnimType and AMTypeMaskAlpha) <> 0 then |
617 Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState))); |
642 Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState))); |
618 end |
643 end |
619 else |
644 else |
620 begin |
645 begin |
621 AMShiftX:= AMShiftTargetX; |
646 AMShiftX:= AMShiftTargetX; |
622 AMShiftY:= AMShiftTargetY; |
647 AMShiftY:= AMShiftTargetY; |
623 prevPoint:= CursorPoint; |
648 prevPoint:= CursorPoint; |
624 AMState:= AMHidden; |
649 AMState:= AMHidden; |
625 end; |
650 end; |
626 end; |
651 end; |
627 |
652 |
628 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); |
653 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); |
629 |
654 |
630 if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then |
655 if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then |
631 Tint($FF, $ff, $ff, $ff); |
656 Tint($FF, $ff, $ff, $ff); |
632 |
657 |
633 Pos:= -1; |
658 Pos:= -1; |
634 Slot:= -1; |
659 Slot:= -1; |
635 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
660 {$IFDEF USE_LANDSCAPE_AMMOMENU} |
646 for t:=0 to cMaxSlotAmmoIndex do |
671 for t:=0 to cMaxSlotAmmoIndex do |
647 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then |
672 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then |
648 begin |
673 begin |
649 if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g * (AMSlotSize+1))) and |
674 if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g * (AMSlotSize+1))) and |
650 (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and |
675 (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and |
651 (CursorPoint.X > AmmoRect.x + ( c * (AMSlotSize+1))) and |
676 (CursorPoint.X > AmmoRect.x + ( c * (AMSlotSize+1))) and |
652 (CursorPoint.X <= AmmoRect.x + ((c+1) * (AMSlotSize+1))) then |
677 (CursorPoint.X <= AmmoRect.x + ((c+1) * (AMSlotSize+1))) then |
653 begin |
678 begin |
654 Slot:= i; |
679 Slot:= i; |
655 Pos:= t; |
680 Pos:= t; |
656 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
681 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
657 if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then |
682 if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then |
658 DrawSprite(sprAMSlot, |
683 DrawSprite(sprAMSlot, |
659 AmmoRect.x + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding, |
684 AmmoRect.x + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding, |
660 AmmoRect.y + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 0); |
685 AmmoRect.y + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 0); |
661 end; |
686 end; |
662 inc(g); |
687 inc(g); |
663 end; |
688 end; |
664 end; |
689 end; |
676 for t:=0 to cMaxSlotAmmoIndex do |
701 for t:=0 to cMaxSlotAmmoIndex do |
677 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then |
702 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then |
678 begin |
703 begin |
679 if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( c * (AMSlotSize+1))) and |
704 if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( c * (AMSlotSize+1))) and |
680 (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and |
705 (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and |
681 (CursorPoint.X > AmmoRect.x + ( g * (AMSlotSize+1))) and |
706 (CursorPoint.X > AmmoRect.x + ( g * (AMSlotSize+1))) and |
682 (CursorPoint.X <= AmmoRect.x + ((g+1) * (AMSlotSize+1))) then |
707 (CursorPoint.X <= AmmoRect.x + ((g+1) * (AMSlotSize+1))) then |
683 begin |
708 begin |
684 Slot:= i; |
709 Slot:= i; |
685 Pos:= t; |
710 Pos:= t; |
686 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
711 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
687 if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then |
712 if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then |
688 DrawSprite(sprAMSlot, |
713 DrawSprite(sprAMSlot, |
689 AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding, |
714 AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding, |
690 AmmoRect.y + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding -1, 0); |
715 AmmoRect.y + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding -1, 0); |
691 end; |
716 end; |
692 inc(g); |
717 inc(g); |
693 end; |
718 end; |
694 end; |
719 end; |
1124 glTranslatef(d, 0, 0); |
1149 glTranslatef(d, 0, 0); |
1125 glMatrixMode(GL_MODELVIEW); |
1150 glMatrixMode(GL_MODELVIEW); |
1126 {$ENDIF} |
1151 {$ENDIF} |
1127 {$ENDIF} |
1152 {$ENDIF} |
1128 end; |
1153 end; |
1129 |
1154 |
1130 procedure ResetDepth(rm: TRenderMode); |
1155 procedure ResetDepth(rm: TRenderMode); |
1131 begin |
1156 begin |
1132 {$IFNDEF S3D_DISABLED} |
1157 {$IFNDEF USE_S3D_RENDERING} |
|
1158 rm:= rm; // avoid hint |
|
1159 exit; |
|
1160 {$ELSE} |
1133 if rm = rmDefault then |
1161 if rm = rmDefault then |
1134 exit; |
1162 exit; |
1135 {$IFDEF GL2} |
1163 {$IFDEF GL2} |
1136 hglMatrixMode(MATRIX_PROJECTION); |
1164 hglMatrixMode(MATRIX_PROJECTION); |
1137 hglTranslatef(-stereoDepth, 0, 0); |
1165 hglTranslatef(-stereoDepth, 0, 0); |
1138 hglMatrixMode(MATRIX_MODELVIEW); |
1166 hglMatrixMode(MATRIX_MODELVIEW); |
1139 {$ELSE} |
1167 {$ELSE} |
1140 glMatrixMode(GL_PROJECTION); |
1168 glMatrixMode(GL_PROJECTION); |
1141 glTranslatef(-stereoDepth, 0, 0); |
1169 glTranslatef(-stereoDepth, 0, 0); |
1142 glMatrixMode(GL_MODELVIEW); |
1170 glMatrixMode(GL_MODELVIEW); |
1143 {$ENDIF} |
1171 {$ENDIF} |
1144 cStereoDepth:= 0; |
1172 cStereoDepth:= 0; |
1145 {$ENDIF} |
1173 {$ENDIF} |
1146 end; |
1174 end; |
1147 |
1175 |
1148 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); |
1176 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); |
1149 var i, t, h: LongInt; |
1177 var i, t, h: LongInt; |
1150 r: TSDL_Rect; |
1178 r: TSDL_Rect; |
1151 tdx, tdy: Double; |
1179 tdx, tdy: Double; |
1152 s: shortstring; |
1180 s: shortstring; |
1180 DrawVisualGears(4); |
1208 DrawVisualGears(4); |
1181 |
1209 |
1182 if (cReducedQuality and rq2DWater) = 0 then |
1210 if (cReducedQuality and rq2DWater) = 0 then |
1183 begin |
1211 begin |
1184 // Waves |
1212 // Waves |
1185 DrawWater(255, SkyOffset); |
1213 DrawWater(255, SkyOffset); |
1186 ChangeDepth(RM, -cStereo_Water_distant); |
1214 ChangeDepth(RM, -cStereo_Water_distant); |
1187 DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); |
1215 DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); |
1188 ChangeDepth(RM, -cStereo_Water_distant); |
1216 ChangeDepth(RM, -cStereo_Water_distant); |
1189 DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48); |
1217 DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48); |
1190 ChangeDepth(RM, -cStereo_Water_distant); |
1218 ChangeDepth(RM, -cStereo_Water_distant); |
1531 t:= i mod 60; |
1559 t:= i mod 60; |
1532 s:= inttostr(t) + ':' + s; |
1560 s:= inttostr(t) + ':' + s; |
1533 if t < 10 then |
1561 if t < 10 then |
1534 s:= '0' + s; |
1562 s:= '0' + s; |
1535 s:= inttostr(i div 60) + ':' + s; |
1563 s:= inttostr(i div 60) + ':' + s; |
1536 |
1564 |
1537 |
1565 |
1538 tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); |
1566 tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); |
1539 tmpSurface:= doSurfaceConversion(tmpSurface); |
1567 tmpSurface:= doSurfaceConversion(tmpSurface); |
1540 FreeTexture(timeTexture); |
1568 FreeTexture(timeTexture); |
1541 timeTexture:= Surface2Tex(tmpSurface, false); |
1569 timeTexture:= Surface2Tex(tmpSurface, false); |
1542 SDL_FreeSurface(tmpSurface) |
1570 SDL_FreeSurface(tmpSurface) |
1637 SDL_FreeSurface(tmpSurface) |
1665 SDL_FreeSurface(tmpSurface) |
1638 end; |
1666 end; |
1639 DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); |
1667 DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); |
1640 |
1668 |
1641 // draw red circle |
1669 // draw red circle |
1642 glDisable(GL_TEXTURE_2D); |
1670 glDisable(GL_TEXTURE_2D); |
1643 Tint($FF, $00, $00, Byte(Round(127*(1 + sin(SDL_GetTicks()*0.007))))); |
1671 Tint($FF, $00, $00, Byte(Round(127*(1 + sin(SDL_GetTicks()*0.007))))); |
1644 glBegin(GL_POLYGON); |
1672 glBegin(GL_POLYGON); |
1645 for i:= 0 to 20 do |
1673 for i:= 0 to 20 do |
1646 glVertex2f(-(cScreenWidth shr 1) + 30 + sin(i*2*Pi/20)*10, 35 + cos(i*2*Pi/20)*10); |
1674 glVertex2f(-(cScreenWidth shr 1) + 30 + sin(i*2*Pi/20)*10, 35 + cos(i*2*Pi/20)*10); |
1647 glEnd(); |
1675 glEnd(); |
1893 if(CurrentHedgehog <> nil)then |
1921 if(CurrentHedgehog <> nil)then |
1894 if (Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0 then |
1922 if (Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0 then |
1895 begin |
1923 begin |
1896 utilityWidget.sprite:= sprTimerButton; |
1924 utilityWidget.sprite:= sprTimerButton; |
1897 animateWidget(@utilityWidget, true, true); |
1925 animateWidget(@utilityWidget, true, true); |
1898 end |
1926 end |
1899 else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then |
1927 else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then |
1900 begin |
1928 begin |
1901 utilityWidget.sprite:= sprTargetButton; |
1929 utilityWidget.sprite:= sprTargetButton; |
1902 animateWidget(@utilityWidget, true, true); |
1930 animateWidget(@utilityWidget, true, true); |
1903 end |
1931 end |