Logo FSBarV1_Archived

SceneBuilder Module

Builds declarative Scene trees from game snapshots.

Functions and values

Function or value Description

buildScene snapshot config viewState

Full Usage: buildScene snapshot config viewState

Parameters:
Returns: Scene

Builds a complete Scene from a game snapshot, viz config, and view state.

snapshot : GameSnapshot
config : VizConfig
viewState : ViewState
Returns: Scene

buildSceneHeadless state map config

Full Usage: buildSceneHeadless state map config

Parameters:
Returns: Scene

Builds a `Scene` for an embedded / headless viewer (feature 035-central-gui-hub R8). Converts a live `GameState` + optional `MapGrid` into a minimal `GameSnapshot` and calls `buildScene` with `VizDefaults.defaultViewState`. Unlike `GameViz.start`, this opens no window — the caller owns the `SkiaViewer.Window` and composes the returned scene into its own frame loop. When `map` is `None` a tiny synthetic 16x16 heightmap stand-in is used so early frames during session start-up render without crashing; replace once the real `MapGrid` is available. This is a stateless, pure-ish function (the pulse-phase clock remains module-level). Cheap enough to call every frame.

state : GameState
map : MapGrid option
config : VizConfig
Returns: Scene

buildSceneHeadlessSized state map metalSpots defCache config viewportWidth viewportHeight

Full Usage: buildSceneHeadlessSized state map metalSpots defCache config viewportWidth viewportHeight

Parameters:
    state : GameState
    map : MapGrid option
    metalSpots : (float32 * float32 * float32 * float32) array
    defCache : UnitDefCache option
    config : VizConfig
    viewportWidth : int
    viewportHeight : int

Returns: Scene

Variant of `buildSceneHeadless` that lets the embedder pin the viewport window dimensions AND supply the engine's metal-spot list. The hub uses this so the scene auto-fits to the Viewer tab's content rectangle instead of `VizDefaults.defaultViewState`'s 1024x640 default, and so metal-spot markers render when `OverlayKind.MetalSpots` is active. `defCache` is consumed by feature 038's `UnitDisplayAdapter` to populate `GameSnapshot.DisplayUnits` with correctly-classified glyph data. `None` keeps the pre-038 legacy placeholder path so tests and preview-only callers without a live `BarClient` continue to work.

state : GameState
map : MapGrid option
metalSpots : (float32 * float32 * float32 * float32) array
defCache : UnitDefCache option
config : VizConfig
viewportWidth : int
viewportHeight : int
Returns: Scene

buildSceneHeadlessView state map metalSpots defCache config viewState

Full Usage: buildSceneHeadlessView state map metalSpots defCache config viewState

Parameters:
Returns: Scene

Variant of `buildSceneHeadlessSized` that composes with a caller- supplied `ViewState` instead of auto-fitting. Used by embedders that want user zoom/pan control (e.g. the hub's Viewer tab) — they keep a mutable `ViewState`, adjust `Scale` / `OriginX/Y` on scroll-wheel + drag events, and pass the current value each frame. `defCache` — see `buildSceneHeadlessSized`.

state : GameState
map : MapGrid option
metalSpots : (float32 * float32 * float32 * float32) array
defCache : UnitDefCache option
config : VizConfig
viewState : ViewState
Returns: Scene

computeFitScale map viewportWidth viewportHeight

Full Usage: computeFitScale map viewportWidth viewportHeight

Parameters:
    map : MapGrid option
    viewportWidth : int
    viewportHeight : int

Returns: float32

Returns the `Scale` value that would letterbox `map` into a viewport of the given dimensions. Callers use this to initialise their `ViewState` or re-fit after a window resize when `AutoFit = true`. Returns `1.0f` if the map is empty.

map : MapGrid option
viewportWidth : int
viewportHeight : int
Returns: float32

computePulseAlpha elapsed periodSeconds

Full Usage: computePulseAlpha elapsed periodSeconds

Parameters:
    elapsed : float
    periodSeconds : float

Returns: byte

Computes a clamped pulse alpha byte in [60, 220] from elapsed seconds and period.

elapsed : float
periodSeconds : float
Returns: byte

resetPulsePhase ()

Full Usage: resetPulsePhase ()

Parameters:
    () : unit

Resets the pulse clock to zero. Call on session start/stop.

() : unit

updatePulsePhase deltaSeconds

Full Usage: updatePulsePhase deltaSeconds

Parameters:
    deltaSeconds : float

Advances the pulse clock by one FrameTick's delta seconds and recomputes the shared phase used by metal-spot markers. Call once per FrameTick.

deltaSeconds : float

Type something to start searching.