Skip to content

Ui beta ​

Interface of @v12-engine/client

ts
export interface Ui

The HUD's model: what it shows, in signals, the client writes and components read (client.ui)

Members ​

addedParts ​

ts
addedParts: Accessor<readonly HudWidgetDef[]>;

The parts the game added to the HUD, besides its own

batch ​

ts
batch: <T>(fn: Accessor<T>) => T;

Runs what sets several of these, and has the screen take them together, once it is done: what shows the selection and its commands never sees one of now with the other of before

cardSize ​

ts
cardSize: Accessor<{
        columns: number;
        rows: number;
    }>;

How many columns and rows the command card has

chatLines ​

ts
chatLines: Accessor<readonly ChatLine[]>;

The lines of chat on the screen now, for a while each

chatOpen ​

ts
chatOpen: Accessor<'allies' | 'all' | null>;

Which chat the player is typing in, allies or all; null while none is open

choice ​

ts
choice: Accessor<ChoiceShown | null>;

The choice a cinematic asks now, with the way to pick (C3), or none

cinematic ​

ts
cinematic: Accessor<CinematicInfo | null>;

A cinematic playing: the HUD makes way for it

clock ​

ts
clock: Accessor<ClockInfo | null>;

The time of day, for a game that has days; null where there is none

commands ​

ts
commands: Accessor<CommandButton[]>;

The buttons of the command card

connection ​

ts
connection: Accessor<ConnectionState>;

How the connection to the server is: connected, trying or lost

debugOpen ​

ts
debugOpen: Accessor<boolean>;

Whether the debug panel is up

debugVersion ​

ts
debugVersion: Accessor<number>;

Bumped when a debug toggle changes, so the panel re-reads them

dialogLook ​

ts
dialogLook: Accessor<DialogLook>;

How the dialog box looks: the view's, and what code changed of it

dialogPrefs ​

ts
dialogPrefs: Accessor<DialogPrefs>;

What the player set of the dialog: subtitles or not, how fast lines are typed (the settings)

dispose ​

ts
dispose(): void;

Stops what is waiting to take a line of chat or a message off the screen

fade ​

ts
fade: Accessor<{
        opacity: number;
        seconds: number;
    }>;

The screen blacked out, as far as it is (see GameClient.fade)

filterMessage ​

ts
filterMessage: ((text: string, kind: UiMessage['kind']) => string | null | undefined) | undefined;

What says something in the middle of the screen goes through first, where the game has a say (GameView.hud.onMessage): other words, or null for none

formation ​

ts
formation: Accessor<string | undefined>;

The formation the player's orders to a point take, by id; the rules' when undefined (controller.setFormation)

game ​

ts
game: Accessor<GameInfo>;

What the game itself puts on the HUD

groups ​

ts
groups: Accessor<GroupInfo[]>;

The control groups the player made, for the row of groups

hiddenParts ​

ts
hiddenParts: Accessor<ReadonlySet<string>>;

The ids of the HUD's parts the game hid

hints ​

ts
hints(): boolean;

Whether the rules' hints are shown (the settings' Hints), and showing them or not

hovered ​

ts
hovered: Accessor<string | undefined>;

The id of the button the pointer is over (controller.hover)

hudConsole ​

ts
hudConsole: Accessor<HudConsole>;

How the HUD's console is laid out (HudConsole): centred, or in the corners

hudHidden ​

ts
hudHidden: Accessor<boolean>;

The HUD is hidden (see client.hideHud): lines of dialog still show

hudKept ​

ts
hudKept: Accessor<ReadonlySet<string> | null>;

The parts that stay while the HUD is hidden, or null for none (see PlayOptions.hud)

hudSize ​

ts
hudSize: Accessor<number>;

How big the HUD is drawn, times its usual size: 1 as it is (the setting HUD size, 0.5 to 2)

idleWorkers ​

ts
idleWorkers: Accessor<number>;

How many of the player's workers are idle

legend ​

ts
legend: Accessor<boolean>;

Whether the list of shortcuts is up

levels ​

ts
levels: Accessor<Readonly<Record<Bus | 'master', number>>>;

