forked from public/foundryvtt-reve-de-dragon
Fix TMR minimize/maximize
Au lieu de minimiser les TMRs, les actions dans les TMRs sont bloquées tant qu'une action liée au TMRs est en cours.
This commit is contained in:
@ -2,7 +2,6 @@ import { SHOW_DICE } from "./constants.js";
|
||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { tmrConstants } from "./tmr-constants.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
@ -39,7 +38,8 @@ export class RdDTMRDialog extends Dialog {
|
||||
title: "Terres Médianes de Rêve",
|
||||
content: html,
|
||||
buttons: {
|
||||
closeButton: { label: "Fermer", callback: html => this.close(html) }
|
||||
closeButton: {
|
||||
label: "Fermer", callback: html => this.close() }
|
||||
},
|
||||
default: "closeButton"
|
||||
}
|
||||
@ -63,6 +63,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.rencontreState = 'aucune';
|
||||
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
||||
this.pixiTMR = new PixiTMR(this, this.pixiApp);
|
||||
this.subdialog = undefined
|
||||
|
||||
this.callbacksOnAnimate = [];
|
||||
if (!this.viewOnly) {
|
||||
@ -73,6 +74,27 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.pixiTMR.load((loader, resources) => this.createPixiSprites());
|
||||
}
|
||||
|
||||
async forceTMRDisplay() {
|
||||
this.bringToTop();
|
||||
if (this.subdialog) {
|
||||
this.subdialog.bringToTop();
|
||||
}
|
||||
}
|
||||
async restoreTMRAfterAction() {
|
||||
this.subdialog = undefined
|
||||
this.bringToTop();
|
||||
}
|
||||
|
||||
forceTMRContinueAction() {
|
||||
ui.notifications.warn('Vous devez finir votre action avant de continuer dans les TMR');
|
||||
this.subdialog.bringToTop();
|
||||
return;
|
||||
}
|
||||
|
||||
setTMRPendingAction(dialog) {
|
||||
this.subdialog = dialog
|
||||
}
|
||||
|
||||
isDemiReveCache() {
|
||||
return !game.user.isGM && this.actor.isTMRCache();
|
||||
}
|
||||
@ -174,6 +196,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async moveFromKey(move) {
|
||||
if (this.subdialog) {
|
||||
return this.forceTMRContinueAction();
|
||||
}
|
||||
let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
|
||||
|
||||
if (move == 'top') oddq.row -= 1;
|
||||
@ -198,7 +223,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
super.activateListeners(html);
|
||||
this.html = html;
|
||||
|
||||
document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view);
|
||||
document.getElementsByClassName("tmr-row")
|
||||
.item(0)
|
||||
.insertCell(0).append(this.pixiApp.view);
|
||||
|
||||
if (this.viewOnly) {
|
||||
this.html.find('.lancer-sort').remove();
|
||||
@ -209,6 +236,10 @@ 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();
|
||||
});
|
||||
|
||||
// Roll Sort
|
||||
this.html.find('.lancer-sort').click((event) => {
|
||||
this.actor.rollUnSort(this._getActorCoord());
|
||||
@ -230,7 +261,6 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.cumulFatigue += this.fatigueParCase;
|
||||
}
|
||||
await this.actor.reveActuelIncDec(reveCout);
|
||||
|
||||
// Le reste...
|
||||
this.updateValuesDisplay();
|
||||
let tmr = TMRUtility.getTMR(this._getActorCoord());
|
||||
@ -270,6 +300,10 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async close() {
|
||||
if (this.subdialog) {
|
||||
return this.forceTMRContinueAction()
|
||||
}
|
||||
|
||||
this.descenteTMR = true;
|
||||
if (this.actor.tmrApp) {
|
||||
this.actor.tmrApp = undefined; // Cleanup reference
|
||||
@ -292,6 +326,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
switch (action) {
|
||||
case 'derober':
|
||||
await this.derober();
|
||||
this.restoreTMRAfterAction();
|
||||
return;
|
||||
case 'refouler':
|
||||
await this.refouler();
|
||||
@ -304,6 +339,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
break;
|
||||
}
|
||||
await this.postRencontre(tmr);
|
||||
this.restoreTMRAfterAction();
|
||||
}
|
||||
|
||||
async derober() {
|
||||
@ -359,7 +395,6 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
checkQuitterTMR() {
|
||||
|
||||
if (this.actor.isDead()) {
|
||||
this._tellToGM("Vous êtes mort : vous quittez les Terres médianes !");
|
||||
this.close();
|
||||
@ -530,8 +565,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
await this.maitriserRencontre();
|
||||
}
|
||||
else {
|
||||
let dialog = new RdDTMRRencontreDialog(this, this.currentRencontre, tmr);
|
||||
const dialog = new RdDTMRRencontreDialog(this.actor, this.currentRencontre, tmr);
|
||||
dialog.render(true);
|
||||
this.setTMRPendingAction(dialog);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -586,7 +622,10 @@ export class RdDTMRDialog extends Dialog {
|
||||
? TMRUtility.getTMRType(tmr.coord) + " ??"
|
||||
: tmr.label + " (" + tmr.coord + ")");
|
||||
|
||||
const fakeDialogRencontre = { bringToTop: () => { } };
|
||||
this.setTMRPendingAction(fakeDialogRencontre)
|
||||
let myRoll = await RdDDice.rollTotal("1dt", { showDice: SHOW_DICE });
|
||||
this.restoreTMRAfterAction()
|
||||
if (myRoll == 7) {
|
||||
this._tellToUser(myRoll + ": Rencontre en " + locTMR);
|
||||
return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre())
|
||||
@ -781,7 +820,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
const dialog = await RdDRoll.create(this.actor, rollData,
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-maitrise-tmr.html',
|
||||
close: html => { this.maximize(); } // Re-display TMR
|
||||
close: html => { this.restoreTMRAfterAction(); }
|
||||
},
|
||||
{
|
||||
name: rollData.maitrise.verbe, label: rollData.maitrise.action,
|
||||
@ -861,7 +900,8 @@ 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
|
||||
for (let drawRect of this.currentRencontre.graphics) {
|
||||
// Suppression des dessins des zones possibles
|
||||
this.pixiApp.stage.removeChild(drawRect);
|
||||
}
|
||||
}
|
||||
@ -894,8 +934,8 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isConnaissanceFleuve(currentTMR, nextTMR) {
|
||||
return TMRUtility.getTMR(currentTMR).type == 'fleuve' &&
|
||||
isConnaissanceFleuve(tmrApp, nextTMR) {
|
||||
return TMRUtility.getTMR(tmrApp).type == 'fleuve' &&
|
||||
TMRUtility.getTMR(nextTMR).type == 'fleuve' &&
|
||||
EffetsDraconiques.isConnaissanceFleuve(this.actor);
|
||||
}
|
||||
@ -905,6 +945,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
if (this.viewOnly) {
|
||||
return;
|
||||
}
|
||||
if (this.subdialog) {
|
||||
return this.forceTMRContinueAction()
|
||||
}
|
||||
let clickOddq = TMRUtility.computeEventOddq(event);
|
||||
let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
|
||||
|
||||
@ -971,9 +1014,11 @@ export class RdDTMRDialog extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
async _messagerDemiReve(targetCoord) {
|
||||
/*
|
||||
TODO: si la case a un sort en réserve, lancer ce sort.
|
||||
TODO:
|
||||
Si la case a un sort en réserve, lancer ce sort.
|
||||
Si la case est le demi-rêve, ne pas lancer de sort.
|
||||
Si un lancement de sort est en cours, trouver un moyen de réafficher cette fenêtre si on essaie de lancer un sort (ou bloquer le lancer de sort)
|
||||
Si un lancement de sort est en cours, trouver un moyen de réafficher cette fenêtre
|
||||
si on essaie de lancer un sort (ou bloquer le lancer de sort)
|
||||
*/
|
||||
this.notifierResonanceSigneDraconique(targetCoord);
|
||||
await this.actor.rollUnSort(targetCoord);
|
||||
@ -990,6 +1035,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _deplacerDemiReve(targetCoord, deplacementType) {
|
||||
if (this.subdialog) {
|
||||
return this.forceTMRContinueAction()
|
||||
}
|
||||
if (this.currentRencontre != 'normal') {
|
||||
this.nettoyerRencontre();
|
||||
}
|
||||
@ -1039,6 +1087,10 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async positionnerDemiReve(coord) {
|
||||
if (this.subdialog) {
|
||||
return this.forceTMRContinueAction()
|
||||
}
|
||||
|
||||
await this.actor.updateCoordTMR(coord);
|
||||
this.forceDemiRevePositionView();
|
||||
let tmr = TMRUtility.getTMR(coord);
|
||||
|
Reference in New Issue
Block a user