From 1dffef8200d293256a1fc50ce0d029cc44f6f884 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 25 Aug 2026 17:09:28 +0200 Subject: [PATCH] Busfahrt: nur EIN Onboarding (Welcome-Overlay abgeloest) Ursache 2x: Busfahrt zeigte sein eigenes #welcome-overlay UND das GgsQuickIntro-Onboarding. Jetzt ist GgsQuickIntro das einzige Start-Gate: - ggs-quick-intro: onStart-Callback (feuert einmal beim Schliessen bzw. sofort wenn schon gesehen), isSeen exportiert. - Busfahrt: welcome-overlay wird nicht mehr gezeigt; onStart -> startGame; startGame wartet per Retry auf boot() (kein Timing-Problem). Co-Authored-By: Claude Opus 4.8 --- App/assets/js/ggs-quick-intro.js | 21 ++++++++++++++++++--- App/sims/busfahrt/game.html | 11 +++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/App/assets/js/ggs-quick-intro.js b/App/assets/js/ggs-quick-intro.js index c729db6..5a296a0 100644 --- a/App/assets/js/ggs-quick-intro.js +++ b/App/assets/js/ggs-quick-intro.js @@ -86,6 +86,17 @@ var _config = null; var _back = null; var _page = 1; + var _startFired = false; + + // onStart wird EINMAL ausgelöst — wenn das Onboarding geschlossen wird + // (oder sofort, falls schon gesehen). Sims können daran den Spielstart hängen. + function fireStart() { + if (_startFired) return; + if (_config && typeof _config.onStart === 'function') { + _startFired = true; + try { _config.onStart(); } catch (_) {} + } + } function lsKey() { return _config && _config.simId ? 'ggs.intro.' + _config.simId : null; } function markSeen() { try { var k = lsKey(); if (k) localStorage.setItem(k, '1'); } catch (_) {} } @@ -97,14 +108,14 @@ _back = null; document.removeEventListener('keydown', onKey); } - function onKey(e) { if (e.key === 'Escape') close(); } + function onKey(e) { if (e.key === 'Escape') { markSeen(); close(); fireStart(); } } function onBackClick(e) { - if (e.target === _back) { markSeen(); close(); return; } + if (e.target === _back) { markSeen(); close(); fireStart(); return; } var a = e.target && e.target.dataset && e.target.dataset.action; if (a === 'next') { _page = 2; render(); } else if (a === 'back') { _page = 1; render(); } - else if (a === 'start') { markSeen(); close(); } + else if (a === 'start') { markSeen(); close(); fireStart(); } } function render() { @@ -180,9 +191,13 @@ if (!isSeen()) { // Kleiner Delay, damit Sim-Boot zuerst sein DOM aufbauen kann. setTimeout(open, 400); + } else { + // Schon gesehen: kein Onboarding, aber die Sim darf trotzdem starten. + fireStart(); } }, open: open, close: close, + isSeen: isSeen, }; })(); diff --git a/App/sims/busfahrt/game.html b/App/sims/busfahrt/game.html index 2c4bcc0..060504d 100644 --- a/App/sims/busfahrt/game.html +++ b/App/sims/busfahrt/game.html @@ -842,6 +842,7 @@ window.addEventListener('DOMContentLoaded', function () { if (window.GgsQuickIntro) GgsQuickIntro.init({ simId: 'busfahrt', + onStart: function () { startGame(); }, // Onboarding schliessen startet die Tour title: '🚌 Busfahrt', lead: 'Du fährst mit dem Reisebus Aufträge quer durch Europa. Wäge gut ab: Zeit, Distanz und Bezahlung entscheiden über deinen Gewinn.', steps: [ @@ -1315,8 +1316,8 @@ async function boot() { ? (ECON.targetBudget[lvl] || 7500) : ECON.targetBudget; document.getElementById('welcome-target').textContent = formatEur(target); - - document.getElementById('welcome-overlay').classList.add('show'); + // Kein separates Welcome-Overlay mehr: das GgsQuickIntro-Onboarding ist das + // einzige Start-Gate — dessen Schliessen ruft startGame() (siehe onStart). } function updateTopbar() { @@ -1334,9 +1335,11 @@ function updateTopbar() { } function startGame() { - document.getElementById('welcome-overlay').classList.remove('show'); + if (!game) { setTimeout(startGame, 60); return; } // auf boot() warten + const wo = document.getElementById('welcome-overlay'); + if (wo) wo.classList.remove('show'); initAudioOnFirstInteraction(); - if (game && !game._startedAt) game._startedAt = Date.now(); + if (!game._startedAt) game._startedAt = Date.now(); loadNextOrder(); }