hedgewars/uWorld.pas
changeset 2855 7e6adeb57427
parent 2851 a9a5ce1d9f23
child 2856 cc70797a0b75
equal deleted inserted replaced
2854:7aac108149d9 2855:7e6adeb57427
   110 
   110 
   111 procedure ShowAmmoMenu;
   111 procedure ShowAmmoMenu;
   112 const MENUSPEED = 15;
   112 const MENUSPEED = 15;
   113 var x, y, i, t, l, g: LongInt;
   113 var x, y, i, t, l, g: LongInt;
   114     Slot, Pos: LongInt;
   114     Slot, Pos: LongInt;
       
   115     Ammo: PHHAmmo;
   115 begin
   116 begin
   116 if (TurnTimeLeft = 0) or (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu) then bShowAmmoMenu:= false;
   117 if (TurnTimeLeft = 0) or (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu) then bShowAmmoMenu:= false;
   117 if bShowAmmoMenu then
   118 if bShowAmmoMenu then
   118    begin
   119    begin
   119    FollowGear:= nil;
   120    FollowGear:= nil;
   134    if cReducedQuality then
   135    if cReducedQuality then
   135        AMxShift:= 210
   136        AMxShift:= 210
   136    else
   137    else
   137        if AMxShift < 210 then inc(AMxShift, MENUSPEED);
   138        if AMxShift < 210 then inc(AMxShift, MENUSPEED);
   138    end;
   139    end;
   139 
   140 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   140 if CurrentTeam = nil then exit;
   141    Ammo:= CurrentHedgehog^.Ammo
       
   142 else 
       
   143    Ammo:= GetAmmoByNum(LocalAmmo);
   141 Slot:= 0;
   144 Slot:= 0;
   142 Pos:= -1;
   145 Pos:= -1;
   143 with CurrentHedgehog^ do
   146 if Ammo = nil then exit;
   144 	begin
   147 SlotsNum:= 0;
   145 	if Ammo = nil then exit;
   148 x:= (cScreenWidth shr 1) - 210 + AMxShift;
   146 	SlotsNum:= 0;
   149 y:= cScreenHeight - 40;
   147 	x:= (cScreenWidth shr 1) - 210 + AMxShift;
   150 dec(y);
   148 	y:= cScreenHeight - 40;
   151 DrawSprite(sprAMBorders, x, y, 0);
   149 	dec(y);
   152 dec(y);
   150 	DrawSprite(sprAMBorders, x, y, 0);
   153 DrawSprite(sprAMBorders, x, y, 1);
   151 	dec(y);
   154 dec(y, 33);
   152 	DrawSprite(sprAMBorders, x, y, 1);
   155 DrawSprite(sprAMSlotName, x, y, 0);
   153 	dec(y, 33);
   156 for i:= cMaxSlotIndex downto 0 do
   154 	DrawSprite(sprAMSlotName, x, y, 0);
   157 	if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   155 	for i:= cMaxSlotIndex downto 0 do
   158 		begin
   156 		if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   159 		if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
       
   160 		dec(y, 33);
       
   161 		inc(SlotsNum);
       
   162 		DrawSprite(sprAMSlot, x, y, 0);
       
   163 		DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
       
   164 		t:= 0;
       
   165                     g:= 0;
       
   166 		while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   157 			begin
   167 			begin
   158 			if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
   168 			if (Ammo^[i, t].AmmoType <> amNothing) then
   159 			dec(y, 33);
       
   160 			inc(SlotsNum);
       
   161 			DrawSprite(sprAMSlot, x, y, 0);
       
   162 			DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
       
   163 			t:= 0;
       
   164                         g:= 0;
       
   165 			while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
       
   166 				begin
   169 				begin
   167 				if (Ammo^[i, t].AmmoType <> amNothing) then
   170 				l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
       
   171 
       
   172 				if l >= 0 then
   168 					begin
   173 					begin
   169 					l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   174 					DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   170 
   175                     if l < 100 then DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l);
   171 					if l >= 0 then
   176 					end else
   172 						begin
   177 					DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   173 						DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   178 				if (Slot = i)
   174                         if l < 100 then DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l);
   179 				and (CursorPoint.X >= x + g * 33 + 35)
   175 						end else
   180 				and (CursorPoint.X < x + g * 33 + 68) then
   176 						DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   181 					begin
   177 					if (Slot = i)
   182 					if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0);
   178 					and (CursorPoint.X >= x + g * 33 + 35)
   183 					Pos:= t;
   179 					and (CursorPoint.X < x + g * 33 + 68) then
       
   180 						begin
       
   181 						if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0);
       
   182 						Pos:= t;
       
   183 						end;
       
   184 					inc(g)
       
   185 					end;
   184 					end;
   186 					inc(t)
   185 				inc(g)
   187 				end
   186 				end;
       
   187 				inc(t)
       
   188 			end
       
   189 		end;
       
   190 dec(y, 1);
       
   191 DrawSprite(sprAMBorders, x, y, 0);
       
   192 
       
   193 if (Pos >= 0) then
       
   194 	begin
       
   195 	if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
       
   196 		if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
       
   197 			begin
       
   198 			amSel:= Ammo^[Slot, Pos].AmmoType;
       
   199 			RenderWeaponTooltip(amSel)
   188 			end;
   200 			end;
   189 	dec(y, 1);
   201 		
   190 	DrawSprite(sprAMBorders, x, y, 0);
   202 		DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   191 
   203 
   192 	if (Pos >= 0) then
   204 		if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   193 		begin
   205 			DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   194 		if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   206 
   195 			if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
   207 		if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   196 				begin
   208 			begin
   197 				amSel:= Ammo^[Slot, Pos].AmmoType;
   209 			bShowAmmoMenu:= false;
   198 				RenderWeaponTooltip(amSel)
   210 			SetWeapon(Ammo^[Slot, Pos].AmmoType);
   199 				end;
   211 			bSelected:= false;
   200 			
   212 			FreeWeaponTooltip;
   201 			DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   213 			exit
   202 
   214 			end;
   203 			if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   215 	end
   204 				DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   216 else
   205 
   217 	FreeWeaponTooltip;
   206 			if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   218 
   207 				begin
   219 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
   208 				bShowAmmoMenu:= false;
   220 	ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, y);
   209 				SetWeapon(Ammo^[Slot, Pos].AmmoType);
       
   210 				bSelected:= false;
       
   211 				FreeWeaponTooltip;
       
   212 				exit
       
   213 				end;
       
   214 		end
       
   215 	else
       
   216 		FreeWeaponTooltip;
       
   217 	
       
   218 	if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
       
   219 		ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, y);
       
   220 	end;
       
   221 
   221 
   222 bSelected:= false;
   222 bSelected:= false;
   223 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   223 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   224 end;
   224 end;
   225 
   225