Cauldron2D.Client.Hud (Cauldron2D v0.1.3)

Copy Markdown View Source

The shapes a game's hud comes in, and one form every front end reads.

A hud is rows of runs — [row] drawn under the world — or %{left: [row], width: columns, bottom: [row]}, a column of rows beside the world and rows under both. A row is [run] or {tag, [run]}, the tag naming the row for a front end that styles or hides rows by name. A run is text, {text, colour} or {text, style}, colour an {r, g, b} or nil and style a map with :fg (an {r, g, b} or a colour name Linocut.Palette knows) and :bold.

Summary

Functions

A run's foreground as {r, g, b}, or nil.

The hud as a column of rows, its width in cells, and the rows under the world.

Every row in reading order: the column, then the rows under.

The runs of a row as {text, style} pairs.

A row's tag, or nil.

A row's text with no styling.

Types

rgb()

@type rgb() :: {byte(), byte(), byte()}

row()

@type row() :: [run()] | {atom(), [run()]}

run()

@type run() :: String.t() | {String.t(), rgb() | nil} | {String.t(), style()}

style()

@type style() :: %{optional(:fg) => rgb() | atom(), optional(:bold) => boolean()}

t()

@type t() ::
  [row()]
  | %{:left => [row()], :width => pos_integer(), optional(:bottom) => [row()]}

Functions

colour(arg)

@spec colour({String.t(), style()}) :: rgb() | nil

A run's foreground as {r, g, b}, or nil.

layout(rows)

@spec layout(t()) :: %{left: [row()], width: non_neg_integer(), bottom: [row()]}

The hud as a column of rows, its width in cells, and the rows under the world.

rows(hud)

@spec rows(t()) :: [row()]

Every row in reading order: the column, then the rows under.

runs(runs)

@spec runs(row()) :: [{String.t(), style()}]

The runs of a row as {text, style} pairs.

tag(arg1)

@spec tag(row()) :: atom() | nil

A row's tag, or nil.

text(row)

@spec text(row()) :: String.t()

A row's text with no styling.