Toast tidak lagi menutupi bilah atas layar VS: toast info lawan Arcade/Survival dihapus (sudah ada di bilah VS) dan toast lain ditahan selama VS tampil, lalu muncul penuh sesudahnya

This commit is contained in:
rizkyaz0 2026-10-04 00:42:24 +07:00
parent fb6abadc92
commit 10a826cdce
1 changed files with 4 additions and 3 deletions

View File

@ -70,8 +70,11 @@
const esc = t => String(t).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
// ---- toasts ----
let toastBox;
let toastBox, held = [];
// Selama layar VS tampil toast ditahan (menutupi bilah atas VS), lalu dimunculkan penuh setelah layar selesai atau dibatalkan.
function holdToasts() { setTimeout(() => { if (window.VS?.active) return holdToasts(); const q = held; held = []; for (const [m, k] of q) toast(m, k); }, 150); }
function toast(msg, kind = '') {
if (window.VS?.active) { held.push([msg, kind]); if (held.length === 1) holdToasts(); return; }
if (!toastBox) { toastBox = document.createElement('div'); toastBox.id = 'meta-toasts'; document.body.append(toastBox); }
const el = document.createElement('div'); el.className = 'meta-toast ' + kind; el.textContent = msg; toastBox.append(el);
setTimeout(() => el.classList.add('out'), 3200); setTimeout(() => el.remove(), 3800);
@ -136,8 +139,6 @@
const g = window.__game, stages = Object.keys(window.MatchRules?.stages || { bellora: 1 });
const enemy = run.kind === 'arcade' ? run.queue[run.wins] : shuffle(roster().filter(x => x !== run.player))[0];
const level = run.kind === 'arcade' ? 'medium' : run.wins < 3 ? 'easy' : run.wins < 6 ? 'medium' : run.wins < 9 ? 'hard' : 'excellent';
const total = run.kind === 'arcade' ? '/' + run.queue.length : '';
toast((run.kind === 'arcade' ? 'ARCADE' : 'SURVIVAL') + ' · LAWAN ' + (run.wins + 1) + total + ': ' + fname(enemy) + ' (' + level + ')');
let ok = false;
for (const st of shuffle(stages.slice()).concat('bellora')) { ok = g.startMatch({ player: run.player, enemy, stage: st, level, mode: 'versus', vs: { label: (run.kind === 'arcade' ? 'ARCADE · LAWAN ' + (run.wins + 1) + ' / ' + run.queue.length : 'SURVIVAL · LAWAN ' + (run.wins + 1)) } }); if (ok) break; }
if (!ok) { toast('Aset belum siap, coba lagi.'); run = null; window.FrontEnd?.home(); }