Open Road MP

ui, UiView and mp.ui

Windows and HUD panels of a gamemode, their building blocks, and notices at the top of the HUD.

Building blocks for gamemode UIs (UiView). Shown with the client's own components (Watermelon UI); nothing but these blocks can be shown, no code of the server runs in the game. How to use them: User interfaces.

mp.ui.notify

mp.ui.notify(player: PlayerRef | readonly PlayerRef[], notice: Notice): void

A notice at the top of the player's HUD, in the style of the game's own messages - for announcements, warnings, results.

Types: Notice

UiView

A gamemode UI - a window (menu, shop, form ...) or a HUD panel - built from the ui.* blocks and shown to players.

const shop = new UiView({ title: "Truck shop" })
shop.add(
  ui.text("Pick your truck"),
  ui.grid({ columns: 3 }, ...trucks.map((t) =>
    ui.card({ title: t.model },
      ui.badge(t.axles),
      ui.button({ label: "Buy", onClick: (player) => buy(player, t) })))),
)
shop.show(player)
MemberDescription
constructor(options?: OpenRoadMP.UiViewOptions)A new, empty view.
readonly id: stringUnique id of the view.
options: OpenRoadMP.UiViewOptionsTitle, size, mode ... - change them, then update().
add(...children: OpenRoadMP.UiChild[]): thisAdds blocks at the end.
set(...children: OpenRoadMP.UiChild[]): thisReplaces all blocks.
clear(): thisRemoves all blocks.
show(player: OpenRoadMP.PlayerRef | readonly OpenRoadMP.PlayerRef[]): voidShows the view to one or more players (again: replaces what they see).
update(): voidSends the current blocks to everyone who has the view open (after add/set/options).
hide(player?: OpenRoadMP.PlayerRef): voidCloses the view for a player, without a player for everyone.
isOpen(player: OpenRoadMP.PlayerRef): booleanWhether the player has the view open.
readonly viewers: readonly OpenRoadMP.Player[]Players who have the view open.
onClose(handler: (player: OpenRoadMP.Player) => void): thisCalled when a player closes the window (X, Escape, a button with close) or leaves.

ui

The building blocks, global as ui (no import needed).

stack

ui.stack(props: UiStackProps, ...children: UiChild[]): UiElement

Children one below the other.

Types: UiStackProps, UiChild, UiElement

row

ui.row(props: UiRowProps, ...children: UiChild[]): UiElement

Children side by side.

Types: UiRowProps, UiChild, UiElement

grid

ui.grid(props: UiGridProps, ...children: UiChild[]): UiElement

Children in a grid with 1 to 6 columns.

Types: UiGridProps, UiChild, UiElement

card

ui.card(props: UiCardProps, ...children: UiChild[]): UiElement

A framed card with title, content and footer.

Types: UiCardProps, UiChild, UiElement

tabs

ui.tabs(props: UiTabsProps): UiElement

Tabs, one content each.

Types: UiTabsProps, UiElement

accordion

ui.accordion(props: UiAccordionProps): UiElement

Sections that open and close.

Types: UiAccordionProps, UiElement

heading

ui.heading(text: string, props?: UiHeadingProps): UiElement

A heading.

Types: UiHeadingProps, UiElement

text

ui.text(text: string, props?: UiTextProps): UiElement

Text.

Types: UiTextProps, UiElement

badge

ui.badge(text: string, props?: UiBadgeProps): UiElement

A small label.

Types: UiBadgeProps, UiElement

alert

ui.alert(props: UiAlertProps): UiElement

A notice box.

Types: UiAlertProps, UiElement

progress

ui.progress(props: UiProgressProps): UiElement

A progress bar.

Types: UiProgressProps, UiElement

table

ui.table(props: UiTableProps): UiElement

A table; cells may hold elements (e.g. buttons).

Types: UiTableProps, UiElement

separator

ui.separator(): UiElement

A line.

Types: UiElement

spinner

ui.spinner(): UiElement

A loading indicator.

Types: UiElement

button

ui.button(props: UiButtonProps): UiElement

A button.

Types: UiButtonProps, UiElement

input

ui.input(props: UiInputProps): UiElement

A text field.

Types: UiInputProps, UiElement

textarea

ui.textarea(props: UiTextareaProps): UiElement

A text field with several lines.

Types: UiTextareaProps, UiElement

select

ui.select(props: UiSelectProps): UiElement

A drop-down list.

Types: UiSelectProps, UiElement

checkbox

ui.checkbox(props: UiCheckProps): UiElement

A checkbox.

Types: UiCheckProps, UiElement

switch

ui.switch(props: UiCheckProps): UiElement

A switch.

Types: UiCheckProps, UiElement

radio

ui.radio(props: UiRadioProps): UiElement

One of several options.

Types: UiRadioProps, UiElement

slider

ui.slider(props: UiSliderProps): UiElement

A slider for numbers.

Types: UiSliderProps, UiElement

logoPicker

ui.logoPicker(props: UiLogoPickerProps): UiElement

The game's 16 company logos as pictures to click on. The value is the logo number (0-15) as a number, as company.logo takes it.

Types: UiLogoPickerProps, UiElement

On this page