Skip to content

GUI controls clientside ​

Graal-style GUI controls: windows, buttons, text, images, scroll views and events (weapons/gui.client.d.ts).

Source

Generated from templates/server/data/scripts/weapons/gui.client.d.ts. To change this page, edit the JSDoc in that file.

Overview ​

Graal-style GUI controls, backed by Gum on the client.

Creation and property writes batch through the command dispatcher: each control costs one guicreate plus at most one guiset per flush window, no matter how many properties are assigned. Reads of text/x/y/width/height/ visible are live from the host once the control exists (end of the creating tick); before that, reads return what you wrote.

Every control is also published as a global under its name, so Login_Window.hide() works like classic GS2 — prefix control names with your weapon's name to avoid collisions with other weapons.

Controls are destroyed automatically when the weapon that created them is unloaded or reloaded. The exception: controls created from setTimeout / setInterval callbacks are only swept on disconnect, so prefer building UI in onCreated or event handlers.

New controls attach to the screen root by default (no window needed). findobj('GameControl') returns a pseudo-control for the game screen itself: GameControl.addControl(ctrl) makes root parenting explicit and also moves a control back out of a window.

Declarations ​

GuiMouseButton type ​

ts
type GuiMouseButton = 'left' | 'right' | 'middle'

Which physical mouse button an event came from.

GuiButtonEvent interface ​

ts
interface GuiButtonEvent

Payload of click/doubleclick/mousedown/mouseup. x/y are relative to the control's top-left.

GuiButtonEvent.button ​

ts
button: GuiMouseButton

GuiButtonEvent.x ​

ts
x: number

GuiButtonEvent.y ​

ts
y: number

GuiMoveEvent interface ​

ts
interface GuiMoveEvent

Payload of mousemove/mouseenter/mouseleave. x/y are relative to the control's top-left.

GuiMoveEvent.x ​

ts
x: number

GuiMoveEvent.y ​

ts
y: number

GuiWheelEvent interface ​

ts
interface GuiWheelEvent

Payload of mousewheel. delta is in wheel notches, positive = scroll up.

GuiWheelEvent.delta ​

ts
delta: number

GuiWheelEvent.x ​

ts
x: number

GuiWheelEvent.y ​

ts
y: number

GuiKeyEvent interface ​

ts
interface GuiKeyEvent

Payload of keydown/keyup. key uses the same names as the global keydown() helper: lowercase MonoGame Keys names ("a", "enter", "space", "escape", "leftshift"), digits as "0".."9".

GuiKeyEvent.key ​

ts
key: string

GuiKeyEvent.shift ​

ts
shift: boolean

Whether either shift key is held at event time.

GuiKeyEvent.control ​

ts
control: boolean

Whether either control key is held at event time.

GuiTouchEvent interface ​

ts
interface GuiTouchEvent

A finger on a touchscreen (touchstart/touchmove/touchend). Every finger is its own stream with a stable id, so several controls can be held at once (a joystick plus an attack button).

GuiTouchEvent.id ​

ts
id: number

Identifies the finger from touchstart until its touchend.

GuiTouchEvent.x ​

ts
x: number

Finger position relative to this control's top-left (may be outside it after the finger slides off).

GuiTouchEvent.y ​

ts
y: number

Finger position relative to this control's top-left (may be outside it after the finger slides off).

GuiTouchEvent.screenx ​

ts
screenx: number

Finger position in screen pixels (the space of mousescreenx/absx).

GuiTouchEvent.screeny ​

ts
screeny: number

Finger position in screen pixels (the space of mousescreenx/absx).

GuiEventMap interface ​

ts
interface GuiEventMap

Events a control can emit, keyed by name, for control.on(event, handler). The handler receives the mapped event object.

GuiEventMap.click ​

ts
click: GuiButtonEvent

Press and release on this control (any button — check e.button).

GuiEventMap.doubleclick ​

ts
doubleclick: GuiButtonEvent

Press and release on this control (any button — check e.button).

GuiEventMap.mousedown ​

ts
mousedown: GuiButtonEvent

Press and release on this control (any button — check e.button).

GuiEventMap.mouseup ​

ts
mouseup: GuiButtonEvent

Fires on the control(s) the press started on, even if the cursor moved off.

GuiEventMap.mousemove ​

ts
mousemove: GuiMoveEvent

Fires on the control(s) the press started on, even if the cursor moved off.

GuiEventMap.mouseenter ​

ts
mouseenter: GuiMoveEvent

Fires on the control(s) the press started on, even if the cursor moved off.

GuiEventMap.mouseleave ​

ts
mouseleave: GuiMoveEvent

Fires on the control(s) the press started on, even if the cursor moved off.

GuiEventMap.mousewheel ​

ts
mousewheel: GuiWheelEvent

Fires on the control(s) the press started on, even if the cursor moved off.

GuiEventMap.keydown ​

ts
keydown: GuiKeyEvent

