From 42acec3f075689abc7d3fd4900b50c1e0b95cf59 Mon Sep 17 00:00:00 2001 From: Danilo Carbonaro <107484701+daniloctdev@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:31:03 +0200 Subject: [PATCH] Let the title-screen language buttons work before a game exists The click dispatcher only lets a short list of actions through while there is no game yet, so picking a language on a fresh title screen did nothing. The test now clicks the button instead of calling the action. --- site/index.html | 2 +- tests/i18n.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/site/index.html b/site/index.html index 4b147cf..db4c120 100644 --- a/site/index.html +++ b/site/index.html @@ -3087,7 +3087,7 @@ let pressing=false; document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left'))pressing=true;}); addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0)); addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;}); -document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','soundSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','scenarios','startScn','startWeekly'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); +document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','soundSet','langSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','scenarios','startScn','startWeekly'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);}); /* ================= LOOP ================= */ let last=performance.now(),acc=0,hudT=0,animT=0; diff --git a/tests/i18n.test.js b/tests/i18n.test.js index 05e23c8..c9ca2ac 100644 --- a/tests/i18n.test.js +++ b/tests/i18n.test.js @@ -79,6 +79,12 @@ test('every Italian entry keeps the placeholders and HTML tags of its English te assert.deepEqual(brokenEntries(dict), []); }); +test('the language buttons on the title screen work before any game exists', () => { + const { ev } = load(); + ev("[...document.querySelectorAll('#modalCard [data-act=langSet]')].find(b=>b.textContent==='Italiano').click()"); + assert.equal(ev("localStorage.getItem('sot-lang')"), 'it'); +}); + test('picking a language saves the choice and the game, then reloads', () => { const { ev } = load(); ev('ACT.start({});dayTick()');