UI

Server-driven screens in the black-glass style. The server describes the screen; the player's game draws it and sends back input.

Server-driven screens in the black-glass style shown in the UI kit. The server describes the screen; the player's game draws it and sends back input. Changes are sent at the end of the server frame, so building a panel line by line costs one message.

static Panel UI.Panel(Player player, string title, string subtitle = null)#

Opens a centered glass panel. A player has at most one panel: opening another replaces the first. While a panel is open the player's cursor is free and game input is off.

panel.Text(string) · panel.Field(string label, bool password = false)#

Adds a paragraph or a text input. Field returns a handle whose Value holds what the player typed when they last pressed a button. Password fields are never sent back to the player's screen.

panel.Button(string label, Action onClick, ButtonKind kind = ButtonKind.Primary)#

Adds a button. The callback runs on the server after the field values have been updated. Kinds: Primary, Secondary, Danger, Ghost. Presses are ignored while the panel is busy.

panel.Tabs(params string[] names)#

Adds tabs such as Sign in / Create account and returns them. tabs.Selected is the selected index and tabs.Changed fires on the server when the player picks another tab.

panel.Error(string) · panel.Busy(bool) · panel.Clear() · panel.SetTitle(title, subtitle)#

An inline error line (null hides it), the loading state, removing the text, fields and buttons (e.g. to rebuild after a tab change), and a new title.

panel.Close()#

Closes the panel and gives the screen back to the game.

static Panel UI.Menu(Player player, string title, string subtitle = null) (v0.4)#

Opens a GTA V-style menu in the top left instead of a centered panel: the title, the subtitle with the player's position in the list ("2/3"), one row per Button, and the Text lines as a description underneath. The player moves with the arrow keys (or the mouse wheel), picks with Enter and goes back with Backspace. The cursor stays locked and game input waits while the menu is open. A menu is a Panel (IsMenu is true), so it shares the player's one panel slot and everything above works on it.

event Action Back (v0.4)#

Raised when the player presses Backspace on a menu. With no handler the menu closes; add one to go up a level instead.

C#
1void MainMenu(Player p)2{3    var menu = UI.Menu(p, "Interaction", p.Name);4    menu.Button("Walk style", () => WalkStyles(p));5    menu.Button("Close", () => menu.Close(), ButtonKind.Secondary);6}7 8void WalkStyles(Player p)9{10    var menu = UI.Menu(p, "Walk style");11    menu.Button("Normal", () => SetWalk(p, "normal"));12    menu.Button("Gangster", () => SetWalk(p, "gang"));13    menu.Text("Backspace goes back.");14    menu.Back += () => MainMenu(p);15}
C#
1var panel = UI.Panel(player, "Next Generation Roleplay");2var tabs = panel.Tabs("Sign in", "Create account");3var name = panel.Field("Name");4var pass = panel.Field("Password", password: true);5panel.Button("Continue", () =>6{7    if (pass.Value.Length < 8)8    {9        panel.Error("Use at least 8 characters.");10        return;11    }12    panel.Close();13    player.Spawn(Spawn.Default);14});15tabs.Changed += i => panel.SetTitle(i == 0 ? "Sign in" : "Create account");