The selection panel
The bottom of the HUD shows what is selected: one unit's sheet, a group's tiles with subgroups, or a hero's panel. You set what a click or a box selects, what the panel shows, and listen to changes.
Quick start
input: {
selection: {
max: 24, // at most 24 at once
clickEmpty: 'clear', // a click on nothing lets go ('keep' is the default)
army: (entity) => entity.def.id !== 'peasant' // what Shift+` selects
},
selectionChanged: (ids, client) => console.log('selected', ids)
},
hud: { heroStats: ['attackDamage', 'armor', 'moveSpeed'] }Selection is capped at 24, clicking empty ground deselects, and the hero panel shows three stats.
Common tasks
Read what is selected
client.ui.selection() // a signal: what the panel shows
const stop = client.hud.on('selection', ({ ids }) => highlight(ids))Select from code
client.controller holds the player's hands: select, control groups, items. In a Solid component, useHud(client).select(ids) and pickSubgroup(type) do what the HUD does.
Change what a box or double-click takes
selection: {
box: (inside) => inside.filter((entity) => entity.def.id !== 'sheep'), // what a drag box takes
similar: (clicked, other) => clicked.def.id === other.def.id, // what a double-click adds
primary: (selected) => selected[0] // who the card is about
}Lock the selection
The selection.lock action (and controller.setSelectionLocked) keeps the selection from changing; selection.locked decides it in code.
Change the words for what a unit is doing
hud: { words: { idle: 'Resting', orders: { move: 'Marching' } } }
// or in code
hud: { activity: (entity) => (entity.def.id === 'peasant' ? 'Working hard' : undefined) }Change the stat lines
GameView.hud.stats(entity, lines) changes the lines a unit's sheet shows. Four tones colour what a line is about (--vg-tone-physical, -magic, -defense, -resist).
Outline or highlight a unit
units: {
hover: { color: [1, 0.85, 0.4], width: 2 }, // what the pointer is over
select: { color: [0.5, 0.8, 1], width: 2 }, // what is selected, beside its ring
target: (entity, ability) => (entity.isEnemy ? { style: 'glow', color: [1, 0.3, 0.2], pulse: true } : false) // what an aimed ability could be cast on
}
// in code: anything, until the handle takes it off
const here = client.outline(hallId, { color: [1, 0.9, 0.3], width: 3, pulse: 1.5, throughWalls: true })
here.set({ color: [0.4, 1, 0.4] })
here.remove()
client.outline({ doodad: gateId }) // the scenery
client.outline({ item: chestId }, { style: 'glow' }) // an item on the groundA line around the thing's silhouette on the screen, as wide wherever it stands (style: 'line', the default), or a soft glow out from it ('glow'). Several outlines on one thing show the latest. A unit drawn among the copies of its crowd is given its own skeleton while outlined; a building is given a copy of its own, so its twins are not outlined with it. client.hoverOutline turns the pointer's off for a player.
Reference
What the panel shows
| Selected | Panel |
|---|---|
| one unit or building | its sheet: portrait, health, mana, stats, queue |
| several | tiles; the card is about one subgroup (Tab or a chip to change) |
| a hero alone | the hero panel (with heroes on: heroesViewPack()) |
useHud(client).focus() says which: 'hero', 'unit', 'group' or 'none'. A hero's experience is shown as tall as its health and mana so its words read.
Selection rules (GameView.input.selection)
| Field | What |
|---|---|
box | what a drag box takes from what is inside |
similar | what a double-click adds |
order | the order of the selection |
primary | who the card is about |
max | how many at most |
army | what select.army selects |
locked | whether a selection is locked |
clickEmpty | 'keep' (default), 'clear', or a function of the click |
GameView.input.selectionChanged(ids, client) hears every change.
The hero panel
hud.heroStats says which stats it shows. GameView.hud.shopTiers sets the shop's tiers. The panel is the HUD part heroPanel; the heroes' column is heroes. Both come from the heroes' view pack (GameView.packs: [heroesViewPack()]).
Outlines (OutlineLook)
| Field | What |
|---|---|
color | red, green, blue, 0 to 1; pale gold when left out |
width | pixels: 2 when left out (a glow's reach) |
pulse | seconds a round, true for 1.2: the line swells from half its width and back; steady when left out |
throughWalls | seen whole where something stands in front of it; left out, the hidden parts are dimmed (a depth pass of the scene while any such line is up) |
style | 'line' (default) along the edge, or 'glow' out from it |
GameView.units.hover, select and target take one, or a function of the entity (target's of the entity and the ability) that gives one or false. client.outline(target, look) puts one on an entity by id, { doodad } or { item }, and gives a handle: set(look), remove(), removed. The pointer's and the selection's go through the renderer's outline layer: each way of drawing a line (its colour, width, pulse, whether it is seen through walls; a glow) is one style of it, made the first time it is asked for, a handful at once; it touches no material, and the picture's anti-aliasing (TAA too) smooths the lines with the rest.