mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
PointerReticle keeps the turn's timers and tool tracking and presents where the user pointed to the gev-pointer-reticle store, one entry per reticle; the command dock teleports each to the body with the same class, aria-hidden, hidden state, target and position. The voice QA reads the card and reticle after Vue's flush, and the application guide says leaving out the command dock leaves out the voice control and its reticle.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The voice pointer reticles as their view renders them. Each PointerReticle
|
|
* (src/voice/pointerReticle.js) presents where the user pointed while its
|
|
* voice turn is live.
|
|
*/
|
|
export const usePointerReticleStore = defineStore('gev-pointer-reticle', () => {
|
|
/**
|
|
* `[{owner, visible, left, top, target}]` in client pixels, one per
|
|
* reticle that has shown, `target` being 'entity' or 'ground'.
|
|
*/
|
|
const reticles = shallowRef([]);
|
|
|
|
/**
|
|
* @param {object} owner The reticle publishing.
|
|
* @param {?object} view Its fresh presentation, or null to remove it.
|
|
*/
|
|
function publish(owner, view) {
|
|
const index = reticles.value.findIndex((item) => item.owner === owner);
|
|
const next = reticles.value.slice();
|
|
if (!view) {
|
|
if (index < 0) return;
|
|
next.splice(index, 1);
|
|
} else if (index < 0) next.push(markRaw({ ...view, owner }));
|
|
else next[index] = markRaw({ ...view, owner });
|
|
reticles.value = next;
|
|
}
|
|
|
|
return { reticles, publish };
|
|
});
|