hedgewars/uWorld.pas
changeset 6631 930d5f070196
parent 6627 18cbb75aba59
child 6637 b4a3310f2974
equal deleted inserted replaced
6630:f8bbfa9a1a36 6631:930d5f070196
   233 {$ELSE}
   233 {$ELSE}
   234     SlotsNumX:= cMaxSlotAmmoIndex + 1;
   234     SlotsNumX:= cMaxSlotAmmoIndex + 1;
   235     SlotsNumY:= SlotsNum + 1;
   235     SlotsNumY:= SlotsNum + 1;
   236 {$ENDIF}
   236 {$ENDIF}
   237 
   237 
   238     ammoRect.w:= (BORDERSIZE*2) + (SlotsNumX * AMSlotSize) + (SlotsNumX-1);
   238     AmmoRect.w:= (BORDERSIZE*2) + (SlotsNumX * AMSlotSize) + (SlotsNumX-1);
   239     ammoRect.h:= (BORDERSIZE*2) + (SlotsNumY * AMSlotSize) + (SlotsNumY-1);
   239     AmmoRect.h:= (BORDERSIZE*2) + (SlotsNumY * AMSlotSize) + (SlotsNumY-1);
   240     amSurface := SDL_CreateRGBSurface(SDL_SWSURFACE, ammoRect.w, ammoRect.h, 32, RMask, GMask, BMask, AMask);
   240     amSurface := SDL_CreateRGBSurface(SDL_SWSURFACE, AmmoRect.w, AmmoRect.h, 32, RMask, GMask, BMask, AMask);
   241     
   241     
   242     AMRect.x:= BORDERSIZE;
   242     AMRect.x:= BORDERSIZE;
   243     AMRect.y:= BORDERSIZE;
   243     AMRect.y:= BORDERSIZE;
   244     AMRect.w:= ammoRect.w - (BORDERSIZE*2);
   244     AMRect.w:= AmmoRect.w - (BORDERSIZE*2);
   245     AMRect.h:= ammoRect.h - (BORDERSIZE*2);
   245     AMRect.h:= AmmoRect.h - (BORDERSIZE*2);
   246 
   246 
   247     SDL_FillRect(amSurface, @AMRect, SDL_MapRGB(amSurface^.format, 0,0,0));
   247     SDL_FillRect(amSurface, @AMRect, SDL_MapRGB(amSurface^.format, 0,0,0));
   248 
   248 
   249     
   249     
   250     x:= 0;
   250     x:= 0;
   318 procedure ShowAmmoMenu;
   318 procedure ShowAmmoMenu;
   319 const BORDERSIZE = 2;
   319 const BORDERSIZE = 2;
   320       MENUSPEED = 15;
   320       MENUSPEED = 15;
   321 var Slot, Pos: LongInt;
   321 var Slot, Pos: LongInt;
   322     Ammo: PHHAmmo;
   322     Ammo: PHHAmmo;
   323     i,g,t,CursorXtmp, CursorYtmp,STurns: LongInt;
   323     c,i,g,t,CursorXtmp, CursorYtmp,STurns: LongInt;
   324 begin
   324 begin
   325 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
   325 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
   326 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
   326 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
   327 bShowAmmoMenu:= false;
   327 bShowAmmoMenu:= false;
   328 
   328 
   426 
   426 
   427     DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   427     DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   428 
   428 
   429     Pos:= -1;
   429     Pos:= -1;
   430     Slot:= -1;
   430     Slot:= -1;
       
   431     c:= -1;
   431 {$IFDEF MOBILE}
   432 {$IFDEF MOBILE}
   432     for i:= 0 to cMaxSlotIndex do
   433     for i:= 0 to cMaxSlotIndex do
   433         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   434         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   434             begin
   435             begin
       
   436             inc(c);
   435             g:= 0;
   437             g:= 0;
   436             for t:=0 to cMaxSlotAmmoIndex do
   438             for t:=0 to cMaxSlotAmmoIndex do
   437                 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
   439                 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
   438                     begin
   440                     begin
   439                     if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g    * (AMSlotSize+1))) and
   441                     if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g    * (AMSlotSize+1))) and
   440                        (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and
   442                        (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and
   441                        (CursorPoint.X >= AmmoRect.x                   + ( i    * (AMSlotSize+1))) and 
   443                        (CursorPoint.X >= AmmoRect.x                   + ( c    * (AMSlotSize+1))) and 
   442                        (CursorPoint.X <= AmmoRect.x                   + ((i+1) * (AMSlotSize+1))) then
   444                        (CursorPoint.X <= AmmoRect.x                   + ((c+1) * (AMSlotSize+1))) then
   443                         begin
   445                         begin
   444                         Slot:= i;
   446                         Slot:= i;
   445                         Pos:= t;
   447                         Pos:= t;
   446                         STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   448                         STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   447                         if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then
   449                         if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then
   448                             DrawSprite(sprAMSlot, 
   450                             DrawSprite(sprAMSlot, 
   449                                        AmmoRect.x + BORDERSIZE + (Slot * (AMSlotSize+1)) + AMSlotPadding -1, 
   451                                        AmmoRect.x + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding -1, 
   450                                        AmmoRect.y + BORDERSIZE + (g  * (AMSlotSize+1)) + AMSlotPadding -1, 0);
   452                                        AmmoRect.y + BORDERSIZE + (g  * (AMSlotSize+1)) + AMSlotPadding -1, 0);
   451                         end;
   453                         end;
   452                         inc(g);
   454                         inc(g);
   453                    end;
   455                    end;
   454             end;
   456             end;
   455 {$ELSE}
   457 {$ELSE}
   456     for i:= 0 to cMaxSlotIndex do
   458     for i:= 0 to cMaxSlotIndex do
   457         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   459         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   458             begin
   460             begin
       
   461             inc(c);
   459             g:= 0;
   462             g:= 0;
   460             for t:=0 to cMaxSlotAmmoIndex do
   463             for t:=0 to cMaxSlotAmmoIndex do
   461                 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
   464                 if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
   462                     begin
   465                     begin
   463                     if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( i    * (AMSlotSize+1))) and
   466                     if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( c    * (AMSlotSize+1))) and
   464                        (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((i+1) * (AMSlotSize+1))) and
   467                        (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and
   465                        (CursorPoint.X >= AmmoRect.x                   + ( g    * (AMSlotSize+1))) and 
   468                        (CursorPoint.X >= AmmoRect.x                   + ( g    * (AMSlotSize+1))) and 
   466                        (CursorPoint.X <= AmmoRect.x                   + ((g+1) * (AMSlotSize+1))) then
   469                        (CursorPoint.X <= AmmoRect.x                   + ((g+1) * (AMSlotSize+1))) then
   467                         begin
   470                         begin
   468                         Slot:= i;
   471                         Slot:= i;
   469                         Pos:= t;
   472                         Pos:= t;
   470                         STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   473                         STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   471                         if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then
   474                         if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then
   472                             DrawSprite(sprAMSlot, 
   475                             DrawSprite(sprAMSlot, 
   473                                        AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 
   476                                        AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 
   474                                        AmmoRect.y + BORDERSIZE + (Slot  * (AMSlotSize+1)) + AMSlotPadding -1, 0);
   477                                        AmmoRect.y + BORDERSIZE + (c  * (AMSlotSize+1)) + AMSlotPadding -1, 0);
   475                         end;
   478                         end;
   476                         inc(g);
   479                         inc(g);
   477                    end;
   480                    end;
   478             end;
   481             end;
   479 {$ENDIF}
   482 {$ENDIF}