diff --git a/module/actor.js b/module/actor.js index b3f0e5f5..359ad860 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2149,7 +2149,6 @@ export class RdDActor extends RdDBaseActor { return; } - const draconicList = this.computeDraconicAndSortIndex(sorts); const reve = duplicate(this.system.carac.reve); @@ -2169,7 +2168,10 @@ export class RdDActor extends RdDBaseActor { diffLibre: RdDItemSort.getDifficulte(sorts[0], -7), // Per default at startup coutreve: Array(30).fill().map((item, index) => 1 + index), }, - callbackAction: r => this._rollUnSortResult(r) + callbackAction: async r => { + await this._rollUnSortResult(r); + if (!r.isSortReserve) this.tmrApp?.close(); + } }); this.tmrApp?.setTMRPendingAction(dialog); } @@ -2262,17 +2264,11 @@ export class RdDActor extends RdDBaseActor { reveActuel = Math.max(reveActuel - rollData.depenseReve, 0); await this.update({ "system.reve.reve.value": reveActuel }); - if (rollData.isSortReserve) { - this.tmrApp.maximize(); // Re-display TMR - } else { - this.tmrApp.close(); // Close TMR ! - } // Final chat message await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-sort.html'); if (reveActuel == 0) { // 0 points de reve ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" }); - closeTMR = true; } } diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index b3d0c63f..415f8574 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -39,7 +39,8 @@ export class RdDTMRDialog extends Dialog { content: html, buttons: { closeButton: { - label: "Fermer", callback: html => this.close() } + label: "Fermer", callback: html => this.close() + } }, default: "closeButton" } @@ -93,6 +94,9 @@ export class RdDTMRDialog extends Dialog { setTMRPendingAction(dialog) { this.subdialog = dialog + if (dialog instanceof Application) { + dialog.bringToTop(); + } } isDemiReveCache() { @@ -579,9 +583,12 @@ export class RdDTMRDialog extends Dialog { _presentCite(tmr) { const presentCite = this.casesSpeciales.find(c => EffetsDraconiques.presentCites.isCase(c, tmr.coord)); if (presentCite) { - this.minimize(); const caseData = presentCite; - EffetsDraconiques.presentCites.choisirUnPresent(caseData, (present => this._utiliserPresentCite(presentCite, present, tmr))); + const dialog = EffetsDraconiques.presentCites.choisirUnPresent(caseData, present => { + this._utiliserPresentCite(presentCite, present, tmr) + this.restoreTMRAfterAction(); + }); + this.setTMRPendingAction(dialog); } return presentCite; } @@ -607,8 +614,6 @@ export class RdDTMRDialog extends Dialog { presentCite: presentCite }; await this._tentativeMaitrise(rencontreData); - - this.maximize(); this.postRencontre(tmr); } @@ -815,22 +820,22 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async _maitriserTMR(rollData, callbackMaitrise) { - this.minimize(); // Hide rollData.isTMRCache = rollData.actor.isTMRCache(); const dialog = await RdDRoll.create(this.actor, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-maitrise-tmr.html', - close: html => { this.restoreTMRAfterAction(); } }, { name: rollData.maitrise.verbe, label: rollData.maitrise.action, callbacks: [ this.actor.createCallbackExperience(), + { action: r => { this.restoreTMRAfterAction() } }, { action: callbackMaitrise } ] } ); dialog.render(true); + this.setTMRPendingAction(dialog); } /* -------------------------------------------- */ diff --git a/module/rdd-tmr-rencontre-dialog.js b/module/rdd-tmr-rencontre-dialog.js index b5426e93..97c4dc2d 100644 --- a/module/rdd-tmr-rencontre-dialog.js +++ b/module/rdd-tmr-rencontre-dialog.js @@ -34,6 +34,7 @@ export class RdDTMRRencontreDialog extends Dialog { async onButtonAction(action) { this.toClose = true; + await this.actor.tmrApp?.restoreTMRAfterAction(); this.actor.tmrApp?.onActionRencontre(action, this.tmr, this.rencontre) } @@ -41,7 +42,6 @@ export class RdDTMRRencontreDialog extends Dialog { async close() { if (this.actor.tmrApp){ if (this.toClose) { - this.actor.tmrApp?.restoreTMRAfterAction(); return await super.close(); } else { diff --git a/module/tmr/present-cites.js b/module/tmr/present-cites.js index ff7027e4..d6bfb4d6 100644 --- a/module/tmr/present-cites.js +++ b/module/tmr/present-cites.js @@ -49,12 +49,13 @@ export class PresentCites extends Draconique { const presents = await game.system.rdd.rencontresTMR.getPresentsCite() const buttons = {}; presents.forEach(r => buttons['present'+r.id] = { icon: '', label: r.name, callback: async () => onChoixPresent(r) }); - let d = new Dialog({ + let dialog = new Dialog({ title: "Présent des cités", content: `La ${this.tmrLabel(casetmr)} vous offre un présent, faites votre choix`, buttons: buttons }); - d.render(true); + dialog.render(true); + return dialog } async ouvrirLePresent(actor, casetmr) {