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
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
| Page | What it covers |
|---|---|
| HUD layout and places | The parts of the HUD, where they go, adding and replacing them, events |
| Your own HUD | From a new skin to a HUD entirely your own, step by step |
| The command card | Card size, slots, buttons of your own, hiding and renaming buttons |
| Keys and hotkeys | Actions, the player's own bindings, keys of your game |
| Unit portraits | The portrait box, live faces, talking portraits |
| The selection panel | What is selected, the hero panel, subgroups, selection rules |
| Floating text and bars | Damage numbers, plates over units, pings, elements pinned to the world |
| Menus, settings and motion | The pause menu, settings, animations, accessibility |
| Sounds | UI sounds, the mixer's buses, 3D sound, what loads first |
| Graphics quality | Presets, shadows, anti-aliasing, resolution, frame caps |
| The UI kit | Themes, components and overlays for screens of your own |
| Languages | Translations, 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:
- Declared: a field of the game's view (
hud.hide,hud.theme,cinematics.dialog). - In code: a function or API on the client (
client.hud.hide(part),client.theme.set(...)). - 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. - 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:
// 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
| Screen | Controller (@v12-engine/client) | Reads | Does | The client's view (@v12-engine/client/app) |
|---|---|---|---|---|
| Saved games | client.saves, a SavesController (createSaves) | list(), said(), canSave(), problem(saved) | save(name), load(id), remove(id), refresh() | SavesWindow, the HUD part saves |
| A campaign between missions | CampaignController (createCampaign) | progress(), next(), won(mission), reached(mission), complete(), total(), saves | play(mission), startOver(), leave() | CampaignMenu |
| Kept replays | ReplaysController (createReplays) | list(), said() | watch(id), open(file), download(id), remove(id), refresh() | ReplaysScreen |
| A replay playing | ReplayPlayback (createReplayPlayback) | playing(), speed(), seconds(), length, speeds, catchingUp() | toggle(), setSpeed(speed), seek(seconds) | ReplayBar |
| A game shared for watching | GameShare | watchers(), note(), name, relay | start(), stop() | SharePanel |
| A watched game, waiting | WatchingController (createWatching) | name, note() | WatchWaiting | |
| A lobby on a server | LobbyController (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 connection | client.connection (createConnection) | state(): connected, trying, lost | retry(), leave() | ConnectionBanner, the HUD part connection |
| Giving up and pausing | client.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:
| Piece | Declared | In code | Component | Element |
|---|---|---|---|---|
| Sharing and watching | GameShare, WatchingController | sharePanel(share, { component }), watchScene({ waiting: { component } }) | the same: mount | |
| Lobby | onlineScene({ url, rules: game, settingsStore }) | createLobby(), scene.lobby | onlineScene({ lobby: { component } }), LobbyScreen | onlineScene({ lobby: { mount } }) |
| Lost connection | client.connection, client.ui.connection() | the part connection, ConnectionBanner | the part's mount | |
| Giving up, pausing online | RuleSettings.talk.pauses; hooks beforeSurrender, beforePause | client.endings | the part paused, PausedBanner; the menu's lines | the 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:
| What | Default | Set with |
|---|---|---|
| Development mode | the bundler's (import.meta.env.DEV, else NODE_ENV) | dev: true |
| Where the game's files are | the app's base (import.meta.env.BASE_URL, else /) | launch({ assets: { base } }) |
| Prefix for what an app keeps | v12 | storagePrefix |
| Where errors are logged | the console | launch({ log }), client.log.to(sink) |
| A project to keep maps in | asked of the dev server (editorFiles) | openEditor({ project: false }), editor.project.set(false) |
| What opens the project's code | nothing; the editor's dev plugin | openCode, runtime.openCode = … |