Fix livre
This commit is contained in:
parent
7d9f6fd6c3
commit
f6c81fd68d
@ -2,6 +2,7 @@
|
||||
* Extend the base Dialog entity by defining a custom window to perform spell.
|
||||
* @extends {Dialog}
|
||||
*/
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
export class RdDTMRDialog extends Dialog {
|
||||
|
||||
@ -28,8 +29,13 @@ export class RdDTMRDialog extends Dialog {
|
||||
dialogOptions.height = 960;
|
||||
super(dialogConf, dialogOptions);
|
||||
|
||||
this.col1_y = 30;
|
||||
this.col2_y = 55;
|
||||
this.cellh = 55;
|
||||
this.cellw = 55;
|
||||
this.sort = sort;
|
||||
this.actor = actor;
|
||||
this.TMRimg = new Image();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -38,22 +44,59 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
loadImage(url) {
|
||||
return new Promise(r => { let i = new Image(); i.onload = (() => r(i)); i.src = url; });
|
||||
updateTMR( myself ) {
|
||||
function rads(x) { return Math.PI*x/180; }
|
||||
|
||||
console.log("IMG", this, this.TMRimg);
|
||||
|
||||
let canvas = document.getElementById('canvas_tmr');
|
||||
let ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(myself.TMRimg, 0, 0, 720, 860);
|
||||
|
||||
// Draw current position
|
||||
let coordTMR = myself.actor.data.data.reve.tmrpos.coord;
|
||||
console.log("TMR coord", coordTMR);
|
||||
let coordXY = RdDUtility.convertToCellCoord( coordTMR );
|
||||
let basey = (coordXY.x % 2 == 0) ? this.col1_y : this.col2_y;
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.beginPath();
|
||||
ctx.arc(28+(coordXY.x * this.cellw), basey+28+(coordXY.y * this.cellh), 15, 0, rads(360), false);
|
||||
ctx.fill();
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
setTimeout(myself.updateTMR, 500, myself);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async init_canvas() {
|
||||
var ctx = document.getElementById('canvas_tmr');
|
||||
ctx = ctx.getContext('2d');
|
||||
let img = await this.loadImage("systems/foundryvtt-reve-de-dragon/styles/ui/tmp_main_r1.webp");
|
||||
await ctx.drawImage(img, 0, 0, 720, 860);
|
||||
getCursorPosition(event) {
|
||||
let canvasRect = event.currentTarget.getBoundingClientRect();
|
||||
let x = event.clientX - canvasRect.left;
|
||||
let y = event.clientY - canvasRect.top;
|
||||
|
||||
let cellx = Math.floor( x / this.cellw);// [From 0 -> 12]
|
||||
if (cellx % 2 == 0)
|
||||
y -= this.col1_y;
|
||||
else
|
||||
y -= this.col2_y;
|
||||
let celly = Math.floor( y / this.cellh);// [From 0 -> 14]
|
||||
|
||||
let coordTMR = RdDUtility.convertToTMRCoord(cellx, celly);
|
||||
let cellDescr = RdDUtility.getTMRDescription( coordTMR );
|
||||
this.actor.data.data.reve.tmrpos.coord = coordTMR;
|
||||
console.log("TMR column is", coordTMR, cellx, celly, cellDescr);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
async activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
this.init_canvas();
|
||||
this.TMRimg.onload = this.updateTMR(this);
|
||||
this.TMRimg.src = "systems/foundryvtt-reve-de-dragon/styles/ui/tmp_main_r1.webp";
|
||||
|
||||
html.find('#canvas_tmr').click(event => {
|
||||
this.getCursorPosition(event);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,13 @@ const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
|
||||
"malaise": { "4":2, "6":3, "8":4, "10":6 },
|
||||
"difficile": { "4":3, "6":4, "8":6 },
|
||||
"tresdifficile": { "4":4, "6":6 } }
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = { A1: { type: "cite", label: "Cité VIDE"}, B1: { type:"plaines", label: "Plaines d'ASSORH"}, C1: { type:"necropole", label: "Nécropole de KROAK"}, D1: { type: "fleuve", label: "Fleuve de l'Oubli"}, E1: { type: "monts", label: "Monts de KANAI"},
|
||||
F1: { type: "cite", label: "Cité GLAUQUE"}, G1: { type: "desolation", label: "Désolation de JAMAIS"}, H1: {type: "lac", label: "Lac d'ANTI-CALME"}, I1: { type: "plaines", label: "Plaines GRISES"}, J1: { type: "monts", label: "Monts FAINEANTS"},
|
||||
K1: { type: "cite", label: "Cité d'ONKAUS"}, L1: { type: "fleuve", label: "Fleuve de l'Oubli"}, M1: { type: "cite", label: "Cité JALOUSE"}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -515,4 +521,25 @@ export class RdDUtility {
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static convertToTMRCoord( x, y )
|
||||
{
|
||||
y = y + 1
|
||||
let letterX = String.fromCharCode(65+x);
|
||||
return letterX+y
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static convertToCellCoord( coordTMR )
|
||||
{
|
||||
let x = coordTMR.charCodeAt(0) - 65;
|
||||
let y = coordTMR.substr(1) - 1;
|
||||
return {x: x, y: y}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getTMRDescription( coordTMR)
|
||||
{
|
||||
return TMRMapping[coordTMR];
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.4 MiB |
@ -224,7 +224,7 @@
|
||||
"label": "Points de Rêve actuels"
|
||||
},
|
||||
"tmrpos": {
|
||||
"coord": "",
|
||||
"coord": "A1",
|
||||
"label": "Position TMR"
|
||||
},
|
||||
"reserve": {
|
||||
|
Loading…
Reference in New Issue
Block a user