Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ <h1>MiniCrafter</h1>
</table>
</details>
<p class="note touch-only">Touch: left stick walks, drag to look, tap to place or flip, hold to mine or attack. Holding a bow or shield? Hold to draw or block.</p>
<p class="note">Your world is saved automatically in this browser. <span id="offline-note"></span></p>
<p class="note">Your world is saved automatically in this browser. <span id="offline-note"></span> <span id="game-version"></span></p>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,12 @@ for (const [overlay, done] of [['inventory', 'inv-done'], ['craft', 'craft-done'
$('robot-panel').appendChild(x);
}

// Game version (the offline cache's name), so testers can tell which build a device runs.
window.caches?.keys().then((keys) => {
const v = Math.max(0, ...keys.map((k) => Number((/^minicrafter-v(\d+)$/.exec(k) || [])[1] || 0)));
if (v) $('game-version').textContent = `Version ${v}`;
}).catch(() => {});

// ---------- today's building idea ----------
$('idea-text').textContent = ideaOfTheDay();
$('btn-idea').addEventListener('click', () => { $('idea-text').textContent = IDEAS[Math.floor(Math.random() * IDEAS.length)]; });
Expand Down
25 changes: 22 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1026; fon
.hidden { display: none !important; }

/* Overlays / panels */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 10, 25, 0.55); backdrop-filter: blur(2px); z-index: 20; padding: 16px; }
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 10, 25, 0.55); backdrop-filter: blur(2px); z-index: 20; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
/* The panel gets its own layer under the ✕: Safari can otherwise paint a scrolling panel over it. */
.overlay > .panel { position: relative; z-index: 1; }
.panel { width: min(440px, 100%); max-height: 100%; overflow: auto; background: rgba(20, 24, 34, 0.92); border: 2px solid #3a4255; border-radius: 10px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.panel.wide { width: min(720px, 100%); }
h1 { margin: 0; font-size: 2.6rem; letter-spacing: 2px; text-shadow: 3px 3px 0 #2b5a1e; color: #9be06a; text-align: center; }
Expand Down Expand Up @@ -267,7 +269,7 @@ select { width: 100%; }
}
/* Short screens (phones held sideways): tighter spacing and a smaller title. */
@media (max-height: 520px) {
.overlay { padding: 8px; }
.overlay { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.menu-panel { padding: 14px 16px; }
.brand { justify-content: flex-start; margin-bottom: 2px; }
.brand .logo { width: 44px; height: 44px; border-radius: 11px; }
Expand Down Expand Up @@ -361,7 +363,7 @@ body.touch #emoji-bar small { display: none; }
}

/* Always-visible close button on pop-up panels */
.x-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 30; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 20px; font-weight: 700; line-height: 1; background: rgba(20, 24, 34, .92); border: 2px solid #8a93a8; color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.x-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 30; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 20px; font-weight: 700; line-height: 1; background: rgba(20, 24, 34, .92); border: 2px solid #8a93a8; color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); transform: translateZ(0); }
.x-close:hover { background: #364058; }
@media (max-height: 520px) { .x-close { width: 40px; height: 40px; top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); } }

Expand Down Expand Up @@ -415,3 +417,20 @@ body.touch #quest-tracker .q-card ~ .q-card ~ .q-card { display: none; }
#rb-blockly { height: calc(100vh - 150px); min-height: 180px; }
#rb-controls { position: sticky; bottom: -10px; z-index: 2; margin-top: 0; padding: 8px 0 10px; background: rgba(20, 24, 34, .98); }
}

/* Crafting on narrow screens: the 9-slot rows shrink to fit instead of pushing the panel
sideways (they were 482px wide, more than an upright phone), and one scroll for the panel. */
.craft-panel > * { min-width: 0; }
.slot-grid { grid-template-columns: repeat(9, minmax(0, 50px)); }
#craft .slot-grid .slot { width: auto; height: auto; aspect-ratio: 1; }
#craft .slot-grid .slot img { width: 68%; height: auto; }
@media (max-width: 860px) { #recipes { max-height: none; overflow: visible; padding-right: 0; } }
/* Done pinned to the bottom on upright phones (sideways ones are too short: the ✕ is enough). */
@media (max-width: 860px) and (min-height: 521px) {
#craft-done { position: sticky; bottom: -1px; z-index: 2; box-shadow: 0 -10px 14px 6px rgba(20, 24, 34, .95); }
}
@media (max-width: 480px) {
.slot-grid { gap: 3px; }
#craft .slot-grid .slot .count { font-size: 11px; right: 2px; bottom: 0; }
}
#game-version { white-space: nowrap; }
2 changes: 1 addition & 1 deletion sw.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Service worker: caches the whole game so it works offline once loaded.
// Bump VERSION whenever files change so players get the update.
const VERSION = 'minicrafter-v21';
const VERSION = 'minicrafter-v22';
const CORE = [
'./', './index.html', './style.css', './manifest.webmanifest', './site-config.json',
'./icons/icon-192.png', './icons/icon-512.png', './icons/icon-maskable-512.png', './icons/apple-touch-icon.png', './icons/favicon-32.png',
Expand Down
9 changes: 9 additions & 0 deletions tests/smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ try {
await t.page.waitForTimeout(300);
const resumed = !(await shown('rotate')) && (await shown('hud'));
ok(askedUpright && resumed, 'phones: upright pauses and asks to turn sideways, sideways carries on');
// Phones: the survival crafting panel fits an upright phone (its 9-slot rows used to push it sideways).
await t.page.setViewportSize({ width: 375, height: 667 });
const craftOverflow = await t.page.evaluate(async () => {
const m = window.minicrafter; m.setMode('survival'); m.forcePlay(); m.openOverlay();
await new Promise((r) => setTimeout(r, 300));
const p = document.querySelector('#craft .panel');
return p.offsetParent ? p.scrollWidth - p.clientWidth : -1;
});
ok(craftOverflow === 0, 'phones: crafting panel fits an upright phone', `${craftOverflow}px sideways`);
ok(t.errors.length === 0, 'no console errors (touch)', t.errors.slice(0, 3).join(' | '));
await t.page.close();

Expand Down
Loading