Triforce v0.8.5

A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-28 10:54:41 -06:00
parent 2df08c751e
commit b527e29adb
203 changed files with 18821 additions and 2051 deletions

View File

@@ -3,7 +3,7 @@
page -> launcher {t:'ready'} {t:'win', a:'min'|'max'|'close'} {t:'pick', kind:'file'|'folder'} {t:'drop', files:[file:// on Linux]}
{t:'cmd', c:<name>, ...args} (build, stop, retry, play, update, playold, showgame, open, lang, folder, setting,
saves.import, saves.export, saves.open, mods.*, bench, benchstop, benchapply,
saves.import, saves.export, saves.open, mods.*, rando.* (rando.js), bench, benchstop, benchapply,
report, sound, color, workback, ...)
launcher -> page {t:'hello', chrome, os} {t:'state', ...parts} {t:'go', s} {t:'check', st, name, msg}
{t:'work', ...} {t:'log', lines} {t:'toast', html} {t:'sfx', id} {t:'bench', ...} {t:'max', on}
@@ -11,7 +11,8 @@
Without a launcher (a plain browser) demo.js answers instead, so the design can be looked at anywhere. */
'use strict';
const $ = (s, r = document) => r.querySelector(s), $$ = (s, r = document) => [...r.querySelectorAll(s)];
const esc = s => String(s ?? '').replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
// ((Triforce, 11-26) the single quote too: a value inside url('...') in a style attribute (a GameBanana picture) cannot end it)
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
/* ---------------- the window this page lives in ---------------- */
const HOST = window.chrome && window.chrome.webview ? 'win' : (window.external && typeof window.external.sendMessage === 'function' ? 'linux' : null);
@@ -234,9 +235,9 @@ document.addEventListener('pointerdown', e => {
});
/* ---------------- screens ---------------- */
const MAIN = ['home', 'mods', 'saves', 'settings'];
const MAIN = ['home', 'mods', 'rando', 'saves', 'settings'];
const FIRST_RUN = ['welcome', 'reveal', 'done'];
const MUSIC = { welcome: null, reveal: 'saria', work: 'temple', done: 'itemget', home: 'fairy', saves: 'fairy', mods: 'fairy', settings: 'fairy', bench: 'fairy', brun: null, playing: null };
const MUSIC = { welcome: null, reveal: 'saria', work: 'temple', done: 'itemget', home: 'fairy', saves: 'fairy', mods: 'fairy', rando: 'fairy', settings: 'fairy', bench: 'fairy', brun: null, playing: null };
let screen = null;
function go(name) {
if (name === screen || !$('#s-' + name)) return;
@@ -254,6 +255,7 @@ function go(name) {
setFocus($('#' + $('#s-' + name).dataset.first) || focusables()[0], false);
if (name === 'mods' && !S.mods.loaded) cmd('mods.list', { tab: S.mods.tab, q: '' });
if (name === 'saves') cmd('saves.list');
if (name === 'rando') cmd('rando.open');
cmd('screen', { s: name });
}
function afterOneShot(name) { if (name === 'itemget' && (MUSIC[screen] === 'fairy' || screen === 'done')) music('fairy'); }
@@ -277,6 +279,7 @@ function setFocus(el, sound) {
const letGo = focused && focused.id === 'cpSv' && focused.classList.contains('held'); // (the colour square lets go when focus leaves it)
if (letGo) focused.classList.remove('held');
focused = el; el.classList.add('kf');
if (typeof randoFocus === 'function') randoFocus(el); // (the Randomizer page's tip line: rando.js)
if (letGo || el.id === 'cpSv') colorMsg();
if (el.tagName === 'INPUT') el.focus(); else if (document.activeElement && document.activeElement.tagName === 'INPUT') document.activeElement.blur();
if (document.body.classList.contains('kb')) el.scrollIntoView({ block: 'nearest' });
@@ -343,7 +346,7 @@ function back() {
function tab(d) {
if (!MAIN.includes(screen) && screen !== 'bench') return;
const i = MAIN.indexOf(screen === 'bench' ? 'settings' : screen);
sfx(d < 0 ? 'tab_l' : 'tab_r'); go(MAIN[(i + d + 4) % 4]);
sfx(d < 0 ? 'tab_l' : 'tab_r'); go(MAIN[(i + d + MAIN.length) % MAIN.length]);
}
let toastT = 0;
function toast(html) {
@@ -371,6 +374,7 @@ const ACTIONS = {
evilhd: () => { const r = evilRow(); if (!r) return; r.v = +r.v === 1 ? 0 : 1; drawEvilHd(); cmd('gopt.value', { key: 'evil_hd', value: r.v }); },
bringin: () => openSaveFlow('import'),
copyout: () => openSaveFlow('export'),
benchstop: () => cmd('benchstop'), // ((Triforce, 11-26) the run screen's Esc / B: its data-back named this, which was no action)
opt: (a, el) => { $$('.opt', el.parentElement).forEach(o => o.classList.toggle('sel', o === el)); },
row: (id) => settingRow(id),
choose: (id) => cmd('choose', { id }),
@@ -386,6 +390,8 @@ function closeSheet(quiet) {
if (!$('#sheetBg').classList.contains('open')) return;
$('#sheetBg').classList.remove('open'); if (!quiet) sfx('close');
if (sheetReturn && document.contains(sheetReturn) && visible(sheetReturn)) { focused = null; setFocus(sheetReturn); }
// (the row it opened from is gone, drawn anew meanwhile: the screen's first place, never a button of the closed sheet)
else if (screen && $('#s-' + screen)) { focused = null; setFocus($('#' + $('#s-' + screen).dataset.first) || focusables()[0]); }
}
function openVol() { $('#vol').classList.add('open'); sfx('open'); setFocus($('[data-vol="music"]')); }
function closeVol(quiet) { if (!$('#vol').classList.contains('open')) return; $('#vol').classList.remove('open'); if (!quiet) sfx('close'); setFocus($('#spk')); }
@@ -513,7 +519,7 @@ function drawHome() {
$('#playBtn').classList.toggle('off', !!h.off);
$('#hLinks').innerHTML = (h.links || []).map(l => l.act ? `<span class="lnk" data-f data-act="${esc(l.act)}">${l.html}</span>` : `<span>${l.html}</span>`).join('');
const url = picUrl(f);
['#homeImg', '#homePic', '#savesImg', '#modsImg', '#setImg', '#playImg', '#benchImg'].forEach(s => $(s).style.backgroundImage = url);
['#homeImg', '#homePic', '#savesImg', '#modsImg', '#randoImg', '#setImg', '#playImg', '#benchImg'].forEach(s => $(s).style.backgroundImage = url);
$('#s-home').classList.toggle('nopic', !f);
$('#hCap').textContent = f ? `${f.label} · ${f.last ? 'your last save · ' : ''}picture from the game` : '';
$('#strip').innerHTML = files.map((x, i) => `<div class="f${i === S.cur ? ' on' : ''}" data-f data-act="file:${i}" id="f${i}"><img src="${esc(x.pic)}" alt=""><small>${esc(x.label)}</small></div>`).join('');
@@ -589,6 +595,10 @@ function gameRows(tab) {
}
function pct(r) { return r.hi > r.lo ? Math.round((r.v - r.lo) / (r.hi - r.lo) * 1000) / 10 : 0; }
function drawSettings() {
// ((Triforce, 11-26) a game-option slider being dragged, or whose value is on its way, is not drawn over: every state
// message drew the page anew, the dragged slider was gone from under the pointer, and the value at that moment was the one kept)
if (S.gDrag || S.gSend) { S.gPending = true; return; }
S.gPending = false;
const tabs = [{ id: 'launcher', name: 'Launcher' }].concat(S.gameopts && S.gameopts.tabs || []);
if (!tabs.some(t => t.id === S.settab)) S.settab = 'launcher';
const keep = focused && focused.id;
@@ -611,20 +621,36 @@ function gStep(el, v) {
v = Math.max(lo, Math.min(hi, lo + Math.round((v - lo) / st) * st));
el.dataset.v = v; const p = hi > lo ? (v - lo) / (hi - lo) * 100 : 0;
el.querySelector('i').style.width = p + '%'; el.querySelector('u').style.left = p + '%';
const lab = el.parentElement.querySelector('.gval'); if (lab) lab.textContent = String(v);
// (the randomizer's multiples show as 1.5x: rando.js rNum)
const lab = el.parentElement.querySelector('.gval'); if (lab) lab.textContent = el.dataset.times ? (v / +el.dataset.times).toFixed(2).replace(/\.?0+$/, '') + '\u00d7' : String(v);
return v;
}
let gSendT = 0;
function gSend(el) { clearTimeout(gSendT); gSendT = setTimeout(() => cmd('gopt.value', { key: el.dataset.gkey, value: +el.dataset.v }), 350); }
let gSendT = 0, gSendEl = null;
// (the randomizer's page waits while a value is on its way (S.rSend) or a slider is held (S.rDrag), then draws: rando.js drawRando.
// Another slider's value on its way goes at once, so none is lost)
const gKey = el => el.dataset.rkey ? 'r:' + el.dataset.rkey : 'g:' + el.dataset.gkey;
function gFire() {
const el = gSendEl; gSendEl = null; clearTimeout(gSendT); if (!el) return;
if (el.dataset.rkey) { S.rSend = false; cmd('rando.set', { id: el.dataset.rkey, value: +el.dataset.v }); } else { S.gSend = false; cmd('gopt.value', { key: el.dataset.gkey, value: +el.dataset.v }); }
}
function gSend(el) {
if (gSendEl && gKey(gSendEl) !== gKey(el)) gFire();
clearTimeout(gSendT); gSendEl = el;
if (el.dataset.rkey) S.rSend = true; else S.gSend = true;
gSendT = setTimeout(gFire, 350);
}
document.addEventListener('pointerdown', e => {
const s = e.target.closest('.slider[data-gkey]'); if (!s || s.closest('.off')) return;
const s = e.target.closest('.slider[data-gkey], .slider[data-rkey]'); if (!s || s.closest('.off')) return;
e.preventDefault(); setFocus(s, true);
const mv = ev => { const b = s.getBoundingClientRect(); gStep(s, +s.dataset.lo + (ev.clientX - b.left) / b.width * (+s.dataset.hi - +s.dataset.lo)); };
if (s.dataset.rkey) S.rDrag = true; else S.gDrag = true;
// (held by the slider, so letting go outside the window still ends the drag; a move with no button down ends it too)
try { s.setPointerCapture(e.pointerId); } catch (x) { }
const up = () => { removeEventListener('pointermove', mv); removeEventListener('pointerup', up); removeEventListener('pointercancel', up); S.rDrag = false; S.gDrag = false; sfx('cursor'); gSend(s); };
const mv = ev => { if (!ev.buttons) return up(); const b = s.getBoundingClientRect(); if (b.width > 0) gStep(s, +s.dataset.lo + (ev.clientX - b.left) / b.width * (+s.dataset.hi - +s.dataset.lo)); };
mv(e);
const up = () => { removeEventListener('pointermove', mv); removeEventListener('pointerup', up); sfx('cursor'); gSend(s); };
addEventListener('pointermove', mv); addEventListener('pointerup', up);
addEventListener('pointermove', mv); addEventListener('pointerup', up); addEventListener('pointercancel', up);
});
function gNudge(d) { if (!focused || !focused.dataset.gkey || focused.closest('.off')) return false; gStep(focused, +focused.dataset.v + d * (+focused.dataset.step || 1)); sfx('cursor'); gSend(focused); return true; }
function gNudge(d) { if (!focused || !(focused.dataset.gkey || focused.dataset.rkey) || focused.closest('.off')) return false; gStep(focused, +focused.dataset.v + d * (+focused.dataset.step || 1)); sfx('cursor'); gSend(focused); return true; }
function settingRow(id) { cmd('setting', { id }); }
// (the list is asked for each time the page opens, so it shows what is true now: Steam, shortcuts, the game folder)
new MutationObserver(() => { if ($('#s-settings').classList.contains('on')) cmd('settings.list'); }).observe($('#s-settings'), { attributes: true, attributeFilter: ['class'] });
@@ -855,6 +881,9 @@ onHost(m => {
if (!had.music && S.media.music && screen) { const want = MUSIC[screen]; curTrack = null; music(want === 'itemget' ? 'fairy' : want); }
}
drawPill(); drawHome(); drawReveal(); drawSaves(); drawSettings(); if (m.mods) drawMods(); nowPlaying();
if (m.rando && m.rando.schema) S.randoSchema = m.rando.schema; // (OOTRR's settings come once; the rows every time)
if (m.randoMade) S.rtab = 'seeds';
if ((m.rando || m.randoMade) && typeof drawRando === 'function') drawRando();
if (m.done) { $('#doneEb').textContent = S.done.eb || ''; $('#doneLead').textContent = S.done.lead || ''; }
break;
}
@@ -879,7 +908,7 @@ document.addEventListener('keydown', e => {
const ca = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[k];
if (ca && colorNudge(ca[0], ca[1])) { } // (the colour picker's square and hue take the arrows first)
else if (focused && focused.dataset.vol && (k === 'ArrowLeft' || k === 'ArrowRight')) { setVol(focused.dataset.vol, S.sound[focused.dataset.vol] + (k === 'ArrowLeft' ? -.05 : .05)); sfx('cursor'); }
else if (focused && focused.dataset.gkey && (k === 'ArrowLeft' || k === 'ArrowRight')) gNudge(k === 'ArrowLeft' ? -1 : 1);
else if (focused && (focused.dataset.gkey || focused.dataset.rkey) && (k === 'ArrowLeft' || k === 'ArrowRight')) gNudge(k === 'ArrowLeft' ? -1 : 1);
else if (k === 'ArrowLeft') move(-1, 0); else if (k === 'ArrowRight') move(1, 0);
else if (k === 'ArrowUp') move(0, -1); else if (k === 'ArrowDown') move(0, 1);
else if (k === 'Enter' || k === ' ') activate(focused);