forked from public/foundryvtt-reve-de-dragon
Création de tâches dans la fenêtre de jets
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user