HUD - Hirato/lamiae GitHub Wiki

Lamiae offers a script hook for the HUD. It exposes a call named r_hud [body] which when executed, sets the body to the HUD. The body is evaluated every time the HUD is drawn (once a frame during normal gameplay). The elements accept colours, sizes, offsets, and miscellaneous other properties, and these are provided to them on the fly via CubeScript.

On Making A Resolution Independent HUD

Lamiae scales a virtual 1600x1200 screen into your chosen resolution. 1600x1200 was chosen so that designers could have a better sense of scale that they would otherwise have with a 0-1 floating point range.

Once scaled down to fit, the boundaries are then adjusted to encompass the whole screen, and are exposed to you via the readonly FVARs, hud_right and hud_bottom which respectively house the horizontal and vertical dimensions.

Some common aspect ratios are listed below with their respective virtual resolutions.

  1. 5:4 --> 1600x1280
  2. 4:3 --> 1600x1200
  3. 16:10 --> 1920x1200
  4. 16:9 --> 2133x1200

This virtual resolution will scale to ANY resolution given to it, allowing HUDs to be created that are truly resolution independent. And with the use of a virtual screen, this assures that the interface will always scale to fit the user's resolution and allow it to be both comfortable and usable.

An identical system is used for the Cutscenes subsystem, although the below doesn't apply to it at all.

'Hudlines'

prototype:
	ICOMMAND(hudline, "C", (const char *t)
script:
	hudline "Quest Complete: Slay the Dragon!"

Hudlines are essentially little info dumps which appear on the centre of the screen. They stack and scroll past and fade as they expire.

Lamiae generates a few of these in hardcoded instances, such as when you're low on resources, or when your journal gets updated. Otherwise, the system is perfectly exposed for use to anyone who wants to make use of them.

The history of these are not saved.

Elements

The elements are drawn in the exact order they are given here, so if you want something to cover something else, define it after it.

Minimap

prototype:
	ICOMMAND(r_hud_minimap, "sffff", (const char *r, float *x, float *y, float *dx, float *dy)

Horizontal Bar

prototype:
	ICOMMAND(r_hud_horizbar, "sfffffii", (const char *i, float *x, float *y, float *dx, float *dy, float *p, int *col)

Vertical Bar

prototype:
	ICOMMAND(r_hud_vertbar, "sfffffi", (const char *i, float *x, float *y, float *dx, float *dy, float *p, int *col)

Text

prototype:
	ICOMMAND(r_hud_text, "fffis", (float *x, float *y, float *sz, int *col, const char *s)

Image

prototype:
	ICOMMAND(r_hud_image, "sffffi", (const char *i, float *x, float *y, float *dx, float *dy, int *c)

Solid

prototype:
	ICOMMAND(r_hud_solid, "ffffi", (float *x, float *y, float *dx, float *dy, int *c)