You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.8KB

  1. /* ---------------------------------------------------------------------------|
  2. *
  3. * Distributed under the CC0 public domain license.
  4. * By Alison G. Watson. Attribution is encouraged, though not required.
  5. * See licenses/cc0.txt for more information.
  6. *
  7. * ---------------------------------------------------------------------------|
  8. *
  9. * HeadsUpDisD upgrade.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include "u_common.h"
  14. #include "p_hud.h"
  15. Str(sp_HUD_D_Ammo2Back, s":HUD_D:Ammo2Back");
  16. Str(sp_HUD_D_AmmoBack, s":HUD_D:AmmoBack");
  17. Str(sp_HUD_D_HPBack, s":HUD_D:HPBack");
  18. Str(sp_HUD_D_WepBack, s":HUD_D:WepBack");
  19. /* Static Functions -------------------------------------------------------- */
  20. static void HUD_Ammo(struct player *p) {
  21. struct invweapon const *wep = p->weapon.cur;
  22. cstr type = nil;
  23. if(wep->ammotype & AT_AMag)
  24. PrintSprite(sp_HUD_D_AmmoBack, 320,2, 239,2);
  25. if(wep->ammotype & AT_NMag) {
  26. type = u8"\n";
  27. char txt[16];
  28. if(wep->ammotype & AT_Ammo && !wep->ammocur)
  29. strcpy(txt, "OUT");
  30. else
  31. sprintf(txt, "%i/%i", wep->magmax - wep->magcur, wep->magmax);
  32. PrintTextChS(txt);
  33. PrintTextX(s_bigupper, Cr(blue), 232,1, 228,0, ptf_no_utf);
  34. }
  35. if(wep->ammotype & AT_Ammo) {
  36. type = u8"\n";
  37. i32 x = 0;
  38. if(wep->ammotype & AT_NMag) {
  39. PrintSprite(sp_HUD_D_Ammo2Back, 230,2, 239,2);
  40. x = 62;
  41. }
  42. ACS_BeginPrint();
  43. ACS_PrintInt(wep->ammocur);
  44. PrintTextX(s_bigupper, Cr(blue), 232-x,1, 228,0, ptf_no_utf);
  45. }
  46. if(type) {
  47. PrintTextChS(type);
  48. PrintTextX(s_lmidfont, Cr(blue), 309,4, 230,0, ptf_no_utf);
  49. }
  50. }
  51. static void HUD_Health(struct player *p) {
  52. StrAry(ws, s":HUD:H_D27", s":HUD:H_D28", s":HUD:H_D24", s":HUD:H_D23",
  53. s":HUD:H_D22", s":HUD:H_D21", s":HUD:H_D25", s":HUD:H_D26");
  54. PrintSprite(sp_HUD_D_HPBack, 0,1, 239,2);
  55. PrintTextChS(u8"");
  56. PrintTextX(s_lmidfont, Cr(blue), 8,4, 229,0, ptf_no_utf);
  57. HUD_DrawHealth(p, p->health, 18, 228, Cr(blue), 0);
  58. str gfx = ws[p->weapon.cur->info->slot];
  59. i32 x = (8 + p->ticks) % 40;
  60. for(i32 i = 0; i < 20; i++) {
  61. i32 xx = x - i;
  62. if(xx < 0) xx += 40;
  63. PrintSpriteA(gfx, 21+xx,1, 220,1, (20 - i) / 20.0);
  64. }
  65. }
  66. /* Extern Functions -------------------------------------------------------- */
  67. void Upgr_HeadsUpDisD_Render(struct player *p, struct upgrade *upgr) {
  68. if(!p->hudenabled) return;
  69. HUD_Log(p, Cr(blue), 0, -10);
  70. HUD_KeyInd(p, 180, 21, true, 0.8);
  71. HUD_Score(p, "%s\Cnscr", p->score, s_smallfnt, Cr(blue), 160,0);
  72. if(p->getCVarI(sc_hud_showweapons))
  73. PrintSprite(sp_HUD_D_WepBack, 320,2, 218,2);
  74. HUD_WeaponSlots(p, Cr(wseld1), Cr(wseld2), Cr(wseld3), Cr(wselds), 323, 216);
  75. /* Status */
  76. HUD_Ammo(p);
  77. HUD_Health(p);
  78. }
  79. /* EOF */