hedgewars/uWorld.pas
changeset 1120 eb5a9f86f9c6
parent 1066 1f1b3686a2b0
child 1125 87937426031b
equal deleted inserted replaced
1119:be9700b424b2 1120:eb5a9f86f9c6
    50                    EndTime: LongWord;
    50                    EndTime: LongWord;
    51                    end;
    51                    end;
    52 
    52 
    53 var cWaterSprCount: LongInt;
    53 var cWaterSprCount: LongInt;
    54     Captions: array[TCapGroup] of TCaptionStr;
    54     Captions: array[TCapGroup] of TCaptionStr;
    55     AMxLeft, AMxCurr, SlotsNum: LongInt;
    55     AMxShift, SlotsNum: LongInt;
    56     tmpSurface: PSDL_Surface;
    56     tmpSurface: PSDL_Surface;
    57     fpsTexture: PTexture = nil;
    57     fpsTexture: PTexture = nil;
    58 
    58 
    59 procedure InitWorld;
    59 procedure InitWorld;
    60 begin
    60 begin
    63 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    63 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    64 prevPoint.X:= cScreenWidth div 2;
    64 prevPoint.X:= cScreenWidth div 2;
    65 prevPoint.Y:= cScreenHeight div 2;
    65 prevPoint.Y:= cScreenHeight div 2;
    66 WorldDx:=  - 1024 + cScreenWidth div 2;
    66 WorldDx:=  - 1024 + cScreenWidth div 2;
    67 WorldDy:=  - 512 + cScreenHeight div 2;
    67 WorldDy:=  - 512 + cScreenHeight div 2;
    68 AMxLeft:= cScreenWidth - 210;
    68 AMxShift:= 210
    69 AMxCurr:= cScreenWidth
       
    70 end;
    69 end;
    71 
    70 
    72 procedure ShowAmmoMenu;
    71 procedure ShowAmmoMenu;
    73 const MENUSPEED = 15;
    72 const MENUSPEED = 15;
    74 var x, y, i, t, l: LongInt;
    73 var x, y, i, t, l: LongInt;
    75     Slot, Pos: LongInt;
    74     Slot, Pos: LongInt;
    76 begin
    75 begin
    77 if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
    76 if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
    78 if bShowAmmoMenu then
    77 if bShowAmmoMenu then
    79    begin
    78    begin
    80    if AMxCurr = cScreenWidth then prevPoint.X:= 0;
    79    if AMxShift = 210 then prevPoint.X:= 0;
    81    if AMxCurr > AMxLeft then dec(AMxCurr, MENUSPEED);
    80    if AMxShift > 0 then dec(AMxShift, MENUSPEED);
    82    end else
    81    end else
    83    begin
    82    begin
    84    if AMxCurr = AMxLeft then
    83    if AMxShift = 0 then
    85       begin
    84       begin
    86       CursorPoint.X:= cScreenWidth div 2;
    85       CursorPoint.X:= cScreenWidth div 2;
    87       CursorPoint.Y:= cScreenHeight div 2;
    86       CursorPoint.Y:= cScreenHeight div 2;
    88       prevPoint:= CursorPoint;
    87       prevPoint:= CursorPoint;
    89       SDL_WarpMouse(CursorPoint.X, CursorPoint.Y)
    88       SDL_WarpMouse(CursorPoint.X, CursorPoint.Y)
    90       end;
    89       end;
    91    if AMxCurr < cScreenWidth then inc(AMxCurr, MENUSPEED);
    90    if AMxShift < 210 then inc(AMxShift, MENUSPEED);
    92    end;
    91    end;
    93 
    92 
    94 if CurrentTeam = nil then exit;
    93 if CurrentTeam = nil then exit;
    95 Slot:= 0;
    94 Slot:= 0;
    96 Pos:= -1;
    95 Pos:= -1;
    97 with CurrentHedgehog^ do
    96 with CurrentHedgehog^ do
    98      begin
    97      begin
    99      if Ammo = nil then exit;
    98      if Ammo = nil then exit;
   100      SlotsNum:= 0;
    99      SlotsNum:= 0;
   101      x:= AMxCurr;
   100      x:= cScreenWidth - 210 + AMxShift;
   102      y:= cScreenHeight - 40;
   101      y:= cScreenHeight - 40;
   103      dec(y);
   102      dec(y);
   104      DrawSprite(sprAMBorders, x, y, 0);
   103      DrawSprite(sprAMBorders, x, y, 0);
   105      dec(y);
   104      dec(y);
   106      DrawSprite(sprAMBorders, x, y, 1);
   105      DrawSprite(sprAMBorders, x, y, 1);
   135      DrawSprite(sprAMBorders, x, y, 0);
   134      DrawSprite(sprAMBorders, x, y, 0);
   136 
   135 
   137      if (Pos >= 0) then
   136      if (Pos >= 0) then
   138         if Ammo^[Slot, Pos].Count > 0 then
   137         if Ammo^[Slot, Pos].Count > 0 then
   139            begin
   138            begin
   140            DrawTexture(AMxCurr + 10, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   139            DrawTexture(cScreenWidth - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   141            if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   140            if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   142               DrawTexture(AMxCurr + 175, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   141               DrawTexture(cScreenWidth + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   143            if bSelected then
   142            if bSelected then
   144               begin
   143               begin
   145               bShowAmmoMenu:= false;
   144               bShowAmmoMenu:= false;
   146               SetWeapon(Ammo^[Slot, Pos].AmmoType);
   145               SetWeapon(Ammo^[Slot, Pos].AmmoType);
   147               bSelected:= false;
   146               bSelected:= false;
   149               end;
   148               end;
   150            end;
   149            end;
   151      end;
   150      end;
   152 
   151 
   153 bSelected:= false;
   152 bSelected:= false;
   154 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8)
   153 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8)
   155 end;
   154 end;
   156 
   155 
   157 procedure MoveCamera; forward;
   156 procedure MoveCamera; forward;
   158 
   157 
   159 procedure DrawWorld(Lag: LongInt);
   158 procedure DrawWorld(Lag: LongInt);
   290 
   289 
   291 // Teams Healths
   290 // Teams Healths
   292 for t:= 0 to Pred(TeamsCount) do
   291 for t:= 0 to Pred(TeamsCount) do
   293    with TeamsArray[t]^ do
   292    with TeamsArray[t]^ do
   294       begin
   293       begin
   295       DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, DrawHealthY, NameTagTex);
   294       DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, cScreenHeight + DrawHealthY, NameTagTex);
   296 
   295 
   297       r.x:= 0;
   296       r.x:= 0;
   298       r.y:= 0;
   297       r.y:= 0;
   299       r.w:= 2 + TeamHealthBarWidth;
   298       r.w:= 2 + TeamHealthBarWidth;
   300       r.h:= HealthTex^.h;
   299       r.h:= HealthTex^.h;
   301 
   300 
   302       DrawFromRect(cScreenWidth div 2,
   301       DrawFromRect(cScreenWidth div 2,
   303                         DrawHealthY,
   302                         cScreenHeight + DrawHealthY,
   304                         @r, HealthTex);
   303                         @r, HealthTex);
   305 
   304 
   306       inc(r.x, cTeamHealthWidth + 2);
   305       inc(r.x, cTeamHealthWidth + 2);
   307       r.w:= 3;
   306       r.w:= 3;
   308 
   307 
   309       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   308       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   310                         DrawHealthY,
   309                         cScreenHeight + DrawHealthY,
   311                         @r, HealthTex);
   310                         @r, HealthTex);
   312       end;
   311       end;
   313 
   312 
   314 // Lag alert
   313 // Lag alert
   315 if isInLag then DrawSprite(sprLag, 32, 32, (RealTicks shr 7) mod 12);
   314 if isInLag then DrawSprite(sprLag, 32, 32, (RealTicks shr 7) mod 12);
   336    r.h:= 13;
   335    r.h:= 13;
   337    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   336    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   338    end;
   337    end;
   339 
   338 
   340 // AmmoMenu
   339 // AmmoMenu
   341 if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu;
   340 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   342 
   341 
   343 DrawChat;
   342 DrawChat;
   344 
   343 
   345 // Cursor
   344 // Cursor
   346 if isCursorVisible then
   345 if isCursorVisible then
   424       CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8
   423       CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8
   425       end;
   424       end;
   426 
   425 
   427 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;
   426 if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;
   428 
   427 
   429 if AMxCurr < cScreenWidth then
   428 if AMxShift < 210 then
   430    begin
   429    begin
   431    if CursorPoint.X < AMxCurr + 35 then CursorPoint.X:= AMxCurr + 35;
   430    if CursorPoint.X < cScreenWidth + AMxShift - 175 then CursorPoint.X:= cScreenWidth + AMxShift - 175;
   432    if CursorPoint.X > AMxCurr + 200 then CursorPoint.X:= AMxCurr + 200;
   431    if CursorPoint.X > cScreenWidth + AMxShift - 10 then CursorPoint.X:= cScreenWidth + AMxShift - 10;
   433    if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33;
   432    if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33;
   434    if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76;
   433    if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76;
   435    prevPoint:= CursorPoint;
   434    prevPoint:= CursorPoint;
   436    if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
   435    if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
   437    exit
   436    exit