Language is a dropdown on the title screen and in Settings
This commit is contained in:
parent
3b8bd4e534
commit
87fac683f0
7 changed files with 54 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ function showTitle(){
|
|||
<label class="f" for="nmIn">${tr('title.name_your_network')}</label><div class="network-name"><input class="t" id="nmIn" maxlength="24" value="${esc(UI.nm)}" autocomplete="off">${btn(tr('common.another_one'),'randomName',{},'ghost sm')}</div>
|
||||
<label class="f">${tr('title.pick_your_home_city')}</label><div class="starts">${starts.map(([c,d])=>`<button class="start ${UI.startCity===c?'on':''}" data-city="${c}" data-act="pickStart" data-args='{"city":"${c}"}'><b>${CITY[c].name}</b><span>${d}</span></button>`).join('')}</div>
|
||||
<label class="f">${tr('common.mode')}</label><div class="btns">${[['normal',tr('common.normal')],['sandbox',tr('common.sandbox')]].map(([m,l])=>`<button class="b sm modeb ${(UI.mode||'normal')===m?'pink':'ghost'}" data-m="${m}" data-act="modeSet" data-args='{"m":"${m}"}'>${l}</button>`).join('')}${btn(tr('title.scenarios_amp_weekly_challenge'),'scenarios',{},'sm')}</div>
|
||||
<label class="f">${tr('common.language')}</label><div class="btns">${segBtns('langSet',LANG,Object.entries(LANGS))}</div>
|
||||
<label class="f" for="langTitle">${tr('common.language')}</label>${langPick('langTitle')}
|
||||
<div class="btns cta" style="margin-top:16px;justify-content:space-between;align-items:center">${btn(sv?tr('common.start_a_new_network'):tr('common.start_building'),'start',{},'big')}${btn(tr('common.how_to_play'),'help',{},'ghost')}${btn(tr('common.import_a_save'),'importPick',{},'ghost sm')}${btn(tr('common.settings'),'settings',{},'ghost sm')}</div><p class="ver">v${APP_VERSION} · <a href="https://github.com/fjaeckel/seriesoftubes" target="_blank" rel="noopener">${tr('title.source_on_github')}</a> · <a href="${SIGNAL}" target="_blank" rel="noopener">${tr('title.chat_on_signal')}</a> · ${tr('title.cookieless_stats_no_tracking')}</p>`);
|
||||
$('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;});
|
||||
if(sv){S=migrate(sv);compute();}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.dataset.i18n);
|
||||
for(const a of ['aria-label','title'])for(const el of document.querySelectorAll(`[data-i18n-${a}]`))el.setAttribute(a,tr(el.getAttribute('data-i18n-'+a)));}
|
||||
// One button per [value,label] option; the current one is highlighted.
|
||||
// One dropdown instead of a button per language: the list keeps growing, and on phones the system picker opens.
|
||||
// Each language is named in itself (lang= lets screen readers say it right).
|
||||
const langPick=id=>`<select class="pick" id="${id}" data-chg="langSet" aria-label="${tr('common.language')}">${Object.entries(LANGS).map(([v,l])=>`<option value="${v}" lang="${v}"${v===LANG?' selected':''}>${esc(l)}</option>`).join('')}</select>`;
|
||||
function segBtns(act,cur,opts){return opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('');}
|
||||
/* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */
|
||||
/* Settings are per device (localStorage), not part of the save: they are about how you like to play. */
|
||||
|
|
@ -23,7 +26,7 @@ function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`<div class="setline"
|
|||
<h3 class="sub4">${tr('settings.display_and_sound')}</h3>
|
||||
${seg(tr('common.animations'),'animSet',UI.anim||'auto',[['auto',tr('common.auto')],['on',tr('common.on')],['off',tr('common.off')]],tr('settings.auto_follows_your_device_s_reduce'))}
|
||||
${seg(tr('common.sound'),'soundSet',UI.muted?'off':'on',[['on',tr('common.on')],['off',tr('common.off')]])}
|
||||
${seg(tr('common.language'),'langSet',LANG,Object.entries(LANGS))}
|
||||
<div class="setline"><label for="langSel">${tr('common.language')}</label>${langPick('langSel')}</div>
|
||||
${seg(tr('common.viewport_info'),'vpSet',VP_T?'on':'off',[['on',tr('common.on')],['off',tr('common.off')]],tr('settings.for_reporting_layout_bugs_shows_what'))}
|
||||
${installRow()}<div class="btns" style="margin-top:12px">${btn(tr('common.done_8dd3'),'settingsClose',{},'pink')}</div>`;}
|
||||
const refreshSettings=()=>{if(UI.setOpen)openModal(settingsHtml());};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ let pressing=false;
|
|||
document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left,#dash,#bankBox,#modal,#tabbar,#toasts'))pressing=true;});
|
||||
addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0));
|
||||
addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;});
|
||||
document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||!S)return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
|
||||
document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||(!S&&el.dataset.chg!=='langSet'))return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
|
||||
/* Taps that land on the wrong thing (#44): a real tap only fires the button it went down on, never something that
|
||||
appeared or moved under the finger, nothing behind a menu that opened or closed mid-tap, and no toast button in
|
||||
the first half second after the toast popped up. Synthetic clicks (keyboard, tests) are not affected. */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@
|
|||
@media (prefers-reduced-motion:reduce){:root:not(.anim-force) .coach-glow{animation:none;outline:3px solid #FF4F9A}}
|
||||
:root.no-anim .coach-glow{outline:3px solid #FF4F9A}
|
||||
.setline{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:4px 0}
|
||||
.setline>span{font-weight:800}
|
||||
.setline>span,.setline>label{font-weight:800}
|
||||
/* Dropdowns that look like the game's buttons. 16px text: iOS zooms into anything smaller when it is tapped. */
|
||||
select.pick{-webkit-appearance:none;appearance:none;font:800 16px var(--display);color:var(--ink);background:var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231E2640' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;border:3px solid var(--ink);border-radius:12px;padding:6px 36px 6px 12px;min-height:44px;cursor:pointer;box-shadow:0 3px 0 var(--ink)}
|
||||
select.pick:focus-visible{outline:3px solid #FF4F9A;outline-offset:2px}
|
||||
label.f+select.pick{width:100%}
|
||||
.thb{font:inherit;font-weight:900;background:none;border:0;padding:0;cursor:pointer;color:inherit}
|
||||
.ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:#FFF6EC;border-radius:6px}
|
||||
.ibx{border:2px solid var(--line,#DDE3EE);border-radius:12px;padding:8px 10px;margin:8px 0;background:#fff}.ibx .nm{font-weight:800}.ibx.mp{border-color:#FF5A5F;background:#FFF1F1}.ibx.ai{border-color:#8E5CF7;background:#F7F2FF}.ibx .term{font-size:11.5px;white-space:pre-wrap;max-height:180px;overflow:auto}.ibx .cnt{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--me);color:#fff;font-size:11px;text-align:center}.ibx .cnt.red{background:#FF5A5F}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue