Skip to content

Commit 85e96c6

Browse files
committed
Midnight Ops: no stretched view after hiding Safari's toolbar; full screen button
- The 3D view follows the game area's real size (a ResizeObserver plus delayed re-checks after resize, rotation, full screen and visual-viewport changes), because iPhone Safari reports a resize before the page has its new size. Going full screen now shows more of the scene at full sharpness instead of stretching the old picture. - Pause menu: a Full screen button where the browser allows it; on iPhone, a tip to use Safari's Hide Toolbar instead. Spanish included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cw2rM7HP4RvtJycwLW1jZr
1 parent a817ebf commit 85e96c6

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎e63334287a3deaa3/ironveil/es.js‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e63334287a3deaa3/ironveil/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ <h2>Before you play</h2>
248248
</div></div>
249249

250250
<div class="screen card-wrap" id="pause"><div class="card">
251-
<h2>Paused</h2><p id="p-obj" data-noi18n></p>
252-
<div class="t-btns"><button class="btn go" id="b-resume">Resume</button><button class="btn" id="b-psettings">Settings</button><button class="btn" id="b-pcontrols">Controls</button><button class="btn" id="b-restart">Restart mission</button><button class="btn" id="b-quit">Quit</button></div>
251+
<h2>Paused</h2><p id="p-obj" data-noi18n></p><p id="p-tip" hidden>For full screen on iPhone: tap the aA button in the address bar, then Hide Toolbar. Turn the phone sideways for the widest view.</p>
252+
<div class="t-btns"><button class="btn go" id="b-resume">Resume</button><button class="btn" id="b-psettings">Settings</button><button class="btn" id="b-pcontrols">Controls</button><button class="btn" id="b-full" hidden>Full screen</button><button class="btn" id="b-restart">Restart mission</button><button class="btn" id="b-quit">Quit</button></div>
253253
</div></div>
254254

255255
<div class="screen card-wrap" id="dead"><div class="card">

‎e63334287a3deaa3/ironveil/js/main.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
const S = MO.settings, on = (id, fn) => $(id).addEventListener('click', fn);
5656
on('b-accept', () => { try { localStorage.setItem('ironveil:terms', '1'); } catch (e) {} show('title'); });
5757
on('b-deploy', () => deploy(false)); on('b-again', () => deploy(false)); on('b-retry', () => deploy(true)); on('b-restart', () => { MO.audio.pause(false); deploy(false); });
58+
// full screen where the browser allows a page to do it (Android, iPad, computers); iPhone Safari doesn't, so it gets a tip
59+
const de = document.documentElement, canFull = !!(de.requestFullscreen || de.webkitRequestFullscreen), isFull = () => !!(document.fullscreenElement || document.webkitFullscreenElement);
60+
$('b-full').hidden = !canFull; $('p-tip').hidden = canFull || !MO.touch;
61+
const fullText = () => { $('b-full').textContent = MO.T(isFull() ? 'Exit full screen' : 'Full screen'); };
62+
on('b-full', () => { try { if (isFull()) (document.exitFullscreen || document.webkitExitFullscreen).call(document); else { const p = (de.requestFullscreen || de.webkitRequestFullscreen).call(de, { navigationUI: 'hide' }); if (p && p.catch) p.catch(() => {}); } } catch (e) {} setTimeout(() => { fullText(); if (!isFull()) $('p-tip').hidden = false; }, 500); });
63+
document.addEventListener('fullscreenchange', fullText); document.addEventListener('webkitfullscreenchange', fullText); fullText();
5864
on('b-missions', missionList); on('b-mclose', () => show('title')); on('b-next', () => { const n = MO.missions.list.find((d) => d.num === MO.missions.current.num + 1); if (n) go(n.id); });
5965
on('b-resume', () => pause(false)); on('b-quit', toTitle); on('b-dquit', toTitle); on('b-gquit', toTitle);
6066
const open = (which) => () => { back = MO.screen; show(which); };

‎e63334287a3deaa3/ironveil/js/render.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@
7171
gl_FragColor = vec4(t * uFade, 1.0); }`, { tA: { value: null }, tB: { value: null }, uPx: { value: new THREE.Vector2() }, uExp: { value: 1 }, uBloom: { value: 0.09 }, uTime: { value: 0 }, uHurt: { value: 0 }, uLow: { value: 0 }, uFade: { value: 1 }, uFlash: { value: 0 }, uAim: { value: 0 } });
7272
R.exposure = 1; R.hooks = []; R.w = 0; R.h = 0;
7373
R.resize();
74-
window.addEventListener('resize', R.resize);
74+
// iPhone Safari sends 'resize' before the page has its new size (hiding the toolbar, turning the phone), so also
75+
// watch the game area itself, and check again a moment after anything that can change the size
76+
const later = () => { R.resize(); setTimeout(R.resize, 120); setTimeout(R.resize, 400); setTimeout(R.resize, 900); };
77+
window.addEventListener('resize', later); window.addEventListener('orientationchange', later);
78+
document.addEventListener('fullscreenchange', later); document.addEventListener('webkitfullscreenchange', later);
79+
if (window.visualViewport) window.visualViewport.addEventListener('resize', later);
80+
if (window.ResizeObserver) new ResizeObserver(() => R.resize()).observe(canvas.parentElement);
7581
return r;
7682
};
7783

@@ -85,6 +91,7 @@
8591
}
8692
R.resize = () => {
8793
const el = R.renderer.domElement.parentElement, w = el.clientWidth || innerWidth, h = el.clientHeight || innerHeight;
94+
if (w === R.vw && h === R.vh && R.dpr === devicePixelRatio) return; R.dpr = devicePixelRatio;
8895
R.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, MO.touch ? 1.5 : 1.25) * R.Q.scale);
8996
R.renderer.setSize(w, h, false);
9097
R.camera.aspect = R.wcam.aspect = w / h; R.camera.updateProjectionMatrix(); R.wcam.updateProjectionMatrix();

0 commit comments

Comments
 (0)