/src/MenuCharacter.h

http://github.com/clintbellanger/flare · C Header · 135 lines · 100 code · 16 blank · 19 comment · 0 complexity · cc634269bb5c275be0303d6c0bd601e4 MD5 · raw file

  1. /*
  2. Copyright 2011 Clint Bellanger
  3. This file is part of FLARE.
  4. FLARE is free software: you can redistribute it and/or modify it under the terms
  5. of the GNU General Public License as published by the Free Software Foundation,
  6. either version 3 of the License, or (at your option) any later version.
  7. FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  9. PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License along with
  11. FLARE. If not, see http://www.gnu.org/licenses/
  12. */
  13. /**
  14. * class MenuCharacter
  15. */
  16. #ifndef MENU_CHARACTER_H
  17. #define MENU_CHARACTER_H
  18. #include <SDL.h>
  19. #include <SDL_image.h>
  20. #include <SDL_mixer.h>
  21. #include "Utils.h"
  22. #include "FontEngine.h"
  23. #include "StatBlock.h"
  24. #include "WidgetTooltip.h"
  25. #include "InputState.h"
  26. #include "WidgetButton.h"
  27. #include "SharedResources.h"
  28. #include "WidgetLabel.h"
  29. #include <string>
  30. #include <sstream>
  31. const int CSTAT_NAME = 0;
  32. const int CSTAT_LEVEL = 1;
  33. const int CSTAT_PHYSICAL = 2;
  34. const int CSTAT_HP = 3;
  35. const int CSTAT_HPREGEN = 4;
  36. const int CSTAT_MENTAL = 5;
  37. const int CSTAT_MP = 6;
  38. const int CSTAT_MPREGEN = 7;
  39. const int CSTAT_OFFENSE = 8;
  40. const int CSTAT_ACCURACYV1 = 9;
  41. const int CSTAT_ACCURACYV5 = 10;
  42. const int CSTAT_DEFENSE = 11;
  43. const int CSTAT_AVOIDANCEV1 = 12;
  44. const int CSTAT_AVOIDANCEV5 = 13;
  45. const int CSTAT_DMGMAIN = 14;
  46. const int CSTAT_DMGRANGED = 15;
  47. const int CSTAT_CRIT = 16;
  48. const int CSTAT_ABSORB = 17;
  49. const int CSTAT_FIRERESIST = 18;
  50. const int CSTAT_ICERESIST = 19;
  51. const int CSTAT_COUNT = 20;
  52. const int CPROF_P2 = 0;
  53. const int CPROF_P3 = 1;
  54. const int CPROF_P4 = 2;
  55. const int CPROF_P5 = 3;
  56. const int CPROF_M2 = 4;
  57. const int CPROF_M3 = 5;
  58. const int CPROF_M4 = 6;
  59. const int CPROF_M5 = 7;
  60. const int CPROF_O2 = 8;
  61. const int CPROF_O3 = 9;
  62. const int CPROF_O4 = 10;
  63. const int CPROF_O5 = 11;
  64. const int CPROF_D2 = 12;
  65. const int CPROF_D3 = 13;
  66. const int CPROF_D4 = 14;
  67. const int CPROF_D5 = 15;
  68. const int CPROF_COUNT = 16;
  69. struct CharStat {
  70. WidgetLabel *label;
  71. WidgetLabel *value;
  72. SDL_Rect hover;
  73. TooltipData tip;
  74. void setHover(int x, int y, int w, int h) {
  75. hover.x=x;
  76. hover.y=y;
  77. hover.w=w;
  78. hover.h=h;
  79. }
  80. };
  81. struct CharProf {
  82. SDL_Rect hover;
  83. TooltipData tip;
  84. void setHover(int x, int y, int w, int h) {
  85. hover.x=x;
  86. hover.y=y;
  87. hover.w=w;
  88. hover.h=h;
  89. }
  90. };
  91. class MenuCharacter {
  92. private:
  93. StatBlock *stats;
  94. SDL_Surface *background;
  95. SDL_Surface *proficiency;
  96. SDL_Surface *upgrade;
  97. WidgetButton *closeButton;
  98. WidgetLabel *labelCharacter;
  99. CharStat cstat[CSTAT_COUNT];
  100. CharProf cprof[CPROF_COUNT];
  101. void displayProficiencies(int value, int y);
  102. void loadGraphics();
  103. int bonusColor(int stat);
  104. public:
  105. MenuCharacter(StatBlock *stats);
  106. ~MenuCharacter();
  107. void logic();
  108. void render();
  109. void refreshStats();
  110. TooltipData checkTooltip();
  111. bool checkUpgrade();
  112. bool visible;
  113. bool newPowerNotification;
  114. };
  115. #endif