UNPKG

@wonderlandengine/editor-api

Version:

Wonderland Engine's Editor API for plugins - very experimental.

164 lines (163 loc) 5.15 kB
/// <reference types="node" resolution-mode="require"/> /** Image to be used in {@link ui}. */ export declare class UiImage { _id: number; constructor(id: number); /** Manually mark this image as no longer needed */ free(): void; } /** Simple text */ export declare const text: (text: string) => void; /** Label for the next UI element */ export declare const label: (text: string) => void; /** * Simple button * @param label Label for the button. * @returns `true` when pressed this frame. * * @example * In a draw function of a plugin, use as follows: * ```ts * if(ui.button('Click me!')) { * console.log('You clicked the button.'); * } * ``` */ export declare const button: (label: string) => boolean; /** * Load a ui image. Any format supported by the editor is supported. * * @param filepath Path to the file. * @returns Promise with the loaded UiImage * * @example * In a draw function of a plugin, use as follows: * ```ts * this.thumbnail = null; * loadImage(fs.readFileSync("cache/plugins/my-plugin/downloads/thumbnail.png")) * .then((img) => this.thumbnail = img); * ``` * * @see image() */ export declare function loadImage(data: ArrayBuffer | Buffer): Promise<UiImage>; export declare function image(image: UiImage, width: number, height: number): boolean; /** * Text input field. * * @param label Label to display next to the field. * @param value Current value to set the field to. * @returns The new string value when changed by the user this frame, otherwise `null`. * * @example * s = ui.inputText("change this:", s) || s; */ export declare const inputText: (label: string, value: string) => string | null; /** * Text input field multi line. * * @param widgetId Unique id for the widget. * @param value Current value to set the field to. * @returns The new string value when changed by the user this frame, otherwise `null`. * * @example * s = ui.inputTextMultiline("change this:", s) || s; */ export declare const inputTextMultiline: (widgetId: string, value: string) => string | null; /** * Checkbox. * * @param label Label to display next to the checkbox. * @param value Current value to set the checkbox to. * @returns The new boolean value when changed by the user this frame, otherwise `null`. * * @example * const n = ui.checkbox("change this:", myBool); * if(n !== null) myBool = n; */ export declare const checkbox: (label: string, value: boolean) => boolean | null; /** * Color picker for RGBA color. * * @param label Label to display next to the picker. * @param value Value to be in-place edited. * @returns `true` if changed by the user this frame, `false` otherwise. * * @example * const col = new Float32Array(4); * if(ui.colorEdit4("My color:", col)) { * console.log("Changed!"); * } */ export declare const colorEdit4: (label: string, value: Float32Array) => boolean; /** * Dummy element (space). * * @param width Width of the dummy element * @param height Height of the dummy element */ export declare const dummy: (width: number, height: number) => void; /** * Draw next widget on the same line. * * @param offset Offset on the x axis. */ export declare const sameLine: (offset?: number) => void; /** Separator line. */ export declare const separator: () => void; /** Begin a widget group. */ export declare const beginGroup: () => void; /** End a widget group. */ export declare const endGroup: () => void; /** Spinner to indicate loading. */ export declare const spinner: () => void; /** * Draggable float input * @param label Label for the input. * @param value Current value. * @returns The new value when changed by the user this frame, otherwise `null`. * * @example * let myFloat = 0; * const n = ui.inputFloat("change this:", myFloat); * if(n !== null) myFloat = n; */ export declare const inputFloat: (label: string, value: number) => number | null; /** * Draggable float3 input * @param label Label for the input. * @param value Current value. * @returns `true` if changed by the user this frame, `false` otherwise. * * @example * const myFloat3 = new Float32Array(3); * if(ui.inputFloat3("change this:", myFloat3)) { * console.log("changed"); * } */ export declare const inputFloat3: (label: string, value: Float32Array) => boolean; /** * Draggable int input * @param label Label for the input. * @param value Current value. * @returns The new value when changed by the user this frame, otherwise `null`. * * @example * let myInt = 0; * const n = ui.inputInt("change this:", myInt); * if(n !== null) myInt = n; */ export declare const inputInt: (label: string, value: number) => number | null; /** * Draggable int3 input * @param label Label for the input. * @param value Current value. * @returns `true` if changed by the user this frame, `false` otherwise. * * @example * const myInt3 = new Int32Array(3); * if(ui.inputInt3("change this:", myInt3)) { * console.log("changed"); * } */ export declare const inputInt3: (label: string, value: Int32Array) => boolean;