208 const BORDERSIZE = 2; |
217 const BORDERSIZE = 2; |
209 var x, y, i, t, g: LongInt; |
218 var x, y, i, t, g: LongInt; |
210 Slot, Pos, STurns: LongInt; |
219 Slot, Pos, STurns: LongInt; |
211 Ammo: PHHAmmo; |
220 Ammo: PHHAmmo; |
212 begin |
221 begin |
213 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then |
222 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or |
214 bShowAmmoMenu:= false; |
223 ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then |
215 if bShowAmmoMenu then |
224 bShowAmmoMenu:= false; |
216 begin |
225 |
217 FollowGear:= nil; |
226 if bShowAmmoMenu then |
218 if AMxShift = AMWidth then prevPoint.X:= 0; |
227 // show ammo menu |
219 if (cReducedQuality and rqSlowMenu) <> 0 then |
228 begin |
220 AMxShift:= 0 |
229 FollowGear:= nil; |
221 else |
230 if AMxShift = AMWidth then prevPoint.X:= 0; |
222 if AMxShift > MENUSPEED then |
231 if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= 0 |
223 dec(AMxShift, MENUSPEED) |
232 else |
224 else |
233 if AMxShift > MENUSPEED then dec(AMxShift, MENUSPEED) |
225 AMxShift:= 0; |
234 else AMxShift:= 0; |
226 end else |
235 end |
227 begin |
236 else |
228 if AMxShift = 0 then |
237 // hide ammo menu |
229 begin |
238 begin |
230 CursorPoint.X:= cScreenWidth shr 1; |
239 if AMxShift = 0 then |
231 CursorPoint.Y:= cScreenHeight shr 1; |
|
232 prevPoint:= CursorPoint; |
|
233 end; |
|
234 if (cReducedQuality and rqSlowMenu) <> 0 then |
|
235 AMxShift:= AMWidth |
|
236 else |
|
237 if AMxShift < (AMWidth - MENUSPEED) then |
|
238 inc(AMxShift, MENUSPEED) |
|
239 else |
|
240 AMxShift:= AMWidth; |
|
241 end; |
|
242 Ammo:= nil; |
|
243 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then |
|
244 Ammo:= CurrentHedgehog^.Ammo |
|
245 else if (LocalAmmo <> -1) then |
|
246 Ammo:= GetAmmoByNum(LocalAmmo); |
|
247 Pos:= -1; |
|
248 if Ammo = nil then |
|
249 begin |
|
250 bShowAmmoMenu:= false; |
|
251 exit |
|
252 end; |
|
253 SlotsNum:= 0; |
|
254 x:= (cScreenWidth shr 1) - AMWidth + AMxShift; |
|
255 |
|
256 {$IFDEF MOBILE} |
|
257 Slot:= cMaxSlotIndex; |
|
258 x:= x - cOffsetY; |
|
259 y:= AMyOffset; |
|
260 dec(y, BORDERSIZE); |
|
261 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
|
262 for i:= 0 to cMaxSlotAmmoIndex do |
|
263 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
|
264 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
|
265 inc(y, BORDERSIZE); |
|
266 |
|
267 for i:= 0 to cMaxSlotIndex do |
|
268 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
|
269 begin |
|
270 if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i; |
|
271 inc(SlotsNum); |
|
272 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
273 t:= 0; |
|
274 g:= 0; |
|
275 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
|
276 begin |
240 begin |
277 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
241 CursorPoint.X:= cScreenWidth shr 1; |
278 if (Ammo^[i, t].AmmoType <> amNothing) then |
242 CursorPoint.Y:= cScreenHeight shr 1; |
|
243 prevPoint:= CursorPoint; |
|
244 end; |
|
245 if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= AMWidth+2 |
|
246 else |
|
247 if AMxShift < (AMWidth - MENUSPEED) then inc(AMxShift, MENUSPEED) |
|
248 else AMxShift:= AMWidth; |
|
249 end; |
|
250 |
|
251 // give the assigned ammo to hedgehog |
|
252 Ammo:= nil; |
|
253 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and |
|
254 (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then |
|
255 Ammo:= CurrentHedgehog^.Ammo |
|
256 else if (LocalAmmo <> -1) then |
|
257 Ammo:= GetAmmoByNum(LocalAmmo); |
|
258 Pos:= -1; |
|
259 if Ammo = nil then |
|
260 begin |
|
261 bShowAmmoMenu:= false; |
|
262 exit |
|
263 end; |
|
264 SlotsNum:= 0; |
|
265 x:= (cScreenWidth shr 1) - AMWidth + AMxShift; |
|
266 |
|
267 {$IFDEF IPHONEOS} |
|
268 Slot:= cMaxSlotIndex; |
|
269 x:= x - cOffsetY; |
|
270 y:= AMyOffset; |
|
271 dec(y, BORDERSIZE); |
|
272 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
|
273 for i:= 0 to cMaxSlotAmmoIndex do |
|
274 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
|
275 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
|
276 inc(y, BORDERSIZE); |
|
277 |
|
278 for i:= 0 to cMaxSlotIndex do |
|
279 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
|
280 begin |
|
281 if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i; |
|
282 inc(SlotsNum); |
|
283 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
284 t:= 0; |
|
285 g:= 0; |
|
286 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
279 begin |
287 begin |
280 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
288 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
281 |
289 if (Ammo^[i, t].AmmoType <> amNothing) then |
282 if STurns >= 0 then |
|
283 begin |
290 begin |
284 DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
291 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
285 if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
292 |
286 end else |
293 if STurns >= 0 then |
287 DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
294 begin |
288 if (Slot = i) |
295 DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
289 and (CursorPoint.X >= x + g * AMSlotSize) |
296 if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
290 and (CursorPoint.X <= x + (g + 1) * AMSlotSize) then |
297 end |
291 begin |
298 else |
292 if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
299 DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
293 Pos:= t; |
300 if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and |
|
301 (CursorPoint.X <= x + (g + 1) * AMSlotSize) then |
|
302 begin |
|
303 if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
|
304 Pos:= t; |
|
305 end; |
|
306 inc(g) |
294 end; |
307 end; |
295 inc(g) |
|
296 end; |
|
297 inc(t) |
308 inc(t) |
298 end; |
309 end; |
299 for g:= g to cMaxSlotAmmoIndex do |
310 |
300 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
311 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
301 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
312 for i:= 0 to cMaxSlotAmmoIndex do |
302 inc(y, AMSlotSize); |
|
303 end; |
|
304 |
|
305 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
|
306 for i:= 0 to cMaxSlotAmmoIndex do |
|
307 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
313 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
308 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
314 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
309 {$ELSE} |
315 {$ELSE} |
310 Slot:= 0; |
316 Slot:= 0; |
311 y:= cScreenHeight - AMyOffset; |
317 y:= cScreenHeight - AMyOffset; |
312 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
318 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
313 for i:= 0 to cMaxSlotAmmoIndex + 1 do |
319 for i:= 0 to cMaxSlotAmmoIndex + 1 do |
314 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
320 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
315 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
321 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
316 dec(y, AMSlotSize); |
322 dec(y, AMSlotSize); |
317 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
323 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
318 for i:= 0 to cMaxSlotAmmoIndex do |
324 for i:= 0 to cMaxSlotAmmoIndex do |
319 DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2); |
325 DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2); |
320 DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1); |
326 DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1); |
321 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
327 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
322 |
328 |
323 for i:= cMaxSlotIndex downto 0 do |
329 for i:= cMaxSlotIndex downto 0 do |
324 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
330 if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
325 begin |
|
326 if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i; |
|
327 dec(y, AMSlotSize); |
|
328 inc(SlotsNum); |
|
329 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
330 DrawSprite(sprAMSlot, x, y, 1); |
|
331 DrawSprite(sprAMSlotKeys, x, y + 1, i); |
|
332 t:= 0; |
|
333 g:= 1; |
|
334 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
|
335 begin |
331 begin |
336 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
332 if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i; |
337 if (Ammo^[i, t].AmmoType <> amNothing) then |
333 dec(y, AMSlotSize); |
|
334 inc(SlotsNum); |
|
335 DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
336 DrawSprite(sprAMSlot, x, y, 1); |
|
337 DrawSprite(sprAMSlotKeys, x, y + 1, i); |
|
338 t:= 0; |
|
339 g:= 1; |
|
340 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
338 begin |
341 begin |
339 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
342 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
340 |
343 if (Ammo^[i, t].AmmoType <> amNothing) then |
341 if STurns >= 0 then |
|
342 begin |
344 begin |
343 DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
345 STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
344 if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
346 |
345 end else |
347 if STurns >= 0 then |
346 DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
348 begin |
347 if (Slot = i) |
349 DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
348 and (CursorPoint.X >= x + g * AMSlotSize) |
350 if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
349 and (CursorPoint.X <= x + (g + 1) * AMSlotSize) then |
351 end else |
350 begin |
352 DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
351 if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
353 if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and |
352 Pos:= t; |
354 (CursorPoint.X <= x + (g + 1) * AMSlotSize) then |
|
355 begin |
|
356 if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
|
357 Pos:= t; |
|
358 end; |
|
359 inc(g) |
353 end; |
360 end; |
354 inc(g) |
361 inc(t) |
355 end; |
362 end; |
356 inc(t) |
363 for g:= g to cMaxSlotAmmoIndex + 1 do |
|
364 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
|
365 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
357 end; |
366 end; |
358 for g:= g to cMaxSlotAmmoIndex + 1 do |
367 |
359 DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
368 dec(y, BORDERSIZE); |
360 DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
369 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
361 end; |
370 for i:= 0 to cMaxSlotAmmoIndex + 1 do |
362 |
371 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
363 dec(y, BORDERSIZE); |
372 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
364 DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
|
365 for i:= 0 to cMaxSlotAmmoIndex + 1 do |
|
366 DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
|
367 DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
|
368 {$ENDIF} |
373 {$ENDIF} |
369 |
374 |
370 if (Pos >= 0) then |
375 if (Pos >= 0) then |
371 begin |
376 begin |
372 if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then |
377 if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then |
373 begin |
|
374 if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then |
|
375 begin |
378 begin |
376 amSel:= Ammo^[Slot, Pos].AmmoType; |
379 if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then |
377 RenderWeaponTooltip(amSel) |
380 begin |
378 end; |
381 amSel:= Ammo^[Slot, Pos].AmmoType; |
379 |
382 RenderWeaponTooltip(amSel) |
380 {$IFDEF MOBILE} |
383 end; |
381 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
384 |
382 |
385 {$IFDEF IPHONEOS} |
383 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
386 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
384 DrawTexture(cScreenWidth div 2 + AMxOffset - 45, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); |
387 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
|
388 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + 163, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); |
385 {$ELSE} |
389 {$ELSE} |
386 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
390 DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
387 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
391 if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
388 DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); |
392 DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); |
389 {$ENDIF} |
393 {$ENDIF} |
390 |
394 |
391 if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
395 if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
392 begin |
396 begin |
393 bShowAmmoMenu:= false; |
397 bShowAmmoMenu:= false; |
394 SetWeapon(Ammo^[Slot, Pos].AmmoType); |
398 SetWeapon(Ammo^[Slot, Pos].AmmoType); |
395 bSelected:= false; |
399 bSelected:= false; |
396 FreeWeaponTooltip; |
400 FreeWeaponTooltip; |
397 exit |
401 exit |
398 end; |
402 end; |
399 end |
403 end |
400 end |
404 end |
401 else |
405 else |
402 FreeWeaponTooltip; |
406 FreeWeaponTooltip; |
403 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
407 |
404 {$IFDEF MOBILE} |
408 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
405 ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, AMyOffset - 1); |
409 {$IFDEF IPHONEOS} |
|
410 ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, 100); |
406 {$ELSE} |
411 {$ELSE} |
407 ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); |
412 ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); |
408 {$ENDIF} |
413 {$ENDIF} |
409 |
414 |
410 bSelected:= false; |
415 bSelected:= false; |
411 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
416 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
412 end; |
417 end; |
413 |
418 |
414 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
419 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
415 var VertexBuffer: array [0..3] of TVertex2f; |
420 var VertexBuffer: array [0..3] of TVertex2f; |
416 r: TSDL_Rect; |
421 r: TSDL_Rect; |