Rest the map while the dashboard covers a phone screen

On a phone the NOC dashboard, scrolled past its top edge, fills the whole
screen, but the map underneath was still drawn every frame: about 4 ms per
frame on a big network on a fast PC, several times that on a phone. While a
panel covers the map completely it is no longer drawn, and it comes back as
soon as any of it shows. At the top of the dashboard the strip of map above
the card keeps moving, and on desktop, where the map shows around the
dashboard, nothing changes. No payday floaters are made while the map is
hidden, so they cannot pile up out of sight.
This commit is contained in:
Frederic Jung 2026-10-26 02:00:33 +01:00
parent e026836169
commit 47c7c19402
3 changed files with 34 additions and 3 deletions

View file

@ -3824,7 +3824,7 @@ const CLOUDS=Array.from({length:7},(_,i)=>({x:R1()*W,y:60+R1()*(H-120),s:.7+R1()
const FLOATS=[];
// Stamped with the map's animation clock, which stops while paused: on the real clock, every floater born after a
// pause lingered off-screen for as long as the pause had lasted, and paydays piled up hundreds of them.
function floater(x,y,text,col){if(!animOn())return;FLOATS.push({x,y,text,col,t:animT});}
function floater(x,y,text,col){if(!animOn()||UI.mapHid)return;FLOATS.push({x,y,text,col,t:animT});}
// Static markup: data-i18n text and every aria-label/title go through the dictionary once at boot.
function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.textContent);
for(const a of ['aria-label','title'])for(const el of document.querySelectorAll('['+a+']'))el.setAttribute(a,tr(el.getAttribute(a)));}
@ -4191,8 +4191,12 @@ function frame(now){
if(n){UI.ticking=true;renderHUD();UI.ticking=false;UI.panelsDue=true;}}
if(UI.speed&&!(S&&S.lost))animT+=dt; /* paused = frozen dots, waves and clouds */
const t=animOn()?animT:0;
if(!mapStill(t,now)){try{draw(t);}catch(e){tickErr(e);}UI.drawnAt=now;}
if(!(UI.mapHid=mapHidden())&&!mapStill(t,now)){try{draw(t);}catch(e){tickErr(e);}UI.drawnAt=now;}
}
/* On a phone the NOC dashboard (or the bank), scrolled past its top edge, covers the whole map. Drawing the map
under it is work nobody sees, so it waits until the map shows again (and no payday money piles up meanwhile). */
function mapHidden(){for(const id of ['dashCard','bankCard']){const c=$(id);if(c.parentNode.hidden)continue;
const r=c.getBoundingClientRect();if(r.top<=1&&r.left<=1&&r.right>=innerWidth-1&&r.bottom>=innerHeight-1)return true;}return false;}
/* Paused, or with animations off, the map only changes when you move it, point at something or the network changes.
Until then the last frame is still right, so it is not drawn again (phones keep cool). It is redrawn at least once
a second anyway, and every frame while the land picture is still catching up with a zoom. */