Skip to content

HudLayout beta ​

Class of @v12-engine/client

ts
export declare class HudLayout

The layout of the HUD while a game is on (see the top of this file). The client has one: client.layout

Members ​

constructor ​

ts
constructor(
    storageKey: string | undefined, 
    spec?: LayoutSpec | undefined, 
    legacyKey?: string | undefined);

Constructs a new instance of the HudLayout class

all ​

ts
all(): Record<string, Readonly<SectionState>>;

Every section that was moved, scaled, folded or locked, by id

collapse ​

ts
collapse(id: string, collapsed?: boolean): void;

Folds a section away to a tab, or opens it with false

edit ​

ts
edit(on?: boolean): void;

Turns the layout mode on or off

editing ​

ts
editing(): boolean;

Whether the layout mode is on: every section shows its box, to move, scale, fold and lock

fromJSON ​

ts
fromJSON(layout: Record<string, Partial<SectionState>>): void;

Puts a layout from toJSON in place of this one

get ​

ts
get(id: string): Readonly<Section>;

A section as it is now, with what the game lets be done with it. Read inside the HUD, it updates as it changes

keep ​

ts
keep(): void;

Keeps the layout for the next game of the same kind, as it is now: after a drag (see set)

lock ​

ts
lock(id: string, locked?: boolean): void;

Locks a section against moves, or unlocks it with false

moveBy ​

ts
moveBy(id: string, dx: number, dy: number): void;

Moves a section by so much more, as the player drags it. Not while it is locked

onChange ​

ts
onChange(listener: (id: string | undefined) => void): () => void;

Calls back when a section changes (with its id), or the layout mode or all of it (with none), until what this gives back is called

reset ​

ts
reset(id?: string): void;

Back to where the game starts it, one section or all of them

set ​

ts
set(id: string, change: Partial<SectionState>, options?: {
        keep?: boolean;
    }): void;

Changes a section: where it is, how big, folded, locked. What the game does not allow is left as it is. keep: false does not keep it for the next game yet: while it is dragged, kept once it is let go of

toJSON ​

ts
toJSON(): Record<string, SectionState>;

The whole layout as plain data, to keep or send somewhere