Fix sélection cible parmi multiples
This commit is contained in:
parent
1c68c34641
commit
2e689f642a
@ -2,6 +2,7 @@
|
|||||||
## 12.0.27 - Les vêtements d'Astrobazzarh
|
## 12.0.27 - Les vêtements d'Astrobazzarh
|
||||||
- Ajout de la liste des armures dans l'onglet caractéristiques
|
- Ajout de la liste des armures dans l'onglet caractéristiques
|
||||||
- Correction des ajouts de blessures (prise en compte de l'endurance et des contusions)
|
- Correction des ajouts de blessures (prise en compte de l'endurance et des contusions)
|
||||||
|
- Correction du choix d'une cible parmi toutes les cibles pour les combats
|
||||||
|
|
||||||
## 12.0.26 - Astrobazzarh le Haut-rêvant
|
## 12.0.26 - Astrobazzarh le Haut-rêvant
|
||||||
- bouton pour le don de haut-rêve en un clic
|
- bouton pour le don de haut-rêve en un clic
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
export class DialogSelect extends Dialog {
|
export class DialogSelect extends Dialog {
|
||||||
static extractIdNameImg(it) { return { id: it.id, name: it.name, img: it.img } }
|
static extractIdNameImg(it) { return { id: it.id, name: it.name, img: it.img } }
|
||||||
|
|
||||||
static async select(selectData, onSelectChoice) {
|
static async select(selectionData, onSelectChoice) {
|
||||||
const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-select.html", selectData)
|
const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-select.html", selectionData)
|
||||||
|
|
||||||
const dialogData = {
|
const dialogData = {
|
||||||
title: selectData.title ?? selectData.label,
|
title: selectionData.title ?? selectionData.label,
|
||||||
content: html,
|
content: html,
|
||||||
buttons: {}
|
buttons: {}
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ export class DialogSelect extends Dialog {
|
|||||||
'max-height': 600,
|
'max-height': 600,
|
||||||
'z-index': 99999
|
'z-index': 99999
|
||||||
}
|
}
|
||||||
new DialogSelect(dialogData, dialogOptions, selectData, onSelectChoice).render(true)
|
new DialogSelect(dialogData, dialogOptions, selectionData, onSelectChoice).render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(dialogData, dialogOptions, selectionData, onSelectChoice) {
|
constructor(dialogData, dialogOptions, selectionData, onSelectChoice) {
|
||||||
@ -36,7 +36,7 @@ export class DialogSelect extends Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
choiceSelected(selectedId) {
|
choiceSelected(selectedId) {
|
||||||
const selected = this.selectionData.find(it => it.id == selectedId)
|
const selected = this.selectionData.list.find(it => it.id == selectedId)
|
||||||
this.close()
|
this.close()
|
||||||
if (selected) {
|
if (selected) {
|
||||||
this.onSelectChoice(selected)
|
this.onSelectChoice(selected)
|
||||||
|
@ -11,7 +11,12 @@ export class Targets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static extractTokenData(target) {
|
static extractTokenData(target) {
|
||||||
return { id: target?.id, name: target?.document.name, img: target?.document.texture.src ?? target?.actor.img ?? 'icons/svg/mystery-man.svg' };
|
return {
|
||||||
|
id: target?.id,
|
||||||
|
name: target?.document.name,
|
||||||
|
img: target?.document.texture.src ?? target?.actor.img ?? 'icons/svg/mystery-man.svg',
|
||||||
|
target
|
||||||
|
};
|
||||||
}
|
}
|
||||||
static buildActorTokenData(tokenId, actor) {
|
static buildActorTokenData(tokenId, actor) {
|
||||||
return { id: tokenId, name: actor.name, img: actor.img ?? 'icons/svg/mystery-man.svg' };
|
return { id: tokenId, name: actor.name, img: actor.img ?? 'icons/svg/mystery-man.svg' };
|
||||||
@ -35,7 +40,7 @@ export class Targets {
|
|||||||
label: "Choisir une seule des cibles",
|
label: "Choisir une seule des cibles",
|
||||||
list: targets.map(it => Targets.extractTokenData(it))
|
list: targets.map(it => Targets.extractTokenData(it))
|
||||||
};
|
};
|
||||||
DialogSelect.select(selectData, onSelectTarget)
|
DialogSelect.select(selectData, t => onSelectTarget(t.target))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user