Création de tâches dans la fenêtre de jets

This commit is contained in:
2025-10-18 00:26:10 +02:00
parent e16f89743a
commit e21f7e398a
9 changed files with 73 additions and 7 deletions

View File

@@ -316,6 +316,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
constructor(rollData, rollOptions) {
super()
this.hooks = []
this.rollData = RollDialog.$prepareRollData(rollData)
this.rollOptions = {
callbacks: [
@@ -328,8 +329,23 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
}
this.chatRollResult = new ChatRollResult()
this.selectType()
this.registerHooks(rollData);
}
registerHooks(rollData) {
ROLL_PARTS.filter(p => p.isValid(rollData))
.forEach(p => p.getHooks(this).forEach(h => {
const hook = h.hook;
const id = Hooks.on(hook, h.fn)
this.hooks.push({ hook, id })
}))
}
unregisterHooks() {
this.hooks.forEach(h => Hooks.off(h.hook, h.id))
}
selectType() {
const selectedType = this.getSelectedType();
this.rollData.type.label = selectedType.title(this.rollData)
@@ -445,6 +461,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
if (this.rollOptions.onClose) {
this.rollOptions.onClose()
}
this.unregisterHooks()
return await super.close(options)
}