hedgewars/uWorld.pas
branchhedgeroid
changeset 6023 a28be05b20bc
parent 5941 db4751cb4f53
parent 6016 85410eef7ba4
child 6224 42b256eca362
equal deleted inserted replaced
5943:5b2b86a37089 6023:a28be05b20bc
    29 procedure InitWorld;
    29 procedure InitWorld;
    30 procedure DrawWorld(Lag: LongInt);
    30 procedure DrawWorld(Lag: LongInt);
    31 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
    31 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
    32 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    32 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    33 procedure HideMission;
    33 procedure HideMission;
    34 procedure ShakeCamera(amount: LongWord);
    34 procedure ShakeCamera(amount: LongInt);
    35 procedure InitCameraBorders;
    35 procedure InitCameraBorders;
    36 procedure MoveCamera;
    36 procedure MoveCamera;
    37 procedure onFocusStateChanged;
    37 procedure onFocusStateChanged;
    38 
    38 
    39 implementation
    39 implementation
    52     uUtils,
    52     uUtils,
    53     uTextures,
    53     uTextures,
    54     uRender,
    54     uRender,
    55     uCaptions,
    55     uCaptions,
    56     uCursor,
    56     uCursor,
    57     uCommands
    57     uCommands,
       
    58     uMobile
    58     ;
    59     ;
    59 
    60 
    60 var cWaveWidth, cWaveHeight: LongInt;
    61 var cWaveWidth, cWaveHeight: LongInt;
    61     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    62     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    62     tmpSurface: PSDL_Surface;
    63     tmpSurface: PSDL_Surface;
   916 {$IFDEF ANDROID}
   917 {$IFDEF ANDROID}
   917 // Draw buttons Related to the Touch interface
   918 // Draw buttons Related to the Touch interface
   918 DrawTexture(Round(-cScreenWidth*0.5 + cScreenHeight*0.02),Round((cScreenHeight*0.98)-(spritesData[sprFireButton].Height*0.4) ),spritesData[sprFireButton].Texture, 0.4);
   919 DrawTexture(Round(-cScreenWidth*0.5 + cScreenHeight*0.02),Round((cScreenHeight*0.98)-(spritesData[sprFireButton].Height*0.4) ),spritesData[sprFireButton].Texture, 0.4);
   919 {$ENDIF}
   920 {$ENDIF}
   920 // Teams Healths
   921 // Teams Healths
   921 if TeamsCount * 20 > cScreenHeight div 7 then  // take up less screen on small displays
   922 if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
   922     begin
   923     begin
   923     SetScale(1.5);
   924     SetScale(1.5);
   924     smallScreenOffset:= cScreenHeight div 6;
   925     smallScreenOffset:= cScreenHeight div 6;
   925     if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80);
   926     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80);
   926     end
   927     end
   927 else smallScreenOffset:= 0;
   928 else smallScreenOffset:= 0;
   928 for t:= 0 to Pred(TeamsCount) do
   929 for t:= 0 to Pred(TeamsCount) do
   929    with TeamsArray[t]^ do
   930    with TeamsArray[t]^ do
   930       begin
   931       begin
   959 
   960 
   960       // if highlighted, draw flag and other contents again to keep their colors
   961       // if highlighted, draw flag and other contents again to keep their colors
   961       // this approach should be faster than drawing all borders one by one tinted or not
   962       // this approach should be faster than drawing all borders one by one tinted or not
   962       if highlight then
   963       if highlight then
   963          begin
   964          begin
   964          if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80)
   965          if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80)
   965          else Tint($FF, $FF, $FF, $FF);
   966          else Tint($FF, $FF, $FF, $FF);
   966 
   967 
   967          // draw name
   968          // draw name
   968          r.x:= 2;
   969          r.x:= 2;
   969          r.y:= 2;
   970          r.y:= 2;
   981          end;
   982          end;
   982       end;
   983       end;
   983 if smallScreenOffset <> 0 then
   984 if smallScreenOffset <> 0 then
   984     begin
   985     begin
   985     SetScale(cDefaultZoomLevel);
   986     SetScale(cDefaultZoomLevel);
   986     if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$FF);
   987     if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$FF);
   987     end;
   988     end;
   988 
   989 
   989 // Lag alert
   990 // Lag alert
   990 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
   991 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
   991 
   992 
  1198         exit
  1199         exit
  1199     end
  1200     end
  1200     else
  1201     else
  1201     begin
  1202     begin
  1202         CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx) div 8;
  1203         CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx) div 8;
  1203         CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y)+ hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1204         if isPhone() then
       
  1205             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8
       
  1206         else
       
  1207             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1204     end;
  1208     end;
  1205 
  1209 
  1206 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1210 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1207 if WorldDy < wdy then WorldDy:= wdy;
  1211 if WorldDy < wdy then WorldDy:= wdy;
  1208 
  1212 
  1314 begin
  1318 begin
  1315     missionTimer:= 0;
  1319     missionTimer:= 0;
  1316     if missionTex <> nil then FreeTexture(missionTex);
  1320     if missionTex <> nil then FreeTexture(missionTex);
  1317 end;
  1321 end;
  1318 
  1322 
  1319 procedure ShakeCamera(amount: LongWord);
  1323 procedure ShakeCamera(amount: LongInt);
  1320 begin
  1324 begin
  1321     if isCursorVisible then exit;
  1325     if isCursorVisible then exit;
  1322     amount:= Max(1, round(amount*zoom/2));
  1326     amount:= Max(1, round(amount*zoom/2));
  1323     WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
  1327     WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
  1324     WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));
  1328     WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));