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.
// 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
| Default | What you get | Change it | Page |
|---|---|---|---|
| The HUD | console, minimap, card, top bar, quests, dialog | GameView.hud: theme, hide, widgets, places, console | Your own HUD |
| The start screen | a title, a button per scene, the settings | appScenes({ home, menu, scenes, extra }), or your own menuScene | Menus and starting scenes |
| The campaign menu | the missions, won and locked, the saves, the difficulty | CampaignDef.menu: component or mount | Menus and starting scenes |
| Briefing and debrief | the mission's words, picture, objectives, rating | CampaignDef.screens: briefing, debrief | Menus and starting scenes |
| Which scene opens first | the start screen (or the one the address names) | startApp({ start }), a scene of your own that goes on | Menus and starting scenes |
| Loading and error screens | a bar over the map's picture | loading, error on a scene or a mission | Loading and error screens |
| The end screen | victory or defeat, retry, score | GameView.hud.outcome | The interface |
| How scenes cross over | a fade | startApp({ transition }), Scene.transition | Scenes |
| How a mission is won | by buildings left | Rules.victory: objectiveVictory | Classic missions |
| How the computer plays | the melee brain | Rules.brains, world.computers.seat | AI 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.
| Way | What you write | Example |
|---|---|---|
| Declared | data: words, colours, what to hide | outcome: { victory: 'The mission is accomplished.' } |
| In code | a call while the game runs | client.hud.hide('clock', true), client.theme.set('bone') |
| A component | a Solid component, given the piece's props; wrap the client's | menu: { component: (props) => <MyFrame><CampaignMenu {...props} /></MyFrame> } |
| An element | mount(element, …) with any HTML, React or Vue; return what takes it away | menu: { 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
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
hud: { theme: { accent: '#c0392b', radius: '2px' } }
registerTheme('blood', { accent: '#c0392b' }, 'iron') // a named theme, built on a skinThe 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
| Default | Off |
|---|---|
| a HUD part | hud: { hide: ['minimap'] } |
| the whole HUD (one game) | launch({ hud: false }) |
a scene of appScenes | it is a plain list: scenes.filter((scene) => scene.id !== 'random') |
| the full screen button | startApp({ fullscreenButton: false }) |
| the page guards (zoom, context menu) | startApp({ guards: false }) |
| the debug panel | launch({ debug: false }), or leave it out of a built page |
Reference
- The interface: every piece and its controller.
- HUD layout and places: places, sizes, widgets, skins, the HUD model.
- Scenes: scenes,
startApp, transitions. - Give your game its own interface: the same, as a walk-through.