Fires while this control (or a child of it, e.g. a textedit inside a listening panel) has keyboard focus — click a textedit to focus it. Edge-triggered per key press, no auto-repeat. Keys still reach the control itself (Enter won't insert into a textedit, but letters do).

GuiEventMap.keyup ​

ts
keyup: GuiKeyEvent

Key released while this control (or a child) has keyboard focus. See keydown.

GuiEventMap.touchstart ​

ts
touchstart: GuiTouchEvent

A finger touched down on this control (the deepest visible control listening to touch events; bubbles to listening parents). The finger then stays with this control — its touchmove/touchend arrive here even after it slides off. Touchscreens only (see istouchdevice).

GuiEventMap.touchmove ​

ts
touchmove: GuiTouchEvent

A finger that started on this control moved.

GuiEventMap.touchend ​

ts
touchend: GuiTouchEvent

A finger that started on this control was lifted (or the app lost focus).

GuiControl class ​

ts
declare abstract class GuiControl

Base of all GUI controls. Use a concrete Gui*Ctrl subclass.

GuiControl.name ​

ts
readonly name: string

The registry name the control was created with.

GuiControl.x ​

ts
x: number

The registry name the control was created with.

GuiControl.y ​

ts
y: number

The registry name the control was created with.

GuiControl.width ​

ts
width: number

The registry name the control was created with.

GuiControl.height ​

ts
height: number

The registry name the control was created with.

GuiControl.absx ​

ts
readonly absx: number

Screen-absolute position (live read) — for hit-testing mouse coordinates, wherever the control sits.

GuiControl.absy ​

ts
readonly absy: number

Screen-absolute position (live read) — for hit-testing mouse coordinates, wherever the control sits.

GuiControl.position ​

ts
position: string

"x,y" — write-only convenience that sets x and y.

GuiControl.extent ​

ts
extent: string

"w,h" — write-only convenience that sets width and height.

GuiControl.visible ​

ts
visible: boolean

"w,h" — write-only convenience that sets width and height.

GuiControl.alpha ​

ts
alpha: number

Opacity, 0 (invisible) .. 1 (opaque; the default). Fades the whole control together with its children, so fading a window fades everything in it. While below 1 the control is drawn through an offscreen layer the size of the control, so anything poking outside its rectangle is clipped until it is back at 1. On a {@link GuiImageCtrl} it fades just the picture.

GuiControl.interactive ​

ts
get interactive(): boolean
set interactive(value: boolean | null)

Whether the control takes input (default true). Set false for render-only UI such as a HUD: the mouse and touches pass straight through it to whatever is underneath (other controls or the game), mouseonui() ignores it, it can't be focused (clicking, Tab or makefirstresponder()), windows can't be dragged, buttons don't highlight, and it never receives mouse or touch events — not even ones bubbling up from its children.

Children inherit it: unset (or null) means "same as the nearest ancestor that set it". A child can opt back in with true, e.g. one clickable button inside a click-through HUD. Reading returns the effective value, inherited or not.

@example

ts
const hud = new GuiStretchCtrl('HUD_Root')
hud.extent = `${ScreenWidth},${ScreenHeight}`
hud.interactive = false            // the whole HUD is click-through...
const menu = new GuiButtonCtrl('HUD_Menu')
hud.addControl(menu)
menu.interactive = true            // ...except this button

GuiControl.profile ​

ts
get profile(): string
set profile(value: string | GuiControlProfile)

Name of the {@link GuiControlProfile} this control takes its style from ('' = none). Accepts a profile object too. Props you set directly on the control always win over the profile's. The name may refer to a profile that isn't defined yet (e.g. another weapon's that hasn't loaded) — it applies as soon as it is. Set '' to detach: the profile-supplied props go back to the control's defaults.

GuiControl.show ​

ts
show(): void

Name of the {@link GuiControlProfile} this control takes its style from ('' = none). Accepts a profile object too. Props you set directly on the control always win over the profile's. The name may refer to a profile that isn't defined yet (e.g. another weapon's that hasn't loaded) — it applies as soon as it is. Set '' to detach: the profile-supplied props go back to the control's defaults.

GuiControl.hide ​

ts
hide(): void

Name of the {@link GuiControlProfile} this control takes its style from ('' = none). Accepts a profile object too. Props you set directly on the control always win over the profile's. The name may refer to a profile that isn't defined yet (e.g. another weapon's that hasn't loaded) — it applies as soon as it is. Set '' to detach: the profile-supplied props go back to the control's defaults.

GuiControl.bringtofront ​

ts
bringtofront(): void

Moves the control above its siblings (the last one drawn wins): a screen-level control goes on top of every other screen-level control, a child on top of the other children of its parent. Its own children come along with it.

GuiControl.makefirstresponder ​

ts
makefirstresponder(focus?: boolean): void

Gives this control keyboard focus (Graal's makefirstresponder), as if the player had clicked it — e.g. focus a custom chat bar's text edit when a hotkey opens it. Pass false to release focus (only if this control holds it), so movement and onKeyPressed resume. Meaningful for text inputs; applies after the batch's other writes, so a control shown in the same tick can take focus.

GuiControl.isfirstresponder ​

ts
isfirstresponder(): boolean

Whether this control has keyboard focus right now (live read). Only a focused text input or one given focus via makefirstresponder() counts — a focused child does not make its parent the first responder. A makefirstresponder() from the same tick isn't applied yet, so this reads the old state until the batch flushes. See getfirstresponder().

GuiControl.destroy ​

ts
destroy(): void

Removes the control (and any children added via addControl) for good.

GuiControl.animate ​

ts
animate(props: GuiAnimatableProps, options?: GuiAnimationOptions | number): GuiAnimation

Animates props from their current values to props and returns a {@link GuiAnimation} you can await, cancel() or finish(). Pass a number instead of options as the duration in seconds.

Numbers tween smoothly ('+=n' / '-=n' are relative to the start value); colors tween per channel. Start values are read when the animation begins (after any delay). Starting another animation of the same prop, or setting the prop directly, takes it over from the running one. Destroying the control ends its animations (they resolve false); unloading the script stops them silently.

@example win.alpha = 0 await win.animate({ alpha: 1, y: '-=20' }, { duration: 0.3, easing: 'outBack' }) btn.animate({ width: '+=8' }, { duration: 0.4, yoyo: true, loop: true })

GuiControl.stopanimations ​

ts
stopanimations(finish?: boolean): void

Stops every animation running on this control. By default they freeze where they are and resolve false; with finish true they jump to their end values and resolve true.

GuiControl.addControl ​

ts
addControl(child: GuiControl): void

Parents child inside this control. Children are positioned relative to the parent's top-left corner — for windows that includes the title bar (GS2-style), so start content at y ≈ 40 to clear it.

GuiControl.skin ​

ts
skin: string

Server image asset used as a 9-slice skin (e.g. "gui/fancywindow.png"), replacing the default themed look: corners render 1:1, edges and the center stretch. Fetched through the asset cache; the first use may pop in a moment later, later uses of a loaded image apply instantly. Set '' to return to the default look. Windows: the skin covers the whole frame including the title-bar area. Labels, images, checkboxes, radios, sliders and tab controls ignore skins.

GuiControl.skinrect ​

ts
skinrect: string

"left,top,width,height" in pixels — sub-region of the skin texture to use (atlas support). Defaults to the whole image.

GuiControl.on ​

ts
on<K extends keyof GuiEventMap>(event: K, listener: (e: GuiEventMap[K]) => void): this

Listens for a mouse event on this control. Works on every control kind. Events bubble: a click on a child (e.g. an image inside a panel) also fires on its parents, deepest control first. Multiple listeners per event are called in registration order. Returns the control for chaining.

GuiControl.off ​

ts
off<K extends keyof GuiEventMap>(event: K, listener?: (e: GuiEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiControl.skinborder ​

ts
skinborder: number

9-slice border thickness in source-image pixels. Unset = one third of the region per border; 0 = stretch the whole region (no borders).

GuiEasing type ​

ts
type GuiEasing = 'linear'
    | 'inQuad' | 'outQuad' | 'inOutQuad'
    | 'inCubic' | 'outCubic' | 'inOutCubic'
    | 'inQuart' | 'outQuart' | 'inOutQuart'
    | 'inSine' | 'outSine' | 'inOutSine'
    | 'inExpo' | 'outExpo' | 'inOutExpo'
    | 'inBack' | 'outBack' | 'inOutBack'
    | 'inElastic' | 'outElastic' | 'inOutElastic'
    | 'inBounce' | 'outBounce' | 'inOutBounce'

Easing curve names for {@link GuiAnimationOptions.easing}: 'linear', or 'in' / 'out' / 'inOut' + a family. 'out' curves start fast and settle (good for things appearing), 'in' curves start slow (things leaving). Back overshoots slightly, Elastic springs, Bounce bounces.

GuiAnimatableProps interface ​

ts
interface GuiAnimatableProps

Target values for {@link GuiControl.animate}. Numbers accept '+=n' / '-=n' strings, relative to the value when the animation begins. Props a control doesn't have (e.g. value on a panel) are ignored, as with writes.

GuiAnimatableProps.x ​

ts
x?: number | string

GuiAnimatableProps.y ​

ts
y?: number | string

GuiAnimatableProps.width ​

ts
width?: number | string

GuiAnimatableProps.height ​

ts
height?: number | string

GuiAnimatableProps.alpha ​

ts
alpha?: number | string

0..1; see {@link GuiControl.alpha}.

GuiAnimatableProps.scale ​

ts
scale?: number | string

Image controls only.

GuiAnimatableProps.fontsize ​

ts
fontsize?: number | string

Image controls only.

GuiAnimatableProps.bordersize ​

ts
bordersize?: number | string

Image controls only.

GuiAnimatableProps.borderradius ​

ts
borderradius?: number | string

Image controls only.

GuiAnimatableProps.value ​

ts
value?: number | string

Slider value.

GuiAnimatableProps.color ​

ts
color?: string

"r,g,b[,a]". A panel with no fill fades in from transparent.

GuiAnimatableProps.bordercolor ​

ts
bordercolor?: string

"r,g,b[,a]" panel border.

GuiAnimatableProps.tint ​

ts
tint?: string

"r,g,b" image tint.

GuiAnimationOptions interface ​

ts
interface GuiAnimationOptions

Timing for {@link GuiControl.animate} and animation steps.

GuiAnimationOptions.duration ​

ts
duration?: number

Seconds for one play. Default 0.25.

GuiAnimationOptions.delay ​

ts
delay?: number

Seconds to wait before starting; start values are read after it. Default 0.

GuiAnimationOptions.easing ​

ts
easing?: GuiEasing | ((t: number) => number)

A {@link GuiEasing} name or a function mapping 0..1 progress to 0..1. Default 'outQuad'.

GuiAnimationOptions.yoyo ​

ts
yoyo?: boolean

Plays back to the start values after reaching the targets (each play alternates direction). Without loop that's one there-and-back.

GuiAnimationOptions.loop ​

ts
loop?: boolean | number

true repeats until cancelled; a number is how many times it plays in total.

GuiAnimationOptions.onupdate ​

ts
onupdate?: (progress: number) => void

Called every frame with the play's raw progress, 0..1.

GuiAnimationOptions.oncomplete ​

ts
oncomplete?: () => void

Called when it finishes normally (not when cancelled).

GuiAnimationGroupOptions interface ​

ts
interface GuiAnimationGroupOptions

Options for {@link GuiAnimation.sequence} / {@link GuiAnimation.parallel} groups.

GuiAnimationGroupOptions.loop ​

ts
loop?: boolean | number

true repeats the whole group until cancelled; a number is how many passes in total.

GuiAnimationGroupOptions.oncomplete ​

ts
oncomplete?: () => void

Called when the group finishes normally.

GuiAnimationStep type ​

ts
type GuiAnimationStep =
    | ({ target: GuiControl, to: GuiAnimatableProps } & GuiAnimationOptions)
    | number
    | (() => unknown)
    | ({ sequence: GuiAnimationStep[] } & GuiAnimationGroupOptions)
    | ({ parallel: GuiAnimationStep[] } & GuiAnimationGroupOptions)

One step of a {@link GuiAnimation.sequence} or {@link GuiAnimation.parallel}:

  • { target, to, ...options } animates a control (like
ts
`target.animate(to, options)`, started when the step is reached);
  • a number pauses for that many seconds;
  • a function is called; if it returns a promise (or a GuiAnimation) the
ts
group waits for it;
  • { sequence: [...] } / { parallel: [...] } nests a group (with
ts
optional `loop` / `oncomplete`).

GuiAnimation class ​

ts
declare class GuiAnimation implements PromiseLike<boolean>

A running animation, returned by {@link GuiControl.animate}, {@link GuiAnimation.sequence} and {@link GuiAnimation.parallel}. Await it (or use .then) to continue when it ends: it resolves true when it finished and false when it was cancelled, taken over or its control was destroyed — it never rejects. Code after the await runs as your script, like code after await sleep(). Animations advance once per frame, before onUpdate.

@example await GuiAnimation.sequence([

ts
{ target: toast, to: { alpha: 1, y: 20 }, duration: 0.25 },
2,
{ target: toast, to: { alpha: 0 }, duration: 0.5, easing: 'inQuad' },
() => toast.destroy(),

])

GuiAnimation.constructor ​

ts
private constructor()

GuiAnimation.playing ​

ts
readonly playing: boolean

Whether it is still running.

GuiAnimation.finished ​

ts
readonly finished: Promise<boolean>

A promise of the same outcome as awaiting the animation itself.

GuiAnimation.then ​

ts
then<A = boolean, B = never>(
        onfulfilled?: ((ok: boolean) => A | PromiseLike<A>) | null,
        onrejected?: ((reason: unknown) => B | PromiseLike<B>) | null,
    ): Promise<A | B>

A promise of the same outcome as awaiting the animation itself.

GuiAnimation.cancel ​

ts
cancel(): void

Stops where it is; resolves false. On a group, stops the running steps and skips the rest.

GuiAnimation.finish ​

ts
finish(): void

Jumps to the end values and resolves true. On a group, runs every remaining step straight to its end (functions still get called; pauses are skipped) — on a looping group, ends the current pass.

GuiAnimation.sequence ​

ts
static sequence(steps: GuiAnimationStep[], options?: GuiAnimationGroupOptions): GuiAnimation

Runs steps one after another; starts immediately. Ends false if a step is cancelled.

GuiAnimation.parallel ​

ts
static parallel(steps: GuiAnimationStep[], options?: GuiAnimationGroupOptions): GuiAnimation

Runs steps all at once; ends when the last one does (false if any was cancelled).

GuiWindowCtrl class ​

ts
declare class GuiWindowCtrl extends GuiControl

A draggable window with a title bar.

GuiWindowCtrl.constructor ​

ts
constructor(name: string)

GuiWindowCtrl.text ​

ts
text: string

Title bar text.

GuiWindowCtrl.font ​

ts
font: string

Font family of the title text, loaded from the server's font folders ("Tahoma" -> Tahoma.ttf, with Tahoma-Bold/-Italic/-BoldItalic for styles). Draws in the default font while it downloads and when the server doesn't have it. '' (default) keeps the control's themed font.

GuiWindowCtrl.fontsize ​

ts
fontsize: number

Title text size in points (1-256); re-rasterized, so it stays crisp.

GuiWindowCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the title text, e.g. "bi"; '' for plain.

GuiWindowCtrl.color ​

ts
color: string

"r,g,b" or "r,g,b,a" (0-255) tint multiplied into the window's frame, preserving the 9-slice: a white skin renders in exactly this color; without a skin it tints the default themed look. Survives setting or clearing the skin. Set '' to remove the tint again.

GuiWindowCtrl.clientextent ​

ts
clientextent: string

"w,h" — alias of extent, for GS2 compatibility.

GuiWindowCtrl.canmove ​

ts
canmove: boolean

Accepted for GS2 compatibility; windows always drag by their title bar.

GuiWindowCtrl.canresize ​

ts
canresize: boolean

Accepted for GS2 compatibility; windows always drag by their title bar.

GuiWindowCtrl.canclose ​

ts
canclose: boolean

Shows a close button at the right end of the title bar (default false). Clicking it fires onCloseQuery and hides the window (hidden, not destroyed: show() brings it back) unless closequery is set.

GuiWindowCtrl.closequery ​

ts
closequery: boolean

When true, the close button only fires onCloseQuery and leaves the window open, so the script decides (confirm first, destroy, hide...). Default false.

GuiWindowCtrl.onCloseQuery ​

ts
onCloseQuery?: () => void

Fired when the title-bar close button (canclose) is clicked, after the window hides — or instead of hiding when closequery is true.

GuiButtonCtrl class ​

ts
declare class GuiButtonCtrl extends GuiControl

A clickable push button with a text caption; listen with .on('click', ...).

GuiButtonCtrl.constructor ​

ts
constructor(name: string)

GuiButtonCtrl.text ​

ts
text: string

GuiButtonCtrl.font ​

ts
font: string

Font family of the caption, loaded from the server's font folders ("Tahoma" -> Tahoma.ttf, with Tahoma-Bold/-Italic/-BoldItalic for styles). Draws in the default font while it downloads and when the server doesn't have it. '' (default) keeps the control's themed font.

GuiButtonCtrl.fontsize ​

ts
fontsize: number

Caption size in points (1-256); re-rasterized, so it stays crisp.

GuiButtonCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the caption, e.g. "bi"; '' for plain.

GuiButtonCtrl.skinrecthover ​

ts
skinrecthover: string

"left,top,width,height" skin region shown while the mouse hovers. With a skin but no per-state rects, hover/press auto-lighten/darken the skin instead; setting either state rect switches to untinted rect-swapping (unset states fall back: pressed -> hover -> skinrect).

GuiButtonCtrl.skinrectpressed ​

ts
skinrectpressed: string

"left,top,width,height" skin region shown while pressed. See skinrecthover.

GuiButtonCtrl.active ​

ts
active: boolean

Whether the button is enabled (default true; Graal's active). A disabled button draws its disabled look, can't be clicked, focused or tabbed to, and fires no click/mousedown/mouseup/doubleclick/ mousewheel/touch events (hover events still fire, e.g. for a tooltip explaining why). Unlike interactive = false it still blocks the mouse: clicks on it don't reach the game.

GuiButtonCtrl.skinrectdisabled ​

ts
skinrectdisabled: string

"left,top,width,height" skin region shown while disabled (active = false). Without it a skinned button grays its normal region. Can come from a {@link GuiControlProfile}.

GuiButtonCtrl.onAction ​

ts
onAction?: () => void

Fired when the button is clicked. Deprecated — use on('click', ...) instead.

GuiTextCtrl class ​

ts
declare class GuiTextCtrl extends GuiControl

A static text label. Auto-sizes to its text until width/height are set explicitly; set width when using the 'c' style so there is a box to center within.

GuiTextCtrl.constructor ​

ts
constructor(name: string)

GuiTextCtrl.text ​

ts
text: string

GuiTextCtrl.font ​

ts
font: string

Font family, loaded from the server's font folders: "Tahoma" is Tahoma.ttf (or .otf), and the b/i styles use Tahoma-Bold, Tahoma-Italic and Tahoma-BoldItalic when present (synthesized otherwise). Names ignore case. The text draws in the built-in opensans font while the family downloads and when the server doesn't have it. '' (default) is opensans.

GuiTextCtrl.fontsize ​

ts
fontsize: number

Text size in points (1-256); the font is re-rasterized, so it stays crisp at any size. Default 18.

GuiTextCtrl.style ​

ts
style: string

Any combination of 'b'old, 'i'talic, 'c'entered, in any order — same grammar as findimg's style. 'c' centers the text within the control's width; '' resets to plain left-aligned.

GuiTextCtrl.color ​

ts
color: string

"r,g,b" or "r,g,b,a" (0-255) text color; white until set.

GuiTextEditCtrl class ​

ts
declare class GuiTextEditCtrl extends GuiControl

A single-line text input.

GuiTextEditCtrl.constructor ​

ts
constructor(name: string)

GuiTextEditCtrl.text ​

ts
text: string

GuiTextEditCtrl.placeholder ​

ts
placeholder: string

Hint text shown while the field is empty.

GuiTextEditCtrl.font ​

ts
font: string

Font family of the text and placeholder, loaded from the server's font folders ("Tahoma" -> Tahoma.ttf, with Tahoma-Bold/-Italic/-BoldItalic for styles). Draws in the default font while it downloads and when the server doesn't have it. '' (default) keeps the control's themed font.

GuiTextEditCtrl.fontsize ​

ts
fontsize: number

Text and placeholder size in points (1-256); re-rasterized, so it stays crisp.

GuiTextEditCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the text and placeholder, e.g. "bi"; '' for plain.

GuiTextEditCtrl.password ​

ts
password: boolean

Set true in the creating tick to make this a masked password field; it has no effect once the control exists.

GuiTextEditCtrl.readonly ​

ts
readonly: boolean

When true the user can focus, select and copy the text but not edit it. Script writes to text still apply. Default false.

GuiTextEditCtrl.active ​

ts
active: boolean

Whether the input is enabled (default true; Graal's active). A disabled input draws grayed out (or with skinrectdisabled), can't be focused, typed into, selected with the mouse or tabbed to, and fires no click/mousedown/mouseup/doubleclick/mousewheel/touch events. Disabling a focused input releases focus; script writes to text still apply. For a box the player can still select and copy from, use readonly.

GuiTextEditCtrl.skinrectdisabled ​

ts
skinrectdisabled: string

"left,top,width,height" skin region shown while disabled (active = false). Without it a skinned input grays its normal region. Can come from a {@link GuiControlProfile}.

GuiTextEditCtrl.setselection ​

ts
setselection(start: number, end: number): void

Selects the characters from start up to (not including) end and puts the caret at end. Both are clamped to the text and swapped when reversed; start == end just moves the caret. The highlight shows even while the control isn't focused, and the user's next click replaces it. Applied after any same-tick text write and makefirstresponder().

GuiTextEditCtrl.selectall ​

ts
selectall(): void

Selects the whole text (see {@link GuiTextEditCtrl.setselection}).

GuiTextEditCtrl.setcursorpos ​

ts
setcursorpos(pos: number): void

Moves the caret to pos (a character index: 0 is before the first character, text.length after the last) and clears any selection. Clamped to the text; the box scrolls to keep the caret in view. Applied after any same-tick text write and makefirstresponder(), and shares a slot with {@link GuiTextEditCtrl.setselection}: the last call in a tick wins.

GuiTextEditCtrl.cursorpos ​

ts
readonly cursorpos: number

The caret's character index (live read), 0 to text.length. Moved with {@link GuiTextEditCtrl.setcursorpos}.

GuiTextEditCtrl.selectionstart ​

ts
readonly selectionstart: number

Index of the first selected character (live read); equals selectionend when nothing is selected (the caret position).

GuiTextEditCtrl.selectionend ​

ts
readonly selectionend: number

Index just past the last selected character (live read).

GuiTextEditCtrl.selectedtext ​

ts
readonly selectedtext: string

The selected part of the text (live read); '' when nothing is selected.

GuiTextEditCtrl.onTextChanged ​

ts
onTextChanged?: (text: string) => void

Fired when the user edits the text.

GuiTextEditCtrl.onAction ​

ts
onAction?: () => void

Fired when the user finishes an entry with Enter (on iOS: the keyboard's done key). Graal's name for the submit event; prefer on('submit', ...).

GuiTextEditCtrl.on ​

ts
on<K extends keyof GuiTextEditEventMap>(event: K, listener: (e: GuiTextEditEventMap[K]) => void): this

Listens for an event; submit fires when the user presses Enter (iOS: the done key) in the box. The box keeps focus — clear text or call makefirstresponder(false) yourself.

GuiTextEditCtrl.off ​

ts
off<K extends keyof GuiTextEditEventMap>(event: K, listener?: (e: GuiTextEditEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiTextSubmitEvent interface ​

ts
interface GuiTextSubmitEvent

Payload of a {@link GuiTextEditCtrl}'s submit event.

GuiTextSubmitEvent.text ​

ts
text: string

The box's text when Enter was pressed (the password, for a password box).

GuiTextEditEventMap interface ​

ts
interface GuiTextEditEventMap extends GuiEventMap

Events of a {@link GuiTextEditCtrl}: every {@link GuiEventMap} event plus submit. @example const input = new GuiTextEditCtrl('Chat_Input'); input.on('submit', e => {

ts
if (e.text) sendchat(e.text);
input.text = '';
input.makefirstresponder(false);

});

GuiTextEditEventMap.submit ​

ts
submit: GuiTextSubmitEvent

The user finished an entry: Enter on a keyboard, done on the iOS on-screen keyboard. Fires on the box itself (it doesn't bubble), after any keydown for the same press.

GuiPanelCtrl class ​

ts
declare class GuiPanelCtrl extends GuiControl

A grouping container. Invisible by default; give it a color and/or a border to draw it. The border straddles the panel's edge and is drawn over the fill; borderradius rounds both. Children are not clipped to the rounded shape.

GuiPanelCtrl.constructor ​

ts
constructor(name: string)

GuiPanelCtrl.color ​

ts
color: string

"r,g,b" or "r,g,b,a" (0-255) background fill. Set '' to remove the fill again.

GuiPanelCtrl.bordersize ​

ts
bordersize: number

Border thickness in pixels; 0 (the default) means no border.

GuiPanelCtrl.bordercolor ​

ts
bordercolor: string

"r,g,b" or "r,g,b,a" (0-255) border color; black until set.

GuiPanelCtrl.borderradius ​

ts
borderradius: number

Corner rounding radius in pixels for the fill and border; 0 = square.

GuiDrawingPanelCtrl class ​

ts
declare class GuiDrawingPanelCtrl extends GuiPanelCtrl

A panel with a persistent pixel canvas scripts draw on (Graal's GuiDrawingPanelCtrl). Everything a GuiPanelCtrl does still works — color, border, skin, children — and the canvas sits above the panel's own background and below its child controls.

Drawing is retained: each call paints onto the canvas once and stays until clearall() or clearrectangle() erases it, so draw only what changed (no per-frame redraw needed). Draw calls run in call order, also relative to property writes in the same tick; an image or font that is still downloading holds back the draws after it until it arrives.

Coordinates are pixels from the control's top-left (design units inside a GuiStretchCtrl, where the canvas scales with the control). The canvas is the control's width x height; resizing keeps what was drawn. Shapes are pixel-crisp (no anti-aliasing). The pen — setcolor, setlinewidth, setblendmode, setimagecolor, setfont — applies to every later draw call on this control.

ts
const map = new GuiDrawingPanelCtrl('Minimap');
map.extent = '128,128';
map.setcolor('0,0,0,160');
map.fillrect(0, 0, 128, 128);
map.setcolor('255,220,0');
map.fillcircle(64, 64, 3);

GuiDrawingPanelCtrl.constructor ​

ts
constructor(name: string)

GuiDrawingPanelCtrl.setcolor ​

ts
setcolor(rgba: string): void

Pen color for shapes and text: "r,g,b" or "r,g,b,a" (0-255). Default opaque white. Does not tint images (see setimagecolor).

GuiDrawingPanelCtrl.setimagecolor ​

ts
setimagecolor(rgba: string): void

Color multiplier for drawimage* calls: "r,g,b" or "r,g,b,a" (0-255). "255,255,255,128" draws images half transparent. Default opaque white (unchanged).

GuiDrawingPanelCtrl.setlinewidth ​

ts
setlinewidth(width: number): void

Outline thickness in pixels for drawrect/drawcircle/drawellipse/drawpolygon and the default drawline width. Default 1.

GuiDrawingPanelCtrl.setblendmode ​

ts
setblendmode(mode: 'alpha' | 'add' | 'erase'): void

How later draws combine with the canvas: 'alpha' (default, normal painting), 'add' (brightens, for glows), or 'erase' (the shape or image's coverage erases to transparent, scaled by the pen alpha — an eraser brush).

GuiDrawingPanelCtrl.setfont ​

ts
setfont(family: string, size?: number, style?: string): void

Font for drawtext: a server font family ('' = the default font), its size in pixels (default 16) and style letters 'b'old, 'i'talic, 'c'entered on x. Omitted size/style keep their current values.

GuiDrawingPanelCtrl.clearall ​

ts
clearall(): void

Erases the whole canvas to transparent.

GuiDrawingPanelCtrl.clearrectangle ​

ts
clearrectangle(x: number, y: number, width: number, height: number): void

Erases the width x height rectangle at x,y to transparent.

GuiDrawingPanelCtrl.drawimage ​

ts
drawimage(x: number, y: number, image: string): void

Draws a whole image 1:1 with its top-left at x,y.

GuiDrawingPanelCtrl.drawimagerectangle ​

ts
drawimagerectangle(x: number, y: number, image: string,
        srcx: number, srcy: number, srcw: number, srch: number): void

Draws the srcw x srch region at srcx,srcy of an image 1:1 at x,y (one tile of a tileset, one frame of a sheet).

GuiDrawingPanelCtrl.drawimagestretched ​

ts
drawimagestretched(x: number, y: number, width: number, height: number, image: string,
        srcx?: number, srcy?: number, srcw?: number, srch?: number): void

Draws an image (or its srcw x srch region at srcx,srcy) stretched to width x height at x,y. Without the source arguments the whole image stretches.

GuiDrawingPanelCtrl.drawpixel ​

ts
drawpixel(x: number, y: number): void

Sets the single pixel x,y to the pen color.

GuiDrawingPanelCtrl.drawline ​

ts
drawline(x: number, y: number, endx: number, endy: number, width?: number): void

Draws a line between the pixels x,y and endx,endy, both included. width (default: setlinewidth) above 1 draws round ends, so connected segments — e.g. mouse strokes — join smoothly.

GuiDrawingPanelCtrl.drawrect ​

ts
drawrect(x: number, y: number, endx: number, endy: number): void

Outlines the rectangle between corners x,y and endx,endy (end exclusive: drawrect(0, 0, 10, 10) is 10x10); the outline is setlinewidth thick, inside the rectangle.

GuiDrawingPanelCtrl.fillrect ​

ts
fillrect(x: number, y: number, endx: number, endy: number): void

Fills the rectangle between corners x,y and endx,endy (end exclusive).

GuiDrawingPanelCtrl.drawcircle ​

ts
drawcircle(x: number, y: number, radius: number): void

Outlines a circle centered on x,y; the setlinewidth-thick outline is centered on the radius.

GuiDrawingPanelCtrl.fillcircle ​

ts
fillcircle(x: number, y: number, radius: number): void

Fills a circle centered on x,y.

GuiDrawingPanelCtrl.drawellipse ​

ts
drawellipse(x: number, y: number, rx: number, ry: number): void

Outlines an ellipse centered on x,y with horizontal/vertical radii rx/ry.

GuiDrawingPanelCtrl.fillellipse ​

ts
fillellipse(x: number, y: number, rx: number, ry: number): void

Fills an ellipse centered on x,y with horizontal/vertical radii rx/ry.

GuiDrawingPanelCtrl.drawpolygon ​

ts
drawpolygon(points: number[]): void

Outlines a closed polygon through points ([x1, y1, x2, y2, ...], at least 2 points), setlinewidth thick.

GuiDrawingPanelCtrl.fillpolygon ​

ts
fillpolygon(points: number[]): void

Fills a polygon ([x1, y1, x2, y2, ...], at least 3 points). Concave and self-intersecting outlines fill even-odd, like findimg polygons.

GuiDrawingPanelCtrl.drawtext ​

ts
drawtext(x: number, y: number, text: string): void

Draws text with its top-left at x,y (centered on x with style 'c') in the pen color and setfont font.

GuiImageCtrl class ​

ts
declare class GuiImageCtrl extends GuiControl

Displays (a region of) a server image asset, e.g. a tileset. The region selected by imagerect stretches to the control's extent: extent == region size shows it 1:1, double extent shows it at 2x zoom.

Live reads of absx/absy (screen-absolute position, e.g. TE_Palette.absx) exist on every control for hit-testing mouse coordinates, which matters once the control sits inside a draggable window.

GuiImageCtrl.constructor ​

ts
constructor(name: string)

GuiImageCtrl.image ​

ts
image: string

Server asset name, e.g. "images/pics1.png". Fetched through the asset cache; the first use may pop in a moment later, later uses of a loaded image apply instantly. Set '' for a solid rectangle in the tint color (e.g. a highlight overlay).

GuiImageCtrl.imagerect ​

ts
imagerect: string

"left,top,width,height" in pixels — the source region of the image to show. Defaults to the whole image.

GuiImageCtrl.tint ​

ts
tint: string

"r,g,b" (0-255) color multiplier; "255,255,255" is unchanged.

GuiImageCtrl.alpha ​

ts
alpha: number

0 (invisible) .. 1 (opaque). On images this fades the picture (or actor) only, not child controls, and costs no offscreen layer.

GuiImageCtrl.scale ​

ts
scale: number

Zooms the whole control, image or actor included: on screen it is width * scale by height * scale. width/height, actor.x/y and mouse event x/y all stay in the unscaled units, so extent = '32,48' with scale = 2 shows 64x96 while clicks still report 0..32, 0..48. Default 1.

GuiImageCtrl.onClick ​

ts
onClick?: (pos: string) => void

Fired on mouse press over the control; pos is "x,y" relative to its top-left. Deprecated — use on('mousedown', ...) instead.

GuiImageCtrl.actor ​

ts
get actor(): GuiActor
set actor(value: Partial<GuiActor> | null)

Draws a gani character instead of image. Setting any field turns the actor on (unset fields keep their defaults); actor = null turns it off and brings the image back. Assigning an object sets the whole actor at once: pic.actor = { ani: 'walk', dir: 'left' }.

The gani's origin sits at the control's top-left, zoomed by scale, shifted by actor.x/actor.y; anything outside the extent is cut off (a stock idle character (head drawn 14px above the origin) fits in '32,48' with actor.y = 16). tint/alpha still apply. Gani sounds don't play and gani scripts don't run.

attr/aniParams feed the gani's ATTR/PARAM sprites, and pic.actor = { player } mirrors a live character's look: pic.actor = { player, head: 'head5.png' } shows you with another head.

GuiActor interface ​

ts
interface GuiActor

The character a GuiImageCtrl draws; see GuiImageCtrl.actor.

GuiActor.ani ​

ts
ani: string

Gani name without .gan, e.g. 'walk'. Default (and '') 'idle'.

GuiActor.head ​

ts
head: string

Head image, e.g. 'head0.png'. '' = the gani's default, else head0.png. Unset, it follows the mirrored player's head; reads give the head drawn.

GuiActor.body ​

ts
body: string

Body image, e.g. 'body.png'. '' = the gani's default, else body.png. Unset, it follows the mirrored player's body; reads give the body drawn.

GuiActor.colors ​

ts
colors: string[]

Body colors as 'r,g,b' (same slots as player.colors: skin, coat, sleeves, shoes, belt). Default: the player defaults, or the mirrored player's colors. Assign an array (e.g. pic.actor.colors = player.colors) or one index (pic.actor.colors[1] = '255,0,0', which keeps the other slots as currently drawn); invalid values throw.

GuiActor.dir ​

ts
dir: 'up' | 'left' | 'down' | 'right' | 0 | 1 | 2 | 3

Facing. Also accepts Graal's 0-3 (up, left, down, right) on write; reads are names. Default 'down'.

GuiActor.x ​

ts
x: number

Pixel offset of the gani origin from the control's top-left. Default 0.

GuiActor.y ​

ts
y: number

Pixel offset of the gani origin from the control's top-left. Default 0.

GuiActor.attr ​

ts
attr: Readonly<Record<string, unknown>>

Attributes for the gani's ATTR sprites, shaped like player.attr: each sprite draws the image named by the string value of its attribute (other values draw nothing). With a mirrored player, names set here win and the rest come from that character's attributes. Default {}; reads give this actor's own attributes (frozen), not the mirrored ones. Assign a whole object (pic.actor.attr = { hat: 'hat1.png' }); null clears it.

GuiActor.aniParams ​

ts
aniParams: readonly unknown[]

setAni-style params for the gani's PARAM sprites, shaped like player.aniParams: a PARAM sprite with slot n draws aniParams[n]. At most 16 values; only strings draw. Never mirrored. Default []; reads are frozen; null clears it.

GuiActor.player ​

ts
player: ClientPlayer | typeof player | { readonly id: number } | null

A live character whose look (head, body, colors, attr) this actor mirrors every frame: player, a findplayer()/players handle, an NPC's this or an NPC gani's player. The pose (ani, dir, aniParams) stays the actor's own, and any head/body/colors/attr set on the actor overrides the mirrored value. While the character isn't loaded on this client the actor draws its own fields (or the defaults). Anything else throws; null stops mirroring. Reads give the handle assigned.

GuiScrollCtrl class ​

ts
declare class GuiScrollCtrl extends GuiControl

A scrollable viewport. Children added via addControl land in the inner content area and may be larger than the viewport; scrollbars appear as needed and the mouse wheel scrolls when the cursor is over it. Children's absx/absy shift as the content scrolls, so hit-testing against a scrolled child keeps working unchanged.

GuiScrollCtrl.constructor ​

ts
constructor(name: string)

GuiStretchCtrl class ​

ts
declare class GuiStretchCtrl extends GuiControl

A container designed at a fixed virtual resolution that scales everything inside it to its real extent — build a screen once (say 720x480) and let it fill any window size. Children are positioned and sized in the VIRTUAL units: their x/y/width/height reads, and the x/y of their mouse events, stay in those design units. absx/absy stay real screen pixels, so they compare directly with mousescreenx()/mousescreeny(). Stretch controls nest (factors multiply).

What scales: position, extent, image scale, gani actors, all text (labels, buttons, text edits, checkboxes, dropdowns, tabs, window titles — at their fontsize, or their default size when none is set) and panel bordersize/borderradius. Text and borders scale by the SMALLER axis factor, so they never distort or overflow their box; fonts are re-rasterized at the new size, so they stay crisp. Themed chrome keeps its native pixel metrics even though it resizes: window title bars, the default button height and scrollbar thickness — give scaled buttons an explicit height so their scaled text fits. 9-slice skin corners stay 1:1 unless scaleskins is on.

There are no anchors, so a full-screen stretch control re-asserts its extent when the window resizes:

ts
const ui = new GuiStretchCtrl('Battle_Root')
ui.virtualextent = '720,480'
ui.extent = `${ScreenWidth},${ScreenHeight}`
// onUpdate: if the size changed, ui.extent = `${ScreenWidth},${ScreenHeight}`

GuiStretchCtrl.constructor ​

ts
constructor(name: string)

GuiStretchCtrl.virtualwidth ​

ts
virtualwidth: number

Design (virtual) width children are laid out in. Unset = the control's own width (no scaling).

GuiStretchCtrl.virtualheight ​

ts
virtualheight: number

Design (virtual) height children are laid out in. Unset = the control's own height (no scaling).

GuiStretchCtrl.virtualextent ​

ts
virtualextent: string

"w,h" — write-only convenience that sets virtualwidth and virtualheight.

GuiStretchCtrl.stretchmode ​

ts
stretchmode: 'stretch' | 'fit' | 'fill'

How the virtual area maps onto the real extent:

  • 'stretch' (default): each axis scales independently to fill the
ts
extent exactly (distorts when the aspect ratios differ).
  • 'fit': uniform scale to the largest size that fits, centered —
ts
leaves empty bars on mismatched aspect ratios (letterboxing).
  • 'fill': uniform scale to cover the whole extent, centered; the
ts
overflow is cropped.

GuiStretchCtrl.scaleskins ​

ts
scaleskins: boolean

Scale the corners and edges of 9-slice skins (the skin* props and the default theme's frames) inside this control by the smaller axis factor, so a skinned button keeps its proportions as the screen grows or shrinks. Off by default: corners stay 1:1 texture pixels and only the middle stretches. Applies to every descendant, including inside nested stretch controls that don't set it themselves; a nested one that does overrides it for its own subtree.

ts
ui.scaleskins = true

GuiCheckChangeEvent interface ​

ts
interface GuiCheckChangeEvent

Payload of a checkbox's or radio button's change event.

GuiCheckChangeEvent.checked ​

ts
checked: boolean

The new checked state. Radios only report becoming checked (always true).

GuiSliderChangeEvent interface ​

ts
interface GuiSliderChangeEvent

Payload of a slider's change event.

GuiSliderChangeEvent.value ​

ts
value: number

The new value (snapped to step when one is set).

GuiSelectChangeEvent interface ​

ts
interface GuiSelectChangeEvent

Payload of a dropdown's or tab control's change event.

GuiSelectChangeEvent.index ​

ts
index: number

Index of the newly selected item/tab.

GuiSelectChangeEvent.text ​

ts
text: string

Text of the newly selected item/tab.

GuiTextChangeEvent interface ​

ts
interface GuiTextChangeEvent

Payload of a multi-line text box's change event.

GuiTextChangeEvent.text ​

ts
text: string

The full text after the edit.

GuiCheckEventMap interface ​

ts
interface GuiCheckEventMap extends GuiEventMap

Events of a {@link GuiCheckboxCtrl} or {@link GuiRadioCtrl}: every {@link GuiEventMap} event plus change.

GuiCheckEventMap.change ​

ts
change: GuiCheckChangeEvent

The user toggled the control. Not fired for script writes to checked.

GuiSliderEventMap interface ​

ts
interface GuiSliderEventMap extends GuiEventMap

Events of a {@link GuiSliderCtrl}: every {@link GuiEventMap} event plus change.

GuiSliderEventMap.change ​

ts
change: GuiSliderChangeEvent

The user moved the slider (fires repeatedly while dragging). Not fired for script writes.

GuiSelectEventMap interface ​

ts
interface GuiSelectEventMap extends GuiEventMap

Events of a {@link GuiDropDownCtrl} or {@link GuiTabCtrl}: every {@link GuiEventMap} event plus change.

GuiSelectEventMap.change ​

ts
change: GuiSelectChangeEvent

The user picked a different item/tab. Not fired for script writes to selected, items or tabs.

GuiSyntax type ​

ts
type GuiSyntax = 'none' | 'js' | 'ts' | 'json'

Highlighting language of a {@link GuiMultiLineTextCtrl} in code mode: 'js', 'ts' (JS plus type keywords), 'json' (keys and values coloured apart), or 'none' for plain text.

GuiSyntaxColors interface ​

ts
interface GuiSyntaxColors

Token colours for {@link GuiMultiLineTextCtrl.syntaxcolors}, each an 'r,g,b' or 'r,g,b,a' string (0-255). Tokens left out keep the built-in colour; default covers plain identifiers, which otherwise use the text colour.

GuiSyntaxColors.default ​

ts
default?: string

Plain identifiers and anything unclassified.

GuiSyntaxColors.keyword ​

ts
keyword?: string

Language keywords (const, return, interface...).

GuiSyntaxColors.string ​

ts
string?: string

String and template literals (JSON: values).

GuiSyntaxColors.number ​

ts
number?: string

Number literals.

GuiSyntaxColors.comment ​

ts
comment?: string

Line and block comments.

GuiSyntaxColors.literal ​

ts
literal?: string

true, false, null, undefined, this.

GuiSyntaxColors.property ​

ts
property?: string

Names after a . (JSON: object keys).

GuiSyntaxColors.punctuation ​

ts
punctuation?: string

Operators, brackets and separators.

GuiSyntaxColors.regex ​

ts
regex?: string

Regular-expression literals.

GuiTextEventMap interface ​

ts
interface GuiTextEventMap extends GuiEventMap

Events of a {@link GuiMultiLineTextCtrl}: every {@link GuiEventMap} event plus change.

GuiTextEventMap.change ​

ts
change: GuiTextChangeEvent

The user edited the text. Not fired for script writes to text.

GuiCheckboxCtrl class ​

ts
declare class GuiCheckboxCtrl extends GuiControl

A checkbox with a text label beside it. Listen with .on('change', e => e.checked).

GuiCheckboxCtrl.constructor ​

ts
constructor(name: string)

GuiCheckboxCtrl.text ​

ts
text: string

Label text shown to the right of the box.

GuiCheckboxCtrl.checked ​

ts
checked: boolean

Whether the box is ticked (live read). Default false. Writing it doesn't fire change.

GuiCheckboxCtrl.font ​

ts
font: string

Font family of the label (see {@link GuiTextCtrl.font}). '' keeps the themed font.

GuiCheckboxCtrl.fontsize ​

ts
fontsize: number

Label size in points (1-256).

GuiCheckboxCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the label; '' for plain.

GuiCheckboxCtrl.on ​

ts
on<K extends keyof GuiCheckEventMap>(event: K, listener: (e: GuiCheckEventMap[K]) => void): this

Listens for an event; change fires when the user toggles the box.

GuiCheckboxCtrl.off ​

ts
off<K extends keyof GuiCheckEventMap>(event: K, listener?: (e: GuiCheckEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiRadioCtrl class ​

ts
declare class GuiRadioCtrl extends GuiControl

A radio button. Radios with the same parent control and the same group are mutually exclusive: checking one unchecks the others. Radios in different parents never interact, even with equal group names.

GuiRadioCtrl.constructor ​

ts
constructor(name: string)

GuiRadioCtrl.text ​

ts
text: string

Label text shown to the right of the button.

GuiRadioCtrl.checked ​

ts
checked: boolean

Whether this radio is selected (live read). Setting true unchecks the rest of its group.

GuiRadioCtrl.group ​

ts
group: string

Group name within the parent control. Default '' (all ungrouped radios in a parent form one group).

GuiRadioCtrl.font ​

ts
font: string

Font family of the label (see {@link GuiTextCtrl.font}). '' keeps the themed font.

GuiRadioCtrl.fontsize ​

ts
fontsize: number

Label size in points (1-256).

GuiRadioCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the label; '' for plain.

GuiRadioCtrl.on ​

ts
on<K extends keyof GuiCheckEventMap>(event: K, listener: (e: GuiCheckEventMap[K]) => void): this

Listens for an event; change fires on the radio the user just selected (e.checked is always true).

GuiRadioCtrl.off ​

ts
off<K extends keyof GuiCheckEventMap>(event: K, listener?: (e: GuiCheckEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiSliderCtrl class ​

ts
declare class GuiSliderCtrl extends GuiControl

A horizontal slider. Drag the thumb or click the track to jump there. Listen with .on('change', e => e.value).

GuiSliderCtrl.constructor ​

ts
constructor(name: string)

GuiSliderCtrl.min ​

ts
min: number

Smallest value. Default 0.

GuiSliderCtrl.max ​

ts
max: number

Largest value. Default 100.

GuiSliderCtrl.range ​

ts
range: string

"min,max" — write-only convenience that sets min and max.

GuiSliderCtrl.value ​

ts
value: number

Current value (live read), clamped to min..max and snapped to step. Default 0. Writing it doesn't fire change.

GuiSliderCtrl.step ​

ts
step: number

Snap increment counted from min; 0 (default) = continuous.

GuiSliderCtrl.on ​

ts
on<K extends keyof GuiSliderEventMap>(event: K, listener: (e: GuiSliderEventMap[K]) => void): this

Listens for an event; change fires while the user drags or clicks the slider.

GuiSliderCtrl.off ​

ts
off<K extends keyof GuiSliderEventMap>(event: K, listener?: (e: GuiSliderEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiDropDownCtrl class ​

ts
declare class GuiDropDownCtrl extends GuiControl

A dropdown list (combo box): shows the selected item; clicking opens a list to pick from. Listen with .on('change', e => e.index / e.text).

GuiDropDownCtrl.constructor ​

ts
constructor(name: string)

GuiDropDownCtrl.items ​

ts
items: string[]

The choices, in order. Reads return a copy, so edit by assigning a new array or with additem/clearitems. Replacing the list keeps the selected index while it is still in range, otherwise it clears.

GuiDropDownCtrl.selected ​

ts
selected: number

Index of the selected item (live read); -1 = none (the default). Writing it doesn't fire change.

GuiDropDownCtrl.selectedtext ​

ts
readonly selectedtext: string

Text of the selected item; '' when nothing is selected. Read-only.

GuiDropDownCtrl.additem ​

ts
additem(text: string): void

Appends one item.

GuiDropDownCtrl.clearitems ​

ts
clearitems(): void

Removes every item and clears the selection.

GuiDropDownCtrl.font ​

ts
font: string

Font family of the shown text (see {@link GuiTextCtrl.font}). '' keeps the themed font.

GuiDropDownCtrl.fontsize ​

ts
fontsize: number

Shown text size in points (1-256).

GuiDropDownCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the shown text; '' for plain.

GuiDropDownCtrl.on ​

ts
on<K extends keyof GuiSelectEventMap>(event: K, listener: (e: GuiSelectEventMap[K]) => void): this

Listens for an event; change fires when the user picks an item.

GuiDropDownCtrl.off ​

ts
off<K extends keyof GuiSelectEventMap>(event: K, listener?: (e: GuiSelectEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiTabCtrl class ​

ts
declare class GuiTabCtrl extends GuiControl

A row of tabs (Graal-style tab bar). It only tracks which tab is selected; show and hide your own page panels from its change event. Each tab is as wide as its caption; tabs past the control's width are cut off. Default size 240x24.

@example const tabs = new GuiTabCtrl('Opts_Tabs') tabs.tabs = ['General', 'Audio'] tabs.selected = 0 tabs.on('change', e => pages.forEach((p, i) => p.visible = i === e.index))

GuiTabCtrl.constructor ​

ts
constructor(name: string)

GuiTabCtrl.tabs ​

ts
tabs: string[]

Tab captions, left to right. Reads return a copy, so edit by assigning a new array or with addtab/cleartabs. Replacing the list keeps the selected index while it is still in range, otherwise it clears.

GuiTabCtrl.selected ​

ts
selected: number

Index of the selected tab (live read); -1 = none (the default). Writing it doesn't fire change.

GuiTabCtrl.selectedtext ​

ts
readonly selectedtext: string

Caption of the selected tab; '' when none is selected. Read-only.

GuiTabCtrl.addtab ​

ts
addtab(text: string): void

Appends one tab.

GuiTabCtrl.cleartabs ​

ts
cleartabs(): void

Removes every tab and clears the selection.

GuiTabCtrl.font ​

ts
font: string

Font family of the captions (see {@link GuiTextCtrl.font}). '' keeps the themed font.

GuiTabCtrl.fontsize ​

ts
fontsize: number

Caption size in points (1-256).

GuiTabCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the captions; '' for plain.

GuiTabCtrl.on ​

ts
on<K extends keyof GuiSelectEventMap>(event: K, listener: (e: GuiSelectEventMap[K]) => void): this

Listens for an event; change fires when the user clicks a different tab.

GuiTabCtrl.off ​

ts
off<K extends keyof GuiSelectEventMap>(event: K, listener?: (e: GuiSelectEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiMultiLineTextCtrl class ​

ts
declare class GuiMultiLineTextCtrl extends GuiControl

A multi-line text area: text wraps to the width, Enter inserts a newline, and long text scrolls with the mouse wheel or the scrollbar that appears while it overflows. Set readonly for a scrollable display box (logs, descriptions). Default size 200x96.

Code mode turns it into a small code editor: set code = 'js' (or the separate syntax, autoindent, softtabs, wrap and linenumbers props). In code mode the text is kept exactly as typed: Gum's [color=...] markup is not parsed.

GuiMultiLineTextCtrl.constructor ​

ts
constructor(name: string)

GuiMultiLineTextCtrl.text ​

ts
text: string

The text; lines are separated by "\n".

GuiMultiLineTextCtrl.placeholder ​

ts
placeholder: string

Hint text shown while the box is empty.

GuiMultiLineTextCtrl.readonly ​

ts
readonly: boolean

When true the user can select and scroll but not edit. Default false.

GuiMultiLineTextCtrl.active ​

ts
active: boolean

Whether the input is enabled (default true; Graal's active). A disabled input draws grayed out (or with skinrectdisabled), can't be focused, typed into, selected with the mouse or tabbed to, and fires no click/mousedown/mouseup/doubleclick/mousewheel/touch events. Disabling a focused input releases focus; script writes to text still apply. For a box the player can still select and copy from, use readonly.

GuiMultiLineTextCtrl.skinrectdisabled ​

ts
skinrectdisabled: string

"left,top,width,height" skin region shown while disabled (active = false). Without it a skinned input grays its normal region. Can come from a {@link GuiControlProfile}.

GuiMultiLineTextCtrl.setselection ​

ts
setselection(start: number, end: number): void

Selects the characters from start up to (not including) end and puts the caret at end. Both are clamped to the text and swapped when reversed; start == end just moves the caret. The highlight shows even while the control isn't focused, and the user's next click replaces it. Applied after any same-tick text write and makefirstresponder().

GuiMultiLineTextCtrl.selectall ​

ts
selectall(): void

Selects the whole text (see {@link GuiMultiLineTextCtrl.setselection}).

GuiMultiLineTextCtrl.setcursorpos ​

ts
setcursorpos(pos: number): void

Moves the caret to pos (a character index: 0 is before the first character, text.length after the last) and clears any selection. Clamped to the text; the box scrolls to keep the caret in view. Applied after any same-tick text write and makefirstresponder(), and shares a slot with {@link GuiMultiLineTextCtrl.setselection}: the last call in a tick wins.

GuiMultiLineTextCtrl.cursorpos ​

ts
readonly cursorpos: number

The caret's character index (live read), 0 to text.length. Moved with {@link GuiMultiLineTextCtrl.setcursorpos}.

GuiMultiLineTextCtrl.selectionstart ​

ts
readonly selectionstart: number

Index of the first selected character (live read); equals selectionend when nothing is selected (the caret position).

GuiMultiLineTextCtrl.selectionend ​

ts
readonly selectionend: number

Index just past the last selected character (live read).

GuiMultiLineTextCtrl.selectedtext ​

ts
readonly selectedtext: string

The selected part of the text (live read); '' when nothing is selected.

GuiMultiLineTextCtrl.font ​

ts
font: string

Font family of the text and placeholder (see {@link GuiTextCtrl.font}). '' keeps the themed font.

GuiMultiLineTextCtrl.fontsize ​

ts
fontsize: number

Text and placeholder size in points (1-256).

GuiMultiLineTextCtrl.style ​

ts
style: string

'b'old and/or 'i'talic for the text and placeholder; '' for plain.

GuiMultiLineTextCtrl.code ​

ts
code: GuiSyntax | false

Shorthand for code mode. 'js', 'ts' or 'json' sets syntax to that language, turns on autoindent, softtabs and linenumbers, and turns off wrap. false puts all five back to their defaults. Reads back as syntax, or false when that is 'none'.

GuiMultiLineTextCtrl.syntax ​

ts
syntax: GuiSyntax

Syntax colouring of the text. Default 'none'. Texts longer than 20000 characters draw uncoloured.

GuiMultiLineTextCtrl.syntaxcolors ​

ts
syntaxcolors: GuiSyntaxColors

Overrides token colours for syntax, e.g. { keyword: '255,120,0' }. Each write replaces the earlier overrides; {} restores the built-in colours, which suit the default dark skin.

GuiMultiLineTextCtrl.autoindent ​

ts
autoindent: boolean

Enter keeps the current line's indentation, and adds one level (tabsize spaces) after {, [ or (. Enter between a bracket pair puts the closer on its own line. Default false.

GuiMultiLineTextCtrl.softtabs ​

ts
softtabs: boolean

Tab inserts spaces up to the next tab stop instead of moving focus, and indents (Shift+Tab: dedents) every selected line when the selection spans lines. Backspace inside a line's leading spaces deletes back to the previous tab stop. Default false.

GuiMultiLineTextCtrl.tabsize ​

ts
tabsize: number

Spaces per indent level for softtabs, autoindent and dedent (1-16). Default 4.

GuiMultiLineTextCtrl.wrap ​

ts
wrap: boolean

Whether long lines wrap to the width. With false, lines run off to the right: the box scrolls sideways to keep the caret in view, and a horizontal scrollbar, a sideways swipe or Shift+wheel scrolls it. Default true.

GuiMultiLineTextCtrl.linenumbers ​

ts
linenumbers: boolean

Shows line numbers in a gutter left of the text that scrolls with it. With wrap on, a wrapped line's continuation rows stay unnumbered. Default false.

GuiMultiLineTextCtrl.on ​

ts
on<K extends keyof GuiTextEventMap>(event: K, listener: (e: GuiTextEventMap[K]) => void): this

Listens for an event; change fires when the user edits the text.

GuiMultiLineTextCtrl.off ​

ts
off<K extends keyof GuiTextEventMap>(event: K, listener?: (e: GuiTextEventMap[K]) => void): void

Removes a listener added with on(); with no listener, removes all for that event.

GuiGameScreen interface ​

ts
interface GuiGameScreen

The game screen itself — a pseudo-control for parenting GUI directly onto the game view (custom chatbars, HUDs) without any window chrome. It cannot be created, destroyed, styled, or listened to; 'GameControl' is a reserved control name.

GuiGameScreen.name ​

ts
readonly name: 'GameControl'

GuiGameScreen.width ​

ts
readonly width: number

Live viewport width in pixels (same as ScreenWidth).

GuiGameScreen.height ​

ts
readonly height: number

Live viewport height in pixels (same as ScreenHeight). Position bottom-anchored UI as y = GameControl.height - barHeight; there is no anchor API, so reposition in onUpdate if the window can be resized.

GuiGameScreen.extent ​

ts
readonly extent: string

"w,h" — the viewport size as a pair string.

GuiGameScreen.addControl ​

ts
addControl(child: GuiControl): void

Parents child directly onto the game screen (positions from the canvas top-left). Also moves a control back out of a window.

GuiGameScreen.show ​

ts
show(): void

No-op — the game screen is always visible.

GuiGameScreen.hide ​

ts
hide(): void

No-op — the game screen cannot be hidden.

GuiGameScreen.bringtofront ​

ts
bringtofront(): void

No-op — the game screen is already the bottom-most layer.

GuiGameScreen.makefirstresponder ​

ts
makefirstresponder(focus?: boolean): void

No-op — the game screen can't take keyboard focus.

GuiGameScreen.isfirstresponder ​

ts
isfirstresponder(): boolean

True when no GUI control (script or built-in, e.g. the chat bar) has keyboard focus — the game owns the keyboard, so default movement and onKeyPressed are live. False while the player is typing anywhere.

GameControl global ​

ts
declare const GameControl: GuiGameScreen

The game screen pseudo-control; also returned by findobj('GameControl').

findGuiControl function ​

ts
declare function findGuiControl(name: 'GameControl'): GuiGameScreen
declare function findGuiControl(name: string): GuiControl | undefined

Looks up a live control by name; undefined if it doesn't exist.

findobj function ​

ts
declare function findobj(name: 'GameControl'): GuiGameScreen
declare function findobj(name: string): GuiControl

Graal-style alias of findGuiControl, typed non-optional so property chaining stays terse (findobj('My_Window').visible = true). It still returns undefined at runtime when no control has that name — use findGuiControl when existence is in doubt.

findobj('GameControl') returns the game-screen pseudo-control, e.g. findobj('GameControl').addControl(myChatEdit) for a custom chatbar.

getfirstresponder function ​

ts
declare function getfirstresponder(): GuiControl | GuiGameScreen | null

The control holding keyboard focus right now (live read): a script control (e.g. a focused textedit), GameControl when nothing has focus and the game owns the keyboard, or null when built-in UI such as the chat bar has it.

ts
const fr = getfirstresponder();
if (fr === GameControl) { ... }        // free to use hotkeys
else if (fr === null) { ... }          // typing in the chat bar
else player.chat = 'typing in ' + fr.name;

GuiProfileProps interface ​

ts
interface GuiProfileProps

Style props a {@link GuiControlProfile} can carry. Each one means the same as the control property of that name; a control ignores the ones that don't apply to its kind (e.g. bordercolor on a button).

GuiProfileProps.font ​

ts
font?: string

Font family for text (labels, buttons, edits, window titles).

GuiProfileProps.fontsize ​

ts
fontsize?: number

Font size for text.

GuiProfileProps.style ​

ts
style?: string

Any combination of 'b'old, 'i'talic, 'c'entered (labels only).

GuiProfileProps.color ​

ts
color?: string

"r,g,b[,a]" — label text color, window frame tint, or panel fill.

GuiProfileProps.bordercolor ​

ts
bordercolor?: string

"r,g,b[,a]" — panel border color.

GuiProfileProps.bordersize ​

ts
bordersize?: number

Panel border thickness.

GuiProfileProps.borderradius ​

ts
borderradius?: number

Panel corner radius.

GuiProfileProps.skin ​

ts
skin?: string

9-slice skin image (see {@link GuiControl.skin}).

GuiProfileProps.skinrect ​

ts
skinrect?: string

"left,top,width,height" region of the skin image.

GuiProfileProps.skinborder ​

ts
skinborder?: number

9-slice border thickness in source-image pixels.

GuiProfileProps.skinrecthover ​

ts
skinrecthover?: string

Skin region while a button is hovered.

GuiProfileProps.skinrectpressed ​

ts
skinrectpressed?: string

Skin region while a button is pressed.

GuiProfileProps.skinrectdisabled ​

ts
skinrectdisabled?: string

Skin region while a button or text input is disabled (active = false).

GuiProfileProps.tint ​

ts
tint?: string

"r,g,b" tint of image controls.

GuiProfileProps.alpha ​

ts
alpha?: number

0-1 opacity (see {@link GuiControl.alpha}).

GuiControlProfile class ​

ts
declare class GuiControlProfile implements GuiProfileProps

A named, reusable set of style props (Graal's GuiControlProfile). Define it once — typically in a dedicated theme weapon — and any control in any weapon can use it with ctrl.profile = 'Name'.

Changing a prop on the profile restyles every control using it; assigning null (or delete) removes the prop, which returns those controls to their default for it. Defining a profile under an existing name replaces it. Profiles belong to the weapon that created them: when it unloads they disappear and their controls revert to defaults, keeping the profile name so a reload re-applies it.

@example new GuiControlProfile('Theme_Button', {

ts
skin: 'gui/theme.png', skinrect: '0,0,24,24', skinborder: 6,
skinrecthover: '24,0,24,24', fontsize: 12, style: 'b',

}) const ok = new GuiButtonCtrl('Shop_Ok') ok.profile = 'Theme_Button'

GuiControlProfile.constructor ​

ts
constructor(name: string, props?: GuiProfileProps)

Creates (or replaces) the profile name with the given props.

GuiControlProfile.name ​

ts
readonly name: string

The name controls reference this profile by.

GuiControlProfile.destroy ​

ts
destroy(): void

Removes the profile; its controls revert to their defaults but keep the name.

GuiControlProfile.font ​

ts
font?: string

Font family for text (labels, buttons, edits, window titles).

GuiControlProfile.fontsize ​

ts
fontsize?: number

Font size for text.

GuiControlProfile.style ​

ts
style?: string

Any combination of 'b'old, 'i'talic, 'c'entered (labels only).

GuiControlProfile.color ​

ts
color?: string

"r,g,b[,a]" — label text color, window frame tint, or panel fill.

GuiControlProfile.bordercolor ​

ts
bordercolor?: string

"r,g,b[,a]" — panel border color.

GuiControlProfile.bordersize ​

ts
bordersize?: number

Panel border thickness.

GuiControlProfile.borderradius ​

ts
borderradius?: number

Panel corner radius.

GuiControlProfile.skin ​

ts
skin?: string

9-slice skin image (see {@link GuiControl.skin}).

GuiControlProfile.skinrect ​

ts
skinrect?: string

"left,top,width,height" region of the skin image.

GuiControlProfile.skinborder ​

ts
skinborder?: number

9-slice border thickness in source-image pixels.

GuiControlProfile.skinrecthover ​

ts
skinrecthover?: string

Skin region while a button is hovered.

GuiControlProfile.skinrectpressed ​

ts
skinrectpressed?: string

Skin region while a button is pressed.

GuiControlProfile.skinrectdisabled ​

ts
skinrectdisabled?: string

Skin region while a button or text input is disabled (active = false).

GuiControlProfile.tint ​

ts
tint?: string

"r,g,b" tint of image controls.

GuiControlProfile.alpha ​

ts
alpha?: number

0-1 opacity (see {@link GuiControl.alpha}).

findGuiProfile function ​

ts
declare function findGuiProfile(name: string): GuiControlProfile | undefined

Looks up a defined GUI profile by name; undefined if none exists (yet).