Release viewer 2.3.23 with text actions and consistent board controls

This commit is contained in:
coyotte508 2026-11-02 21:04:17 +00:00
commit ddfae0915f
33 changed files with 591 additions and 45 deletions

View file

@ -0,0 +1,52 @@
{
"game": "powergrid",
"gameVersion": 13,
"publishedAt": "2026-11-02T21:04:06.134Z",
"viewer": {
"version": "2.3.23",
"url": "https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-fdd1a2db7176e23c0b50/powergrid-viewer.umd.min.js",
"stylesheets": [
"https://s3.fr-par.scw.cloud/bgs-assets/games/powergrid/13/viewer/split-fdd1a2db7176e23c0b50/powergrid-viewer.css"
],
"scriptBytes": 1226805,
"sha256": "ddd2b31175fc8d71617bd289323590424355f9537eaad31043e3c10016f791fb",
"bundle": "split-fdd1a2db7176e23c0b50",
"files": 42
},
"addedPreferences": ["textActions"],
"preferences": [
{
"label": "Enable sound when players move",
"type": "checkbox",
"name": "sound",
"items": null,
"default": false
},
{
"name": "showUnselectedRegions",
"label": "Show unselected regions",
"type": "checkbox",
"default": true
},
{
"label": "Adjust player order",
"type": "checkbox",
"name": "adjustPlayerOrder",
"items": null,
"default": false
},
{
"name": "colorBlind",
"label": "Color-blind mode",
"type": "checkbox",
"default": false
},
{
"name": "textActions",
"label": "Show action labels",
"type": "checkbox",
"default": false
}
],
"verified": true
}

View file

@ -46,3 +46,19 @@ It uses the public deck count and remains stable during resource purchases and u
After packaging, run `node viewer/scripts/action-controls-smoke.mjs` to check
normal/only-pass states, hover/focus styling against the board-option buttons,
resource/building/powering transitions, and plant borders.
## Viewer 2.3.23: action labels
The Aa toggle switches the phase and Undo buttons between pictograms and full,
translated text. Both modes reserve identical bounds, and disabled pictograms
fade like disabled text. The utility buttons share a light surface and an active
marker; the duplicate board sound button is removed (sound remains in the sidebar).
This release adds
`{ "name": "textActions", "label": "Show action labels", "type": "checkbox", "default": false }`
to the BGS version 13 preferences, preserving every other preference. BGS only
persists declared preference names, so this addition must accompany the release.
After packaging, `node viewer/scripts/action-labels-smoke.mjs` checks the two
presentations, keyboard toggling, translated text fitting in all 17 languages,
mobile/desktop geometry, saved-move undo and text-mode local undo.

View file

