screens.module
This package holds more than this page lists. See all of its files in its world.
README.md
rtsSkirmishKit.screens
Warfront's whole front end, drawn from rtsSkirmishKit.session state on every machine:
- Title: WARFRONT over the live backdrop (a translucent rail on the left, the map visible on the right): Skirmish, Settings and Credits (menusKit's, fantasy look), and a "Next battle" card with the current setup.
- Skirmish setup: map cards (name, setting, description, painted vignette) and every option in
Settings.OPTIONSas a row of choices with the chosen one's description: opponent, difficulty, victory, start mode, army look, fog style, fog on/off. Back / Start match. Guests (Session.isHost() == false) see the host's picks live, read-only, with "Waiting for host". On small screens the setup splits into three tabs (Battlefield, Foe & terms, Look). - Countdown: MatchFlow's fantasy runic 3-2-1 with its bell, ending on FIGHT, over the battlefield, with the objective of the chosen victory condition and the match-up.
- Objective line: a small top-centre pill during play with
Session.objective()({ label, text, fraction? }), clear of rtsKit's HUD. - Victory / Defeat: the headline, the reason, the victory condition and match time, an after-action table per team (units trained, units lost, kills, buildings built, buildings lost, gold and wood gathered; best value per row in gold), and Rematch / Change setup / Main menu (host; guests wait).
Use
local Screens = require("rtsSkirmishKit.screens")
Screens.mount() -- play mode, every machine
Screens.mount({ session = fake }) -- tests: any table with the Session API
Skirmish.skirmish() already does this through the rtsSkirmishKit.Screens component. The screens only ever call these on the session: open("setup"), setOption(key, value), start(), rematch(), toTitle(); they read phase, on("phase"), config, isHost, countdown, results and objective.
API
mount(opts?):opts = { session?, settings? }; spawns the localrtsSkirmishKit.Screenshost in play if none is there.unmount(),isMounted().tick(dt): the host calls it every frame: follows the phase, plays the countdown ticks and GO, redraws what changed.handle(id): routes awf:*ui callback (wf:title:skirmish,wf:map:<id>,wf:opt:<key>:<value>,wf:tab:<n>,wf:setup:start|back,wf:res:rematch|setup|menu).navigate(dir),select(),back(),tab(d): keyboard / pad navigation (left / right on a setup row changes its value).focused()names the focused element id.current():"title" | "setup" | "countdown" | "playing" | "results".build(w?, h?, safe?),buildObjective(w?, h?, safe?): the trees, at any size (for tests and captures).setTouch(on),setPrompt(fn),refresh(),log()(the session calls the screens made, for tests).- Constants:
SCREEN/HUD(ui screen names),LAYER(940, under menusKit's 950),HUD_LAYER(120),LOOK(menusKit look),COUNTDOWN_STYLE,GO_TEXT.