hedgewars/uWorld.pas
changeset 14008 58e54e737279
parent 13967 9be2926890cd
child 14009 97e48a6c2535
equal deleted inserted replaced
14007:e9ab9639a1af 14008:58e54e737279
  1221 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1221 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1222 
  1222 
  1223 // note: offsetY is negative!
  1223 // note: offsetY is negative!
  1224 offsetY:= 10 *  Min(0, -145 - ScreenBottom); // TODO limit this in the other direction too
  1224 offsetY:= 10 *  Min(0, -145 - ScreenBottom); // TODO limit this in the other direction too
  1225 
  1225 
       
  1226 // Sky and horizont
  1226 if (cReducedQuality and rqNoBackground) = 0 then
  1227 if (cReducedQuality and rqNoBackground) = 0 then
  1227     begin
  1228     begin
  1228         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
  1229         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
  1229         SkyOffset:= offsetY div 35 + cWaveHeight;
  1230         SkyOffset:= offsetY div 35 + cWaveHeight;
  1230         HorizontOffset:= SkyOffset;
  1231         HorizontOffset:= SkyOffset;
  1313 if SuddenDeathDmg then
  1314 if SuddenDeathDmg then
  1314     DrawWater(SDWaterOpacity, 0, 0)
  1315     DrawWater(SDWaterOpacity, 0, 0)
  1315 else
  1316 else
  1316     DrawWater(WaterOpacity, 0, 0);
  1317     DrawWater(WaterOpacity, 0, 0);
  1317 
  1318 
  1318     // Waves
  1319 // Waves
  1319 ChangeDepth(RM, cStereo_Water_near);
  1320 ChangeDepth(RM, cStereo_Water_near);
  1320 DrawWaves( 1, 25 - WorldDx div 9, 0, 0, 12);
  1321 DrawWaves( 1, 25 - WorldDx div 9, 0, 0, 12);
  1321 
  1322 
  1322 if (cReducedQuality and rq2DWater) = 0 then
  1323 if (cReducedQuality and rq2DWater) = 0 then
  1323     begin
  1324     begin
  1324     //DrawWater(WaterOpacity, - offsetY div 40);
       
  1325     ChangeDepth(RM, cStereo_Water_near);
  1325     ChangeDepth(RM, cStereo_Water_near);
  1326     DrawWaves(-1, 50 + WorldDx div 6, - offsetY div 40, 23, 8);
  1326     DrawWaves(-1, 50 + WorldDx div 6, - offsetY div 40, 23, 8);
  1327     if SuddenDeathDmg then
  1327     if SuddenDeathDmg then
  1328         DrawWater(SDWaterOpacity, - offsetY div 20, 23)
  1328         DrawWater(SDWaterOpacity, - offsetY div 20, 23)
  1329     else
  1329     else
  1394         UnshiftWorld();
  1394         UnshiftWorld();
  1395         end;
  1395         end;
  1396 
  1396 
  1397     DrawVisualGears(3, false);
  1397     DrawVisualGears(3, false);
  1398 
  1398 
  1399 // Target
  1399 // Target (e.g. air attack, bee, ...)
  1400 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then
  1400 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then
  1401     begin
  1401     begin
  1402     with PHedgehog(CurrentHedgehog)^ do
  1402     with PHedgehog(CurrentHedgehog)^ do
  1403         begin
  1403         begin
  1404         if CurAmmoType = amBee then
  1404         if CurAmmoType = amBee then
  1438     UnshiftWorld();
  1438     UnshiftWorld();
  1439     end;
  1439     end;
  1440 
  1440 
  1441 RenderAttackBar();
  1441 RenderAttackBar();
  1442 
  1442 
       
  1443 // World edge
  1443 RenderWorldEdge();
  1444 RenderWorldEdge();
  1444 
  1445 
  1445 // this scale is used to keep the various widgets at the same dimension at all zoom levels
  1446 // This scale is used to keep the various widgets at the same dimension at all zoom levels
  1446 SetScale(cDefaultZoomLevel);
  1447 SetScale(cDefaultZoomLevel);
  1447 
  1448 
  1448 // cinematic effects
  1449 // Cinematic Mode: Effects
  1449 if CinematicScript or (InCinematicMode and autoCameraOn
  1450 if CinematicScript or (InCinematicMode and autoCameraOn
  1450     and ((CurrentHedgehog = nil) or CurrentHedgehog^.Team^.ExtDriven
  1451     and ((CurrentHedgehog = nil) or CurrentHedgehog^.Team^.ExtDriven
  1451     or (CurrentHedgehog^.BotLevel <> 0) or (GameType = gmtDemo))) then
  1452     or (CurrentHedgehog^.BotLevel <> 0) or (GameType = gmtDemo))) then
  1452     begin
  1453     begin
  1453     if CinematicSteps < 300 then
  1454     if CinematicSteps < 300 then
  1462     dec(CinematicSteps, Lag);
  1463     dec(CinematicSteps, Lag);
  1463     if CinematicSteps < 0 then
  1464     if CinematicSteps < 0 then
  1464         CinematicSteps:= 0;
  1465         CinematicSteps:= 0;
  1465     end;
  1466     end;
  1466 
  1467 
  1467 // render black bars
  1468 // Cinematic Mode: Render black bars
  1468 if CinematicSteps > 0 then
  1469 if CinematicSteps > 0 then
  1469     begin
  1470     begin
  1470     r.x:= ViewLeftX;
  1471     r.x:= ViewLeftX;
  1471     r.w:= ViewWidth;
  1472     r.w:= ViewWidth;
  1472     r.y:= ViewTopY;
  1473     r.y:= ViewTopY;
  1534 DrawScreenWidget(@AMWidget);
  1535 DrawScreenWidget(@AMWidget);
  1535 DrawScreenWidget(@pauseButton);
  1536 DrawScreenWidget(@pauseButton);
  1536 DrawScreenWidget(@utilityWidget);
  1537 DrawScreenWidget(@utilityWidget);
  1537 {$ENDIF}
  1538 {$ENDIF}
  1538 
  1539 
       
  1540 // Team bars
  1539 if UIDisplay = uiAll then
  1541 if UIDisplay = uiAll then
  1540     RenderTeamsHealth;
  1542     RenderTeamsHealth;
  1541 
  1543 
  1542 // Lag alert
  1544 // Lag alert
  1543 if isInLag then
  1545 if isInLag then
  1626 
  1628 
  1627 // Chat
  1629 // Chat
  1628 DrawChat;
  1630 DrawChat;
  1629 
  1631 
  1630 
  1632 
  1631 // various captions
  1633 // Centered status/menu messages (synchronizing, auto skip, pause, etc.)
  1632 if fastUntilLag then
  1634 if fastUntilLag then
  1633     DrawTextureCentered(0, (cScreenHeight shr 1), SyncTexture)
  1635     DrawTextureCentered(0, (cScreenHeight shr 1), SyncTexture)
  1634 else if isAFK then
  1636 else if isAFK then
  1635     DrawTextureCentered(0, (cScreenHeight shr 1), AFKTexture)
  1637     DrawTextureCentered(0, (cScreenHeight shr 1), AFKTexture)
  1636 else if isPaused then
  1638 else if isPaused then
  1637     DrawTextureCentered(0, (cScreenHeight shr 1), PauseTexture);
  1639     DrawTextureCentered(0, (cScreenHeight shr 1), PauseTexture);
       
  1640 
       
  1641 // Mission panel
  1638 if not isFirstFrame and (missionTimer <> 0) or isShowMission or isPaused or fastUntilLag or (GameState = gsConfirm) then
  1642 if not isFirstFrame and (missionTimer <> 0) or isShowMission or isPaused or fastUntilLag or (GameState = gsConfirm) then
  1639     begin
  1643     begin
  1640     if (ReadyTimeLeft = 0) and (missionTimer > 0) then
  1644     if (ReadyTimeLeft = 0) and (missionTimer > 0) then
  1641         dec(missionTimer, Lag);
  1645         dec(missionTimer, Lag);
  1642     if missionTimer < 0 then
  1646     if missionTimer < 0 then
  1645         DrawTextureCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex);
  1649         DrawTextureCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex);
  1646     end;
  1650     end;
  1647 if missionTimer = 0 then
  1651 if missionTimer = 0 then
  1648     isForceMission := false;
  1652     isForceMission := false;
  1649 
  1653 
  1650 // fps
  1654 // FPS and demo replay time
  1651 {$IFDEF USE_TOUCH_INTERFACE}
  1655 {$IFDEF USE_TOUCH_INTERFACE}
  1652 offsetX:= pauseButton.frame.y + pauseButton.frame.h + 12;
  1656 offsetX:= pauseButton.frame.y + pauseButton.frame.h + 12;
  1653 {$ELSE}
  1657 {$ELSE}
  1654 offsetX:= 10;
  1658 offsetX:= 10;
  1655 {$ENDIF}
  1659 {$ENDIF}
  1658     begin
  1662     begin
  1659     inc(Frames);
  1663     inc(Frames);
  1660 
  1664 
  1661     if cShowFPS or (GameType = gmtDemo) then
  1665     if cShowFPS or (GameType = gmtDemo) then
  1662         inc(CountTicks, Lag);
  1666         inc(CountTicks, Lag);
       
  1667 
       
  1668     // Demo replay time
  1663     if (GameType = gmtDemo) and (CountTicks >= 1000) then
  1669     if (GameType = gmtDemo) and (CountTicks >= 1000) then
  1664         begin
  1670         begin
  1665         i:= GameTicks div 1000;
  1671         i:= GameTicks div 1000;
  1666         t:= i mod 60;
  1672         t:= i mod 60;
  1667         s:= inttostr(t);
  1673         s:= inttostr(t);
  1683         end;
  1689         end;
  1684 
  1690 
  1685     if timeTexture <> nil then
  1691     if timeTexture <> nil then
  1686         DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
  1692         DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
  1687 
  1693 
       
  1694     // FPS counter
  1688     if cShowFPS then
  1695     if cShowFPS then
  1689         begin
  1696         begin
  1690         if CountTicks >= 1000 then
  1697         if CountTicks >= 1000 then
  1691             begin
  1698             begin
  1692             FPS:= Frames;
  1699             FPS:= Frames;
  1702         if fpsTexture <> nil then
  1709         if fpsTexture <> nil then
  1703             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1710             DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
  1704         end;
  1711         end;
  1705 end;
  1712 end;
  1706 
  1713 
  1707 
  1714 // Quit Y/N question
  1708 if GameState = gsConfirm then
  1715 if GameState = gsConfirm then
  1709     DrawTextureCentered(0, (cScreenHeight shr 1)-40, ConfirmTexture);
  1716     DrawTextureCentered(0, (cScreenHeight shr 1)-40, ConfirmTexture);
  1710 
  1717 
  1711 if ScreenFade <> sfNone then
  1718 if ScreenFade <> sfNone then
  1712     begin
  1719     begin
  1737             ScreenFade:= sfNone
  1744             ScreenFade:= sfNone
  1738         end
  1745         end
  1739     end;
  1746     end;
  1740 
  1747 
  1741 {$IFDEF USE_VIDEO_RECORDING}
  1748 {$IFDEF USE_VIDEO_RECORDING}
  1742 // during video prerecording draw red blinking circle and text 'rec'
  1749 // During video prerecording draw red blinking circle and text 'rec'
  1743 if flagPrerecording then
  1750 if flagPrerecording then
  1744     begin
  1751     begin
  1745     if recTexture = nil then
  1752     if recTexture = nil then
  1746         begin
  1753         begin
  1747         s:= 'rec';
  1754         s:= 'rec';
  1751         recTexture:= Surface2Tex(tmpSurface, false);
  1758         recTexture:= Surface2Tex(tmpSurface, false);
  1752         SDL_FreeSurface(tmpSurface)
  1759         SDL_FreeSurface(tmpSurface)
  1753         end;
  1760         end;
  1754     DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture);
  1761     DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture);
  1755 
  1762 
  1756     //a:= Byte(Round(127*(1 + sin(RealTicks*0.007))));
       
  1757     a:= Byte(min(255, abs(-255 + ((RealTicks div 2) and 511))));
  1763     a:= Byte(min(255, abs(-255 + ((RealTicks div 2) and 511))));
  1758 
  1764 
  1759     // draw red circle
  1765     // draw red circle
  1760     DrawCircleFilled(-(cScreenWidth shr 1) + 30, 35, 10, $FF, $00, $00, a);
  1766     DrawCircleFilled(-(cScreenWidth shr 1) + 30, 35, 10, $FF, $00, $00, a);
  1761     end;
  1767     end;
  1786                     end;
  1792                     end;
  1787                 DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1793                 DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1788                 Untint();
  1794                 Untint();
  1789                 end;
  1795                 end;
  1790             end;
  1796             end;
  1791     //DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
       
  1792     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);
  1797     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);
  1793     end;
  1798     end;
  1794 
  1799 
  1795 // debug stuff
  1800 // debug stuff
  1796 if cViewLimitsDebug then
  1801 if cViewLimitsDebug then