feat(viewer): support the shared color-blind preference
This commit is contained in:
parent
9436db2f7a
commit
c197b42042
31 changed files with 236 additions and 54 deletions
|
|
@ -39,3 +39,13 @@ Lessons run the real engine locally with deterministic opponents and private
|
|||
player views. The extra lesson controls make drag actions accessible on mobile.
|
||||
Chapter progress survives refresh. Playback controls return to the previous step,
|
||||
replay the current step or go back to the start. No live game or chat messages are sent.
|
||||
|
||||
## Shared accessibility preference
|
||||
|
||||
The viewer follows BGS's boolean `colorBlind` preference (default `false`).
|
||||
Its eye icon updates the same shared preference through `update:preference`.
|
||||
Shapes identify container colours across pieces, factories, value cards, trade
|
||||
controls, tutorials and the journal. Player numbers match ships, boards and
|
||||
island rows. No engine state or colour identifiers are changed.
|
||||
|
||||
Register `{ "name": "colorBlind", "label": "Color-blind mode", "type": "checkbox", "default": false }` in the BGS viewer preferences.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "container-viewer",
|
||||
"version": "2.0.8",
|
||||
"version": "2.0.9",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/boardgamers/container.git",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { checkHostPresentation } from './host-presentation-smoke.mjs';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createServer } from 'node:http';
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { chromium } from 'playwright';
|
||||
import { checkHostPresentation } from './host-presentation-smoke.mjs';
|
||||
|
||||
const game = 'container';
|
||||
const require = createRequire(import.meta.url);
|
||||
|
|
@ -56,6 +56,7 @@ try {
|
|||
state.log = Array.from({ length: 50 }, (_, index) =>
|
||||
journalEntry(`Journal entry ${index + 1}: Ada buys containers from Bob's warehouse.`)
|
||||
);
|
||||
state.log.unshift(journalEntry('<span style="border:1px solid black">orange</span> container'));
|
||||
const id = (value) => value.toString(16).padStart(24, '0');
|
||||
const messages = Array.from({ length: 35 }, (_, i) => ({
|
||||
_id: id(i + 1),
|
||||
|
|
@ -98,6 +99,26 @@ try {
|
|||
);
|
||||
await page.waitForFunction(() => readyCount === 1);
|
||||
await page.locator('#app').evaluate((el) => (el.style.display = ''));
|
||||
assert.equal(await page.locator('.color-mark').count(), 0, 'colour symbols are off by default');
|
||||
await page.evaluate(() => {
|
||||
window.preferenceChanges = [];
|
||||
host.on('update:preference', (value) => preferenceChanges.push(value));
|
||||
host.emit('preferences', { colorBlind: true });
|
||||
});
|
||||
await page.waitForFunction(() => document.querySelectorAll('.color-mark').length > 20);
|
||||
assert.equal(await page.locator('.point-card .color-mark').count(), 5, 'value card matches cargo symbols');
|
||||
assert.equal(
|
||||
await page.locator('.inline-game-log .color-mark').count(),
|
||||
1,
|
||||
'journal uses the same colour symbols'
|
||||
);
|
||||
assert.equal(await page.locator('.player-number').count(), 6, 'ships and island rows identify all players');
|
||||
await page.screenshot({ path: `/tmp/container-color-blind-${width}.png`, fullPage: true });
|
||||
await page.locator('.color-blind-toggle').scrollIntoViewIfNeeded();
|
||||
await page.locator('.color-blind-toggle').click();
|
||||
await page.waitForFunction(() => document.querySelectorAll('.color-mark').length === 0);
|
||||
assert.deepEqual(await page.evaluate(() => preferenceChanges), [{ name: 'colorBlind', value: false }]);
|
||||
|
||||
const panel = page.locator('.bgs-game-chat');
|
||||
const input = panel.locator('input');
|
||||
const list = panel.locator('.chat-messages');
|
||||
|
|
|
|||
25
viewer/src/color-blind.ts
Normal file
25
viewer/src/color-blind.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const marks: Record<string, string> = {
|
||||
brown: 'M2 2H8V8H2Z',
|
||||
orange: 'M5 1L9 8H1Z',
|
||||
tan: 'M5 1L9 5L5 9L1 5Z',
|
||||
white: 'M5 1V9M1 5H9',
|
||||
darkslategray: 'M5 1a4 4 0 1 0 0 8a4 4 0 1 0 0-8',
|
||||
};
|
||||
|
||||
export function colorMarkPath(color = ''): string {
|
||||
return marks[color] ?? '';
|
||||
}
|
||||
|
||||
export function colorMarkSvg(color = ''): string {
|
||||
const path = colorMarkPath(color);
|
||||
return path
|
||||
? `<svg class="color-mark" viewBox="0 0 10 10" width="10" height="10" aria-hidden="true"><rect width="10" height="10" rx="1" fill="#fff"/><path d="${path}" fill="none" stroke="#172d34" stroke-width="1.5" stroke-linejoin="round"/></svg>`
|
||||
: '';
|
||||
}
|
||||
|
||||
export function colorBadgeHtml(color: string, enabled: boolean): string {
|
||||
if (!marks[color]) return '';
|
||||
return `<span class="container-color-badge" style="display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;width:24px;height:14px;border:1px solid #21343b;background:${color}" title="${
|
||||
color === 'darkslategray' ? 'dark green' : color
|
||||
}">${enabled ? colorMarkSvg(color) : ''}</span>`;
|
||||
}
|
||||
26
viewer/src/components/ColorMark.vue
Normal file
26
viewer/src/components/ColorMark.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<template>
|
||||
<g v-if="preferences.colorBlind && path" class="color-mark" pointer-events="none">
|
||||
<rect x="-5" y="-5" width="10" height="10" rx="1" fill="white" />
|
||||
<path
|
||||
:d="path"
|
||||
transform="translate(-5 -5)"
|
||||
fill="none"
|
||||
stroke="#172d34"
|
||||
stroke-width="1.5"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, InjectReactive, Prop, Vue } from 'vue-property-decorator';
|
||||
import type { Preferences } from '../types/ui-data';
|
||||
import { colorMarkPath } from '../color-blind';
|
||||
@Component
|
||||
export default class ColorMark extends Vue {
|
||||
@InjectReactive() readonly preferences!: Preferences;
|
||||
@Prop() color?: string;
|
||||
get path() {
|
||||
return colorMarkPath(this.color);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<template>
|
||||
<div class="game">
|
||||
<div class="game" :class="{ 'color-blind': preferences.colorBlind }">
|
||||
<div class="statusBar">
|
||||
<strong>CONTAINER</strong><span>{{ getStatusMessage() }}</span>
|
||||
</div>
|
||||
<div v-if="containerActions" class="container-actions" aria-label="Selected container">
|
||||
<div class="container-action-title">
|
||||
<span class="selected-container-colour" :style="{ background: containerActions.colour }"></span>
|
||||
<span v-html="colorBadge(containerActions.colour)"></span>
|
||||
<span>{{ containerActions.title }}</span>
|
||||
<button class="selection-close" aria-label="Cancel selection" @click="ui.selected = null">
|
||||
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="m5 5 10 10M15 5 5 15" /></svg>
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
:title="p.name"
|
||||
@click="viewPlayerBoard(i)"
|
||||
>
|
||||
<span class="player-board-marker" aria-hidden="true"></span
|
||||
<span class="player-board-marker" aria-hidden="true">{{ preferences.colorBlind ? i + 1 : '' }}</span
|
||||
><span class="player-board-name" :data-bgs-player="i">{{ i === player ? 'You' : p.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
@click="selectContainer(offer.id)"
|
||||
:aria-label="offer.label"
|
||||
>
|
||||
<span class="selected-container-colour" :style="{ background: offer.colour }"></span>
|
||||
<span v-html="colorBadge(offer.colour)"></span>
|
||||
${{ offer.price }}
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -89,13 +89,19 @@
|
|||
<LogButton data-thumbnail-omit transform="translate(1105, 67)" @click="showLog()" />
|
||||
<SoundButton
|
||||
data-thumbnail-omit
|
||||
transform="translate(1200, 15)"
|
||||
transform="translate(1200, 3)"
|
||||
:isOn="preferences.sound"
|
||||
@click="toggleSound()"
|
||||
/>
|
||||
<ColorBlindButton
|
||||
data-thumbnail-omit
|
||||
transform="translate(1200, 69)"
|
||||
:isOn="preferences.colorBlind"
|
||||
@click="toggleColorBlind()"
|
||||
/>
|
||||
<HelpButton
|
||||
data-thumbnail-omit
|
||||
transform="translate(1200, 55)"
|
||||
transform="translate(1200, 36)"
|
||||
:isOn="!preferences.disableHelp"
|
||||
@click="toggleHelp()"
|
||||
/>
|
||||
|
|
@ -133,6 +139,20 @@
|
|||
stroke-width="3"
|
||||
:stroke="playerColors[i]"
|
||||
/>
|
||||
<g v-if="preferences.colorBlind" :key="'N' + i" class="player-number" pointer-events="none">
|
||||
<rect
|
||||
x="865"
|
||||
:y="434 + i * 44"
|
||||
width="14"
|
||||
height="14"
|
||||
rx="2"
|
||||
fill="white"
|
||||
stroke="#203a45"
|
||||
/>
|
||||
<text x="872" :y="441 + i * 44" text-anchor="middle" font-size="11" fill="#172d34">
|
||||
{{ i + 1 }}
|
||||
</text>
|
||||
</g>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
|
@ -646,6 +666,8 @@
|
|||
</template>
|
||||
<script lang="ts">
|
||||
import InlineLog from './InlineLog.vue';
|
||||
import ColorBlindButton from './buttons/ColorBlindButton.vue';
|
||||
import { colorBadgeHtml } from '../color-blind';
|
||||
import { journalPieces } from '../journal-pieces';
|
||||
import { Vue, Component, Prop, Watch, Provide, ProvideReactive } from 'vue-property-decorator';
|
||||
import { MoveName, ended, move as engineMove } from 'container-engine';
|
||||
|
|
@ -680,6 +702,7 @@ import { GameEventName, LogMove } from 'container-engine/src/log';
|
|||
UndoButton,
|
||||
LogButton,
|
||||
SoundButton,
|
||||
ColorBlindButton,
|
||||
HelpButton,
|
||||
DropZone,
|
||||
Calculator,
|
||||
|
|
@ -1461,6 +1484,16 @@ export default class Game extends Vue {
|
|||
return !!availableMoves[MoveName.Decline];
|
||||
}
|
||||
|
||||
colorBadge(color: string) {
|
||||
return colorBadgeHtml(color, !!this.preferences.colorBlind);
|
||||
}
|
||||
|
||||
toggleColorBlind() {
|
||||
const value = !this.preferences.colorBlind;
|
||||
this.$set(this.preferences, 'colorBlind', value);
|
||||
this.emitter.emit('update:preference', { name: 'colorBlind', value });
|
||||
}
|
||||
|
||||
toggleSound() {
|
||||
const newSound = !this.preferences.sound;
|
||||
|
||||
|
|
@ -1678,12 +1711,14 @@ export default class Game extends Vue {
|
|||
logReversed.push('New phase: ' + log.phase);
|
||||
} else if (log.type == 'event') {
|
||||
if (log.event.name == GameEventName.Upkeep) {
|
||||
logReversed.push('New event: ' + journalPieces(log.event.interest));
|
||||
logReversed.push(
|
||||
'New event: ' + journalPieces(log.event.interest, this.preferences.colorBlind)
|
||||
);
|
||||
} else {
|
||||
logReversed.push('New event: ' + log.event.name);
|
||||
}
|
||||
} else if (log.type == 'move') {
|
||||
logReversed.push(journalPieces(log.pretty));
|
||||
logReversed.push(journalPieces(log.pretty, this.preferences.colorBlind));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1730,32 +1765,25 @@ export default class Game extends Vue {
|
|||
getFinalScoreHTML(player, i) {
|
||||
let str = player.finalScoreBreakdown ? player.finalScoreBreakdown[i] : '0';
|
||||
|
||||
str = str.replaceAll(
|
||||
'brown',
|
||||
'<span style="font-weight: bold; border: 1px solid black; padding: 0 12px; font-size: 12px; background-color: brown; color: brown;"></span>'
|
||||
);
|
||||
str = str.replaceAll(
|
||||
'darkslategray',
|
||||
'<span style="font-weight: bold; border: 1px solid black; padding: 0 12px; font-size: 12px; background-color: darkslategray; color: darkslategray;"></span>'
|
||||
);
|
||||
str = str.replaceAll(
|
||||
'orange',
|
||||
'<span style="font-weight: bold; border: 1px solid black; padding: 0 12px; font-size: 12px; background-color: orange; color: orange;"></span>'
|
||||
);
|
||||
str = str.replaceAll(
|
||||
'tan',
|
||||
'<span style="font-weight: bold; border: 1px solid black; padding: 0 12px; font-size: 12px; background-color: tan; color: tan;"></span>'
|
||||
);
|
||||
str = str.replaceAll(
|
||||
'white',
|
||||
'<span style="font-weight: bold; border: 1px solid black; padding: 0 12px; font-size: 12px; background-color: white; color: white;"></span>'
|
||||
);
|
||||
str = str.replace(/brown|darkslategray|orange|tan|white/g, (color: string) => this.colorBadge(color));
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.game.color-blind .player-board-marker {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font: bold 11px Arial, sans-serif;
|
||||
color: #172d34;
|
||||
background: white;
|
||||
border: 1px solid #172d34;
|
||||
}
|
||||
|
||||
.game {
|
||||
background-color: #dce9e6;
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
font-weight="600"
|
||||
fill="black"
|
||||
:text-decoration="isCurrentPlayer ? 'underline' : ''"
|
||||
>{{ getPlayerName() }}</text
|
||||
>{{ preferences.colorBlind ? owner + 1 + '. ' : '' }}{{ getPlayerName() }}</text
|
||||
>
|
||||
|
||||
<rect width="250" height="180" x="0" y="20" fill="#e2e0d3" stroke="#899997" />
|
||||
|
|
@ -196,8 +196,9 @@
|
|||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import type { Preferences } from '../types/ui-data';
|
||||
import { Player } from 'container-engine';
|
||||
import { Vue, Component, Prop } from 'vue-property-decorator';
|
||||
import { Vue, Component, Prop, InjectReactive } from 'vue-property-decorator';
|
||||
import DropZone from './DropZone.vue';
|
||||
|
||||
@Component({
|
||||
|
|
@ -206,6 +207,7 @@ import DropZone from './DropZone.vue';
|
|||
},
|
||||
})
|
||||
export default class PlayerBoard extends Vue {
|
||||
@InjectReactive() readonly preferences!: Preferences;
|
||||
@Prop({ default: false })
|
||||
openMoney!: boolean;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@
|
|||
stroke="black"
|
||||
/>
|
||||
<text x="70" y="140" text-anchor="middle">2</text>
|
||||
<ColorMark
|
||||
v-for="(entry, i) in pointCard.containerValues"
|
||||
:key="entry.containerColor"
|
||||
:color="entry.containerColor"
|
||||
:transform="`translate(30 ${20 + 30 * i}) scale(.8)`"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</template>
|
||||
|
|
@ -57,7 +63,8 @@
|
|||
import { Vue, Component, Prop } from 'vue-property-decorator';
|
||||
import type { PointCard as PointCardInfo } from 'container-engine';
|
||||
|
||||
@Component
|
||||
import ColorMark from './ColorMark.vue';
|
||||
@Component({ components: { ColorMark } })
|
||||
export default class PointCard extends Vue {
|
||||
@Prop()
|
||||
pointCard?: PointCardInfo;
|
||||
|
|
|
|||
25
viewer/src/components/buttons/ColorBlindButton.vue
Normal file
25
viewer/src/components/buttons/ColorBlindButton.vue
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<template>
|
||||
<g
|
||||
class="button enabled color-blind-toggle"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Color-blind mode"
|
||||
:aria-pressed="isOn ? 'true' : 'false'"
|
||||
@click="$emit('click')"
|
||||
@keydown.enter.prevent="$emit('click')"
|
||||
@keydown.space.prevent="$emit('click')"
|
||||
>
|
||||
<circle cx="15" cy="15" r="15" :fill="isOn ? '#eaf4cf' : 'gainsboro'" stroke="#203a45" stroke-width="2" />
|
||||
<path d="M4 15Q15 2 26 15Q15 28 4 15Z" fill="none" stroke="#203a45" stroke-width="1.7" />
|
||||
<circle cx="15" cy="15" r="4.5" fill="none" stroke="#203a45" stroke-width="1.7" />
|
||||
<path d="M15 10.5V19.5A4.5 4.5 0 0 1 15 10.5" fill="#203a45" />
|
||||
<title>Color-blind mode</title>
|
||||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop } from 'vue-property-decorator';
|
||||
@Component
|
||||
export default class ColorBlindButton extends Vue {
|
||||
@Prop() isOn?: boolean;
|
||||
}
|
||||
</script>
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
<path d="M4 2V8 M8 2V8 M12 2V8 M16 2V8" stroke="#10252b" stroke-opacity=".3" stroke-width=".7" />
|
||||
<path d="M1 1H19" stroke="white" stroke-opacity=".5" />
|
||||
|
||||
<ColorMark :color="color" transform="translate(10 5) scale(.8)" />
|
||||
<title>Container</title>
|
||||
</g>
|
||||
</template>
|
||||
|
|
@ -15,8 +16,10 @@
|
|||
import { ContainerState, PieceType } from '@/types/ui-data';
|
||||
import { Component, Mixins, Prop } from 'vue-property-decorator';
|
||||
import Piece from './Piece.vue';
|
||||
import ColorMark from '../ColorMark.vue';
|
||||
|
||||
@Component({
|
||||
components: { ColorMark },
|
||||
created(this: Container) {
|
||||
this.pieceType = PieceType.Container;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<path d="M-6 6 V-2 L-1 0 V-4 L4 -1 V-7 H7 V6Z" fill="#172d34" fill-opacity=".85" />
|
||||
<path d="M-4 2 V4 M0 2 V4 M4 2 V4" stroke="#f4eed6" stroke-width="1.3" />
|
||||
|
||||
<ColorMark :color="color" transform="scale(1.25)" />
|
||||
<title>Factory</title>
|
||||
</g>
|
||||
</template>
|
||||
|
|
@ -11,8 +12,10 @@
|
|||
import { PieceType } from '@/types/ui-data';
|
||||
import { Component, Mixins, Prop } from 'vue-property-decorator';
|
||||
import Piece from './Piece.vue';
|
||||
import ColorMark from '../ColorMark.vue';
|
||||
|
||||
@Component({
|
||||
components: { ColorMark },
|
||||
created(this: Factory) {
|
||||
this.pieceType = PieceType.Factory;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,12 +21,18 @@
|
|||
:canDrag="false"
|
||||
:color="container.color"
|
||||
/>
|
||||
<g v-if="preferences.colorBlind" class="player-number" pointer-events="none">
|
||||
<circle cx="15" cy="8" r="5.5" fill="white" stroke="#203a45" />
|
||||
<text x="15" y="8" text-anchor="middle" fill="#172d34" font-size="9" font-weight="bold">{{
|
||||
owner + 1
|
||||
}}</text>
|
||||
</g>
|
||||
<DropZone :width="30" :height="80" :enabled="player == owner" :accepts="'container'" :data="{ type: 'ship' }" />
|
||||
<title>{{ ownerName }}'s Ship</title>
|
||||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { PieceType } from '@/types/ui-data';
|
||||
import { Preferences, PieceType } from '@/types/ui-data';
|
||||
import { ContainerPiece, ShipPosition } from 'container-engine/src/gamestate';
|
||||
import { Component, InjectReactive, Mixins, Prop } from 'vue-property-decorator';
|
||||
import Piece from './Piece.vue';
|
||||
|
|
@ -43,6 +49,7 @@ import DropZone from '../DropZone.vue';
|
|||
},
|
||||
})
|
||||
export default class Ship extends Mixins(Piece) {
|
||||
@InjectReactive() readonly preferences!: Preferences;
|
||||
@InjectReactive()
|
||||
readonly player!: number;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
function pieceIcon(kind: string, color = ''): string {
|
||||
import { colorMarkSvg } from './color-blind';
|
||||
function pieceIcon(kind: string, color = '', colorBlind = false): string {
|
||||
const label = `${color === 'darkslategray' ? 'dark green' : color} ${kind}`.trim();
|
||||
const shape =
|
||||
kind === 'factory'
|
||||
|
|
@ -6,10 +7,12 @@ function pieceIcon(kind: string, color = ''): string {
|
|||
: kind === 'container'
|
||||
? `<g transform="translate(1 6)"><rect width="20" height="10" rx=".8" fill="${color}" stroke="#21343b"/><path d="M4 2V8 M8 2V8 M12 2V8 M16 2V8" stroke="#10252b" stroke-opacity=".3" stroke-width=".7"/><path d="M1 1H19" stroke="white" stroke-opacity=".5"/></g>`
|
||||
: '<g transform="translate(1 1) scale(.66)"><path d="M15 0 L30 10 L30 30 L0 30 L0 10Z" fill="#789298" stroke="#233b43"/><path d="M0 10 L15 0 L30 10" fill="none" stroke="#344a51" stroke-width="2"/><path d="M7 30V14 H23V30" fill="#dae2da" stroke="#425c65"/><path d="M8 18H22 M8 22H22 M8 26H22" stroke="#6c8285"/></g>';
|
||||
return `<span title="${label}" style="display:inline-block;vertical-align:middle;line-height:0"><svg role="img" aria-label="${label}" width="26" height="26" viewBox="0 0 22 22"><title>${label}</title>${shape}</svg></span>`;
|
||||
return `<span title="${label}" style="display:inline-block;vertical-align:middle;line-height:0"><svg role="img" aria-label="${label}" width="26" height="26" viewBox="0 0 22 22"><title>${label}</title>${shape}${
|
||||
colorBlind && color ? `<g transform="translate(6 6)">${colorMarkSvg(color)}</g>` : ''
|
||||
}</svg></span>`;
|
||||
}
|
||||
|
||||
export function journalPieces(html: string): string {
|
||||
export function journalPieces(html: string, colorBlind = false): string {
|
||||
const root = document.createElement('div');
|
||||
root.innerHTML = html;
|
||||
for (const badge of Array.from(root.querySelectorAll('span'))) {
|
||||
|
|
@ -35,7 +38,7 @@ export function journalPieces(html: string): string {
|
|||
if (before?.nodeType === Node.TEXT_NODE) {
|
||||
before.textContent = before.textContent!.replace(/\ba $/, '');
|
||||
}
|
||||
badge.outerHTML = pieceIcon(kind, color);
|
||||
badge.outerHTML = pieceIcon(kind, color, colorBlind);
|
||||
}
|
||||
for (const node of Array.from(root.childNodes)) {
|
||||
if (node.nodeType !== Node.TEXT_NODE || !node.textContent?.includes('a warehouse')) continue;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ function launch(selector: string) {
|
|||
// toggles, platform preference pushes) would only paint on the next re-render.
|
||||
preferences: Vue.observable({
|
||||
sound: true,
|
||||
colorBlind: false,
|
||||
disableHelp: false,
|
||||
}),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Penge: ${p0}"
|
||||
"Money: ${p0}": "Penge: ${p0}",
|
||||
"Color-blind mode": "Farveblind-tilstand"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Geld: ${p0}"
|
||||
"Money: ${p0}": "Geld: ${p0}",
|
||||
"Color-blind mode": "Farbenblindmodus"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Χρήματα: ${p0}"
|
||||
"Money: ${p0}": "Χρήματα: ${p0}",
|
||||
"Color-blind mode": "Λειτουργία για αχρωματοψία"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Money: ${p0}"
|
||||
"Money: ${p0}": "Money: ${p0}",
|
||||
"Color-blind mode": "Color-blind mode"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Argent : ${p0}"
|
||||
"Money: ${p0}": "Argent : ${p0}",
|
||||
"Color-blind mode": "Mode daltonien"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "पैसा: ${p0}"
|
||||
"Money: ${p0}": "पैसा: ${p0}",
|
||||
"Color-blind mode": "रंग-अंधता मोड"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Denaro: ${p0}"
|
||||
"Money: ${p0}": "Denaro: ${p0}",
|
||||
"Color-blind mode": "Modalità daltonici"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "돈: ${p0}"
|
||||
"Money: ${p0}": "돈: ${p0}",
|
||||
"Color-blind mode": "색각 이상 모드"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Geld: ${p0}"
|
||||
"Money: ${p0}": "Geld: ${p0}",
|
||||
"Color-blind mode": "Kleurenblinde modus"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Pieniądze: ${p0}"
|
||||
"Money: ${p0}": "Pieniądze: ${p0}",
|
||||
"Color-blind mode": "Tryb dla daltonistów"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Dinheiro: ${p0}"
|
||||
"Money: ${p0}": "Dinheiro: ${p0}",
|
||||
"Color-blind mode": "Modo daltônico"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Bani: ${p0}"
|
||||
"Money: ${p0}": "Bani: ${p0}",
|
||||
"Color-blind mode": "Mod pentru daltoniști"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Деньги: ${p0}"
|
||||
"Money: ${p0}": "Деньги: ${p0}",
|
||||
"Color-blind mode": "Режим для дальтоников"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "Tiền: ${p0}"
|
||||
"Money: ${p0}": "Tiền: ${p0}",
|
||||
"Color-blind mode": "Chế độ mù màu"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,5 +617,6 @@
|
|||
"translate(140, {p0})": "translate(140, {p0})",
|
||||
"translate(280, 425)": "translate(280, 425)",
|
||||
"translate(770, 425)": "translate(770, 425)",
|
||||
"Money: ${p0}": "金錢:${p0}"
|
||||
"Money: ${p0}": "金錢:${p0}",
|
||||
"Color-blind mode": "色盲模式"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { GameState, Move, stripSecret } from 'container-engine';
|
|||
import { Phase } from 'container-engine/src/gamestate';
|
||||
import { EventEmitter } from 'events';
|
||||
import Vue from 'vue';
|
||||
import { colorMarkSvg } from '../color-blind';
|
||||
import Game from '../components/Game.vue';
|
||||
import { colorName, colors, lessons, LessonState, TutorialAction } from './lessons';
|
||||
import './tutorial.css';
|
||||
|
|
@ -36,7 +37,7 @@ export const mountTutorial: TutorialMount = async (target, { chapter, onProgress
|
|||
state: null as GameState | null,
|
||||
player: 0,
|
||||
emitter,
|
||||
preferences: Vue.observable({ sound: false, disableHelp: false }),
|
||||
preferences: Vue.observable({ sound: false, colorBlind: false, disableHelp: false }),
|
||||
interactionDisabled: false,
|
||||
tutorialMove: (move: Move) => {
|
||||
void play({ kind: 'move', move });
|
||||
|
|
@ -95,9 +96,13 @@ export const mountTutorial: TutorialMount = async (target, { chapter, onProgress
|
|||
animate = false;
|
||||
}
|
||||
}
|
||||
emitter.on('update:preference', ({ name }) => {
|
||||
if (name === 'colorBlind' && latest) renderSummary(latest);
|
||||
});
|
||||
function swatch(color: string) {
|
||||
const chip = element('span', 'tutorial-container');
|
||||
chip.style.backgroundColor = color;
|
||||
if (params.preferences.colorBlind) chip.innerHTML = colorMarkSvg(color);
|
||||
chip.setAttribute('aria-hidden', 'true');
|
||||
return chip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export interface UIData {
|
|||
export type Preferences = {
|
||||
analysis?: boolean;
|
||||
sound: boolean;
|
||||
colorBlind?: boolean;
|
||||
disableHelp: boolean;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue