DIvers rework de CSS/LESS et améliorations de messages/layout

This commit is contained in:
2026-05-03 20:20:30 +02:00
parent 4f8735f86f
commit 267f992874
113 changed files with 11565 additions and 843 deletions
+36
View File
@@ -44,6 +44,29 @@ export class LesOubliesUtility {
return ITEM_IMAGES[type] ?? "icons/svg/item-bag.svg"
}
static createChoices(values = [], labels = {}) {
return values.map((value) => ({
value,
label: labels[value] ?? String(value),
}))
}
static createRangeChoices(min, max, labels = {}) {
return Array.from({ length: Math.max(max - min + 1, 0) }, (_, index) => min + index).map((value) => ({
value,
label: labels[value] ?? String(value),
}))
}
static ensureChoice(choices = [], value, label = null) {
if (value === undefined || value === null || value === "") return choices
if (choices.some((choice) => String(choice.value) === String(value))) return choices
return [{
value,
label: label ?? `${value} (personnalisé)`,
}, ...choices]
}
static createEmptyProfiles() {
return PROFILE_KEYS.reduce((profiles, key) => {
profiles[key] = 0
@@ -73,4 +96,17 @@ export class LesOubliesUtility {
static sortByName(documents = []) {
return [...documents].sort((left, right) => left.name.localeCompare(right.name, "fr"))
}
static async prepareEnrichedHtml(documentName, type, systemData) {
const htmlFields = game.system.documentTypes?.[documentName]?.[type]?.htmlFields ?? []
const enriched = {}
for (const path of htmlFields) {
const value = foundry.utils.getProperty(systemData, path) ?? ""
const html = await foundry.applications.ux.TextEditor.implementation.enrichHTML(value, { async: true })
foundry.utils.setProperty(enriched, path, html)
}
return enriched
}
}