Apply platform colours to crew markers
This commit is contained in:
parent
c360758095
commit
08095ae1e6
3 changed files with 26 additions and 7 deletions
|
|
@ -51,9 +51,17 @@ export function mountConsole(root, host = null) {
|
|||
hosted: !!host,
|
||||
});
|
||||
let appearance = {};
|
||||
const playerColor = (i) => {
|
||||
const color = appearance.playerColors?.[i];
|
||||
return typeof color === "string" && /^#[a-f0-9]{6}$/i.test(color)
|
||||
? color
|
||||
: "";
|
||||
};
|
||||
const playerBadge = (i) => {
|
||||
const badge = appearance.players?.[i]?.pro && appearance.supporterBadge;
|
||||
return badge ? `<img class="supporter-badge" src="${esc(badge.url)}" alt="${esc(badge.label)}" title="${esc(badge.label)}" width="14" height="14">` : "";
|
||||
return badge
|
||||
? `<img class="supporter-badge" src="${esc(badge.url)}" alt="${esc(badge.label)}" title="${esc(badge.label)}" width="14" height="14">`
|
||||
: "";
|
||||
};
|
||||
const playerName = (i) =>
|
||||
esc(view?.players[i]?.name ?? `${t("Joueur", "Player")} ${i + 1}`);
|
||||
|
|
@ -119,6 +127,7 @@ export function mountConsole(root, host = null) {
|
|||
esc,
|
||||
symbol,
|
||||
zoneName,
|
||||
playerColor,
|
||||
});
|
||||
function updateSound() {
|
||||
const button = $("#sound");
|
||||
|
|
@ -303,7 +312,7 @@ export function mountConsole(root, host = null) {
|
|||
$("#crew").innerHTML = view.players
|
||||
.map(
|
||||
(p) =>
|
||||
`<span class="crew-member ${p.ready ? "ready" : ""} ${p.seat === seat ? "own" : ""}">${playerName(p.seat)}${playerBadge(p.seat)} · ${p.planningPhase ? `${p.finishedPlanning ? "🔒" : t("Phase", "Phase")} ${p.planningPhase}` : p.ready ? t("présent", "ready") : t("attente", "waiting")}</span>`,
|
||||
`<span style="${playerColor(p.seat) ? `--player-color:${playerColor(p.seat)}` : ""}" class="crew-member ${p.ready ? "ready" : ""} ${p.seat === seat ? "own" : ""}">${playerName(p.seat)}${playerBadge(p.seat)} · ${p.planningPhase ? `${p.finishedPlanning ? "🔒" : t("Phase", "Phase")} ${p.planningPhase}` : p.ready ? t("présent", "ready") : t("attente", "waiting")}</span>`,
|
||||
)
|
||||
.join("");
|
||||
$("#ship-title").textContent = t("Le vaisseau", "The ship");
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ h1 {
|
|||
margin: 8px 0 16px;
|
||||
}
|
||||
.crew-member {
|
||||
box-shadow: inset 3px 0 var(--player-color, transparent);
|
||||
font-size: 12px;
|
||||
border: 1px solid var(--line);
|
||||
padding: 5px 9px;
|
||||
|
|
@ -1360,19 +1361,22 @@ input:not([type="checkbox"]):not([type="range"]) {
|
|||
display: inline-flex;
|
||||
width: 23px;
|
||||
height: 29px;
|
||||
color: #bfd0db;
|
||||
color: var(--player-color, #bfd0db);
|
||||
}
|
||||
.crew-pawn > svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
fill: currentColor;
|
||||
stroke: #0a2231;
|
||||
stroke: var(--player-stroke, #0a2231);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
.crew-pawn .visor {
|
||||
fill: #2a5969;
|
||||
}
|
||||
.crew-pawn b {
|
||||
text-shadow:
|
||||
0 0 2px #fff,
|
||||
0 0 2px #fff;
|
||||
position: absolute;
|
||||
bottom: 3px;
|
||||
width: 100%;
|
||||
|
|
@ -1381,7 +1385,7 @@ input:not([type="checkbox"]):not([type="range"]) {
|
|||
font-size: 11px;
|
||||
}
|
||||
.crew-pawn.selected {
|
||||
color: #ffe0a0;
|
||||
color: var(--player-color, #ffe0a0);
|
||||
filter: drop-shadow(0 0 2px #e8c98460);
|
||||
}
|
||||
.crew-pawn.out {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
import { illustration, threatIllustration } from "./art.js";
|
||||
import { pictogram, shipLocator } from "./icons.js";
|
||||
|
||||
export function createTacticalView({ t, esc, symbol, zoneName }) {
|
||||
export function createTacticalView({
|
||||
t,
|
||||
esc,
|
||||
symbol,
|
||||
zoneName,
|
||||
playerColor = () => "",
|
||||
}) {
|
||||
const meter = (value, capacity) =>
|
||||
`<span class="charge-pips" aria-hidden="true">${Array.from({ length: capacity }, (_, i) => `<i class="${i < value ? "filled" : ""}"></i>`).join("")}</span>`;
|
||||
|
||||
|
|
@ -141,7 +147,7 @@ export function createTacticalView({ t, esc, symbol, zoneName }) {
|
|||
level === "upper"
|
||||
? t("Pont supérieur", "Upper deck")
|
||||
: t("Pont inférieur", "Lower deck");
|
||||
return `<section class="station ${occupants.some((p) => p.id === selectedCrew) ? "selected-station" : ""}" data-station="${station}" style="--zone:var(--${zone})" aria-label="${esc(zoneName(zone))} · ${deckName}"><div class="station-title">${esc(zoneName(zone))}${symbol(level === "upper" ? "up" : "down", deckName)}${level === "upper" && s.damage.length ? `<span class="damage">${symbol("warning", `${t("Dégâts de la zone", "Zone damage")} : ${s.damage.length}/6`, `${s.damage.length}/6`)}</span>` : ""}</div>${stationControls({ station, zone, deck: level, ship, power, capacity, system, cIcon, c, canPlan })}<div class="occupants">${occupants.map((p) => `<span class="crew-pawn ${p.id === selectedCrew ? "selected" : ""} ${p.knockedOut ? "out" : ""}" role="img" title="${esc(crewLabel(p.id))}${p.knockedOut ? " · " + t("Hors combat", "Knocked out") : ""}${p.bots !== null ? " · " + t("Robots", "Battlebots") : ""}" aria-label="${esc(crewLabel(p.id))}${p.knockedOut ? " · " + t("Hors combat", "Knocked out") : ""}${p.bots !== null ? " · " + t("Robots", "Battlebots") : ""}"><svg viewBox="0 0 24 30" aria-hidden="true"><path d="M4 28v-9a8 8 0 0 1 16 0v9Z"/><circle cx="12" cy="8" r="7"/><path class="visor" d="M7 6h10v5H7z"/></svg><b>${p.id + 1}</b>${p.bots !== null ? `<i>${pictogram("bots")}</i>` : ""}</span>`).join("")}</div></section>`;
|
||||
return `<section class="station ${occupants.some((p) => p.id === selectedCrew) ? "selected-station" : ""}" data-station="${station}" style="--zone:var(--${zone})" aria-label="${esc(zoneName(zone))} · ${deckName}"><div class="station-title">${esc(zoneName(zone))}${symbol(level === "upper" ? "up" : "down", deckName)}${level === "upper" && s.damage.length ? `<span class="damage">${symbol("warning", `${t("Dégâts de la zone", "Zone damage")} : ${s.damage.length}/6`, `${s.damage.length}/6`)}</span>` : ""}</div>${stationControls({ station, zone, deck: level, ship, power, capacity, system, cIcon, c, canPlan })}<div class="occupants">${occupants.map((p) => `<span style="${playerColor(p.id) ? `--player-color:${playerColor(p.id)};--player-stroke:#c4d4e0` : ""}" class="crew-pawn ${p.id === selectedCrew ? "selected" : ""} ${p.knockedOut ? "out" : ""}" role="img" title="${esc(crewLabel(p.id))}${p.knockedOut ? " · " + t("Hors combat", "Knocked out") : ""}${p.bots !== null ? " · " + t("Robots", "Battlebots") : ""}" aria-label="${esc(crewLabel(p.id))}${p.knockedOut ? " · " + t("Hors combat", "Knocked out") : ""}${p.bots !== null ? " · " + t("Robots", "Battlebots") : ""}"><svg viewBox="0 0 24 30" aria-hidden="true"><path d="M4 28v-9a8 8 0 0 1 16 0v9Z"/><circle cx="12" cy="8" r="7"/><path class="visor" d="M7 6h10v5H7z"/></svg><b>${p.id + 1}</b>${p.bots !== null ? `<i>${pictogram("bots")}</i>` : ""}</span>`).join("")}</div></section>`;
|
||||
})
|
||||
.join(
|
||||
"",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue