No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

140 líneas
4.3KB

  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. * Generalized HUD functions.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include "p_player.h"
  14. #include "p_hud.h"
  15. #include "p_hudid.h"
  16. /* Extern Functions -------------------------------------------------------- */
  17. void HUD_WeaponSlots(struct player *p, i32 cr_one, i32 cr_two, i32 cr_many, i32 cr_cur, i32 _x, i32 _y) {
  18. if(p->getCVarI(sc_hud_showweapons))
  19. for(i32 i = 1; i < SLOT_MAX; i++)
  20. ifauto(i32, slot, p->weapon.slot[i])
  21. {
  22. k32 x = _x+0.2 - 8 * (SLOT_MAX - i);
  23. k32 y = _y+0.2;
  24. i32 cr;
  25. switch(slot) {
  26. case 1: cr = cr_one; break;
  27. case 2: cr = cr_two; break;
  28. default: cr = cr_many; break;
  29. }
  30. ACS_BeginPrint();
  31. ACS_PrintInt(i);
  32. PrintTextX(s_lhudfontsmall, cr, x,2, y,2, ptf_no_utf);
  33. if(p->weapon.cur->info->slot == i)
  34. SetFade(fid_slotnS + i, 1, 6);
  35. if(CheckFade(fid_slotnS + i)) {
  36. ACS_BeginPrint();
  37. ACS_PrintInt(i);
  38. PrintTextFX(s_lhudfontsmall, cr_cur, x,2, y,2, fid_slotnS + i, ptf_no_utf);
  39. }
  40. }
  41. }
  42. void HUD_Score(struct player *p, cstr fmt, i96 scrn, str font, i32 cr, i32 x, i32 xa) {
  43. if(p->getCVarI(sc_hud_showscore)) {
  44. char scr[64];
  45. sprintf(scr, fmt, scoresep(scrn));
  46. PrintTextChS(scr);
  47. PrintTextX(font, cr, x,xa, 3,1, ptf_no_utf);
  48. if(p->score > p->old.score) {
  49. SetFade(fid_schit1, 4, 12);
  50. } else if(p->score < p->old.score) {
  51. i96 scrdif = p->old.score - p->score;
  52. u32 tics = scrdif * 8 / 0xFFFF;
  53. u32 mmx = 30000 - minmax(scrdif / 4, 3276, 29490);
  54. SetFade(fid_schit2, minmax(tics, 1, 35), mmx >> 8);
  55. }
  56. if(p->scoreaccumtime > 0) {
  57. SetFade(fid_scacum, 5, 12);
  58. p->scoreaccumstr = StrParam("%c%s", p->scoreaccum >= 0 ? '+' : ' ', scoresep(p->scoreaccum));
  59. }
  60. if(CheckFade(fid_schit1)) {
  61. PrintTextChS(scr);
  62. PrintTextFX(font, CR_ORANGE, x,xa, 3,1, fid_schit1, ptf_no_utf);
  63. } else if(CheckFade(fid_schit2)) {
  64. PrintTextChS(scr);
  65. PrintTextFX(font, CR_PURPLE, x,xa, 3,1, fid_schit2, ptf_no_utf);
  66. }
  67. if(CheckFade(fid_scacum))
  68. PrintTextFX_str(p->scoreaccumstr, font, CR_WHITE, x,xa, 10,1, fid_scacum, ptf_no_utf);
  69. }
  70. if(p->getCVarI(sc_hud_showlvl)) {
  71. PrintTextFmt("Lv.%u", p->attr.level);
  72. if(p->attr.points) __nprintf(" (\Cn%u\C- pts)", p->attr.points);
  73. PrintTextX(font, cr, x,xa, 17,1, ptf_no_utf);
  74. }
  75. i32 expbar = p->getCVarI(sc_hud_expbar);
  76. if(expbar > 0) {
  77. Str(exp_bar_0, s":Bars:ExpBar0");
  78. PrintSprite(exp_bar_0, x,xa, 24,1);
  79. i32 xx = x;
  80. u32 fr =
  81. ((u64)(p->attr.exp - p->attr.expprev) * 24) /
  82. (u64)(p->attr.expnext - p->attr.expprev);
  83. switch(xa) {
  84. case 0: xx -= 12; break;
  85. case 2: xx -= 24; break;
  86. }
  87. SetClip(xx, 24, fr, 2);
  88. PrintSprite(StrParam(":Bars:ExpBar%i", expbar), xx,1, 24,1);
  89. ClearClip();
  90. }
  91. }
  92. void HUD_KeyInd(struct player *p, i32 x, i32 y, bool horz, k32 a) {
  93. #define Inc (horz ? (x -= 10) : (y += 10))
  94. if(p->krs) PrintSpriteA(sp_HUD_H_KS1, x,2, y,1, a), Inc;
  95. if(p->kys) PrintSpriteA(sp_HUD_H_KS2, x,2, y,1, a), Inc;
  96. if(p->kbs) PrintSpriteA(sp_HUD_H_KS3, x,2, y,1, a), Inc;
  97. if(p->krc) PrintSpriteA(sp_HUD_H_KC1, x,2, y,1, a), Inc;
  98. if(p->kyc) PrintSpriteA(sp_HUD_H_KC2, x,2, y,1, a), Inc;
  99. if(p->kbc) PrintSpriteA(sp_HUD_H_KC3, x,2, y,1, a), Inc;
  100. #undef Inc
  101. }
  102. void HUD_DrawHealth(struct player *p, i32 health, i32 x, i32 y, i32 cr, i32 cr_fade) {
  103. i32 protect = p->megaProtect;
  104. ACS_BeginPrint();
  105. ACS_PrintInt(health);
  106. PrintTextX(s_bigupper, cr, x,1, y,0, ptf_no_utf);
  107. if(protect) {
  108. k32 amt = protect / 200.0;
  109. ACS_BeginPrint();
  110. ACS_PrintInt(health);
  111. PrintTextAX(s_bigupper, CR_TAN, x,1, y,0, amt, ptf_no_utf);
  112. }
  113. if(CheckFade(fid_health)) {
  114. ACS_BeginPrint();
  115. ACS_PrintInt(health);
  116. PrintTextFX(s_bigupper, cr_fade, x,1, y,0, fid_health, ptf_no_utf);
  117. }
  118. }
  119. /* EOF */