@ -1,6 +1,6 @@
{
"name": "powergrid-viewer",
"version": "2.3.22",
"version": "2.3.23",
"repository": {
"type": "git",
"url": "git+https://github.com/boardgamers/powergrid.git",

View file

@ -91,6 +91,38 @@ try {
await page.close();
console.log(`${mode}: hover matches board options; focus and market cues passed`);
}
{
const page = await browser.newPage();
await page.goto(`http://127.0.0.1:${server.address().port}/?mode=public&text=1`);
const pass = page.locator('[data-board-control="pass"]');
const undo = page.locator('[data-board-control="undo"]');
await pass.locator('[data-action-label]').waitFor();
assert.equal(await pass.getAttribute('aria-disabled'), 'true');
assert.equal(await undo.getAttribute('aria-disabled'), 'true');
const fadedText = await pass.locator('[data-action-label]').evaluate((e) => getComputedStyle(e).fill);
assert.equal(fadedText, 'rgb(192, 192, 192)');
await page.locator('[data-board-control="text-actions"]').click();
await pass.locator('[data-phase-icon]').waitFor();
const checkDisabled = async () => {
for (const selector of ['[data-phase-icon]', '[data-action-icon]', '.button-divider']) {
assert.equal(await pass.locator(selector).evaluate((e) => getComputedStyle(e).stroke), fadedText);
}
assert.equal(
await pass.locator('.phase-background').evaluate((e) => getComputedStyle(e).fill),
'rgb(220, 220, 220)'
);
assert.equal(await pass.locator('.button-outline').evaluate((e) => getComputedStyle(e).strokeWidth), '1px');
assert.equal(
await undo.locator('[data-action-icon]').evaluate((e) => getComputedStyle(e).filter),
'invert(0.75)'
);
};
await checkDisabled();
await pass.hover();
await checkDisabled();
await page.close();
console.log('Disabled controls: pictograms and divider match faded text, including on hover');
}
const page = await browser.newPage();
await page.goto(`http://127.0.0.1:${server.address().port}/?mode=resources`);
const phaseButton = page.locator('[data-board-control="pass"]');

View file

@ -0,0 +1,162 @@
// Run after packaging: node viewer/scripts/action-labels-smoke.mjs
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { chromium } from 'playwright';
import { auctionPreviewServer } from './auction-preview.mjs';
const server = auctionPreviewServer();
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const origin = `http://127.0.0.1:${server.address().port}`;
const locales = [
'en',
'de',
'fr',
'pl',
'ro',
'el',
'hi',
'ru',
'da',
'pt-BR',
'ko',
'zh-TW',
'zh-CN',
'vi',
'it',
'nl',
'fa',
];
const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_EXECUTABLE });
const errors = [];
async function fits(page) {
await page.waitForFunction(() =>
[...document.querySelectorAll('[data-action-label]')].every((label) => {
const border = label.parentElement.querySelector('.turn-action-border');
const b = label.getBBox();
return (
b.x >= 7 &&
b.x + b.width <= Number(border.getAttribute('width')) - 7 &&
b.y >= 1 &&
b.y + b.height <= Number(border.getAttribute('height')) - 1
);
})
);
const sizes = await page
.locator('[data-action-label]')
.evaluateAll((labels) => labels.map((label) => Number(label.getAttribute('font-size'))));
assert(
sizes.every((size) => size >= 10),
`complete labels remain readable: ${sizes}`
);
}
try {
for (const width of [390, 1400]) {
const page = await browser.newPage({ viewport: { width, height: 900 } });
page.on('pageerror', (error) => errors.push(error.message));
await page.goto(`${origin}/?mode=your-turn`);
const toggle = page.locator('[data-board-control="text-actions"]');
await toggle.waitFor();
await page.evaluate(() => {
window.beforeTextMode = JSON.stringify(document.querySelector('.game').__vue__.G);
window.textModeMoves = [];
window.host.on('move', (move) => window.textModeMoves.push(move));
});
const geometry = await page.locator('[data-board-control="pass"]').boundingBox();
await toggle.focus();
await page.keyboard.press('Enter');
await page.waitForFunction(() => document.querySelector('[data-action-label]'));
assert.equal(await toggle.getAttribute('aria-pressed'), 'true');
assert.equal(await page.locator('[data-phase-icon]').count(), 0);
assert.equal(
await page.locator('[data-board-control="pass"] [data-action-label]').textContent(),
'Skip auction'
);
await fits(page);
// All language changes happen through the host, including back to English.
for (const locale of [...locales, 'en']) {
const catalog = JSON.parse(await readFile(new URL(`../src/localization/${locale}.json`, import.meta.url)));
await page.evaluate((locale) => window.host.emit('preferences', { locale }), locale);
await page.waitForFunction(
(expected) =>
document.querySelector('[data-board-control="pass"] [data-action-label]').textContent === expected,
catalog['Skip auction']
);
await page.waitForFunction(
(expected) =>
document.querySelector('[data-board-control="undo"] [data-action-label]').textContent === expected,
catalog['Undo last move']
);
await fits(page);
}
// The enabled map toggle uses the same light surface treatment and dark pictogram.
const map = page.locator('[data-board-control="unselected-regions"]');
await map.hover();
assert.equal(
await map.locator('.option-background').evaluate((e) => getComputedStyle(e).fill),
'rgb(192, 192, 192)'
);
assert.equal(
await map
.locator(':scope > g')
.first()
.evaluate((e) => getComputedStyle(e).stroke),
'rgb(0, 0, 0)'
);
await toggle.focus();
await page.keyboard.press('Space');
await page.waitForFunction(() => !document.querySelector('[data-action-label]'));
assert.equal(await toggle.getAttribute('aria-pressed'), 'false');
const after = await page.locator('[data-board-control="pass"]').boundingBox();
for (const key of ['x', 'y', 'width', 'height'])
assert(Math.abs(geometry[key] - after[key]) < 1, `stable ${key}`);
assert(
await page.evaluate(
() => window.beforeTextMode === JSON.stringify(document.querySelector('.game').__vue__.G)
)
);
assert.deepEqual(await page.evaluate(() => window.textModeMoves), []);
// Host pushes also select presentation, independent of clicking the toolbar.
await page.evaluate(() => window.host.emit('preferences', { textActions: true }));
await page.locator('[data-action-label]').first().waitFor();
await page.evaluate(() => window.host.emit('undo:available', true));
await page.locator('[data-board-control="undo-move"] [data-action-label]').waitFor();
assert.equal(
await page.locator('[data-board-control="undo-move"] [data-action-label]').textContent(),
'Undo my move'
);
await fits(page);
await page.close();
console.log(
`${width}px: Text/Icons, keyboard, host preference, saved-move undo, map hover and all 17 languages passed`
);
}
for (const [mode, move, label] of [
['resources', 'BuyResource', 'Finish buying'],
['building', 'Build', 'Finish building'],
['powering', 'UsePowerPlant', 'Finish powering'],
]) {
const page = await browser.newPage();
page.on('pageerror', (error) => errors.push(error.message));
await page.goto(`${origin}/?mode=${mode}&text=1`);
const actionLabel = page.locator('[data-board-control="pass"] [data-action-label]');
await actionLabel.waitFor();
assert.equal(await actionLabel.textContent(), label);
const echo = page.waitForResponse((r) => r.url().includes('/move?'));
await page.evaluate((move) => {
const game = document.querySelector('.game').__vue__;
game.sendMove({ name: move, data: game.G.players[0].availableMoves[move][0] });
}, move);
await echo;
await page.locator('[data-board-control="undo"].enabled').waitFor();
await page.locator('[data-board-control="undo"]').click();
await page.locator('[data-board-control="undo"][aria-disabled="true"]').waitFor();
assert.equal(await actionLabel.textContent(), label);
await fits(page);
await page.close();
console.log(`${mode}: full action wording and working text-mode Undo passed`);
}
assert.deepEqual(errors, []);
} finally {
await browser.close();
await new Promise((resolve) => server.close(resolve));
}

