slop game oder so
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Disclaimer als HTML-Overlay. Der Text kommt aus dem Template
|
||||
* `_disclaimer_content.html` (einzige Quelle, auch für die Seite /disclaimer).
|
||||
* Die Bestätigung wird in localStorage gespeichert.
|
||||
* @module scenes/DisclaimerScene
|
||||
*/
|
||||
|
||||
import { DISCLAIMER } from '../content/texts.js';
|
||||
import { el, Overlay } from '../systems/Overlay.js';
|
||||
|
||||
export class DisclaimerScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super('Disclaimer');
|
||||
}
|
||||
|
||||
/** @param {{mandatory?: boolean}} data */
|
||||
create(data) {
|
||||
const services = this.registry.get('services');
|
||||
const context = this.registry.get('context');
|
||||
const mandatory = Boolean(data?.mandatory);
|
||||
|
||||
const content = [];
|
||||
const template = document.getElementById('disclaimer-content');
|
||||
if (template instanceof HTMLTemplateElement) {
|
||||
content.push(template.content.cloneNode(true));
|
||||
} else {
|
||||
content.push(el('p', '', DISCLAIMER.missingTemplate));
|
||||
}
|
||||
const link = /** @type {HTMLAnchorElement} */ (el('a', '', DISCLAIMER.openPage));
|
||||
link.href = context.disclaimerUrl;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener';
|
||||
const linkLine = el('p');
|
||||
linkLine.append(link);
|
||||
content.push(linkLine);
|
||||
|
||||
const close = () => {
|
||||
// Der Klick ist eine Nutzeraktion – guter Moment, um den Ton freizuschalten.
|
||||
services.audio.unlock();
|
||||
services.audio.play('ui-confirm');
|
||||
services.settings.acceptDisclaimer();
|
||||
this.overlay.close();
|
||||
this.events.emit('disclaimer-closed');
|
||||
this.scene.stop();
|
||||
};
|
||||
|
||||
this.overlay = new Overlay({
|
||||
id: 'disclaimer-overlay',
|
||||
content,
|
||||
buttons: [{ label: mandatory ? DISCLAIMER.accept : DISCLAIMER.close, onClick: close, testId: 'disclaimer-accept' }],
|
||||
// Beim ersten Start muss aktiv bestätigt werden; Esc schließt nur den erneuten Aufruf.
|
||||
onEscape: mandatory ? undefined : close,
|
||||
});
|
||||
this.events.once('shutdown', () => this.overlay?.element.isConnected && this.overlay.close());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user