The volumes the player set (sounds.setLevel)

line ​

ts
line: Accessor<LineInfo | null>;

The line of dialog said to the player now

log ​

ts
log: Accessor<readonly MessageLogLine[]>;

What was said so far on the screen and in the chat, the newest last

logOpen ​

ts
logOpen: Accessor<boolean>;

Whether the window of the log is up

messages ​

ts
messages: Accessor<UiMessage[]>;

The messages said on the screen now, for a while each

minimapLook ​

ts
minimapLook: Accessor<MinimapLook>;

The game's say over the minimap now (MinimapLook)

mode ​

ts
mode: Accessor<ModeInfo>;

What the pointer is doing: normal, aiming an ability, placing a building

muted ​

ts
muted: Accessor<boolean>;

Whether all sound is off (sounds.setMuted)

objectives ​

ts
objectives: Accessor<ObjectiveInfo[]>;

What the player is set to do, in a mission

outcome ​

ts
outcome: Accessor<Outcome>;

How the game ended for the player: playing, won or lost

places ​

ts
places: Accessor<HudPlaces>;

The places of the HUD's layout, in the HUD's pixels (HudPlaces)

portraitBoxes ​

ts
portraitBoxes: Accessor<number>;

How many portrait boxes of the HUD are up (the selection's sheet, the group's panel, the hero's): a line's speaker talks there (DialogLook.portraitIn)

portraits ​

ts
portraits: Accessor<HudPortraits>;

What the selection's sheet and the hero's panel show as faces (HudPortraits)

pushChat ​

ts
pushChat(line: Omit<ChatLine, 'id'>): void;

A line of chat for the screen, for a while

pushLog ​

ts
pushLog(entry: Omit<MessageLogLine, 'id' | 'tick'> & {
        tick?: number;
    }): void;

Puts a line in the log, as the client does with every message and line of chat: a game's own too

pushMessage ​

ts
pushMessage(text: string, kind?: UiMessage['kind'], seconds?: number): void;

Says something in the middle of the screen for a while: seconds when that is not the usual few

quickCast ​

ts
quickCast: Accessor<boolean>;

Quick cast: a key casts at the pointer at once (controller.setQuickCast)

renderer ​

ts
renderer: Accessor<HudRenderer>;

What draws the game: the renderer, the graphics card (HudRenderer)

resources ​

ts
resources: Accessor<ResourceInfo>;

The amounts of the game's resources and its supply, for the top bar

screenBox ​

ts
screenBox: Accessor<ScreenBox>;

Where the picture shows between the screen's bars (ScreenBox): the skip hint and the HUD's kept parts lay out to it

selection ​

ts
selection: Accessor<SelectionItem[]>;

What is selected, each unit once

selectionLocked ​

ts
selectionLocked: Accessor<boolean>;

Whether the selection is locked, so a click does not change it

setAddedParts ​

ts
setAddedParts: Setter<readonly HudWidgetDef[]>;

Sets the parts the game added to the HUD

setCardSize ​

ts
setCardSize: Setter<{
        columns: number;
        rows: number;
    }>;

Sets how many columns and rows the command card has

setChatOpen ​

ts
setChatOpen: Setter<'allies' | 'all' | null>;

Sets which chat is being typed in, or null for none

setChoice ​

ts
setChoice: Setter<ChoiceShown | null>;

Sets the choice a cinematic asks, or null for none

setCinematic ​

ts
setCinematic: Setter<CinematicInfo | null>;

Sets the cinematic that is playing, or null for none

setClock ​

ts
setClock: (value: ClockInfo | null) => false | ClockInfo | null;

Sets the time of day, giving back false where it says what it said before

setCommands ​

ts
setCommands: (value: CommandButton[]) => false | CommandButton[];

Sets the command card's buttons, giving back false where they say what they said before

setConnection ​

ts
setConnection: Setter<ConnectionState>;

Sets how the connection to the server is

setDebugOpen ​

ts
setDebugOpen: Setter<boolean>;

Opens or closes the debug panel

setDialogLook ​

ts
setDialogLook: Setter<DialogLook>;

Sets how the dialog box looks

setDialogPrefs ​

ts
setDialogPrefs: Setter<DialogPrefs>;

Sets what the player set of the dialog: subtitles, how fast lines are typed

setFade ​

ts
setFade: Setter<{
        opacity: number;
        seconds: number;
    }>;

Sets how far the screen is blacked out and over how many seconds it gets there

setFormation ​

ts
setFormation: Setter<string | undefined>;

Sets the formation the player's orders to a point take, by id; undefined for the rules' own

setGame ​

ts
setGame: (value: GameInfo) => false | GameInfo;

Sets what the game itself puts on the HUD, giving back false where it says what it said before

setGroups ​

ts
setGroups: (value: GroupInfo[]) => false | GroupInfo[];

Sets the control groups, giving back false where they say what they said before

setHiddenParts ​

ts
setHiddenParts: Setter<ReadonlySet<string>>;

Sets the ids of the HUD's parts the game hid

setHints ​

ts
setHints(shown: boolean): void;

Sets whether the rules' hints are shown

setHovered ​

ts
setHovered: Setter<string | undefined>;

Sets the id of the button the pointer is over, or undefined for none

setHudConsole ​

ts
setHudConsole: Setter<HudConsole>;

Sets how the HUD's console is laid out

setHudHidden ​

ts
setHudHidden: Setter<boolean>;

Sets whether the HUD is hidden

setHudKept ​

ts
setHudKept: Setter<ReadonlySet<string> | null>;

Sets which parts stay while the HUD is hidden, or null for none

setHudSize ​

ts
setHudSize: Setter<number>;

Sets how big the HUD is drawn

setIdleWorkers ​

ts
setIdleWorkers: Setter<number>;

Sets how many of the player's workers are idle

setLegend ​

ts
setLegend: Setter<boolean>;

Shows or hides the list of shortcuts

setLevels ​

ts
setLevels: Setter<Readonly<Record<Bus | 'master', number>>>;

Sets the volumes the player set, of everything and of each bus

setLine ​

ts
setLine: Setter<LineInfo | null>;

Sets the line of dialog said to the player now, or null for none

setLogOpen ​

ts
setLogOpen: Setter<boolean>;

Sets whether the window of the log is up

setMinimapLook ​

ts
setMinimapLook: Setter<MinimapLook>;

Sets the game's say over the minimap

setMode ​

ts
setMode: (value: ModeInfo) => false | ModeInfo;

Sets what the pointer is doing, giving back false where it says what it said before

setMuted ​

ts
setMuted: Setter<boolean>;

Sets whether all sound is off

setObjectives ​

ts
setObjectives: (value: ObjectiveInfo[]) => false | ObjectiveInfo[];

Sets the player's objectives, giving back false where they say what they said before

setOutcome ​

ts
setOutcome: Setter<Outcome>;

Sets how the game ended for the player

setPlaces ​

ts
setPlaces: Setter<HudPlaces>;

Sets the places of the HUD's layout

setPortraitBoxes ​

ts
setPortraitBoxes: Setter<number>;

Sets how many portrait boxes of the HUD are up: a box counts itself up as it mounts, down as it goes

setPortraits ​

ts
setPortraits: Setter<HudPortraits>;

Sets what the selection's sheet and the hero's panel show as faces

setQuickCast ​

ts
setQuickCast: Setter<boolean>;

Sets quick cast, so a key casts at the pointer at once

setRenderer ​

ts
setRenderer: Setter<HudRenderer>;

Sets what draws the game: the renderer and the graphics card

setResources ​

ts
setResources: (value: ResourceInfo) => false | ResourceInfo;

Sets the resources, giving back false where they say what they said before

setScreenBox ​

ts
setScreenBox: Setter<ScreenBox>;

Sets where the picture shows between the screen's bars

setSelection ​

ts
setSelection: (value: SelectionItem[]) => false | SelectionItem[];

Sets what is selected, giving back false where it says what it said before

setSelectionLocked ​

ts
setSelectionLocked: Setter<boolean>;

Sets whether the selection is locked

setSlot ​

ts
setSlot<K extends keyof HudModelSlots>(name: K, value: HudModelSlots[K] | undefined): void;

Writes a slot, as its describer does: what reads it hears only of a value that says something else

setStats ​

ts
setStats: Setter<StatsShown>;

Sets what the stats window shows

setStopped ​

ts
setStopped: Setter<ClientStop | null>;

Sets why the client stopped drawing the game, or null

setSubgroups ​

ts
setSubgroups: (value: SubgroupInfo[]) => false | SubgroupInfo[];

Sets the selection by type, giving back false where it says what it said before

setTimers ​

ts
setTimers: (value: TimerInfo[]) => false | TimerInfo[];

Sets the timers the rules show, giving back false where they say what they said before

setTitle ​

ts
setTitle: (value: HudTitle | null) => false | HudTitle | null;

Sets what the top bar says the game is, giving back false where it says what it said before

setViewport ​

ts
setViewport: Setter<{
        width: number;
        height: number;
    }>;

Sets the HUD's viewport, the view's size in CSS pixels

slot ​

ts
slot<K extends keyof HudModelSlots>(name: K): HudModelSlots[K] | undefined;

What a feature described for the HUD (HudModelSlots): the hero alone selected (hero), the player's heroes (heroes), the shop open (shop), a game's own. Undefined where nothing describes it. A signal

snapshot ​

ts
snapshot: () => {
        resources: ResourceInfo;
        selection: SelectionItem[];
        commands: CommandButton[];
        mode: ModeInfo;
        groups: GroupInfo[];
        subgroups: SubgroupInfo[];
        title: HudTitle | null;
        slots: Partial<HudModelSlots>;
        legend: boolean;
        debugOpen: boolean;
        idleWorkers: number;
        quickCast: boolean;
        formation: string | undefined;
        muted: boolean;
        levels: Readonly<Record<Bus | 'master', number>>;
        outcome: Outcome;
        stopped: ClientStop | null;
        connection: ConnectionState;
        messages: UiMessage[];
        stats: StatsShown;
        clock: ClockInfo | null;
        game: GameInfo;
        objectives: ObjectiveInfo[];
        line: LineInfo | null;
        cinematic: CinematicInfo | null;
        fade: {
            opacity: number;
            seconds: number;
        };
        hudHidden: boolean;
        hudKept: string[] | null;
        hiddenParts: string[];
        viewport: {
            width: number;
            height: number;
        };
        hudSize: number;
        chatLines: readonly ChatLine[];
        chatOpen: 'allies' | 'all' | null;
        log: readonly MessageLogLine[];
        logOpen: boolean;
        selectionLocked: boolean;
    };

All of what the HUD shows, read once, as plain data: for a page that draws it in another framework or in plain elements, and to start from before following it with watch. Nothing in it is a signal or holds one

stats ​

ts
stats: Accessor<StatsShown>;

What the stats window shows: frames a second, ping, tick, entities and game speed

stopped ​

ts
stopped: Accessor<ClientStop | null>;

Why the client stopped drawing the game, with the report of what went wrong; null while it runs

subgroups ​

ts
subgroups: Accessor<SubgroupInfo[]>;

The selection by type, for the group panel's chips (SubgroupInfo)

timers ​

ts
timers: Accessor<TimerInfo[]>;

The timers the rules show the player, counted down (world.timers.show)

title ​

ts
title: Accessor<HudTitle | null>;

What the top bar says the game is (HudTitle): null where nothing says

touchDebug ​

ts
touchDebug: () => number;

Bumps the counter debugVersion reads, so the debug panel reads its toggles again, and gives the new count

viewport ​

ts
viewport: Accessor<{
        width: number;
        height: number;
    }>;

Where the HUD is laid out, in CSS pixels: the view's width and height

watch ​

ts
watch: <T>(read: () => T, listener: (value: T) => void, options?: {
        immediate?: boolean;
    }) => () => void;

Follows what a read of the state uses, from any code, with no Solid in it: ui.watch(() = ui.selection().length, (count) = draw(count)). Told when the value changes, not as it starts; gives back what stops it (see watch)