Fix: tooltips sorts TMRs

This commit is contained in:
2023-11-10 03:39:35 +01:00
parent ecb47addba
commit 1759e6d1c3
5 changed files with 141 additions and 115 deletions

View File

@ -62,8 +62,8 @@ export class RdDTMRDialog extends Dialog {
this.loadCasesSpeciales();
this.allTokens = [];
this.rencontreState = 'aucune';
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
this.pixiTMR = new PixiTMR(this, this.pixiApp);
this.pixiTMR = new PixiTMR(this);
this.subdialog = undefined
this.callbacksOnAnimate = [];
@ -128,7 +128,7 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
createPixiSprites() {
EffetsDraconiques.carteTmr.createSprite(this.pixiTMR);
this.pixiTMR.setup()
this.updateTokens();
this.forceDemiRevePositionView();
}
@ -139,13 +139,9 @@ export class RdDTMRDialog extends Dialog {
this.demiReve = this._tokenDemiReve();
this._trackToken(this.demiReve);
}
let tokens = this._getTokensCasesTmr()
.concat(this._getTokensRencontres())
.concat(this._getTokensSortsReserve());
for (let t of tokens) {
this._trackToken(t);
}
this._getTokensCasesTmr().forEach(t => this._trackToken(t))
this._getTokensRencontres().forEach(t => this._trackToken(t))
this._getTokensSortsReserve().forEach(t => this._trackToken(t))
}
/* -------------------------------------------- */
@ -204,6 +200,7 @@ export class RdDTMRDialog extends Dialog {
if (this.subdialog) {
return this.forceTMRContinueAction();
}
let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
if (move == 'top') oddq.row -= 1;
@ -230,7 +227,8 @@ export class RdDTMRDialog extends Dialog {
document.getElementsByClassName("tmr-row")
.item(0)
.insertCell(0).append(this.pixiApp.view);
.insertCell(0)
.append(this.pixiTMR.view);
if (this.viewOnly) {
this.html.find('.lancer-sort').remove();
@ -241,24 +239,17 @@ export class RdDTMRDialog extends Dialog {
HtmlUtility.showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionnelles.isUsing("appliquer-fatigue"));
HtmlUtility.showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
this.html.find('tr.tmr-row *').click((event) => {
this.subdialog?.bringToTop();
});
this.html.find('tr.tmr-row *').click(event => this.subdialog?.bringToTop());
// Roll Sort
this.html.find('.lancer-sort').click((event) => {
this.actor.rollUnSort(this._getActorCoord());
});
this.html.find('.lire-signe-draconique').click((event) => {
this.actor.rollLireSigneDraconique(this._getActorCoord());
});
this.html.find('#dir-top').click((event) => this.moveFromKey("top"));
this.html.find('#dir-top-left').click((event) => this.moveFromKey("top-left"));
this.html.find('#dir-top-right').click((event) => this.moveFromKey("top-right"));
this.html.find('#dir-bottom-left').click((event) => this.moveFromKey("bottom-left"));
this.html.find('#dir-bottom-right').click((event) => this.moveFromKey("bottom-right"));
this.html.find('#dir-bottom').click((event) => this.moveFromKey("bottom"));
this.html.find('.lancer-sort').click(event => this.actor.rollUnSort(this._getActorCoord()));
this.html.find('.lire-signe-draconique').click(event => this.actor.rollLireSigneDraconique(this._getActorCoord()));
this.html.find('#dir-top').click(event=> this.moveFromKey("top"));
this.html.find('#dir-top-left').click(event=> this.moveFromKey("top-left"));
this.html.find('#dir-top-right').click(event=> this.moveFromKey("top-right"));
this.html.find('#dir-bottom-left').click(event=> this.moveFromKey("bottom-left"));
this.html.find('#dir-bottom-right').click(event=> this.moveFromKey("bottom-right"));
this.html.find('#dir-bottom').click(event=> this.moveFromKey("bottom"));
// Gestion du cout de montée en points de rêve
let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1) - this.actor.countMonteeLaborieuse();
@ -382,19 +373,8 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
$marquerCasesTMR(listCoordTMR) {
this.currentRencontre.graphics = []; // Keep track of rectangles to delete it
this.currentRencontre.locList = duplicate(listCoordTMR); // And track of allowed location
for (let coordTMR of listCoordTMR) {
const rect = this._getCaseRectangleCoord(coordTMR);
const rectDraw = new PIXI.Graphics();
rectDraw.beginFill(0xffff00, 0.3);
// set the line style to have a width of 5 and set the color to red
rectDraw.lineStyle(5, 0xff0000);
// draw a rectangle
rectDraw.drawRect(rect.x, rect.y, rect.w, rect.h);
this.pixiApp.stage.addChild(rectDraw);
this.currentRencontre.graphics.push(rectDraw); // garder les objets pour gestion post-click
}
this.currentRencontre.graphics = listCoordTMR.map(coordTMR => this.pixiTMR.addMarkTMR(coordTMR))
}
/* -------------------------------------------- */
@ -907,15 +887,11 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
nettoyerRencontre() {
if (!this.currentRencontre) return; // Sanity check
if (this.currentRencontre.graphics) {
for (let drawRect of this.currentRencontre.graphics) {
// Suppression des dessins des zones possibles
this.pixiApp.stage.removeChild(drawRect);
}
}
this.currentRencontre = undefined; // Nettoyage de la structure
this.rencontreState = 'aucune'; // Et de l'état
// Suppression des dessins des zones possibles
this.currentRencontre?.graphics?.forEach(graphic => this.pixiTMR.removeGraphic(graphic))
// Nettoyage de la structureet de l'état
this.currentRencontre = undefined;
this.rencontreState = 'aucune';
}
/* -------------------------------------------- */
@ -1106,18 +1082,10 @@ export class RdDTMRDialog extends Dialog {
await this.postRencontre(tmr);
return tmr;
}
/* -------------------------------------------- */
/** Retourne les coordonnées x, h, w, h du rectangle d'une case donnée */
_getCaseRectangleCoord(coord) {
return this.pixiTMR.getCaseRectangle(TMRUtility.coordTMRToOddq(coord));
}
/* -------------------------------------------- */
_removeTokens(filter) {
const tokensToRemove = this.allTokens.filter(filter);
for (let token of tokensToRemove) {
this.pixiApp.stage.removeChild(token.sprite);
}
this.allTokens.filter(filter).forEach(token => this.pixiTMR.removeToken(token))
}
/* -------------------------------------------- */
@ -1125,7 +1093,9 @@ export class RdDTMRDialog extends Dialog {
if (this.demiReve === token && this.isDemiReveCache()) {
return;
}
this.pixiTMR.setPosition(token.sprite, TMRUtility.coordTMRToOddq(token.coordTMR()));
this.allTokens.push(token);
this.pixiTMR.positionToken(token);
if (!this.allTokens.includes(token)) {
this.allTokens.push(token);
}
}
}