Fix multi-dialogs

Arrêter d'utiliser le jQuery $(selector) qui cause des effets de bord si
plusieurs élements de la page (ie: foundry) correspondent
au selector.

Stocker le html dans les Sheet/Dialogs lors de l'appel
activateListeners  afin de pouvoir s'y référer ensuite.

Utiliser this.html.find pour chercher dans le html de la fenêtre
courante.

Eliminer les référence par id html car l'id est unique (donc ne marche
pas en multi-fenêtres)
This commit is contained in:
Vincent Vandemeulebrouck
2022-12-09 02:00:31 +01:00
parent aefc7a434b
commit 63770790b9
42 changed files with 706 additions and 759 deletions

View File

@ -197,32 +197,33 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */
async activateListeners(html) {
super.activateListeners(html);
this.html = html;
document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view);
if (this.viewOnly) {
html.find('.lancer-sort').remove();
html.find('.lire-signe-draconique').remove();
this.html.find('.lancer-sort').remove();
this.html.find('.lire-signe-draconique').remove();
return;
}
HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
HtmlUtility._showControlWhen($(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
// Roll Sort
html.find('.lancer-sort').click((event) => {
this.html.find('.lancer-sort').click((event) => {
this.actor.rollUnSort(this._getActorCoord());
});
html.find('.lire-signe-draconique').click((event) => {
this.html.find('.lire-signe-draconique').click((event) => {
this.actor.rollLireSigneDraconique(this._getActorCoord());
});
html.find('#dir-top').click((event) => this.moveFromKey("top"));
html.find('#dir-top-left').click((event) => this.moveFromKey("top-left"));
html.find('#dir-top-right').click((event) => this.moveFromKey("top-right"));
html.find('#dir-bottom-left').click((event) => this.moveFromKey("bottom-left"));
html.find('#dir-bottom-right').click((event) => this.moveFromKey("bottom-right"));
html.find('#dir-bottom').click((event) => this.moveFromKey("bottom"));
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();
@ -244,7 +245,7 @@ export class RdDTMRDialog extends Dialog {
}
const coord = this._getActorCoord();
HtmlUtility._showControlWhen($(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord));
HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord));
let ptsreve = document.getElementById("tmr-pointsreve-value");
ptsreve.innerHTML = this.actor.system.reve.reve.value;
@ -279,7 +280,7 @@ export class RdDTMRDialog extends Dialog {
}
await this.actor.santeIncDec("fatigue", this.cumulFatigue)
}
await super.close(); // moving 1 cell costs 1 fatigue
await super.close();
}
/* -------------------------------------------- */