Keep the top bar on one row in every language

Longer Italian labels wrapped the HUD over the side panels on laptop
widths. fitHud() now hides the less important readouts until the bar fits,
whatever the language. Also shortens two Italian HUD labels and translates
the How the Internet Works links.
This commit is contained in:
Frederic Jung 2026-10-24 22:21:17 +02:00
parent f1ea017b39
commit 9315b37b82
No known key found for this signature in database
3 changed files with 14 additions and 3 deletions

View file

@ -365,6 +365,9 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
.speed button{min-width:26px;height:28px;font-size:11.5px}
.chip{padding:2px 7px}
}
/* Whatever the language, the HUD stays on one row: fitHud() drops chips until it fits. */
#hud.fit1 .hide-md2,#hud.fit2 .hide-md{display:none !important}
#hud.fit3 .brand>div,#hud.fit3 .brand .caret{display:none}
@media (max-width:760px){
.chip{min-height:40px;padding:2px 8px}
.chip .val{font-size:16px}
@ -2345,6 +2348,9 @@ const logo=n=>`<span class="logo" style="--c:${n.col}">${initials(n)}</span>`;
const barCls=u=>u>=0.9?'bad':u>=0.65?'warn':'';
function renderAll(){if(isTablet()&&!UI.sel)UI.leftOpen=false;renderHUD();renderLeft();renderPanel();renderHint();renderMega();renderCoach();}
function renderMega(){const el=$('mega');if(!el)return;const on=!!(S&&S.ev&&S.ev.php>S.day);if(el.hidden===!on)return;el.hidden=!on;}
function fitHud(){const h=$('hud');if(!h)return;h.classList.remove('fit1','fit2','fit3');if(innerWidth<=760)return;
const row=()=>{let m=0;for(const c of h.children)if(c.offsetParent)m=Math.max(m,c.offsetHeight);return m;};
for(const c of ['fit1','fit2','fit3']){if(h.offsetHeight<=row()*1.5)break;h.classList.add(c);}}
function renderHUD(){
for(const v of [0,0.5,1,2,4,8]){const b=$('sp'+v);if(b)b.classList.toggle('on',UI.speed===v);}
$('muteBtn').style.opacity=UI.muted?.4:1;
@ -2360,6 +2366,7 @@ function renderHUD(){
$('hDate').textContent=dateStr(S.day);
{const bo=(S.loanOffers||[]).length,hb=$('hBank');hb.hidden=!bo;hb.textContent=bo;}
const n=S.inc.length;$('hNoc').classList.toggle('hot',n>0);$('hNocVal').textContent=n?trn('{n} incident','{n} incidents',n):tr('All quiet');
if(!window.__TUBES_TEST__)fitHud();
}
function renderLeft(){
// Tablets in landscape: both side panels don't fit next to the map, so the left one tucks away
@ -2834,7 +2841,7 @@ const cv=$('map'),ctx=cv.getContext('2d');
const cam={x:1050,y:330,z:0.8};
let CW=0,CH=0,DPR=1;
function resize(){DPR=Math.min(2,window.devicePixelRatio||1);CW=innerWidth;CH=innerHeight;cv.width=CW*DPR;cv.height=CH*DPR;}
addEventListener('resize',()=>{resize();WL.key=null;renderLeft();});resize();
addEventListener('resize',()=>{resize();WL.key=null;renderLeft();fitHud();});resize();
function rng(seed){return()=>{seed|=0;seed=seed+0x6D2B79F5|0;let t=Math.imul(seed^seed>>>15,1|seed);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
function inPoly(x,y,pts){let ins=false;for(let i=0,j=pts.length-1;i<pts.length;j=i++){const [xi,yi]=pts[i],[xj,yj]=pts[j];if(((yi>y)!==(yj>y))&&(x<(xj-xi)*(y-yi)/(yj-yi)+xi))ins=!ins;}return ins;}
function smoothPath(pts){const p=new Path2D();const n=pts.length;const mid=(a,b)=>[(a[0]+b[0])/2,(a[1]+b[1])/2];let m=mid(pts[n-1],pts[0]);p.moveTo(m[0],m[1]);for(let i=0;i<n;i++){const nx=pts[(i+1)%n];m=mid(pts[i],nx);p.quadraticCurveTo(pts[i][0],pts[i][1],m[0],m[1]);}p.closePath();return p;}