better textes

This commit is contained in:
Didictateur 2025-05-03 18:37:25 +02:00
parent c3544be414
commit 34fef7be0a
28 changed files with 101 additions and 137 deletions

1
build/txt.js Normal file
View file

@ -0,0 +1 @@
(()=>{"use strict";const t=document.getElementById("myTextCanvas"),n=t.getContext("2d");t.width=800,t.height=1050;const e=window.txtNumber;n.fillStyle="#007733",n.fillRect(0,0,800,1050),function(t,n){return e=this,o=void 0,f=function*(){console.log(t,"\n");const e=yield fetch(t).then((t=>t.text())),o="#ffffff";n.fillStyle=o,n.font="30px Garamond";let l=!1,f="",i="",c="",a=1,r=0;for(var d of e)"*"===d?(i=""===i?"bold ":"",n.font=c+i+30+"px Garamond"):"~"===d?(c=""===c?"italic ":"",n.font=c+i+30+"px Garamond"):"#"===d?(f="#",l=!0):"{"===d?(l=!1,n.fillStyle=f):"}"===d?(f="",n.fillStyle=o):l?f+=d:"\n"===d?(a++,r=0):(n.fillText(d,10+r,20+35*a),r+=n.measureText(d).width)},new((l=void 0)||(l=Promise))((function(t,n){function i(t){try{a(f.next(t))}catch(t){n(t)}}function c(t){try{a(f.throw(t))}catch(t){n(t)}}function a(n){var e;n.done?t(n.value):(e=n.value,e instanceof l?e:new l((function(t){t(e)}))).then(i,c)}a((f=f.apply(e,o||[])).next())}));var e,o,l,f}("src/text/txt"+e+".txt",n).catch((t=>console.error(t)))})();

View file

@ -94,25 +94,25 @@
<ul class="menu-item"> <ul class="menu-item">
<a href="#">Partie réelle</a> <a href="#">Partie réelle</a>
<div class="dropdown"> <div class="dropdown">
<a href="#" onclick="loadScript('')">Chap 1: Placement des joueurs</a> <a href="#" onclick="loadScript('dp16.js')">Chap 1: Placement des joueurs</a>
<a href="#" onclick="loadScript('')">Chap 2: Construction des murs</a> <a href="#" onclick="loadScript('dp17.js')">Chap 2: Construction des murs</a>
<a href="#" onclick="loadScript('')">Chap 3: Désigner la pioche</a> <a href="#" onclick="loadScript('dp18.js')">Chap 3: Désigner la pioche</a>
<a href="#" onclick="loadScript('')">Chap 4: Le mur mort</a> <a href="#" onclick="loadScript('dp19.js')">Chap 4: Le mur mort</a>
</ul> </ul>
<ul class="menu-item"> <ul class="menu-item">
<a href="#" onclick="loadScript('')">Riichi à trois</a> <a href="#" onclick="loadScript('dp20.js')">Riichi à trois</a>
</ul> </ul>
<ul class="menu-item"> <ul class="menu-item">
<a href="#">Yaku trainer</a> <a href="#">Yaku trainer</a>
<div class="dropdown"> <div class="dropdown">
<a href="#" onclick="loadScript('')">Yaku 1</a> <a href="#" onclick="loadScript('dp21.js')">Yaku 1</a>
</div> </div>
</ul> </ul>
<ul class="menu-item"> <ul class="menu-item">
<a href="#">MCR</a> <a href="#">MCR</a>
<div class="dropdown"> <div class="dropdown">
<a href="#" onclick="loadScript('')">Chap 1:</a> <a href="#" onclick="loadScript('dp22.js')">Chap 1:</a>
<a href="#" onclick="loadScript('')">Chap 2:</a> <a href="#" onclick="loadScript('dp23.js')">Chap 2:</a>
</div> </div>
</ul> </ul>
</nav> </nav>
@ -125,10 +125,11 @@
<script> <script>
let currentScript = null; let currentScript = null;
function loadText(scriptName) { function loadText(scriptName, nb) {
if (window.cleanup) { if (window.cleanup) {
window.cleanup(); window.cleanup();
} }
window.txtNumber = nb;
const container = document.getElementById("anotherCanvasContainer"); const container = document.getElementById("anotherCanvasContainer");
container.innerHTML = `<canvas id="myTextCanvas" width="1000" height="1000"></canvas>`; container.innerHTML = `<canvas id="myTextCanvas" width="1000" height="1000"></canvas>`;
@ -166,7 +167,7 @@
if (txt) { if (txt) {
const number = scriptName.substring(2, scriptName.length - 3); const number = scriptName.substring(2, scriptName.length - 3);
loadText("txt" + number + ".js"); loadText("txt.js", number);
} }
} }

View file

@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"@types/node": "^22.15.3",
"ts-loader": "^9.5.2", "ts-loader": "^9.5.2",
"webpack": "^5.98.0", "webpack": "^5.98.0",
"webpack-cli": "^6.0.1" "webpack-cli": "^6.0.1"

5
src/text/default.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

View file

@ -7,12 +7,14 @@ const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>; const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w; canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h; canvas.height = BG_RECT.h;
const number = (window as any).txtNumber;
const path = "src/text/" const path = "src/text/"
ctx.fillStyle = BG_RECT.color; ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h); ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt0.txt", ctx).catch(error => console.error(error)); const filePath = path + "txt" + number + ".txt";
drawText(filePath, ctx).catch(error => console.error(error));
export {}; export {};

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt1.txt", ctx).catch(error => console.error(error));
export {};

5
src/text/txt10.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt11.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt12.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt13.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt14.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt15.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt16.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt17.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt18.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt19.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt2.txt", ctx).catch(error => console.error(error));
export {};

5
src/text/txt20.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt21.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt22.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt23.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt3.txt", ctx).catch(error => console.error(error));
export {};

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt4.txt", ctx).catch(error => console.error(error));
export {};

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt5.txt", ctx).catch(error => console.error(error));
export {};

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt6.txt", ctx).catch(error => console.error(error));
export {};

View file

@ -1,18 +0,0 @@
import { drawText } from "./parse"
const CANVAS_ID = "myTextCanvas";
const BG_RECT = { x: 0, y: 0, w: 800, h: 1050, color: "#007733" };
const canvas = document.getElementById(CANVAS_ID) as HTMLCanvasElement;
const ctx = canvas.getContext("2d") as NonNullable<CanvasRenderingContext2D>;
canvas.width = BG_RECT.w;
canvas.height = BG_RECT.h;
const path = "src/text/";
ctx.fillStyle = BG_RECT.color;
ctx.fillRect(BG_RECT.x, BG_RECT.y, BG_RECT.w, BG_RECT.h);
drawText(path + "txt7.txt", ctx).catch(error => console.error(error));
export {};

5
src/text/txt8.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.

5
src/text/txt9.txt Normal file
View file

@ -0,0 +1,5 @@
Cette page n'a pas *encore* été implémentée.
Merci de votre compréhension et de votre patience.