The campaign menu
Between missions, a campaign shows its menu: the missions, which are won and which are open, the saves. Before and after a mission come its briefing and debrief. Each is the client's, and each can be your own drawing over the same controller.
Quick start
menu: {
title: 'The Long Road',
subtitle: 'A campaign in three missions',
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>
)
}A map of pins: won ones marked, locked ones shut, a click plays the mission. The menu's behaviour is the controller's; you only draw it. The whole walk-through is The campaign menu tutorial and A campaign of missions.
Common tasks
Wrap the client's menu
menu: { component: (props) => <MyFrame><CampaignMenu {...props} /></MyFrame> }Draw it in plain HTML
menu: { mount: (element, props) => drawCampaign(element, props.campaign) }Change the briefing and debrief
A mission's briefing and debrief have words, a picture, objectives and a rating. To draw them yourself:
screens: {
briefing: { component: MyBriefing }, // BriefingProps: begin, back
debrief: { mount: (element, props) => drawDebrief(element, props) } // DebriefProps: goOn
}BriefingScreen and DebriefScreen are the client's, to wrap.
Load a saved mission
The menu is given the campaign's saves (props.campaign.saves, a SavesController): saves(), load(id) (returns the words when it can't), refusal(reason).
Reference
CampaignController (createCampaign, props.campaign)
| Reads | Does |
|---|---|
progress(), next() | play(mission) |
won(mission), reached(mission) | startOver() |
complete(), total() | leave() |
missions, saves |
CampaignDef.menu
title, subtitle, background, component (CampaignMenu to wrap), mount(element, props). Missions keep their own store.
Saves that don't load
A list of saves shows one the game can't load greyed, with why: saved by a newer version, or by one with no way from it (Rules.saves, see Saving and loading). The reasons are message keys: save.newer, save.noWay, save.rules, save.missing, save.game, save.notASave, save.failed, save.gone (reword them in GameView.hud.messages).
| In code | A list of your own |
|---|---|
listSaves(scenes, registry): each with its problem; wordsFor(saveRefused(reason)) | loadSave(id), then updateSave(from, registry), which throws a SaveError |