gdmp.ui
Este conteúdo não está disponível em sua língua ainda.
Runs on: client.
GDMP-owned native UI drawn over the game, in GD’s own fonts.
| Call | What it does |
|---|---|
createWindow({title, x, y, width, height, visible, transparent}) → window |
UI points (screen()), top-left origin |
window .addLabel({text, x, y, width, height, font, align, size, color}) → element |
text ≤ 48 characters |
window .addButton({...same}) → element |
|
window / element .setText(text) |
|
element .onClick(cb) |
buttons |
destroy(obj) get(obj) → snapshot setVisible(obj, visible) |
|
screen() → {width, height} | null |
the surface in UI points (null before the first level) |
setCursor(visible) → the previous request |
(level 93) the MOUSE CURSOR: GD hides it during play; true keeps it shown (a panel or a menu to click), false gives GD its own behaviour back. It ends with the experience |
Styles: font 1..60 (GD’s fonts; 0 = GDMP’s stroke font), align "left" | "center" | "right", size 0.25..4,
color "#RRGGBB" or a number, opacity 0..1 (level 90).
Level 90 adds pictures and fades:
| Call | What it does |
|---|---|
window .addIcon({x, y, width, height, player}) → element |
that player’s REAL GD icon (their cube, icon id and colours), centred in the box and scaled to fit |
window .addIcon({x, y, width, height, icon, primary, secondary}) → element |
an explicit look: GD cube icon 1..999, two colours |
window .addSprite({x, y, width, height, frame, size, color, opacity}) → element |
one of GD’s own loaded sprite frames ("GJ_completesIcon_001.png" is GD’s check mark), fitted to the box x size; color tints it |
element .setStyle({color, opacity, size}) → bool |
only what is given changes (a fade: call it from gdmp.time.every) |
window / element .setPosition(x, y) → bool |
(level 91) the new top-left in UI points (a window’s on the surface, an element’s in its window), -4096..4096. What is drawn moves – nothing is rebuilt – so it can run every frame (a minimap, a marker that follows something). A bad value throws TypeError |
// a kill-feed line that fades out over half a second, 3 s after it appearedconst line = feed.addLabel({ x: 0, y: 0, text: "Ann is IT!", font: 1, size: 0.7, color: "#ff5555" });gdmp.time.after(3000, () => { let o = 1; const t = gdmp.time.every(50, () => { o -= 0.1; line.setStyle({ opacity: Math.max(0, o) }); if (o <= 0) { gdmp.time.cancel(t); gdmp.ui.destroy(line); } });});TypeScript
Section titled “TypeScript”The declarations from the GDMP types (namespace GDMP), comments included:
interface TextStyle { /** GD's fonts 1..60; 0 = GDMP's stroke font. */ font?: number; align?: 'left' | 'center' | 'right'; /** 0.25..4. */ size?: number; color?: Color; /** 0..1 (level 90). */ opacity?: number;}
interface Box { x?: number; y?: number; width?: number; height?: number }
interface UiElement extends UiNode { /** Buttons. */ onClick(cb: () => void): void; /** Level 90: only what is given changes. */ setStyle(style: { color?: Color; opacity?: number; size?: number }): boolean;}
interface UiWindow extends UiNode { /** Text up to 48 characters. */ addLabel(options: Box & TextStyle & { text?: string }): UiElement; addButton(options: Box & TextStyle & { text?: string }): UiElement; /** Level 90: a player's real GD icon, or an explicit look (cube icon 1..999, two colours). */ addIcon(options: Box & ({ player: PlayerId } | { icon: number; primary?: Color; secondary?: Color })): UiElement; /** Level 90: one of GD's own sprite frames (`"GJ_completesIcon_001.png"`). */ addSprite(options: Box & { frame: string; size?: number; color?: Color; opacity?: number }): UiElement;}
interface Ui { createWindow(options: Box & { title?: string; visible?: boolean; transparent?: boolean }): UiWindow; destroy(node: UiWindow | UiElement): void; get(node: UiWindow | UiElement): { readonly [key: string]: unknown } | null; setVisible(node: UiWindow | UiElement, visible: boolean): void; /** The surface in UI points (null before the first level). */ screen(): { readonly width: number; readonly height: number } | null; /** Level 93: keep the mouse cursor shown during play (`true`) or give GD its own behaviour back. */ setCursor(visible: boolean): boolean;}