hud.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
  4. Copyright (C) 2017 red-001 <red-001@outlook.ie>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #pragma once
  18. #include "irrlichttypes_extrabloated.h"
  19. #include <string>
  20. #include "common/c_types.h"
  21. #define HUD_DIR_LEFT_RIGHT 0
  22. #define HUD_DIR_RIGHT_LEFT 1
  23. #define HUD_DIR_TOP_BOTTOM 2
  24. #define HUD_DIR_BOTTOM_TOP 3
  25. #define HUD_CORNER_UPPER 0
  26. #define HUD_CORNER_LOWER 1
  27. #define HUD_CORNER_CENTER 2
  28. #define HUD_STYLE_BOLD 1
  29. #define HUD_STYLE_ITALIC 2
  30. #define HUD_STYLE_MONO 4
  31. // Note that these visibility flags do not determine if the hud items are
  32. // actually drawn, but rather, whether to draw the item should the rest
  33. // of the game state permit it.
  34. #define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
  35. #define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
  36. #define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)
  37. #define HUD_FLAG_WIELDITEM_VISIBLE (1 << 3)
  38. #define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4)
  39. #define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
  40. #define HUD_FLAG_MINIMAP_RADAR_VISIBLE (1 << 6)
  41. #define HUD_FLAG_BASIC_DEBUG (1 << 7)
  42. #define HUD_FLAG_CHAT_VISIBLE (1 << 8)
  43. #define HUD_PARAM_HOTBAR_ITEMCOUNT 1
  44. #define HUD_PARAM_HOTBAR_IMAGE 2
  45. #define HUD_PARAM_HOTBAR_SELECTED_IMAGE 3
  46. #define HUD_HOTBAR_ITEMCOUNT_DEFAULT 8
  47. #define HUD_HOTBAR_ITEMCOUNT_MAX 32
  48. #define HOTBAR_IMAGE_SIZE 48
  49. enum HudElementType {
  50. HUD_ELEM_IMAGE = 0,
  51. HUD_ELEM_TEXT = 1,
  52. HUD_ELEM_STATBAR = 2,
  53. HUD_ELEM_INVENTORY = 3,
  54. HUD_ELEM_WAYPOINT = 4,
  55. HUD_ELEM_IMAGE_WAYPOINT = 5,
  56. HUD_ELEM_COMPASS = 6,
  57. HUD_ELEM_MINIMAP = 7
  58. };
  59. enum HudElementStat : u8 {
  60. HUD_STAT_POS = 0,
  61. HUD_STAT_NAME,
  62. HUD_STAT_SCALE,
  63. HUD_STAT_TEXT,
  64. HUD_STAT_NUMBER,
  65. HUD_STAT_ITEM,
  66. HUD_STAT_DIR,
  67. HUD_STAT_ALIGN,
  68. HUD_STAT_OFFSET,
  69. HUD_STAT_WORLD_POS,
  70. HUD_STAT_SIZE,
  71. HUD_STAT_Z_INDEX,
  72. HUD_STAT_TEXT2,
  73. HUD_STAT_STYLE,
  74. HudElementStat_END // Dummy for validity check
  75. };
  76. enum HudCompassDir {
  77. HUD_COMPASS_ROTATE = 0,
  78. HUD_COMPASS_ROTATE_REVERSE,
  79. HUD_COMPASS_TRANSLATE,
  80. HUD_COMPASS_TRANSLATE_REVERSE,
  81. };
  82. struct HudElement {
  83. HudElementType type;
  84. v2f pos;
  85. std::string name;
  86. v2f scale;
  87. std::string text;
  88. u32 number;
  89. u32 item;
  90. u32 dir;
  91. v2f align;
  92. v2f offset;
  93. v3f world_pos;
  94. v2s32 size;
  95. s16 z_index = 0;
  96. std::string text2;
  97. u32 style;
  98. };
  99. extern const EnumString es_HudElementType[];
  100. extern const EnumString es_HudElementStat[];
  101. extern const EnumString es_HudBuiltinElement[];
  102. // Minimap stuff
  103. enum MinimapType {
  104. MINIMAP_TYPE_OFF,
  105. MINIMAP_TYPE_SURFACE,
  106. MINIMAP_TYPE_RADAR,
  107. MINIMAP_TYPE_TEXTURE,
  108. };