hud

package
v0.1.81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hud draws a mod's HUD in the stock HUD's look, from the tokens in package theme. Text sets VALVEPulp capitals over a soft shadow, plates and pills hold text over a bright sky, and pips count as the stock round counter does. The roster lists the players down the top right corner. Actions are the game's menu buttons, with its hover and press sounds, and a meter fills toward its value.

ui.Show(p, hud.TopStrip{Heading: "Round 2", Children: hud.Score{Points: [2]int{1, 0}}})

Each component is a struct whose Render returns the elements of package ui that stand for it.

Index

Constants

View Source
const RosterRows = 6

RosterRows is the most players the roster shows, above the minimap.

Variables

This section is empty.

Functions

func RosterKey

func RosterKey(rows []RosterRow) string

RosterKey is what the roster shows, to redraw only when it changes.

Types

type Action

type Action struct {
	// Kind is Primary, Secondary or Quiet; Secondary unless set.
	Kind ActionKind
	// Disabled dims the action and takes no presses.
	Disabled bool
	// OnPress runs when the player presses the action.
	OnPress func(p mod.Player)
	// Style is drawn over the action's style.
	Style ui.Style
	// Text is what the action reads.
	Text string
}

Action is a button in the game's menu look: capitals on a fill that lights as the pointer enters, with the main menu's hover and press sounds.

func (Action) Render

func (a Action) Render() ui.Node

Render returns the action's button.

type ActionKind

type ActionKind string

ActionKind is how much an action draws the eye.

const (
	// Secondary is every action but the one a screen leads with; it is the
	// default.
	Secondary ActionKind = ""
	// Primary is the one action a screen leads with.
	Primary ActionKind = "primary"
	// Quiet is an action that should not draw the eye.
	Quiet ActionKind = "quiet"
)

The action kinds.

type Banner struct {
	// Title is the banner's heading.
	Title string
	// Detail is the line under the title, if any.
	Detail string
	// Tone colors the title.
	Tone theme.Tone
	// Style is drawn over the banner's style.
	Style ui.Style
}

Banner announces a moment: a centered title in the heading face with a muted detail under it. It grows in as it appears and fades as it goes.

func (Banner) Render

func (b Banner) Render() ui.Node

Render returns the banner's panel.

type Meter

type Meter struct {
	// Value is how full the meter is, from 0 to 1.
	Value float32
	// Tone fills the bar; Accent unless set.
	Tone theme.Tone
	// Width is the meter's width in pixels; 160 unless set.
	Width float32
	// Height is the meter's height in pixels; 8 unless set.
	Height float32
	// Style is drawn over the meter's style.
	Style ui.Style
}

Meter is a bar that fills from the left toward its value, easing to each new value: a charge, a capture or a timer.

func (Meter) Render

func (m Meter) Render() ui.Node

Render returns the meter's panels.

type Pill

type Pill struct {
	// Flow places the children; Right unless set.
	Flow ui.Flow
	// Style is drawn over the pill's style.
	Style ui.Style
	// Children are what the pill holds.
	Children ui.Node
}

Pill is the plate rounded into a capsule with a faint parchment edge, flowing right: the counter under a top strip's heading.

func (Pill) Render

func (b Pill) Render() ui.Node

Render returns the pill's panel.

type Pips

type Pips struct {
	// Filled is how many pips are lit.
	Filled int
	// Total is how many pips show.
	Total int
	// Tone fills the lit pips.
	Tone theme.Tone
	// Shape is a round point, as the stock round counter, or a narrow tick;
	// Round unless set.
	Shape theme.PipShape
	// Mirror fills from the right, for the far side of a counter.
	Mirror bool
	// Style is drawn over the row's style.
	Style ui.Style
}

Pips shows a count out of a fixed total as filled and empty pips, as the stock round counter does.

func (Pips) Render

func (p Pips) Render() ui.Node

Render returns the row of pips.

type Plate

type Plate struct {
	// Flow places the children; Down unless set.
	Flow ui.Flow
	// Style is drawn over the plate's style.
	Style ui.Style
	// Children are what the plate holds.
	Children ui.Node
}

Plate is the dark plate under HUD text, readable over a bright sky.

func (Plate) Render

func (b Plate) Render() ui.Node

Render returns the plate's panel.

type Roster

type Roster struct {
	// Rows are the players, in the order they show.
	Rows []RosterRow
	// Top is the roster's top margin in pixels, under the FPS readout unless
	// set.
	Top *float32
}

Roster stacks up to RosterRows players down the top right corner, each one's hero portrait at the edge with their name and a line, such as what they are doing or their score, to its left. It shows nothing without rows. A mode that hides the stock scoreboard's heroes shows who else is here with it.

func (Roster) Render

func (r Roster) Render() ui.Node

Render returns the roster's panel, or nil without rows.

type RosterRow

type RosterRow struct {
	// Name is the player's name.
	Name string
	// Self marks the viewing player's own row.
	Self bool
	// Hero is the player's hero as the pawn reports it, or 0 without one.
	Hero uint32
	// Activity is the line under the name, such as "Free roam".
	Activity string
	// SteamID badges the portrait's corner with the player's Steam avatar;
	// 0 shows none.
	SteamID uint64
	// OnPress makes the row a button the viewer presses while they have a
	// cursor, such as to open a card about that player.
	OnPress func(p mod.Player)
	// Selected edges the portrait in the accent, as for the row a card shows.
	Selected bool
}

RosterRow is one player as the roster shows them.

type Score

type Score struct {
	// Points are each side's points, the near side first.
	Points [2]int
	// Tones color each side; unset, the near side is the accent and the far
	// side the text.
	Tones [2]theme.Tone
}

Score is a counter's points, each side in its tone, in the title face. It sits in a pill, so its text is plated.

func (Score) Render

func (s Score) Render() ui.Node

Render returns the row of points.

type Tag

type Tag struct {
	// Tone colors the border, and the text or the fill.
	Tone theme.Tone
	// Filled fills the tag, for a result; unset, it is outlined, for a status
	// read in a list.
	Filled bool
	// Style is drawn over the tag's style.
	Style ui.Style
	// Text is what the tag reads.
	Text string
}

Tag names a status or a result in small heading capitals, in a 1px border of its tone.

func (Tag) Render

func (t Tag) Render() ui.Node

Render returns the tag's label.

type Text

type Text struct {
	// Role is the label's step of the type scale.
	Role theme.Role
	// Tone colors the text; a Label role is muted and the rest are text.
	Tone theme.Tone
	// Plated marks text on a plate or pill, which takes no shadow: on the dark
	// plate a shadow only smears the glyphs.
	Plated bool
	// Style is drawn over the role's style.
	Style ui.Style
	// Text is what the label reads.
	Text string
}

Text is one label in a type role, over the soft shadow unless plated.

func (Text) Render

func (t Text) Render() ui.Node

Render returns the label.

type TopStrip

type TopStrip struct {
	// Heading names the mode or round and the lane, over the counter.
	Heading string
	// Line is a short line under the counter, such as a clock or the news.
	Line string
	// LineTone colors the line; Text unless set.
	LineTone theme.Tone
	// KeepTeamBar seats the strip under the stock team bar, which keeps its
	// clock, heroes and player slots; unset, it takes the bar's place.
	KeepTeamBar bool
	// Children are the counter's content, such as Score and Pips.
	Children ui.Node
}

TopStrip is the top block of an arena HUD: a heading in spaced capitals, the counter pill, and a line under it. Under the kept team bar, the heading and pill fit above the stock objective bar and the line goes below that bar.

func (TopStrip) Render

func (s TopStrip) Render() ui.Node

Render returns the strip's panels.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL