Skip to content

The interface ​

Everything the player sees on top of the 3D view: the HUD, the menus, the settings, the keys and the kit you build your own screens with.

Quick start ​

tsx
import type { GameView } from '@v12-engine/client'

export const view: GameView = {
	units: { looks: {} },
	hud: {
		theme: 'moonlight', // or { accent: '#7fe07a', radius: '6px' }
		hide: ['clock', 'layoutButton'], // parts of the client's HUD you don't want
		widgets: [
			// a part of your own in the top bar, after the resources
			{ id: 'td.mana', place: 'top-bar-right', order: 15, component: (props) => <Mana client={props.client} /> }
		]
	}
}

That themes the HUD, drops two of its parts and adds one of yours. Everything else stays the client's classic RTS HUD.

Pages ​

PageWhat it covers
HUD layout and placesThe parts of the HUD, where they go, adding and replacing them, events
Your own HUDFrom a new skin to a HUD entirely your own, step by step
The command cardCard size, slots, buttons of your own, hiding and renaming buttons
Keys and hotkeysActions, the player's own bindings, keys of your game
Unit portraitsThe portrait box, live faces, talking portraits
The selection panelWhat is selected, the hero panel, subgroups, selection rules
Floating text and barsDamage numbers, plates over units, pings, elements pinned to the world
Menus, settings and motionThe pause menu, settings, animations, accessibility
SoundsUI sounds, the mixer's buses, 3D sound, what loads first
Graphics qualityPresets, shadows, anti-aliasing, resolution, frame caps
The UI kitThemes, components and overlays for screens of your own
LanguagesTranslations, right to left, typefaces

Four ways to change any piece ​

Every piece of the interface can be changed four ways, from least work to most control:

  1. Declared: a field of the game's view (hud.hide, hud.theme, cinematics.dialog).
  2. In code: a function or API on the client (client.hud.hide(part), client.theme.set(...)).
  3. A component (Solid) in the client's place. It gets what the client's own gets, so it can wrap it (as children) or replace it.
  4. An element of your own: mount(element, …) draws into it with any HTML or framework and returns what takes it away.

Component and element are said the same way everywhere (Own): a piece has component and mount, and mount wins when both are given. The client's own screens are there to wrap: ErrorScreen, LoadingScreen, OutcomeScreen, MenuScreen, CampaignMenu (from @v12-engine/client/app).

Screens are a controller and a view ​

Each screen splits into a controller (what it knows and what you can do, no elements) and a view (what draws it). Replace the view and you keep the behaviour:

tsx
// a campaign menu of your own: how it looks, nothing of what it does
menu: {
	component: (props) => (
		<MyMap>
			<For each={props.campaign.missions}>
				{(mission) => (
					<MyPin won={!!props.campaign.won(mission.id)} locked={!props.campaign.reached(mission.id)} onClick={() => props.campaign.play(mission.id)}>
						{mission.name}
					</MyPin>
				)}
			</For>
		</MyMap>
	)
}

What a controller knows is read by calling it (saves.list()): these are signals, so a Solid component follows them, and other code reads them or follows them with watch. What it does is a method; one that takes time returns a promise and reports problems in words (said()) instead of throwing.

Reference ​

Screens and their controllers ​

ScreenController (@v12-engine/client)ReadsDoesThe client's view (@v12-engine/client/app)
Saved gamesclient.saves, a SavesController (createSaves)list(), said(), canSave(), problem(saved)save(name), load(id), remove(id), refresh()SavesWindow, the HUD part saves
A campaign between missionsCampaignController (createCampaign)progress(), next(), won(mission), reached(mission), complete(), total(), savesplay(mission), startOver(), leave()CampaignMenu
Kept replaysReplaysController (createReplays)list(), said()watch(id), open(file), download(id), remove(id), refresh()ReplaysScreen
A replay playingReplayPlayback (createReplayPlayback)playing(), speed(), seconds(), length, speeds, catchingUp()toggle(), setSpeed(speed), seek(seconds)ReplayBar
A game shared for watchingGameSharewatchers(), note(), name, relaystart(), stop()SharePanel
A watched game, waitingWatchingController (createWatching)name, note()WatchWaiting
A lobby on a serverLobbyController (createLobby)state(), said(), seats(), you(), game(), phase(), settings(), offered(), name(), ready()join(options), sit(player), rename(name), setReady(on), set(setting, value), start(), leave(), reconnect(session)LobbyScreen
The server connectionclient.connection (createConnection)state(): connected, trying, lostretry(), leave()ConnectionBanner, the HUD part connection
Giving up and pausingclient.endings (createEndings)canSurrender(), online, pausesLeft(), canPause(), paused()surrender(), pause(), resume()the pause menu's lines, PausedBanner

Controllers come from @v12-engine/client, which loads no component, so they work where there is no page too. The command card and the selection work the same way (client.ui.commands(), client.controller).

Online pieces, four ways ​

Each page of this section lists its piece's four ways. These online pieces have no page of their own:

PieceDeclaredIn codeComponentElement
Sharing and watchingGameShare, WatchingControllersharePanel(share, { component }), watchScene({ waiting: { component } })the same: mount
LobbyonlineScene({ url, rules: game, settingsStore })createLobby(), scene.lobbyonlineScene({ lobby: { component } }), LobbyScreenonlineScene({ lobby: { mount } })
Lost connectionclient.connection, client.ui.connection()the part connection, ConnectionBannerthe part's mount
Giving up, pausing onlineRuleSettings.talk.pauses; hooks beforeSurrender, beforePauseclient.endingsthe part paused, PausedBanner; the menu's linesthe part's mount

Overlays (tooltip, toast, dialog, menu) are in The UI kit; the editor's panels, tools and inspector in Panels of the editor.

What the app's runtime asks ​

Each app (startApp, launch, openEditor) has its runtime (ClientRuntime, RuntimeOptions), each with a default:

WhatDefaultSet with
Development modethe bundler's (import.meta.env.DEV, else NODE_ENV)dev: true
Where the game's files arethe app's base (import.meta.env.BASE_URL, else /)launch({ assets: { base } })
Prefix for what an app keepsv12storagePrefix
Where errors are loggedthe consolelaunch({ log }), client.log.to(sink)
A project to keep maps inasked of the dev server (editorFiles)openEditor({ project: false }), editor.project.set(false)
What opens the project's codenothing; the editor's dev pluginopenCode, runtime.openCode = …