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.

107 lines
2.9KB

  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. * Attribute handling.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include "common.h"
  14. #include "p_player.h"
  15. #include "w_world.h"
  16. /* Static Functions -------------------------------------------------------- */
  17. static void AttrBar(struct gui_state *g, i32 x, i32 y, i32 w, str gfx)
  18. {
  19. G_Clip(g, x, y, w * 4, 8);
  20. PrintSprite(gfx, x,1, y,1);
  21. G_ClipRelease(g);
  22. }
  23. static void DrawAttr(struct gui_state *g, i32 x, i32 y, struct player *p, i32 at)
  24. {
  25. u32 attr = p->attr.attrs[at];
  26. cstr name = p->attr.names[at];
  27. k32 helptrns = 0.5;
  28. if(p->attr.points)
  29. if(G_Button_HId(g, at, .x = x-42 + gui_p.btnnext.w, y-2, Pre(btnnext), .slide = true))
  30. {
  31. p->attr.points--;
  32. p->attr.attrs[at]++;
  33. }
  34. PrintTextChr(name, 3);
  35. PrintText(s_lmidfont, g->defcr, x-24,1, y,1);
  36. PrintSprite(sp_UI_AttrBar1, x,1, y,1);
  37. AttrBar(g, x, y, attr, sp_UI_AttrBar2);
  38. if(attr > ATTR_VIS_MAX)
  39. {
  40. i32 vatr = attr - ATTR_VIS_MAX;
  41. AttrBar(g, x, y, (vatr / (k64)ATTR_VIS_DIFF) * ATTR_VIS_MAX, sp_UI_AttrBar4);
  42. helptrns += 0.3;
  43. }
  44. PrintTextA_str(Language(LANG "ATTR_HELP_%.3s", name), s_smallfnt, g->defcr, x+1,1, y,1, helptrns);
  45. PrintTextFmt("%u/%i", attr, ATTR_VIS_MAX);
  46. PrintText(s_lmidfont, g->defcr, x+202,1, y,1);
  47. }
  48. static void StatusInfo(struct gui_state *g, i32 y, str left, str right)
  49. {
  50. PrintText_str(left, s_lmidfont, g->defcr, 30,1, y,1);
  51. PrintText_str(right, s_smallfnt, g->defcr, 280,2, y,1);
  52. }
  53. /* Extern Functions -------------------------------------------------------- */
  54. void P_CBI_TabStatus(struct gui_state *g, struct player *p)
  55. {
  56. Str(exp, sLANG "STATUS_XP");
  57. Str(hp, sLANG "STATUS_HP");
  58. Str(lv, sLANG "STATUS_LV");
  59. Str(mp, sLANG "STATUS_MP");
  60. Str(next, sLANG "STATUS_NX");
  61. Str(class, sLANG "STATUS_CL");
  62. i32 y = 40;
  63. PrintText_str(p->name, s_lmidfont, g->defcr, 30,1, y,1);
  64. y += 10;
  65. StatusInfo(g, y += 10, L(class), p->classname);
  66. StatusInfo(g, y += 10, L(lv), StrParam("%u", p->attr.level));
  67. StatusInfo(g, y += 10, L(hp), StrParam("%i/%i", p->health, p->maxhealth));
  68. if(p->pclass & pcl_magicuser)
  69. StatusInfo(g, y += 10, L(mp), StrParam("%i/%i", p->mana, p->manamax));
  70. StatusInfo(g, y += 10, L(exp), StrParam("%u", p->attr.exp));
  71. StatusInfo(g, y += 10, L(next), StrParam("%u", p->attr.expnext));
  72. y += p->pclass & pcl_magicuser ? 20 : 30;
  73. if(p->attr.points) {
  74. PrintTextFmt(LC(LANG "STATUS_LEVELUP"), p->attr.points);
  75. PrintText(s_smallfnt, g->defcr, 20,1, y,1);
  76. }
  77. y += 10;
  78. for(i32 i = 0; i < at_max; i++, y += 10)
  79. DrawAttr(g, 53, y, p, i);
  80. }
  81. /* EOF */