Nouvelle fenêtre de jets de dés

This commit is contained in:
2025-09-05 01:09:32 +02:00
parent 652c435833
commit 1ff32697f4
134 changed files with 4025 additions and 400 deletions

View File

@@ -0,0 +1,61 @@
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
export class RollPartCheckbox extends RollPart {
get section() { return ROLLDIALOG_SECTION.CONDITIONS }
get useCheckboxTemplate() { return true }
get template() { return this.useCheckboxTemplate ? 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-part-checkbox.hbs' : super.template }
get isDefaultChecked() { return true }
restore(rollData) {
const checked = this.getSaved(rollData).checked
this.getCurrent(rollData).checked = checked == undefined? this.isDefaultChecked : checked
}
store(rollData, targetData) {
this.setSaved(targetData, { checked: this.getCurrent(rollData).checked })
}
loadRefs(rollData) {
const current = this.getCurrent(rollData)
current.label = this.getCheckboxLabel(rollData)
}
prepareContext(rollData) {
const current = this.getCurrent(rollData)
if (current.checked == undefined) {
/* TODO: user setting? */
current.checked = true
}
if (current.value == undefined) {
current.value = this.getCheckboxValue(rollData)
}
current.icon = this.getCheckboxIcon(rollData)
}
getAjustements(rollData) {
const current = this.getCurrent(rollData)
if (current.checked) {
return [{ label: this.getCheckboxLabelAjustement(rollData), diff: current.value }]
}
return []
}
getCheckboxLabelAjustement(rollData) {
return `${this.getCheckboxIcon(rollData)} ${this.getCurrent(rollData).label}`
}
async _onRender(rollDialog, context, options) {
const checkbox = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
checkbox?.addEventListener("change", e => {
this.getCurrent(rollDialog.rollData).checked = e.currentTarget.checked
rollDialog.render()
})
}
getCheckboxIcon(rollData) { return '' }
getCheckboxLabel(rollData) { return "LABEL" }
getCheckboxValue(rollData) { return 0 }
}