hedgewars/uWorld.pas
changeset 6606 fb6163ff4ebf
parent 6603 ef9ed71e3cf7
child 6607 ae523c0e8e54
equal deleted inserted replaced
6605:800d4c029d53 6606:fb6163ff4ebf
    59     uCommands,
    59     uCommands,
    60     uMobile
    60     uMobile
    61     ;
    61     ;
    62 
    62 
    63 var cWaveWidth, cWaveHeight: LongInt;
    63 var cWaveWidth, cWaveHeight: LongInt;
    64     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    64     AMSlotSize, AMxOffset, AMyOffset, AMShiftTarget, AMShift, SlotsNum: LongInt;
    65     tmpSurface: PSDL_Surface;
    65     tmpSurface: PSDL_Surface;
    66     fpsTexture: PTexture;
    66     fpsTexture: PTexture;
    67     timeTexture: PTexture;
    67     timeTexture: PTexture;
    68     FPS: Longword;
    68     FPS: Longword;
    69     CountTicks: Longword;
    69     CountTicks: Longword;
   197 AMSlotSize:= 33;
   197 AMSlotSize:= 33;
   198 {$IFDEF MOBILE}
   198 {$IFDEF MOBILE}
   199 if isPhone() then
   199 if isPhone() then
   200     begin
   200     begin
   201     AMxOffset:= -30 + cScreenHeight div 2;
   201     AMxOffset:= -30 + cScreenHeight div 2;
   202     AMyOffset:= 10;
   202     AMyOffset:= AMSlotSize;
   203     end
   203     end
   204 else
   204 else
   205     begin
   205     begin
   206     AMxOffset:= AMSlotSize + cScreenHeight div 2;
   206     AMxOffset:= 0;
   207     AMyOffset:= -10 + cScreenWidth div 3;
   207     AMyOffset:= AMSlotSize * 2;
   208     end;
   208     end;
   209 AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset;
   209 //aligns it to the bottom of the screen, minus the border
       
   210 AMShiftTarget:= ((cMaxSlotAmmoIndex + 1) * AMSlotSize) + AMyOffset;
       
   211 AMShift:= AMShiftTarget;
   210 {$ELSE}
   212 {$ELSE}
   211 AMxOffset:= 10;
   213 AMxOffset:= 10;
   212 AMyOffset:= 60;
   214 AMyOffset:= 60;
   213 AMWidth:= (cMaxSlotAmmoIndex + 2) * AMSlotSize + AMxOffset;
   215 AMShiftTarget:= (cMaxSlotAmmoIndex + 2) * AMSlotSize + AMxOffset;
       
   216 AMShift:= AMShiftTarget;
   214 {$ENDIF}
   217 {$ENDIF}
   215 AMxShift:= AMWidth;
       
   216 SkyOffset:= 0;
   218 SkyOffset:= 0;
   217 HorizontOffset:= 0;
   219 HorizontOffset:= 0;
   218 end;
   220 end;
   219 
   221 
   220 procedure InitCameraBorders;
   222 procedure InitCameraBorders;
   246 
   248 
   247     if bShowAmmoMenu then
   249     if bShowAmmoMenu then
   248     // show ammo menu
   250     // show ammo menu
   249         begin
   251         begin
   250         FollowGear:= nil;
   252         FollowGear:= nil;
   251         if AMxShift = AMWidth then
   253         if AMShift = AMShiftTarget then
       
   254 {$IFDEF MOBILE}
       
   255             prevPoint.Y:= 0;
       
   256 {$ELSE}
   252             prevPoint.X:= 0;
   257             prevPoint.X:= 0;
       
   258 {$ENDIF}
   253         if (cReducedQuality and rqSlowMenu) <> 0 then
   259         if (cReducedQuality and rqSlowMenu) <> 0 then
   254             AMxShift:= 0
   260             AMShift:= 0
   255         else
   261         else
   256             if AMxShift > MENUSPEED then
   262             if AMShift > MENUSPEED then
   257                 dec(AMxShift, MENUSPEED)
   263                 dec(AMShift, MENUSPEED)
   258             else
   264             else
   259                 AMxShift:= 0;
   265                 AMShift:= 0;
   260         end
   266         end
   261     else
   267     else
   262     // hide ammo menu
   268     // hide ammo menu
   263         begin
   269         begin
   264         if AMxShift = 0 then
   270         if AMShift = 0 then
   265             begin
   271             begin
   266             CursorPoint.X:= cScreenWidth shr 1;
   272             CursorPoint.X:= cScreenWidth shr 1;
   267             CursorPoint.Y:= cScreenHeight shr 1;
   273             CursorPoint.Y:= cScreenHeight shr 1;
   268             prevPoint:= CursorPoint;
   274             prevPoint:= CursorPoint;
   269             end;
   275             end;
   270         if (cReducedQuality and rqSlowMenu) <> 0 then
   276         if (cReducedQuality and rqSlowMenu) <> 0 then
   271             AMxShift:= AMWidth+2
   277             AMShift:= AMShiftTarget+2
   272         else
   278         else
   273             if AMxShift < (AMWidth - MENUSPEED) then
   279             if AMShift < (AMShiftTarget - MENUSPEED) then
   274                 inc(AMxShift, MENUSPEED)
   280                 inc(AMShift, MENUSPEED)
   275             else
   281             else
   276                 AMxShift:= AMWidth;
   282                 AMShift:= AMShiftTarget;
   277         end;
   283         end;
   278 
   284 
   279     // give the assigned ammo to hedgehog
   285     // give the assigned ammo to hedgehog
   280     Ammo:= nil;
   286     Ammo:= nil;
   281     if (CurrentTeam <> nil) and (CurrentHedgehog <> nil)
   287     if (CurrentTeam <> nil) and (CurrentHedgehog <> nil)
   288         begin
   294         begin
   289         bShowAmmoMenu:= false;
   295         bShowAmmoMenu:= false;
   290         exit
   296         exit
   291         end;
   297         end;
   292     SlotsNum:= 0;
   298     SlotsNum:= 0;
   293     x:= (cScreenWidth shr 1) - AMWidth + AMxShift;
       
   294 
   299 
   295 {$IFDEF MOBILE}
   300 {$IFDEF MOBILE}
   296     Slot:= cMaxSlotIndex;
   301     Slot:= cMaxSlotIndex;
   297     x:= x - cOffsetY;
   302 
   298     y:= AMyOffset;
   303     for i:= 0 to cMaxSlotIndex do
   299     dec(y, BORDERSIZE);
   304         if((i = 0) and (Ammo^[i,1].Count > 0)) or ((i <> 0) and (Ammo^[i,0].Count > 0)) then
   300     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   305             inc(SlotsNum);
       
   306 
       
   307     x:= AMxOffset - ((SlotsNum * AMSlotSize) shr 1);
       
   308     y:= cScreenHeight - AMShiftTarget + AMShift;
       
   309     dec(x, BORDERSIZE);
       
   310     DrawSprite(sprAMCorners, x, y - BORDERSIZE, 0);//top left corner
   301     for i:= 0 to cMaxSlotAmmoIndex do
   311     for i:= 0 to cMaxSlotAmmoIndex do
   302         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   312         DrawSprite(sprAMBorderVertical, x, y + i * AMSlotSize, 0);
   303     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   313     DrawSprite(sprAMCorners, x, y + ((cMaxSlotAmmoIndex+1) * AMSlotSize) , 2);
   304     inc(y, BORDERSIZE);
   314     inc(x, BORDERSIZE);
   305 
   315 
   306     for i:= 0 to cMaxSlotIndex do
   316     for i:= 0 to cMaxSlotIndex do
   307         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   317         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   308             begin
   318             begin
   309             if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then
   319             if (CursorPoint.X >= x) and (CursorPoint.X <= x + AMSlotSize) then
   310                 Slot:= i;
   320                 Slot:= i;
   311             inc(SlotsNum);
   321             DrawSprite(sprAMBorderHorizontal, x, y - BORDERSIZE, 0);
   312             DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
       
   313             t:= 0;
       
   314             g:= 0;
   322             g:= 0;
   315             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   323             for t:=0 to cMaxSlotAmmoIndex do
   316                 begin
   324                 begin
   317                 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
   325                 DrawSprite(sprAMSlot, x, y + t * AMSlotSize, 1);
   318                 if (Ammo^[i, t].AmmoType <> amNothing) then
   326                 if (Ammo^[i, t].Count > 0) then
   319                     begin
   327                     begin
   320                     STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   328                     if (Ammo^[i, t].AmmoType <> amNothing) then
   321 
       
   322                     if STurns >= 0 then
       
   323                         begin
   329                         begin
   324                         DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   330                         STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   325                         if STurns < 100 then
   331 
   326                             DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns);
   332                         if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining
   327                         end
   333                             begin
   328                     else
   334                             DrawSprite(sprAMAmmosBW, x, y + (g * AMSlotSize) + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   329                         DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   335                             if STurns < 100 then
   330                     if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and
   336                                 DrawSprite(sprTurnsLeft, x + AMSlotSize-16, y + (g + 1) * AMSlotSize-16, STurns);
   331                        (CursorPoint.X <= x + (g + 1) * AMSlotSize) then
   337                             end
   332                         begin
   338                         else //draw colored version
   333                         if (STurns < 0) then
   339                             DrawSprite(sprAMAmmos, x, y + (g * AMSlotSize) + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   334                             DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0);
   340                         if (Slot = i) and (CursorPoint.Y <= (cScreenHeight - y) - (g * AMSlotSize)) and
   335                         Pos:= t;
   341                            (CursorPoint.Y >= (cScreenHeight - y) - ((g+1) * AMSlotSize)) then
       
   342                             begin
       
   343                             if (STurns < 0) then
       
   344                                 DrawSprite(sprAMSlot, x, y + (g * AMSlotSize), 0);
       
   345                             Pos:= t;
       
   346                             end;
       
   347                         inc(g);
   336                         end;
   348                         end;
   337                     inc(g)
       
   338                     end;
   349                     end;
   339                 inc(t)
       
   340                 end;
   350                 end;
   341             for g:= g to cMaxSlotAmmoIndex do
   351             DrawSprite(sprAMBorderHorizontal, x, y + ((cMaxSlotAmmoIndex+1) * AMSlotSize), 1);
   342                 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
   352             inc(x, AMSlotSize);
   343             DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
       
   344             inc(y, AMSlotSize);
       
   345             end;
   353             end;
   346 
   354 
   347     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   355     DrawSprite(sprAMCorners, x, y + ((cMaxSlotAmmoIndex+1) * AMSlotSize), 3); //bottom right corner
       
   356     DrawSprite(sprAMCorners, x - BORDERSIZE, y + (AMSlotSize * cMaxSlotAmmoIndex), 1);//top right  corner
       
   357 
   348     for i:= 0 to cMaxSlotAmmoIndex do
   358     for i:= 0 to cMaxSlotAmmoIndex do
   349         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   359         DrawSprite(sprAMBorderVertical, x,y + i * AMSlotSize, 1);
   350     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
       
   351 {$ELSE}
   360 {$ELSE}
   352     Slot:= 0;
   361     Slot:= 0;
       
   362     x:= (cScreenWidth shr 1) - AMShiftTarget + AMShift;
   353     y:= cScreenHeight - AMyOffset;
   363     y:= cScreenHeight - AMyOffset;
   354     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   364     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
   355     for i:= 0 to cMaxSlotAmmoIndex + 1 do
   365     for i:= 0 to cMaxSlotAmmoIndex + 1 do
   356         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   366         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
   357     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
   367     DrawSprite(sprAMCorners, x + AMShiftTarget - AMxOffset, y, 3);
   358     dec(y, AMSlotSize);
   368     dec(y, AMSlotSize);
   359     DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   369     DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
   360     for i:= 0 to cMaxSlotAmmoIndex do
   370     for i:= 0 to cMaxSlotAmmoIndex do
   361         DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
   371         DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
   362     DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
   372     DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
   363     DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   373     DrawSprite(sprAMBorderVertical, x + AMShiftTarget - AMxOffset, y, 1);
   364 
   374 
   365     for i:= cMaxSlotIndex downto 0 do
   375     for i:= cMaxSlotIndex downto 0 do
   366         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   376         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   367             begin
   377             begin
   368             if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then
   378             if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then
   399                     end;
   409                     end;
   400                     inc(t)
   410                     inc(t)
   401                 end;
   411                 end;
   402             for g:= g to cMaxSlotAmmoIndex + 1 do
   412             for g:= g to cMaxSlotAmmoIndex + 1 do
   403                 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
   413                 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
   404             DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
   414             DrawSprite(sprAMBorderVertical, x + AMShiftTarget - AMxOffset, y, 1);
   405             end;
   415             end;
   406 
   416 
   407     dec(y, BORDERSIZE);
   417     dec(y, BORDERSIZE);
   408     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   418     DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
   409     for i:= 0 to cMaxSlotAmmoIndex + 1 do
   419     for i:= 0 to cMaxSlotAmmoIndex + 1 do
   410         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   420         DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
   411     DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
   421     DrawSprite(sprAMCorners, x + AMShiftTarget - AMxOffset, y, 1);
   412 {$ENDIF}
   422 {$ENDIF}
   413 
   423 
   414     if (Pos >= 0) then
   424     if (Pos >= 0) then
   415         begin
   425         begin
   416         if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   426         if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   420                 amSel:= Ammo^[Slot, Pos].AmmoType;
   430                 amSel:= Ammo^[Slot, Pos].AmmoType;
   421                 RenderWeaponTooltip(amSel)
   431                 RenderWeaponTooltip(amSel)
   422                 end;
   432                 end;
   423 
   433 
   424 {$IFDEF MOBILE}
   434 {$IFDEF MOBILE}
   425             DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   435             DrawTexture(cScreenWidth div 2 - (AMShiftTarget - 10) + AMShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   426             if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   436             if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   427                 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + 163, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
   437                 DrawTexture(cScreenWidth div 2 - (AMShiftTarget - 10) + 163, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
   428 {$ELSE}
   438 {$ELSE}
   429             DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   439             DrawTexture(cScreenWidth div 2 - (AMShiftTarget - 10) + AMShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   430             if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   440             if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   431                 DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
   441                 DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]);
   432 {$ENDIF}
   442 {$ENDIF}
   433 
   443 
   434             if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   444             if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   442             end
   452             end
   443         end
   453         end
   444     else
   454     else
   445         FreeWeaponTooltip;
   455         FreeWeaponTooltip;
   446 
   456 
   447     if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
   457     if (WeaponTooltipTex <> nil) and (AMShift = 0) then
   448 {$IFDEF MOBILE}
   458 {$IFDEF MOBILE}
   449     {$IFDEF ANDROID}
   459         ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, cScreenHeight - (AMShiftTarget + AMSlotSize + WeaponTooltipTex^.h));
   450         ShowWeaponTooltip((AMxOffset - (cScreenHeight div 2)) - WeaponTooltipTex^.w, (AMyOffset + ((SlotsNum * AmSlotSize)div 2)) - (WeaponTooltipTex^.h div 2));
       
   451     {$ELSE}
       
   452         ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, 100);
       
   453     {$ENDIF}
       
   454 {$ELSE}
   460 {$ELSE}
   455         ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   461         ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
   456 {$ENDIF}
   462 {$ENDIF}
   457 
   463 
   458     bSelected:= false;
   464     bSelected:= false;
   459     if AMxShift = 0 then
   465     if AMShift = 0 then
   460         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   466         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   461 end;
   467 end;
   462 
   468 
   463 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   469 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   464 var VertexBuffer: array [0..3] of TVertex2f;
   470 var VertexBuffer: array [0..3] of TVertex2f;
  1097             r.h:= 13;
  1103             r.h:= 13;
  1098             DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
  1104             DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
  1099         end;
  1105         end;
  1100 
  1106 
  1101 // AmmoMenu
  1107 // AmmoMenu
  1102 if (AMxShift < AMWidth) or bShowAmmoMenu then
  1108 if (AMShift < AMShiftTarget) or bShowAmmoMenu then
  1103     ShowAmmoMenu;
  1109     ShowAmmoMenu;
  1104 
  1110 
  1105 // Cursor
  1111 // Cursor
  1106 if isCursorVisible and bShowAmmoMenu then
  1112 if isCursorVisible and bShowAmmoMenu then
  1107     DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
  1113     DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
  1294     WorldDy:= wdy;
  1300     WorldDy:= wdy;
  1295 
  1301 
  1296 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then
  1302 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then
  1297     exit;
  1303     exit;
  1298 
  1304 
  1299 if AMxShift < AMWidth then
  1305 if AMShift < AMShiftTarget then
  1300 begin
  1306 begin
  1301 {$IFDEF MOBILE}
  1307 {$IFDEF MOBILE}
  1302     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then
  1308     if CursorPoint.X < AMxOffset - ((SlotsNum * AMSlotSize) shr 1) then//check left 
  1303         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth;
  1309         CursorPoint.X:= AMxOffset - ((SlotsNum* AMSlotSize) shr 1);
  1304     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then
  1310     if CursorPoint.X > (AMxOffset + (SlotsNum * AMSlotSize) shr 1) then//check right
  1305         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1311         CursorPoint.X:= (AMxOffset + (SlotsNum * AMSlotSize) shr 1);
  1306     if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then
  1312     if CursorPoint.Y > (AMShiftTarget + AMShift) then//check top
  1307         CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize;
  1313         CursorPoint.Y:= AMShiftTarget + AMShift;
  1308     if CursorPoint.Y > cScreenHeight - AMyOffset then
  1314     if CursorPoint.Y < (AMShiftTarget + AMShift) - ((cMaxSlotAmmoIndex+1) * AMSlotSize) then//check bottom
  1309         CursorPoint.Y:= cScreenHeight - AMyOffset;
  1315         CursorPoint.Y:= (AMShiftTarget + AMShift) - ((cMaxSlotAmmoIndex+1) * AMSlotSize);
  1310 {$ELSE}
  1316 {$ELSE}
  1311     if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then
  1317     if CursorPoint.X < cScreenWidth div 2 + AMShift - AMShiftTarget + AMSlotSize then
  1312         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize;
  1318         CursorPoint.X:= cScreenWidth div 2 + AMShift - AMShiftTarget + AMSlotSize;
  1313     if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then
  1319     if CursorPoint.X > cScreenWidth div 2 + AMShift - AMxOffset then
  1314         CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset;
  1320         CursorPoint.X:= cScreenWidth div 2 + AMShift - AMxOffset;
  1315     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then
  1321     if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then
  1316         CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
  1322         CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize;
  1317     if CursorPoint.Y < AMyOffset + AMSlotSize then
  1323     if CursorPoint.Y < AMyOffset + AMSlotSize then
  1318         CursorPoint.Y:= AMyOffset + AMSlotSize;
  1324         CursorPoint.Y:= AMyOffset + AMSlotSize;
  1319 {$ENDIF}
  1325 {$ENDIF}