ludic/fn-ui_build.html
2026-09-17 22:10:03 +00:00

55 lines
No EOL
2.6 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ui_build — Ludic</title>
<meta name="description" content="Build the declared UI tree so it can be opened and rendered.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#builtins">Builtin functions</a> <span>›</span> <span class="here">ui_build</span></div>
<div class="item-head">
<span class="kind-badge kind-builtin">function</span>
<h1 id="top">ui_build</h1>
</div>
<code class="sig">ui_build()</code>
<div class="desc"><p>Constructs the retained-UI tree you declared in a <code>ui</code> block, laying out its panels, labels, and buttons and loading any skins or images they reference. Call it once during a <code>Start</code>-phase handler, after loading any fonts the UI needs, and before you open a screen with <code>ui_open</code> or draw it with <code>ui_render</code>. Because the UI is declared as data and built in one step, the game code only has to build it, open it, and read clicks. It takes no arguments.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program TitleMenu {
var title_font: int = 0
ui MainMenu {
panel id: Root w: 240 pad: 16 gap: 6 bg: 0x1a1a2c align: center {
label text: "CHRONORIFT" font: title_font size: 24 fg: 0xffe060 align: center
button id: NewGame text: "New Game" font: title_font size: 16 w: 200
button id: Quit text: "Quit" font: title_font size: 16 w: 200
}
}
handler Boot phase Start {
title_font = Font.load("/System/Library/Fonts/Supplemental/Arial.ttf")
ui_build()
Ui.open(UI_MainMenu)
}
handler Navigate phase Update {
Ui.tick(Input.key())
if Ui.clicked(UI_Quit) { quit() }
}
handler DrawWorld phase Render {
Screen.clear(Color.MidnightBlue)
Ui.render()
Screen.show()
}
}</pre></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>