hedgewars/uWorld.pas
branchwebgl
changeset 8330 aaefa587e277
parent 8099 a7f02b902b6f
parent 8204 9a6030d96273
child 8444 75db7bb8dce8
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    58     , uTextures
    58     , uTextures
    59     , uRender
    59     , uRender
    60     , uCaptions
    60     , uCaptions
    61     , uCursor
    61     , uCursor
    62     , uCommands
    62     , uCommands
    63     , uMobile
    63 {$IFDEF USE_VIDEO_RECORDING}
    64 {$IFDEF USE_VIDEO_RECORDING}    
       
    65     , uVideoRec
    64     , uVideoRec
    66 {$ENDIF}    
    65 {$ENDIF}
    67 {$IFDEF GL2}
    66 {$IFDEF GL2}
    68     , uMatrix
    67     , uMatrix
    69 {$ENDIF}
    68 {$ENDIF}
    70     ;
    69     ;
    71 
    70 
    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
   221 procedure InitTouchInterface;
   246 procedure InitTouchInterface;
   222 begin
   247 begin
   223 {$IFDEF USE_TOUCH_INTERFACE}
   248 {$IFDEF USE_TOUCH_INTERFACE}
   224 
   249 
   225 //positioning of the buttons
   250 //positioning of the buttons
   226 buttonScale:= uMobile.getScreenDPI/cDefaultZoomLevel;
   251 buttonScale:= mobileRecord.getScreenDPI()/cDefaultZoomLevel;
   227 
   252 
   228 
   253 
   229 with JumpWidget do
   254 with JumpWidget do
   230     begin
   255     begin
   231     show:= true;
   256     show:= true;
   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);
   529     bShowAmmoMenu:= false;
   554     bShowAmmoMenu:= false;
   530     AMState:= AMHidden;
   555     AMState:= AMHidden;
   531     exit
   556     exit
   532     end;
   557     end;
   533 
   558 
   534 //Init the menu 
   559 //Init the menu
   535 if(AmmoMenuInvalidated) then 
   560 if(AmmoMenuInvalidated) then
   536     begin
   561     begin
   537     AmmoMenuInvalidated:= false;
   562     AmmoMenuInvalidated:= false;
   538     FreeTexture(AmmoMenuTex);
   563     FreeTexture(AmmoMenuTex);
   539     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   564     AmmoMenuTex:= GetAmmoMenuTexture(Ammo);
   540 
   565 
   586     else
   611     else
   587         if AMAnimState < 1 then
   612         if AMAnimState < 1 then
   588             begin
   613             begin
   589             AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState));
   614             AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState));
   590             AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState));
   615             AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState));
   591             if (AMAnimType and AMTypeMaskAlpha) <> 0 then 
   616             if (AMAnimType and AMTypeMaskAlpha) <> 0 then
   592                 Tint($FF, $ff, $ff, Round($ff * AMAnimState));
   617                 Tint($FF, $ff, $ff, Round($ff * AMAnimState));
   593             end
   618             end
   594         else
   619         else
   595             begin
   620             begin
   596             AMShiftX:= 0;
   621             AMShiftX:= 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;
   757 {$ENDIF}
   782 {$ENDIF}
   758 end;
   783 end;
   759 
   784 
   760 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   785 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   761 var VertexBuffer : array [0..3] of TVertex2f;
   786 var VertexBuffer : array [0..3] of TVertex2f;
   762     r		 : TSDL_Rect;
   787     r        : TSDL_Rect;
   763     lw, lh	 : GLfloat;
   788     lw, lh   : GLfloat;
   764 begin
   789 begin
   765 if SuddenDeathDmg then
   790 if SuddenDeathDmg then
   766     begin
   791     begin
   767     SDWaterColorArray[0].a := Alpha;
   792     SDWaterColorArray[0].a := Alpha;
   768     SDWaterColorArray[1].a := Alpha;
   793     SDWaterColorArray[1].a := Alpha;
   784 r.y:= OffsetY + WorldDy + cWaterLine;
   809 r.y:= OffsetY + WorldDy + cWaterLine;
   785 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
   810 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
   786     begin
   811     begin
   787         if r.y < 0 then
   812         if r.y < 0 then
   788             r.y:= 0;
   813             r.y:= 0;
   789  
   814 
   790         glDisable(GL_TEXTURE_2D);
   815         glDisable(GL_TEXTURE_2D);
   791         VertexBuffer[0].X:= -lw;
   816         VertexBuffer[0].X:= -lw;
   792         VertexBuffer[0].Y:= r.y;
   817         VertexBuffer[0].Y:= r.y;
   793         VertexBuffer[1].X:= lw;
   818         VertexBuffer[1].X:= lw;
   794         VertexBuffer[1].Y:= r.y;
   819         VertexBuffer[1].Y:= r.y;
   989     if cStereoMode = smNone then
  1014     if cStereoMode = smNone then
   990         begin
  1015         begin
   991         glClear(GL_COLOR_BUFFER_BIT);
  1016         glClear(GL_COLOR_BUFFER_BIT);
   992         DrawWorldStereo(Lag, rmDefault)
  1017         DrawWorldStereo(Lag, rmDefault)
   993         end
  1018         end
   994 {$IFNDEF S3D_DISABLED}
  1019 {$IFDEF USE_S3D_RENDERING}
   995     else if (cStereoMode = smAFR) then
  1020     else if (cStereoMode = smAFR) then
   996         begin
  1021         begin
   997         AFRToggle:= (not AFRToggle);
  1022         AFRToggle:= (not AFRToggle);
   998         glClear(GL_COLOR_BUFFER_BIT);
  1023         glClear(GL_COLOR_BUFFER_BIT);
   999         if AFRToggle then
  1024         if AFRToggle then
  1102 {$ENDIF}
  1127 {$ENDIF}
  1103 end;
  1128 end;
  1104 
  1129 
  1105 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1130 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1106 begin
  1131 begin
  1107 {$IFDEF S3D_DISABLED}
  1132 {$IFNDEF USE_S3D_RENDERING}
  1108     rm:= rm; d:= d; // avoid hint
  1133     rm:= rm; d:= d; // avoid hint
  1109     exit;
  1134     exit;
  1110 {$ELSE}
  1135 {$ELSE}
  1111     d:= d / 5;
  1136     d:= d / 5;
  1112     if rm = rmDefault then
  1137     if rm = rmDefault then
  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);
  1297     begin
  1325     begin
  1298     if ReadyTimeLeft <> 0 then
  1326     if ReadyTimeLeft <> 0 then
  1299         i:= Succ(Pred(ReadyTimeLeft) div 1000)
  1327         i:= Succ(Pred(ReadyTimeLeft) div 1000)
  1300     else
  1328     else
  1301         i:= Succ(Pred(TurnTimeLeft) div 1000);
  1329         i:= Succ(Pred(TurnTimeLeft) div 1000);
  1302    
  1330 
  1303     if i>99 then
  1331     if i>99 then
  1304         t:= 112
  1332         t:= 112
  1305     else if i>9 then
  1333     else if i>9 then
  1306         t:= 96
  1334         t:= 96
  1307     else
  1335     else
  1477     if (AMState = AMShowing) then
  1505     if (AMState = AMShowing) then
  1478         AMAnimStartTime:= RealTicks
  1506         AMAnimStartTime:= RealTicks
  1479     else
  1507     else
  1480         AMAnimStartTime:= RealTicks - (AMAnimDuration - (RealTicks - AMAnimStartTime));
  1508         AMAnimStartTime:= RealTicks - (AMAnimDuration - (RealTicks - AMAnimStartTime));
  1481     AMState:= AMHiding;
  1509     AMState:= AMHiding;
  1482     end; 
  1510     end;
  1483 
  1511 
  1484 if bShowAmmoMenu or (AMState = AMHiding) then
  1512 if bShowAmmoMenu or (AMState = AMHiding) then
  1485     ShowAmmoMenu;
  1513     ShowAmmoMenu;
  1486 
  1514 
  1487 // Cursor
  1515 // Cursor
  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();
  1746     {$ELSE}
  1774     {$ELSE}
  1747     amNumOffsetX:= 0;
  1775     amNumOffsetX:= 0;
  1748     {$ENDIF}
  1776     {$ENDIF}
  1749 
  1777 
  1750 {$ENDIF}
  1778 {$ENDIF}
  1751     if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left 
  1779     if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left
  1752         CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3;
  1780         CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3;
  1753     if CursorPoint.X > AmmoRect.x + AmmoRect.w - 3 then//check right
  1781     if CursorPoint.X > AmmoRect.x + AmmoRect.w - 3 then//check right
  1754         CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3;
  1782         CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3;
  1755     if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top
  1783     if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top
  1756         CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1;
  1784         CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1;
  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
  1917 begin
  1945 begin
  1918 with widget^ do
  1946 with widget^ do
  1919     begin
  1947     begin
  1920     show:= showWidget;
  1948     show:= showWidget;
  1921     if fade then fadeAnimStart:= RealTicks;
  1949     if fade then fadeAnimStart:= RealTicks;
  1922     
  1950 
  1923     with moveAnim do
  1951     with moveAnim do
  1924         begin
  1952         begin
  1925         animate:= true;
  1953         animate:= true;
  1926         startTime:= RealTicks;
  1954         startTime:= RealTicks;
  1927         source.x:= source.x xor target.x; //swap source <-> target
  1955         source.x:= source.x xor target.x; //swap source <-> target