diff --git a/index.html b/index.html index 67141a0..168d02c 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,10 @@
- +
+ + +
Quest complete!
@@ -124,6 +127,9 @@

MiniCrafter

+ diff --git a/src/main.js b/src/main.js index 6853865..a786385 100644 --- a/src/main.js +++ b/src/main.js @@ -592,11 +592,36 @@ quests.ctx = { const starStr = (n) => '⭐'.repeat(n); +// Quest tracker: shown, folded to a small pill, or hidden (Settings). Phones start folded so it +// doesn't cover the view; desktops start shown. A folded tracker peeks open for a few seconds +// when a quest finishes or a new one starts, so nobody misses it. +const questView = () => settings.quests || (touchMode ? 'folded' : 'open'); +function applyQuestView() { + const v = questView(), folded = v === 'folded'; + $('quest-tracker').classList.toggle('folded', folded); + $('quest-tracker').classList.toggle('off', v === 'off'); + $('qt-fold').textContent = folded ? '▾' : '▴'; + $('qt-fold').setAttribute('aria-label', folded ? 'Show quests' : 'Hide quests'); + $('qt-fold').setAttribute('aria-expanded', String(!folded)); + $('quest-view').value = v; +} +function setQuestView(v) { settings.quests = v; store.set(SETTINGS_KEY, settings); $('quest-tracker').classList.remove('peek'); applyQuestView(); } +let shownQuests = null, peekTimer; + function renderQuests() { $('qt-stars').textContent = `⭐ ${quests.stars}`; $('menu-stars').textContent = `(${quests.stars} / ${quests.maxStars})`; const list = $('qt-list'); const act = quests.active(); + const top = act[0]; + $('qt-mini').textContent = top ? `· ${top.icon} ${quests.progress(top)}/${top.count}` : '· 🏆'; + const ids = act.map((q) => q.id).join(); + if (shownQuests !== null && ids !== shownQuests && questView() === 'folded') { + $('quest-tracker').classList.add('peek'); + clearTimeout(peekTimer); + peekTimer = setTimeout(() => $('quest-tracker').classList.remove('peek'), 5000); + } + shownQuests = ids; list.innerHTML = act.length ? '' : '
All quests done! You are a MiniCrafter star! 🏆
'; for (const q of act) { const p = quests.progress(q); @@ -1047,7 +1072,13 @@ $('craft-done').addEventListener('click', () => closeOverlay(true)); $('pet-done').addEventListener('click', () => closeOverlay(true)); $('qb-done').addEventListener('click', () => closeOverlay(true)); $('btn-quests').addEventListener('click', () => openQuestBook(true)); -$('qt-head').addEventListener('click', () => { if (state === 'playing') openQuestBook(false); }); +$('qt-head').addEventListener('click', () => { + if (questView() === 'folded') setQuestView('open'); + else if (state === 'playing') openQuestBook(false); +}); +$('qt-fold').addEventListener('click', () => setQuestView(questView() === 'folded' ? 'open' : 'folded')); +$('quest-view').addEventListener('change', (e) => setQuestView(e.target.value)); +applyQuestView(); // ---------- Play Together screens ---------- let knockId = null; let emojiOpen = false; diff --git a/src/news.js b/src/news.js index ffe6470..8260bf9 100644 --- a/src/news.js +++ b/src/news.js @@ -6,6 +6,14 @@ // the same number. Small bug-fix releases can skip the news (the card only shows entries // newer than the last one this player saw). export const NEWS = [ + { + v: 34, + title: 'More room to play', + items: [ + ['⭐', 'The quest list can fold away: tap ▴ to fold it, tap ⭐ to open it again. Phones start folded.'], + ['⚙️', 'Settings has a new choice: show, fold or hide quests on screen.'], + ], + }, { v: 31, title: 'Pets got upgrades!', diff --git a/style.css b/style.css index a73259d..f7b5745 100644 --- a/style.css +++ b/style.css @@ -138,6 +138,14 @@ button.done { margin-top: 14px; } .wide-btn { display: block; width: 100%; margin-top: 8px; } #quest-tracker { position: absolute; top: 10px; right: max(10px, env(safe-area-inset-right)); width: 250px; max-width: 46vw; } #qt-head { pointer-events: auto; width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: rgba(0,0,0,.5); border: 2px solid rgba(255,215,90,.6); font-weight: 700; color: #ffe27a; } +.qt-row { display: flex; gap: 4px; } +#qt-fold { pointer-events: auto; flex: none; min-width: 36px; padding: 0 8px; background: rgba(0,0,0,.5); border: 2px solid rgba(255,215,90,.6); color: #ffe27a; font: inherit; font-weight: 700; cursor: pointer; } +#qt-mini { display: none; margin-left: 8px; font-weight: 400; color: #fff; white-space: nowrap; } +/* Folded: just a small "⭐ 3 · 🔨 4/20" pill. It opens by itself for a few seconds when a quest finishes or a new one starts. */ +#quest-tracker.folded:not(.peek) { width: auto; } +#quest-tracker.folded:not(.peek) #qt-list, #quest-tracker.folded:not(.peek) .qt-key { display: none; } +#quest-tracker.folded:not(.peek) #qt-mini { display: inline; } +#quest-tracker.off { display: none; } .qt-key { font-size: .72rem; color: #cfd6e4; font-weight: 400; } body.touch .qt-key { display: none; } .q-card { margin-top: 5px; padding: 6px 9px; background: rgba(0,0,0,.45); border-radius: 6px; font-size: .8rem; } diff --git a/sw.js b/sw.js index d29673c..a56b2f8 100644 --- a/sw.js +++ b/sw.js @@ -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-v33'; +const VERSION = 'minicrafter-v34'; const CORE = [ './', './index.html', './style.css', './privacy.html', './terms.html', './legal.css', './features.html', './features.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', diff --git a/tests/smoke.mjs b/tests/smoke.mjs index 0a8a865..6bf9f3e 100644 --- a/tests/smoke.mjs +++ b/tests/smoke.mjs @@ -88,6 +88,7 @@ try { ok(core.lit, 'chunks carry voxel light data'); ok(core.worlds >= 1, 'a saved world exists'); ok(core.hotbar === 9, 'hotbar has 9 slots'); + ok(await page.evaluate(() => !document.getElementById('quest-tracker').classList.contains('folded')), 'quest tracker: shown in full on desktop'); // What's new: hidden for a brand-new player; shown once to a returning player after an update. const news = await page.evaluate(async () => { @@ -100,7 +101,7 @@ try { return { newHidden: document.getElementById('news').classList.contains('hidden'), shown, after: unseenNews(returning).length, sameVersion: sw.includes(`minicrafter-v${NEWS[0].v}'`) || Number(/minicrafter-v(\d+)/.exec(sw)[1]) > NEWS[0].v }; }); - ok(news.newHidden && news.shown === 1 && news.after === 0, "what's new: hidden for new players, shown once to returning players", JSON.stringify(news)); + ok(news.newHidden && news.shown >= 1 && news.after === 0, "what's new: hidden for new players, shown once to returning players", JSON.stringify(news)); ok(news.sameVersion, "what's new: the newest news is not ahead of sw.js VERSION"); const features = await page.evaluate(async () => { @@ -319,6 +320,17 @@ try { return document.getElementById('touch').classList.contains('active'); }); ok(touch, 'touch controls appear in touch mode'); + const qt = await t.page.evaluate(() => { + const el = document.getElementById('quest-tracker'); + const r = { startFolded: el.classList.contains('folded'), listHidden: getComputedStyle(document.getElementById('qt-list')).display === 'none' }; + document.getElementById('qt-fold').click(); + r.opens = !el.classList.contains('folded'); + document.getElementById('quest-view').value = 'off'; document.getElementById('quest-view').dispatchEvent(new Event('change')); + r.hides = getComputedStyle(el).display === 'none'; + document.getElementById('quest-view').value = 'folded'; document.getElementById('quest-view').dispatchEvent(new Event('change')); + return r; + }); + ok(qt.startFolded && qt.listHidden && qt.opens && qt.hides, 'quest tracker: folded on touch screens, opens with a tap, can be hidden in Settings', JSON.stringify(qt)); // Phones: turning the phone upright pauses and asks for sideways; turning it back carries on. // (Waits for the change itself: CI runners render slowly, so a fixed pause isn't enough.) const settle = (fn) => t.page.waitForFunction(fn, null, { timeout: 15000 }).then(() => true).catch(() => false);