From a4695e7799f77b2d2b14db876407dec9ae135ebf Mon Sep 17 00:00:00 2001 From: Melon-PieldeSapo Date: Tue, 19 Aug 2025 11:49:04 +0200 Subject: [PATCH] character generator - v13 : fix stat popup at the time as skills --- module/windows/actor-generator.js | 65 ++++++++++++++++++------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/module/windows/actor-generator.js b/module/windows/actor-generator.js index fc635c1..f5bfe11 100644 --- a/module/windows/actor-generator.js +++ b/module/windows/actor-generator.js @@ -433,6 +433,43 @@ export class DLActorGenerator extends FormApplication { } } + /** + * Ask the user for the stat options, and apply the bonuses to the form. + * @param {Array} list_option_stats_and_saves + * @returns + */ + async statOptions(list_option_stats_and_saves){ + return new Promise((resolve) => { + for(let i =0;i {this._element.find(`input[name="system.stats.${option_stats_and_saves.stats[j]}.bonus"]`).prop("value", (parseInt(option_stats_and_saves.modification) + parseInt(prev_bonus))); + resolve(); + } + }); + } + let d = new foundry.applications.api.DialogV2({ + window: {title: game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupTitle")}, + classes: ["macro-popup-dialog"], + content: `

${game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupText")} (${option_stats_and_saves.modification})

`, + buttons: buttons_options, + default: "1", + //render: html => console.log("Register interactivity in the rendered dialog"), + //close: html => console.log("This always is logged no matter which option is chosen") + }); + d.render({force: true}); + } + } + }); + } + /** * Apply the changed or dropped class into the generator, stats, skills and table configuration. * @param {uuid} classUuid @@ -477,37 +514,11 @@ export class DLActorGenerator extends FormApplication { * Stats */ //stats options - let list_option_stats_and_saves = droppedObject.system.selected_adjustment.choose_stat; - for(let i =0;i this._element.find(`input[name="system.stats.${option_stats_and_saves.stats[j]}.bonus"]`).prop("value", (parseInt(option_stats_and_saves.modification) + parseInt(prev_bonus))) - }); - } - let d = new foundry.applications.api.DialogV2({ - window: {title: game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupTitle")}, - classes: ["macro-popup-dialog"], - content: `

${game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupText")} (${option_stats_and_saves.modification})

`, - buttons: buttons_options, - default: "1", - //render: html => console.log("Register interactivity in the rendered dialog"), - //close: html => console.log("This always is logged no matter which option is chosen") - }); - d.render({force: true}); - } - } + await this.statOptions(droppedObject.system.selected_adjustment.choose_stat) /** * Skills * */ - await this.applyClassSkills(this._element);