mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat(hud): render the Intel HUD from a store
IntelHUD no longer builds #intel-hud with innerHTML or writes its readouts by id: it publishes its readouts, typing summary, REC blink, visibility, layout variant and style colors through its publish option to the gev-hud store, and the intel-hud application view renders them. The corners render from mount so the panel layout controllers register them as obstacles. The vessel layer presents the selected vessel's readout through src/hudReadouts.js, which IntelHUD follows, instead of writing into the HUD. The Cyber sonar state answers a HUD toggle from IntelHUD's visibility rather than the class the view renders on its next update.
This commit is contained in:
1 parent
b96cc37ab5
commit
c03b4a7643
26 files changed
+556
-243
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Readouts other owners show in the Intel HUD. The vessel layer presents the
|
||||
* selected vessel here and the HUD subscribes, so neither reaches into the
|
||||
* other's markup.
|
||||
*/
|
||||
|
||||
/** @type {?{text: string}} The selected vessel's lines, or null for none. */
|
||||
let selectedVessel = null;
|
||||
const vesselListeners = new Set();
|
||||
|
||||
/**
|
||||
* Show the selected vessel's readout, or clear it.
|
||||
* @param {?{text: string}} readout Its lines joined by newlines, or null.
|
||||
*/
|
||||
export function presentSelectedVessel(readout) {
|
||||
selectedVessel = readout ? Object.freeze({ text: readout.text }) : null;
|
||||
for (const listener of vesselListeners) listener(selectedVessel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the selected vessel's readout; the current one is replayed at once.
|
||||
* @param {(readout: ?{text: string}) => void} listener
|
||||
* @returns {() => void} Stop following.
|
||||
*/
|
||||
export function subscribeSelectedVessel(listener) {
|
||||
vesselListeners.add(listener);
|
||||
listener(selectedVessel);
|
||||
return () => vesselListeners.delete(listener);
|
||||
}
|
||||
Reference in new issue
Block a user