Skip to content

EditorPanel beta ​

Interface of @v12-engine/editor

ts
export interface EditorPanel<A = unknown>

A panel open in the editor, as it is given to what draws it (EditorPanelProps.panel, mount's third argument): made as it opens, done with as it closes. Its reads (title, badge, shown, size) follow in Solid. What is started through it (onShown, onClose) is taken away when it closes

Members ​

api ​

ts
readonly api: A | undefined;

What it offers the other panels (provide), for editor.panels.api(id) and panels.when(id): the waves panel's pick(wave), which the preview panel calls. Nothing until it provides

badge ​

ts
badge(): EditorPanelBadge | undefined;

What its icon has on it now: what it set, else what its definition works out

close ​

ts
close(): void;

Closes the panel

closed ​

ts
readonly closed: boolean;

Whether it is closed: the handle of a panel that was, and is no more

draw ​

ts
draw(make: (lines: PanelLines, editor: EditorClient) => PanelDrawing, options?: PanelDrawOptions): () => void;

Draws something of the panel's into the editor's view (the rings of a wave's spawns, a lane): make is given lines to draw with (PanelLines: line, path, circle), said once as it is made, and gives back something to dispose, or nothing. Made as the panel shows, hidden while it cannot be seen, taken away as it closes, and made again on the map's changes where asked (again). Unlit and never picked; in the world unless the options say (onTop). Gives back what takes it away sooner

editor ​

ts
readonly editor: EditorClient;

The editor the panel is open in

failed ​

ts
failed(error: unknown, where: string): void;

Says a failure of the panel's, as one it threw would be: in the Console with its id, and over the panel with Reload (what went wrong, where, its stack). The editor goes on

filter ​

ts
filter(options?: {
        placeholder?: string;
        fuzzy?: boolean;
    }): PanelFilter;

What the panel searches its own list by: the words typed in a search field of the kit's, and the field itself (PanelFilter). One per panel, made the first time; empty each time the panel opens. fuzzy: false makes its find take the words as typed, a typo finding nothing

focus ​

ts
focus(): void;

Brings it to the front, and the keyboard into it

frame ​

ts
frame(run: (dt: number, editor: EditorClient) => void): () => void;

Something to do before each frame the editor draws, while the panel shows, with the seconds since the last: what moves what the panel drew. One that throws is taken out and said in the Console, and the editor draws on. Gives back what stops it

guard ​

ts
guard<T>(where: string, run: () => T): T | undefined;

Runs something as the panel's: what it throws is the panel's failure (failed), and it gives back nothing then

id ​

ts
readonly id: string;

The panel's id, as EditorPanelDef.id has it

on ​

ts
on<K extends EditorEventName>(name: K, listener: (data: EditorEvents[K]) => void): () => void;

Hears of an event of the editor's bus (editor.bus.on), as long as the panel is open: what it registers goes with it when it closes. One that throws is said in the Console with the panel's name. Gives back what stops it

on ​

ts
on(name: string, listener: (data: unknown) => void): () => void;

Hears of an event of the bus that has no entry in EditorEvents, while the panel is open; gives back what stops it

onClose ​

ts
onClose(listener: () => void): () => void;

Something to do when it closes (what it started, taken away). Gives back what stops it

onReveal ​

ts
onReveal(listener: (id: string) => void): () => void;

Told the id of one of its entries picked in the search of everything (EditorPanelDef.search), or asked for in code (editor.panels.reveal): shows it, scrolled to and picked. Gives back what stops it

onShown ​

ts
onShown(listener: (shown: boolean) => void): () => void;

Told each time it is shown or hidden. Gives back what stops it

pick ​

ts
pick(options: MapPickOptions | ((at: MapPick) => void)): () => void;

Asks for the next click in the scene (or every one, many): it goes to the panel with the ground under it, its cell and what stands there (MapPick), not to the picked tool, and the pointer is told of meanwhile (hover). Escape stops asking, as does the panel going behind another or closing (cancelled). The status line says hint while it asks. A panel that wants a whole tool declares one (GameToolDef) and picks it (editor.setTool({ kind: 'custom', id })). Gives back what stops asking

provide ​

ts
provide(api: A): void;

Offers the other panels what it can do, from now on while it is open: an object of functions, typed by EditorPanelApis

run ​

ts
run<T>(where: string, promise: Promise<T>): Promise<T | undefined>;

Waits for something of the panel's: what it rejects with is the panel's failure (failed), said in the Console and over the panel with Reload, and it gives back nothing then. Without it a promise that fails is nobody's

setBadge ​

ts
setBadge(badge?: EditorPanelBadge): void;

What its icon has on it while it is open (a count, a few words); none takes it away

setTitle ​

ts
setTitle(title?: string): void;

What its tab and its icon say, from now on while it is open; its definition's name again with none

shown ​

ts
shown(): boolean;

Whether it can be seen now: open and in front, over the scene or floating. Not while another's tab is in front of it, while the panels are put away (the scene alone), nor while it slides out

size ​

ts
size(): {
        width: number;
        height: number;
    };

How big its room is, in CSS pixels

state ​

ts
state<T>(key: string, initial: T): EditorPanelState<T>;

A value of its own, kept in this browser for the next time it opens (a filter, a tab, what is picked): read as a function (it follows in Solid) or get(), changed with set. What it was last set to, or initial. Written a moment after it changes, not on every change; per game and per panel, not shared with the team

title ​

ts
title(): string;

What its tab and its icon say now: its definition's name, or what it set

viewport ​

ts
viewport(canvas: HTMLCanvasElement, options?: PanelViewportOptions): PanelViewport;

A view of the panel's own on a canvas of the panel's: another look at the editor's map, from over its middle. Drawn while the panel shows, at the canvas's size and the window's pixel ratio, not at the low graphics preset unless it says (always): every draws it less often, maxWidth smaller. Taken away with the panel, or sooner (dispose)