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 <noreply@anthropic.com>
This commit is contained in:
2026-08-25 17:09:28 +02:00
parent 496fc59c7b
commit 1dffef8200
2 changed files with 25 additions and 7 deletions
+18 -3
View File
@@ -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,
};
})();
+7 -4
View File
@@ -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();
}