This commit is contained in:
@@ -6,6 +6,8 @@ import { LesOubliesRolls } from "./les-oublies-rolls.js"
|
||||
import * as models from "./models/index.mjs"
|
||||
import * as sheets from "./applications/sheets/_module.mjs"
|
||||
|
||||
const DEFAULT_PERSONNAGE_TOKEN_TEXTURE = "systems/fvtt-les-oublies/assets/tokens/border_token_oublies.webp"
|
||||
|
||||
function ensureSystemStyles() {
|
||||
const href = `systems/${game.system.id}/css/les-oublies.css`
|
||||
const existingLink = document.querySelector(`link[href$="${href}"]`)
|
||||
@@ -19,6 +21,13 @@ function ensureSystemStyles() {
|
||||
document.head.append(link)
|
||||
}
|
||||
|
||||
function usesFoundryDefaultTokenTexture(actor, data) {
|
||||
const tokenTexture = foundry.utils.getProperty(data, "prototypeToken.texture.src")
|
||||
?? foundry.utils.getProperty(actor, "prototypeToken.texture.src")
|
||||
?? ""
|
||||
return !tokenTexture || tokenTexture === CONST.DEFAULT_TOKEN || tokenTexture === "icons/svg/mystery-man.svg"
|
||||
}
|
||||
|
||||
Hooks.once("init", function () {
|
||||
console.info("Les Oubliés | Initialisation du système")
|
||||
ensureSystemStyles()
|
||||
@@ -67,3 +76,16 @@ Hooks.once("init", function () {
|
||||
|
||||
LesOubliesUtility.registerHandlebarsHelpers()
|
||||
})
|
||||
|
||||
Hooks.on("preCreateActor", function (actor, data) {
|
||||
if (actor.type !== "personnage") return
|
||||
if (!usesFoundryDefaultTokenTexture(actor, data)) return
|
||||
|
||||
actor.updateSource({
|
||||
prototypeToken: {
|
||||
texture: {
|
||||
src: DEFAULT_PERSONNAGE_TOKEN_TEXTURE,
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user