forked from public/foundryvtt-reve-de-dragon
Nouvelle fenêtre de jets de dés
This commit is contained in:
32
module/roll/roll-part-rollmode.mjs
Normal file
32
module/roll/roll-part-rollmode.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
|
||||
|
||||
const ROLLMODE = "rollmode"
|
||||
|
||||
export class RollPartRollMode extends RollPart {
|
||||
|
||||
get code() { return ROLLMODE }
|
||||
get section() { return ROLLDIALOG_SECTION.CONDITIONS }
|
||||
|
||||
loadRefs(rollData) {
|
||||
const refs = this.getRefs(rollData)
|
||||
refs.rollmodes = Object.entries(CONFIG.Dice.rollModes).map(([k, v]) => { return { key: k, label: v.label, icon: v.icon } })
|
||||
}
|
||||
|
||||
restore(rollData) {
|
||||
this.setCurrent(rollData, { key: this.getSaved(rollData)?.key ?? game.settings.get("core", "rollMode") })
|
||||
}
|
||||
|
||||
store(rollData, targetData) {
|
||||
this.setSaved(targetData, { key: this.getCurrent(rollData).key })
|
||||
}
|
||||
|
||||
async _onRender(rollDialog, context, options) {
|
||||
const rollvisibilityButtons = rollDialog.element.querySelectorAll(`button[name="roll-rollmode"]`)
|
||||
rollvisibilityButtons?.forEach(it => it.addEventListener(
|
||||
"click", e => {
|
||||
e.preventDefault()
|
||||
this.getCurrent(rollDialog.rollData).key = e.currentTarget.dataset.key
|
||||
rollDialog.render()
|
||||
}))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user