added play button

This commit is contained in:
Didictateur 2025-05-05 20:07:38 +02:00
parent 34fef7be0a
commit 890036094a
5 changed files with 56 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -20,6 +20,7 @@
.menu-item {
position: relative;
list-style: none;
z-index: 9999;
}
.menu-item > a {
color: white;
@ -124,11 +125,17 @@
<script>
let currentScript = null;
function removePlayButton() {
const btn = document.getElementById("playButton");
if (btn) btn.remove();
}
function loadText(scriptName, nb) {
if (window.cleanup) {
window.cleanup();
}
removePlayButton();
window.txtNumber = nb;
const container = document.getElementById("anotherCanvasContainer");
@ -150,6 +157,7 @@
if (window.cleanup) {
window.cleanup();
}
removePlayButton();
const container = document.getElementById("canvasContainer");
container.innerHTML = `<canvas id="myCanvas" width="1000" height="1000"></canvas>`;

View file

@ -2,6 +2,28 @@ import { Deck } from "../deck";
import { Hand } from "../hand";
import { Game } from "../game";
function showPlayButton() {
const button = document.createElement('button');
button.id = 'playButton';
button.textContent = 'Jouer';
button.style.position = 'absolute';
button.style.left = `${1050/2}px`;
button.style.top = `${1050/2}px`;
button.style.transform = 'translate(-50%, -50%)';
button.style.fontSize = '2rem';
button.style.padding = '1em 2em';
button.style.zIndex = '1000';
document.body.appendChild(button);
button.addEventListener('click', async () => {
button.disabled = true;
button.textContent = 'Chargement...';
await initDisplay();
button.remove();
});
}
class RiichiGameManager {
// Configuration globale
private readonly CANVAS_ID: string = "myCanvas";
@ -249,5 +271,5 @@ declare global {
// Initialisation automatique si le script est chargé directement
if (typeof window !== 'undefined') {
initDisplay().catch(console.error);
showPlayButton();
}

View file

@ -2,6 +2,28 @@ import { Deck } from "../deck";
import { Hand } from "../hand";
import { Game } from "../game";
function showPlayButton() {
const button = document.createElement('button');
button.id = 'playButton';
button.textContent = 'Jouer';
button.style.position = 'absolute';
button.style.left = `${1050/2}px`;
button.style.top = `${1050/2}px`;
button.style.transform = 'translate(-50%, -50%)';
button.style.fontSize = '2rem';
button.style.padding = '1em 2em';
button.style.zIndex = '1000';
document.body.appendChild(button);
button.addEventListener('click', async () => {
button.disabled = true;
button.textContent = 'Chargement...';
await initDisplay();
button.remove();
});
}
class RiichiGameManager {
// Configuration globale
private readonly CANVAS_ID: string = "myCanvas";
@ -252,5 +274,5 @@ declare global {
// Initialisation automatique si le script est chargé directement
if (typeof window !== 'undefined') {
initDisplay().catch(console.error);
showPlayButton();
}