hedgewars/uWorld.pas
changeset 3395 095273ad0e08
parent 3390 1d4926d10a9e
child 3405 8fdb08497bf1
equal deleted inserted replaced
3394:47b51e22e670 3395:095273ad0e08
   170 HorizontOffset:= 0;
   170 HorizontOffset:= 0;
   171 end;
   171 end;
   172 
   172 
   173 procedure ShowAmmoMenu;
   173 procedure ShowAmmoMenu;
   174 const MENUSPEED = 15;
   174 const MENUSPEED = 15;
       
   175 {$IFDEF IPHONEOS}
       
   176 const MENUWIDTH = 210;
       
   177 {$ELSE}
       
   178 const MENUWIDTH = 240;
       
   179 {$ENDIF}
   175 var x, y, i, t, l, g: LongInt;
   180 var x, y, i, t, l, g: LongInt;
   176     Slot, Pos: LongInt;
   181     Slot, Pos: LongInt;
   177     Ammo: PHHAmmo;
   182     Ammo: PHHAmmo;
   178 begin
   183 begin
   179 if  (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false;
   184 if  (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false;
   180 if bShowAmmoMenu then
   185 if bShowAmmoMenu then
   181    begin
   186    begin
   182    FollowGear:= nil;
   187    FollowGear:= nil;
   183    if AMxShift = 210 then prevPoint.X:= 0;
   188    if AMxShift = MENUWIDTH then prevPoint.X:= 0;
   184    if cReducedQuality then
   189    if cReducedQuality then
   185        AMxShift:= 0
   190        AMxShift:= 0
   186    else
   191    else
   187        if AMxShift > 0 then dec(AMxShift, MENUSPEED);
   192        if AMxShift > 0 then dec(AMxShift, MENUSPEED);
   188    end else
   193    end else
   193       CursorPoint.Y:= cScreenHeight shr 1;
   198       CursorPoint.Y:= cScreenHeight shr 1;
   194       prevPoint:= CursorPoint;
   199       prevPoint:= CursorPoint;
   195       SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
   200       SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
   196       end;
   201       end;
   197    if cReducedQuality then
   202    if cReducedQuality then
   198        AMxShift:= 210
   203        AMxShift:= MENUWIDTH
   199    else
   204    else
   200        if AMxShift < 210 then inc(AMxShift, MENUSPEED);
   205        if AMxShift < MENUWIDTH then inc(AMxShift, MENUSPEED);
   201    end;
   206    end;
   202 Ammo:= nil;
   207 Ammo:= nil;
   203 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   208 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   204    Ammo:= CurrentHedgehog^.Ammo
   209    Ammo:= CurrentHedgehog^.Ammo
   205 else if (LocalAmmo <> -1) then
   210 else if (LocalAmmo <> -1) then
   210     begin
   215     begin
   211     bShowAmmoMenu:= false;
   216     bShowAmmoMenu:= false;
   212     exit
   217     exit
   213     end;
   218     end;
   214 SlotsNum:= 0;
   219 SlotsNum:= 0;
   215 x:= (cScreenWidth shr 1) - 210 + AMxShift;
   220 x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift;
   216 y:= cScreenHeight - 40;
   221 y:= cScreenHeight - 40;
       
   222 
       
   223 {$IFDEF IPHONEOS}
       
   224 dec(y);
       
   225 DrawSprite(sprAMBordersIPhone, x, y, 0);
       
   226 dec(y);
       
   227 DrawSprite(sprAMBordersIPhone, x, y, 1);
       
   228 dec(y, 33);
       
   229 DrawSprite(sprAMSlotNameIPhone, x, y, 0);
       
   230 {$ELSE}
   217 dec(y);
   231 dec(y);
   218 DrawSprite(sprAMBorders, x, y, 0);
   232 DrawSprite(sprAMBorders, x, y, 0);
   219 dec(y);
   233 dec(y);
   220 DrawSprite(sprAMBorders, x, y, 1);
   234 DrawSprite(sprAMBorders, x, y, 1);
   221 dec(y, 33);
   235 dec(y, 33);
   222 DrawSprite(sprAMSlotName, x, y, 0);
   236 DrawSprite(sprAMSlotName, x, y, 0);
       
   237 {$ENDIF}
       
   238 
   223 for i:= cMaxSlotIndex downto 0 do
   239 for i:= cMaxSlotIndex downto 0 do
   224     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   240     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   225         begin
   241         begin
   226         if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
   242         if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
   227         dec(y, 33);
   243         dec(y, 33);
   228         inc(SlotsNum);
   244         inc(SlotsNum);
       
   245         {$IFDEF IPHONEOS}
       
   246         DrawSprite(sprAMSlotIPhone, x, y, 0);
       
   247         {$ELSE}
   229         DrawSprite(sprAMSlot, x, y, 0);
   248         DrawSprite(sprAMSlot, x, y, 0);
   230         DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
   249         DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
       
   250         {$ENDIF}
   231         t:= 0;
   251         t:= 0;
   232                     g:= 0;
   252         {$IFDEF IPHONEOS}
       
   253         g:= -1;
       
   254         {$ELSE}
       
   255         g:= 0;
       
   256         {$ENDIF}
   233         while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   257         while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   234             begin
   258             begin
   235             if (Ammo^[i, t].AmmoType <> amNothing) then
   259             if (Ammo^[i, t].AmmoType <> amNothing) then
   236                 begin
   260                 begin
   237                 l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   261                 l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   253                 end;
   277                 end;
   254                 inc(t)
   278                 inc(t)
   255             end
   279             end
   256         end;
   280         end;
   257 dec(y, 1);
   281 dec(y, 1);
       
   282 {$IFDEF IPHONEOS}
       
   283 DrawSprite(sprAMBordersIPhone, x, y, 0);
       
   284 {$ELSE}
   258 DrawSprite(sprAMBorders, x, y, 0);
   285 DrawSprite(sprAMBorders, x, y, 0);
       
   286 {$ENDIF}
   259 
   287 
   260 if (Pos >= 0) then
   288 if (Pos >= 0) then
   261     begin
   289     begin
   262     if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   290     if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   263         if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
   291         if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
   264             begin
   292             begin
   265             amSel:= Ammo^[Slot, Pos].AmmoType;
   293             amSel:= Ammo^[Slot, Pos].AmmoType;
   266             RenderWeaponTooltip(amSel)
   294             RenderWeaponTooltip(amSel)
   267             end;
   295             end;
   268         
   296         
   269         DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   297         DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   270 
   298 
   271         if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   299         if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   272             DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   300             DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   273 
   301 
   274         if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   302         if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   913 
   941 
   914 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit;
   942 if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit;
   915 
   943 
   916 if AMxShift < 210 then
   944 if AMxShift < 210 then
   917     begin
   945     begin
   918     if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175;
   946     if CursorPoint.X < cScreenWidth div 2 + AMxShift - 206 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 206;
   919     if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10;
   947     if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10;
   920     if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33;
   948     if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33;
   921     if CursorPoint.Y < 76 then CursorPoint.Y:= 76;
   949     if CursorPoint.Y < 76 then CursorPoint.Y:= 76;
   922     prevPoint:= CursorPoint;
   950     prevPoint:= CursorPoint;
   923     if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
   951     if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);