diff --git a/assets/icons/aspect.svg b/assets/icons/aspect.svg new file mode 100644 index 0000000..e7100b6 --- /dev/null +++ b/assets/icons/aspect.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/equipment.svg b/assets/icons/equipment.svg new file mode 100644 index 0000000..b3e49f0 --- /dev/null +++ b/assets/icons/equipment.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fvtt-celestopol.mjs b/fvtt-celestopol.mjs index 4537a5c..7ddc2f3 100644 --- a/fvtt-celestopol.mjs +++ b/fvtt-celestopol.mjs @@ -330,8 +330,21 @@ Hooks.on("preCreateItem", (item, data) => { aspect: () => game.i18n.localize("TYPES.Item.aspect"), equipment: () => game.i18n.localize("TYPES.Item.equipment"), } + const defaultIcons = { + weapon: "systems/fvtt-celestopol/assets/icons/weapon.svg", + armure: "systems/fvtt-celestopol/assets/icons/armure.svg", + anomaly: "systems/fvtt-celestopol/assets/icons/anomaly.svg", + aspect: "systems/fvtt-celestopol/assets/icons/aspect.svg", + equipment: "systems/fvtt-celestopol/assets/icons/equipment.svg", + } + const updates = {} const fn = defaultNames[item.type] if (fn && (!data.name || data.name === "New Item" || data.name === item.type)) { - item.updateSource({ name: fn() }) + updates.name = fn() } + const defaultIcon = defaultIcons[item.type] + if (defaultIcon && (!data.img || data.img === "icons/svg/item-bag.svg")) { + updates.img = defaultIcon + } + if (Object.keys(updates).length) item.updateSource(updates) })