View file

@ -63,10 +63,11 @@ document.querySelector('#mode').value=mode;
if(mode==='only-pass')document.querySelector('.hint').textContent='You have 1. No plant is affordable, so passing is the only legal action.';
if(mode==='building')document.querySelector('.hint').textContent='Build a city to change skip to confirm. Undo all builds to restore skip.';
if(mode==='powering')document.querySelector('.hint').textContent='Activate your oil plant to change skip to confirm. Hover its border to see the white highlight.';
document.querySelector('#mode').onchange=e=>location.search='?mode='+e.target.value;
document.querySelector('#mode').onchange=e=>{query.set('mode',e.target.value);location.search='?'+query;};
async function send(path,body){const response=await fetch(path+'?mode='+mode,{method:body?'POST':'GET',headers:{'Content-Type':'application/json'},body:body?JSON.stringify(body):undefined});const data=await response.json();document.querySelector('#error').textContent=data.error||'';if(data.error)return;host.emit('settings',data.settings);host.emit('state',data.state);const button=document.querySelector('#opponent');button.textContent=data.next;button.disabled=!data.opponent;}
host.on('fetchState',()=>send('/state'));host.on('move',move=>send('/move',{move}));host.on('update:setting',setting=>send('/setting',setting));
host.emit('player',{index:0});host.emit('preferences',{sound:false,fitToScreen:true,locale:query.get('locale')||'en'});host.emit('chat:state',{canSend:false,mentions:[]});
host.on('update:preference',({name,value})=>{if(name==='textActions'){query.set('text',value?'1':'0');history.replaceState(null,'','?'+query);}});
host.emit('player',{index:0});host.emit('preferences',{sound:false,textActions:query.get('text')==='1',locale:query.get('locale')||'en'});host.emit('chat:state',{canSend:false,mentions:[]});
document.querySelector('#opponent').onclick=()=>send('/opponent',{});document.querySelector('#reset').onclick=()=>send('/reset',{});send('/state');
</script></body></html>`;
export function auctionPreviewServer() {

View file

@ -485,6 +485,9 @@
:enabled="canUsePhaseButton"
:highlightButton="highlightPhaseButton"
:text="phaseButtonText"
:showText="!!preferences.textActions"
:width="168"
:height="32"
:icon="phaseButtonIcon"
:action="phaseButtonAction"
@click="usePhaseButton"
@ -498,6 +501,9 @@
transform="translate(15, 56)"
control="undo-move"
text="Undo my move"
:showText="!!preferences.textActions"
:width="168"
:height="32"
:enabled="true"
:highlightButton="true"
@click="undoMove()"
@ -510,10 +516,25 @@
:highlightButton="changingBid || canUndo()"
:icon="changingBid ? 'cancel' : 'undo'"
:text="changingBid ? 'Cancel bid edit' : 'Undo last move'"
:showText="!!preferences.textActions"
:width="168"
:height="32"
@click="useUndoButton()"
/>
<BoardOption
transform="translate(15, 97)"
:width="30"
:height="32"
control="text-actions"
icon="text"
label="Show action labels"
:active="!!preferences.textActions"
@click="toggleTextActions()"
/>
<BoardOption
transform="translate(49.5, 97)"
:width="30"
:height="32"
control="color-blind"
icon="shapes"
label="Color-blind mode"
@ -522,7 +543,9 @@
/>
<BoardOption
v-if="roundPlan || canPlanRound"
transform="translate(59, 97)"
transform="translate(84, 97)"
:width="30"
:height="32"
control="plan"
:icon="roundPlan ? 'return' : 'plan'"
:label="
@ -542,17 +565,27 @@
: startPlanning()
"
/>
<SoundButton :transform="iconButton(0)" :isOn="preferences.sound" @click="toggleSound()" />
<BoardOption
v-if="hasUnselectedRegions"
:transform="iconButton(1)"
transform="translate(118.5, 97)"
:width="30"
:height="32"
control="unselected-regions"
icon="regions"
label="Show unselected regions"
:active="preferences.showUnselectedRegions !== false"
@click="toggleUnselectedRegions()"
/>
<RulesButton :transform="iconButton(hasUnselectedRegions ? 2 : 1)" @click="rulesVisible = true" />
<BoardOption
transform="translate(153, 97)"
:width="30"
:height="32"
control="rules"
icon="rules"
label="Rules"
:toggle="false"
@click="rulesVisible = true"
/>
</g>
<g
@ -933,7 +966,7 @@ import {
} from '../util/turn-buffer';
import { UIData, Preferences } from '../types/ui-data';
import { Card, House, Coal, Oil, Garbage, Uranium } from './pieces';
import { Button, PassButton, UndoButton, BoardOption, SoundButton, RulesButton } from './buttons';
import { Button, PassButton, UndoButton, BoardOption } from './buttons';
import PlayerBoard from './PlayerBoard.vue';
import Calculator from './Calculator.vue';
import PowerPlantMarket from './boards/PowerPlantMarket.vue';
@ -1104,8 +1137,6 @@ let nextGeographyClipId = 0;
PassButton,
UndoButton,
BoardOption,
SoundButton,
RulesButton,
Button,
Calculator,
RoundPlanner,
@ -2808,11 +2839,10 @@ export default class Game extends Vue {
this.emitter.emit('update:preference', { name: 'colorBlind', value: this.preferences.colorBlind });
}
toggleSound() {
const newSound = !this.preferences.sound;
this.emitter.emit('update:preference', { name: 'sound', value: newSound });
this.preferences.sound = newSound;
toggleTextActions() {
const value = !this.preferences.textActions;
this.$set(this.preferences, 'textActions', value);
this.emitter.emit('update:preference', { name: 'textActions', value });
}
toggleUnselectedRegions() {
@ -3052,12 +3082,6 @@ export default class Game extends Vue {
return this.slotTransforms[name];
}
/** Align portrait icons with the compact action buttons; retain desktop spacing. */
iconButton(index: number): string {
if (!this.portraitViewport) return `translate(110, ${13 + 41 * index})`;
return `translate(110, ${13 + 30 * index}) scale(${round(26 / 30, 4)})`;
}
/**
* Only portrait viewports are re-laid out. A landscape phone already reads
* well (the scene's own aspect ratio is close to the screen's), so leaving
@ -3317,6 +3341,8 @@ export default class Game extends Vue {
get layoutPreferencesKey() {
const preferences = { ...this.preferences };
delete preferences.showUnselectedRegions;
// Both presentations reserve identical button bounds; toggling is purely visual.
delete preferences.textActions;
return JSON.stringify(preferences);
}

View file

@ -0,0 +1,69 @@
<template>
<text
ref="label"
data-action-label
:x="width / 2"
:y="height / 2"
text-anchor="middle"
dominant-baseline="central"
:font-size="fontSize"
fill="black"
aria-hidden="true"
pointer-events="none"
>{{ text }}</text
>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
/** Keep the complete source in one text node for the DOM localization adapter.
* Fit the translated glyphs, never truncate the action or squeeze only its width. */
@Component
export default class ActionLabel extends Vue {
@Prop() text!: string;
@Prop() width!: number;
@Prop() height!: number;
fontSize = 13;
private textObserver: MutationObserver | null = null;
private sizeObserver: ResizeObserver | null = null;
private disposed = false;
@Watch('text')
@Watch('width')
@Watch('height')
fit() {
if (this.disposed) return;
const label = this.$refs.label as SVGTextElement | undefined;
if (!label || typeof label.getComputedTextLength !== 'function') return;
const length = label.getComputedTextLength();
const height = label.getBBox().height;
if (!length || !height) return; // Hidden iframe: ResizeObserver retries on reveal.
const current = Number(label.getAttribute('font-size'));
this.fontSize =
Math.round(
Math.min(13, (current * (this.width - 16)) / length, (current * (this.height - 8)) / height) * 100
) / 100;
}
mounted() {
const label = this.$refs.label as SVGTextElement;
// Locale switches change the actual DOM, without changing the English prop.
if (typeof MutationObserver !== 'undefined') {
this.textObserver = new MutationObserver(() => this.fit());
this.textObserver.observe(label, { childList: true, characterData: true, subtree: true });
}
if (typeof ResizeObserver !== 'undefined') {
this.sizeObserver = new ResizeObserver(() => this.fit());
this.sizeObserver.observe(label);
}
this.$nextTick(this.fit);
document.fonts?.ready.then(() => this.fit());
}
beforeDestroy() {
this.disposed = true;
this.textObserver?.disconnect();
this.sizeObserver?.disconnect();
}
}
</script>

View file

@ -5,14 +5,20 @@
:data-board-control="control"
role="button"
:aria-label="label"
:aria-pressed="active ? 'true' : 'false'"
:aria-pressed="toggle ? (active ? 'true' : 'false') : undefined"
tabindex="0"
@click="$emit('click')"
@keydown.enter.prevent="$emit('click')"
@keydown.space.prevent="$emit('click')"
>
<rect class="option-background board-control-border" width="36" height="26" rx="4" stroke="black" />
<g transform="translate(7, 2)" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true">
<rect class="option-background board-control-border" :width="width" :height="height" rx="4" stroke="black" />
<g
:transform="`translate(${(width - 22) / 2}, ${(height - 22) / 2 - 1})`"
fill="none"
stroke="currentColor"
stroke-width="1.7"
aria-hidden="true"
>
<template v-if="icon === 'shapes'">
<path d="M6 1L11 9H1Z" />
<circle cx="16" cy="6" r="4" />
@ -21,13 +27,40 @@
<template v-else-if="icon === 'regions'">
<path d="M1 5L7 2L15 5L21 2V18L15 21L7 18L1 21ZM7 2V18M15 5V21" />
</template>
<text
v-else-if="icon === 'text'"
x="11"
y="12"
text-anchor="middle"
dominant-baseline="central"
fill="currentColor"
stroke="none"
font-size="14"
font-weight="600"
translate="no"
>Aa</text
>
<path
v-else-if="icon === 'rules'"
d="M3 2H18V20H3Q0 20 0 17V5Q0 2 3 2ZM3 2V16M0 17Q0 15 3 15H18M6 6H14M6 10H14"
/>
<path v-else-if="icon === 'return'" d="M9 5L3 11L9 17M3 11H14Q20 11 20 17" />
<path v-else d="M2 2V20H21M5 15L10 8L15 11L21 3M16 3H21V8" />
</g>
<path
v-if="active"
class="active-marker"
:d="`M${width / 2 - 5} ${height - 2}H${width / 2 + 5}`"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
aria-hidden="true"
pointer-events="none"
/>
<g v-if="badge" aria-hidden="true" pointer-events="none">
<circle cx="32" cy="3" r="7" fill="#203a45" stroke="#fff" />
<circle :cx="width - 4" cy="3" r="7" fill="#203a45" stroke="#fff" />
<text
x="32"
:x="width - 4"
y="3"
fill="white"
text-anchor="middle"
@ -49,6 +82,9 @@ export default class BoardOption extends Vue {
@Prop() label!: string;
@Prop({ default: false }) active!: boolean;
@Prop({ default: 0 }) badge!: number;
@Prop({ default: 36 }) width!: number;
@Prop({ default: 26 }) height!: number;
@Prop({ default: true }) toggle!: boolean;
}
</script>
<style scoped>
@ -62,10 +98,10 @@ export default class BoardOption extends Vue {
fill: gainsboro;
}
.active .option-background {
fill: #203a45;
fill: #c8d6dc;
}
.active {
color: white;
.board-option:hover .option-background {
fill: silver;
}
.board-option:focus {

View file

@ -10,12 +10,20 @@
@keydown.enter.prevent="enabled && $emit('click')"
@keydown.space.prevent="enabled && $emit('click')"
>
<path class="phase-background" d="M4 0H76Q80 0 80 4V22Q80 26 76 26H4Q0 26 0 22V4Q0 0 4 0Z" fill="gainsboro" />
<path class="button-divider" d="M40 0V26" stroke="#88949a" aria-hidden="true" />
<path class="phase-background" :d="backgroundPath" fill="gainsboro" />
<ActionLabel v-if="showText" :text="text" :width="width" :height="height" />
<path
v-if="!showText"
class="button-divider"
:d="`M${width / 2} 0V${height}`"
stroke="#88949a"
aria-hidden="true"
/>
<path
v-if="!showText"
:d="iconPath"
data-phase-icon
transform="translate(12, 5)"
:transform="`translate(${width / 4 - 8}, ${(height - 16) / 2})`"
fill="none"
stroke="black"
stroke-width="1.5"
@ -24,9 +32,10 @@
aria-hidden="true"
/>
<path
v-if="!showText"
:d="actionPath"
data-action-icon
transform="translate(52, 5)"
:transform="`translate(${(3 * width) / 4 - 8}, ${(height - 16) / 2})`"
fill="none"
stroke="black"
stroke-width="1.5"
@ -37,8 +46,8 @@
<!-- Paint the shared outline last so neither half can cover the highlight. -->
<rect
class="button-outline board-control-border turn-action-border"
width="80"
height="26"
:width="width"
:height="height"
fill="none"
stroke="black"
rx="4"
@ -49,14 +58,24 @@
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import ActionLabel from './ActionLabel.vue';
@Component
@Component({ components: { ActionLabel } })
export default class PassButton extends Vue {
@Prop() enabled!: boolean;
@Prop() highlightButton!: boolean;
@Prop() text!: string;
@Prop({ default: 'done' }) icon!: string;
@Prop({ default: 'finish' }) action!: string;
@Prop({ default: false }) showText!: boolean;
@Prop({ default: 80 }) width!: number;
@Prop({ default: 26 }) height!: number;
get backgroundPath(): string {
const w = this.width,
h = this.height;
return `M4 0H${w - 4}Q${w} 0 ${w} 4V${h - 4}Q${w} ${h} ${w - 4} ${h}H4Q0 ${h} 0 ${h - 4}V4Q0 0 4 0Z`;
}
get actionPath(): string {
const paths: Record<string, string> = {

View file

@ -12,16 +12,18 @@
>
<rect
class="undo-background board-control-border turn-action-border"
width="80"
height="26"
:width="width"
:height="height"
fill="gainsboro"
stroke="black"
rx="4"
/>
<ActionLabel v-if="showText" :text="text" :width="width" :height="height" />
<image
v-if="icon === 'undo'"
x="30"
y="3"
v-else-if="icon === 'undo'"
data-action-icon
:x="width / 2 - 10"
:y="height / 2 - 10"
width="20"
height="20"
href="../../icons/undo.svg"
@ -29,7 +31,9 @@
/>
<path
v-else
d="M33 6L47 20 M47 6L33 20"
data-action-icon
d="M-7 -7L7 7 M7 -7L-7 7"
:transform="`translate(${width / 2}, ${height / 2})`"
stroke="black"
stroke-width="2"
stroke-linecap="round"
@ -40,13 +44,17 @@
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import ActionLabel from './ActionLabel.vue';
@Component
@Component({ components: { ActionLabel } })
export default class UndoButton extends Vue {
@Prop({ default: 'Undo last move' }) text!: string;
@Prop() enabled!: boolean;
@Prop() highlightButton!: boolean;
@Prop({ default: 'undo' }) control!: string;
@Prop({ default: 'undo' }) icon!: 'undo' | 'cancel';
@Prop({ default: false }) showText!: boolean;
@Prop({ default: 80 }) width!: number;
@Prop({ default: 26 }) height!: number;
}
</script>

View file

@ -1,5 +1,11 @@
/* Shared border treatment for phase actions, Undo and board-option controls.
Backgrounds/icons remain owned by their components. */
/* Shared border treatment for phase actions, Undo and board-option controls. */
/* Outlined pictograms need the same disabled silver as text and borders.
Undo's image already uses the global disabled-image filter. */
.button:not(.enabled) [data-phase-icon],
.button:not(.enabled) path[data-action-icon],
.button:not(.enabled) .button-divider {
stroke: silver;
}
.button .board-control-border {
stroke-width: 1px;
}

View file

@ -45,6 +45,7 @@ function launch(selector: string) {
preferredPlayerColors: undefined as (string | null)[] | undefined,
sound: true,
colorBlind: false,
textActions: false,
showUnselectedRegions: true,
adjustPlayerOrder: false,

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Pengene er offentlige: Spillere passer automatisk i auktioner, de ikke har råd til.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Passer automatisk i auktioner, du ikke har råd til. Med skjulte penge kan det afsløre, at du ikke har råd til buddet. Gælder efter næste træk.",
"Show unselected regions": "Vis ikke-valgte regioner",
"Show action labels": "Vis handlingsnavne",
"Color-blind mode": "Farveblind-tilstand",
"\" not found for variant \"": "\" ikke fundet for variant \"",
"#scene g.button": "#scene g.knap",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Das Geld ist öffentlich: Spieler passen automatisch bei Auktionen, die sie sich nicht leisten können.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Automatisch bei Auktionen passen, die du dir nicht leisten kannst. Bei verdecktem Geld kann dies verraten, dass du dir das Gebot nicht leisten kannst. Gilt nach dem nächsten Zug.",
"Show unselected regions": "Nicht ausgewählte Regionen anzeigen",
"Show action labels": "Aktionsbeschriftungen anzeigen",
"Color-blind mode": "Modus für Farbenblindheit",
"\" not found for variant \"": "„ nicht gefunden für Variante „",
"#scene g.button": "#szene g.knopf",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Τα χρήματα είναι φανερά: Οι παίκτες κάνουν αυτόματα πάσο όταν δεν μπορούν να πληρώσουν την προσφορά.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Αυτόματο πάσο σε δημοπρασίες που δεν μπορείς να πληρώσεις. Με κρυφά χρήματα, αυτό μπορεί να αποκαλύψει ότι δεν έχεις αρκετά για την προσφορά. Ισχύει μετά την επόμενη κίνηση.",
"Show unselected regions": "Εμφάνιση μη επιλεγμένων περιοχών",
"Show action labels": "Εμφάνιση ετικετών ενεργειών",
"Color-blind mode": "Λειτουργία για αχρωματοψία",
"\" not found for variant \"": "\" δεν βρέθηκε για την παραλλαγή \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Money is public: players automatically pass auctions they cannot afford.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.",
"Show unselected regions": "Show unselected regions",
"Show action labels": "Show action labels",
"Color-blind mode": "Color-blind mode",
"\" not found for variant \"": "\" not found for variant \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "پول‌ها آشکارند: بازیکنان در مزایده‌هایی که پول کافی ندارند، خودکار پاس می‌دهند.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "در مزایده‌هایی که پول کافی نداری، خودکار پاس بده. با پول مخفی، این کار ممکن است نشان دهد که توان پرداخت پیشنهاد را نداری. پس از حرکت بعدی اعمال می‌شود.",
"Show unselected regions": "نمایش مناطق انتخاب‌نشده",
"Show action labels": "نمایش برچسب‌های عملکرد",
"Color-blind mode": "حالت کوررنگی",
"\" not found for variant \"": "» برای نسخهٔ « پیدا نشد",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "L’argent est visible : les joueurs passent automatiquement les enchères qu’ils ne peuvent pas payer.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Passer automatiquement les enchères que vous ne pouvez pas payer. Avec l’argent caché, cela peut révéler que vos fonds sont insuffisants. S’applique après le prochain coup.",
"Show unselected regions": "Afficher les régions non sélectionnées",
"Show action labels": "Afficher les libellés des actions",
"Color-blind mode": "Mode daltonien",
"\" not found for variant \"": "\" introuvable pour la variante \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "पैसा खुला है: खिलाड़ी उन नीलामियों में अपने-आप पास करते हैं जिनकी बोली वे नहीं चुका सकते।",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "जिन नीलामियों की बोली आप नहीं चुका सकते, उनमें अपने-आप पास करें। पैसा छिपा होने पर इससे पता चल सकता है कि आपके पास बोली के लिए पर्याप्त पैसे नहीं हैं। अगली चाल के बाद लागू होगा।",
"Show unselected regions": "न चुने गए क्षेत्र दिखाएँ",
"Show action labels": "कार्रवाई के लेबल दिखाएँ",
"Color-blind mode": "रंग-अंधता मोड",
"\" not found for variant \"": "\" वैरिएंट के लिए नहीं मिला \"",
"#scene g.button": "#दृश्य g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Il denaro è pubblico: i giocatori passano automaticamente nelle aste che non possono permettersi.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Passa automaticamente nelle aste che non puoi permetterti. Con denaro nascosto, questo può rivelare che non puoi permetterti l’offerta. Si applica dopo la prossima mossa.",
"Show unselected regions": "Mostra le regioni non selezionate",
"Show action labels": "Mostra le etichette delle azioni",
"Color-blind mode": "Modalità daltonici",
"\" not found for variant \"": "\" non trovato per la variante \"",
"#scene g.button": "#scena g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "자금이 공개되어 있습니다. 입찰할 돈이 부족한 플레이어는 자동으로 패스합니다.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "입찰할 돈이 부족하면 자동으로 패스합니다. 자금이 비공개일 때는 입찰 금액을 감당할 수 없다는 사실이 드러날 수 있습니다. 다음 행동 이후 적용됩니다.",
"Show unselected regions": "선택하지 않은 지역 표시",
"Show action labels": "행동 이름 표시",
"Color-blind mode": "색각 이상 모드",
"\" not found for variant \"": "\" 변형에 대해 찾을 수 없음 \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Geld is openbaar: spelers passen automatisch bij veilingen die ze niet kunnen betalen.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Pas automatisch bij veilingen die je niet kunt betalen. Bij verborgen geld kan dit onthullen dat je het bod niet kunt betalen. Geldt na de volgende zet.",
"Show unselected regions": "Niet-geselecteerde regio’s tonen",
"Show action labels": "Actielabels tonen",
"Color-blind mode": "Modus voor kleurenblindheid",
"\" not found for variant \"": "\" niet gevonden voor variant \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Pieniądze są jawne: gracze automatycznie pasują w aukcjach, na które ich nie stać.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Automatycznie pasuj w aukcjach, na które Cię nie stać. Przy ukrytych pieniądzach może to ujawnić, że nie stać Cię na ofertę. Działa po następnym ruchu.",
"Show unselected regions": "Pokaż niewybrane regiony",
"Show action labels": "Pokaż etykiety akcji",
"Color-blind mode": "Tryb dla daltonistów",
"\" not found for variant \"": "\" nie znaleziono dla wariantu \"",
"#scene g.button": "#scena g.przycisk",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "O dinheiro é público: jogadores passam automaticamente em leilões que não podem pagar.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Passe automaticamente em leilões que você não pode pagar. Com dinheiro oculto, isso pode revelar que você não pode pagar o lance. Vale após a próxima jogada.",
"Show unselected regions": "Mostrar regiões não selecionadas",
"Show action labels": "Mostrar rótulos das ações",
"Color-blind mode": "Modo daltônico",
"\" not found for variant \"": "\" não encontrado para a variante \"",
"#scene g.button": "#cena g.botão",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Banii sunt publici: jucătorii spun automat pas la licitațiile pe care nu și le permit.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Spune automat pas la licitațiile pe care nu ți le permiți. Cu bani ascunși, asta poate dezvălui că nu îți permiți oferta. Se aplică după următoarea mutare.",
"Show unselected regions": "Arată regiunile neselectate",
"Show action labels": "Arată etichetele acțiunilor",
"Color-blind mode": "Mod pentru daltoniști",
"\" not found for variant \"": "\" nu a fost găsit pentru varianta \"",
"#scene g.button": "#scena g.buton",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Деньги открыты: игроки автоматически пасуют на аукционах, если не могут оплатить ставку.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Автоматически пасовать на аукционах, если не хватает денег. При скрытых деньгах это может показать, что вы не можете оплатить ставку. Применяется после следующего хода.",
"Show unselected regions": "Показать невыбранные регионы",
"Show action labels": "Показывать названия действий",
"Color-blind mode": "Режим для дальтоников",
"\" not found for variant \"": "\" не найдено для варианта \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "Tiền được công khai: người chơi tự động bỏ lượt đấu giá nếu không đủ tiền.",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "Tự động bỏ lượt đấu giá nếu bạn không đủ tiền. Khi tiền được giữ kín, điều này có thể tiết lộ rằng bạn không đủ tiền trả giá. Áp dụng sau nước đi tiếp theo.",
"Show unselected regions": "Hiển thị các vùng chưa được chọn",
"Show action labels": "Hiển thị nhãn hành động",
"Color-blind mode": "Chế độ mù màu",
"\" not found for variant \"": "\" không tìm thấy cho biến thể \"",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "资金公开:玩家在无力支付出价时自动放弃竞价。",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "在无力支付出价时自动放弃竞价。资金隐藏时,这可能暴露你无力支付该出价。下次行动后生效。",
"Show unselected regions": "显示未选地区",
"Show action labels": "显示操作文字",
"Color-blind mode": "色盲模式",
"\" not found for variant \"": "”在此变体中未找到:“",
"#scene g.button": "#scene g.button",

View file

@ -3,6 +3,7 @@
"Money is public: players automatically pass auctions they cannot afford.": "資金公開:玩家在無力支付出價時自動放棄競價。",
"Automatically pass auctions you cannot afford. With hidden money, this can reveal that you cannot afford the bid. Applies after the next move.": "在無力支付出價時自動放棄競價。資金隱藏時,這可能暴露你無力支付該出價。下次行動後生效。",
"Show unselected regions": "顯示未選取的區域",
"Show action labels": "顯示操作文字",
"Color-blind mode": "色盲模式",
"\" not found for variant \"": "」未找到,用於變體「",
"#scene g.button": "#scene g.button",

View file

@ -36,6 +36,7 @@ export const mountTutorial: TutorialMount = async (target, { chapter, onProgress
preferences: Vue.observable({
sound: false,
colorBlind: false,
textActions: false,
disableHelp: false,
adjustPlayerOrder: false,
}),

View file

@ -17,6 +17,7 @@ export type Preferences = {
analysis?: boolean;
sound: boolean;
colorBlind: boolean;
textActions?: boolean;
/** Legacy host preference; help indicators are now always visible. */
disableHelp?: boolean;
showUnselectedRegions?: boolean;

View file

@ -0,0 +1,99 @@
import BoardOption from '@/components/buttons/BoardOption.vue';
import PassButton from '@/components/buttons/PassButton.vue';
import UndoButton from '@/components/buttons/UndoButton.vue';
import Game from '@/components/Game.vue';
import { mount } from '@vue/test-utils';
import { expect } from 'chai';
describe('action label presentation', () => {
it('switches phase labels without changing geometry, activation or disabled semantics', async () => {
const wrapper = mount(PassButton, {
propsData: {
text: 'Finish buying',
icon: 'resources',
action: 'finish',
enabled: true,
width: 168,
height: 32,
},
});
const bounds = wrapper.find('.button-outline').attributes();
await wrapper.setProps({ showText: true });
expect(wrapper.find('[data-action-label]').text()).to.equal('Finish buying');
expect(wrapper.find('[data-phase-icon]').exists()).to.equal(false);
expect(wrapper.find('[data-action-icon]').exists()).to.equal(false);
expect(wrapper.find('.button-divider').exists()).to.equal(false);
expect(wrapper.find('.button-outline').attributes()).to.deep.equal(bounds);
await wrapper.find('[data-action-label]').trigger('click');
await wrapper.trigger('keydown.enter');
await wrapper.trigger('keydown.space');
expect(wrapper.emitted('click')!.length).to.equal(3);
await wrapper.setProps({ enabled: false });
await wrapper.trigger('click');
await wrapper.trigger('keydown.enter');
expect(wrapper.emitted('click')!.length).to.equal(3);
expect(wrapper.attributes('aria-disabled')).to.equal('true');
await wrapper.setProps({ showText: false });
expect(wrapper.find('[data-action-label]').exists()).to.equal(false);
expect(wrapper.find('[data-phase-icon]').exists()).to.equal(true);
wrapper.destroy();
});
it('shows complete labels for local undo, saved-move undo and cancel bid edit', async () => {
for (const [text, control, icon] of [
['Undo last move', 'undo', 'undo'],
['Undo my move', 'undo-move', 'undo'],
['Cancel bid edit', 'undo', 'cancel'],
]) {
const wrapper = mount(UndoButton, {
propsData: { text, control, icon, showText: true, width: 168, height: 32, enabled: true },
});
expect(wrapper.find('[data-action-label]').text()).to.equal(text);
expect(wrapper.attributes('aria-label')).to.equal(text);
expect(wrapper.find('image').exists()).to.equal(false);
expect(wrapper.find('path').exists()).to.equal(false);
await wrapper.trigger('keydown.space');
expect(wrapper.emitted('click')!.length).to.equal(1);
await wrapper.setProps({ enabled: false });
await wrapper.trigger('click');
expect(wrapper.emitted('click')!.length).to.equal(1);
wrapper.destroy();
}
});
it('toggles only the presentation preference, not game state or moves', () => {
const events: any[] = [];
const context = {
preferences: { textActions: false },
$set: (object: any, key: string, value: boolean) => {
object[key] = value;
},
emitter: { emit: (...args: any[]) => events.push(args) },
};
const toggle = (Game as any).options.methods.toggleTextActions;
toggle.call(context);
expect(context.preferences.textActions).to.equal(true);
toggle.call(context);
expect(context.preferences.textActions).to.equal(false);
expect(events).to.deep.equal([
['update:preference', { name: 'textActions', value: true }],
['update:preference', { name: 'textActions', value: false }],
]);
});
it('supports a keyboard toggle and exposes pressed state without making Rules a toggle', async () => {
const wrapper = mount(BoardOption, {
propsData: { control: 'text-actions', icon: 'text', label: 'Show action labels' },
});
expect(wrapper.attributes('aria-pressed')).to.equal('false');
await wrapper.trigger('keydown.enter');
await wrapper.trigger('keydown.space');
expect(wrapper.emitted('click')!.length).to.equal(2);
await wrapper.setProps({ active: true });
expect(wrapper.attributes('aria-pressed')).to.equal('true');
expect(wrapper.find('.active-marker').exists()).to.equal(true);
await wrapper.setProps({ toggle: false, icon: 'rules', label: 'Rules' });
expect(wrapper.attributes('aria-pressed')).to.equal(undefined);
wrapper.destroy();
});
});