Skip to content

Customize the defaults ​

V12 gives every game a working set of defaults: a HUD, a start screen, menus, a campaign menu with briefings, loading screens and an end screen. Each one can be kept, tweaked, or replaced, one piece at a time.

ts
// in src/view.ts: the look of the game
export const view: GameView = {
	hud: {
		theme: 'iron', // the HUD's metal
		hide: ['clock'], // a part of the client's taken away
		widgets: [{ id: 'my.boss', place: 'top', component: BossBar }], // a part of your own
		outcome: { victory: 'The pass is ours.', defeat: 'The pass is lost.' } // the end screen's words
	}
}

// in src/main.ts: the screens around the game
const scenes = appScenes({ game, home: { component: MyStartScreen }, extra: campaign.scenes })
startApp({ target: '#game', game, scenes, start: sceneAsked(scenes, 'home') })

The HUD wears iron, the clock is gone, a boss bar hangs at the top, the end screen says your words, and the start screen is yours. Everything else stays as it was.

The defaults, and where to change each ​

DefaultWhat you getChange itPage
The HUDconsole, minimap, card, top bar, quests, dialogGameView.hud: theme, hide, widgets, places, consoleYour own HUD
The start screena title, a button per scene, the settingsappScenes({ home, menu, scenes, extra }), or your own menuSceneMenus and starting scenes
The campaign menuthe missions, won and locked, the saves, the difficultyCampaignDef.menu: component or mountMenus and starting scenes
Briefing and debriefthe mission's words, picture, objectives, ratingCampaignDef.screens: briefing, debriefMenus and starting scenes
Which scene opens firstthe start screen (or the one the address names)startApp({ start }), a scene of your own that goes onMenus and starting scenes
Loading and error screensa bar over the map's pictureloading, error on a scene or a missionLoading and error screens
The end screenvictory or defeat, retry, scoreGameView.hud.outcomeThe interface
How scenes cross overa fadestartApp({ transition }), Scene.transitionScenes
How a mission is wonby buildings leftRules.victory: objectiveVictoryClassic missions
How the computer playsthe melee brainRules.brains, world.computers.seatAI for missions and campaigns

Four ways to change any piece ​

Every piece of the interface can be changed the same four ways. Pick the lightest one that does the job.

WayWhat you writeExample
Declareddata: words, colours, what to hideoutcome: { victory: 'The mission is accomplished.' }
In codea call while the game runsclient.hud.hide('clock', true), client.theme.set('bone')
A componenta Solid component, given the piece's props; wrap the client'smenu: { component: (props) => <MyFrame><CampaignMenu {...props} /></MyFrame> }
An elementmount(element, …) with any HTML, React or Vue; return what takes it awaymenu: { mount: (element, props) => drawMyMenu(element, props.campaign) }

A screen is a controller (what it knows and does) and a view (how it looks). When you replace a screen you replace only the view: the controller still plays missions, loads saves and keeps progress. That is why your own campaign menu is a few lines: props.campaign.play(id) does the work.

Common tasks ​

Keep the defaults and change only the words ​

ts
hud: {
	messages: { objectiveNew: 'Quest discovered: {text}', objectiveDone: 'Quest completed: {text}', objectiveFailed: 'Quest failed: {text}' },
	words: { idle: 'Awaiting orders' }
}

Every word the client says is a message key, reworded in GameView.hud.messages (and translated the same way: Languages).

Change the look everywhere at once ​

ts
hud: { theme: { accent: '#c0392b', radius: '2px' } }
registerTheme('blood', { accent: '#c0392b' }, 'iron') // a named theme, built on a skin

The menus, the HUD and the kit's panels all read the same tokens (--vg-accent, --vg-panel…). See The UI kit.

Turn a default off ​

DefaultOff
a HUD parthud: { hide: ['minimap'] }
the whole HUD (one game)launch({ hud: false })
a scene of appScenesit is a plain list: scenes.filter((scene) => scene.id !== 'random')
the full screen buttonstartApp({ fullscreenButton: false })
the page guards (zoom, context menu)startApp({ guards: false })
the debug panellaunch({ debug: false }), or leave it out of a built page

Reference ​