hud.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ---@meta
  2. ---HUD element types
  3. --------------------
  4. ---@class mt.HUDProto
  5. -- The `position` field is used for all element types.
  6. --
  7. -- To account for differing resolutions, the position coordinates are the
  8. -- percentage of the screen, ranging in value from `0` to `1`.
  9. --
  10. -- The name field is not yet used, but should contain a description of what the
  11. -- HUD element represents.
  12. ---@field position mt.Vector
  13. -- The `offset` field specifies a pixel offset from the position. Contrary to
  14. -- position, the offset is not scaled to screen size. This allows for some
  15. -- precisely positioned items in the HUD.
  16. --
  17. -- **Note**: `offset` _will_ adapt to screen DPI as well as user defined scaling
  18. -- factor!
  19. ---@field offset mt.Vector
  20. -- Displays an image on the HUD.
  21. ---@class mt.HUDImage:mt.HUDProto
  22. -- * The scale of the image, with 1 being the original texture size.
  23. -- * Only the X coordinate scale is used (positive values).
  24. -- * Negative values represent that percentage of the screen it
  25. -- should take; e.g. `x=-100` means 100% (width).
  26. ---@field scale number
  27. ---@field text string The name of the texture that is displayed.
  28. ---@field alignment mt.Vector The alignment of the image.
  29. -- Displays text on the HUD.
  30. ---@class mt.HUDText:mt.HUDProto
  31. ---@field scale mt.Vector Defines the bounding rectangle of the text.
  32. ---@field text string The text to be displayed in the HUD element.
  33. ---@field number mt.ColorInteger Color used to draw the text.
  34. ---@field alignment mt.Vector The alignment of the text.
  35. -- The player-set font size is multiplied by size.x (y value isn't used).
  36. ---@field size mt.Vector
  37. -- Displays a horizontal bar made up of half-images with an optional background.
  38. ---@class mt.HUDStatBar:mt.HUDProto
  39. ---@field text string The name of the texture to use.
  40. -- Optional texture name to enable a background / "off state"
  41. -- texture (useful to visualize the maximal value). Both textures
  42. -- must have the same size.
  43. ---@field text2 string|nil
  44. -- The number of half-textures that are displayed.
  45. -- If odd, will end with a vertically center-split texture.
  46. ---@field number number
  47. ---@field item number Same as `number` but for the "off state" texture.
  48. ---@field direction number To which direction the images will extend to.
  49. -- If used, will force full-image size to this value
  50. -- (override texture pack image size)
  51. ---@field size mt.Vector|nil
  52. ---@class mt.HUDInventory:mt.HUDProto
  53. ---@field text string The name of the inventory list to be displayed.
  54. ---@field number number Number of items in the inventory to be displayed.
  55. ---@field item number Position of item that is selected.
  56. ---@field direction number
  57. -- Displays distance to selected world position.
  58. ---@class mt.HUDWaypoint:mt.HUDProto
  59. ---@field name string The name of the waypoint.
  60. ---@field text string Distance suffix. Can be blank.
  61. -- * Waypoint precision, integer >= 0.
  62. -- * Defaults to 10.
  63. -- * If set to 0, distance is not shown.
  64. -- * Shown value is `floor(distance*precision)/precision`.
  65. -- * When the precision is an integer multiple of 10, there will be
  66. -- `log_10(precision)` digits after the decimal point.
  67. -- * `precision = 1000`, for example, will show 3 decimal places (eg: `0.999`).
  68. -- * `precision = 2` will show multiples of `0.5`;
  69. -- * `precision = 5` will show multiples of `0.2` and so on:
  70. -- * `precision = n` will show multiples of `1/n`.
  71. ---@field precision integer
  72. ---@field number mt.ColorInteger Color used to draw the text.
  73. ---@field world_pos mt.Vector World position of the waypoint.
  74. ---@field alignment mt.Vector The alignment of the waypoint.
  75. -- Same as `mt.HUDWaypoint`, but does not accept a `position`;
  76. -- the position is instead determined by `world_pos`,
  77. -- the world position of the waypoint.
  78. ---@class mt.HUDImageWaypoint:mt.HUDProto
  79. -- * The scale of the image, with 1 being the original texture size.
  80. -- * Only the X coordinate scale is used (positive values).
  81. -- * Negative values represent that percentage of the screen it
  82. -- should take; e.g. `x=-100` means 100% (width).
  83. ---@field scale mt.Vector
  84. ---@field text string The name of the texture that is displayed.
  85. ---@field alignment mt.Vector The alignment of the image.
  86. ---@field world_pos mt.Vector World position of the waypoint.
  87. -- Displays an image oriented or translated according to current heading direction.
  88. ---@class mt.HUDCompass:mt.HUDProto
  89. -- The size of this element. Negative values represent percentage
  90. -- of the screen; e.g. `x=-100` means 100% (width).
  91. ---@field size mt.Vector
  92. ---@field scale number Scale of the translated image (used only for dir = 2 or dir = 3).
  93. ---@field text string The name of the texture to use.
  94. ---@field alignment mt.Vector The alignment of the image.
  95. -- How the image is rotated/translated:
  96. --
  97. -- * 0 - Rotate as heading direction
  98. -- * 1 - Rotate in reverse direction
  99. -- * 2 - Translate as landscape direction
  100. -- * 3 - Translate in reverse direction
  101. -- If translation is chosen, texture is repeated horizontally to fill the whole element.
  102. ---@field dir integer
  103. -- Displays a minimap on the HUD.
  104. ---@class mt.HudMinimap:mt.HUDProto
  105. -- Size of the minimap to display. Minimap should be a square to avoid distortion.
  106. ---@field size mt.Vector
  107. ---@field alignment mt.Vector The alignment of the minimap.
  108. ---@alias mt.HUDElement mt.HudMinimap|mt.HUDWaypoint|mt.HUDInventory|mt.HUDCompass|mt.HUDStatBar|mt.HUDText|mt.HUDImageWaypoint|mt.HUDImage|mt.HUDFlags