Message de bienvenue
This commit is contained in:
@@ -7,6 +7,8 @@ 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"
|
||||
const UBERWALD_URL = "https://www.uberwald.me"
|
||||
const XII_SINGES_URL = "https://www.les12singes.com/84-les-oublies"
|
||||
|
||||
function ensureSystemStyles() {
|
||||
const href = `systems/${game.system.id}/css/les-oublies.css`
|
||||
@@ -28,6 +30,53 @@ function usesFoundryDefaultTokenTexture(actor, data) {
|
||||
return !tokenTexture || tokenTexture === CONST.DEFAULT_TOKEN || tokenTexture === "icons/svg/mystery-man.svg"
|
||||
}
|
||||
|
||||
async function getHelpJournalEntry() {
|
||||
const pack = game.packs.get(`${game.system.id}.aide-systeme`)
|
||||
if (!pack) return null
|
||||
|
||||
const documents = await pack.getDocuments()
|
||||
return documents[0] ?? null
|
||||
}
|
||||
|
||||
async function buildWelcomeMessageContent(helpJournal) {
|
||||
const helpContent = helpJournal
|
||||
? await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
`@UUID[${helpJournal.uuid}]{${game.i18n.localize("LESOUBLIES.welcome.helpLinkLabel")}}`,
|
||||
{ async: true },
|
||||
)
|
||||
: game.i18n.localize("LESOUBLIES.welcome.helpUnavailable")
|
||||
|
||||
return `
|
||||
<div class="les-oublies-chat-card les-oublies-welcome-chat">
|
||||
<div class="chat-card-header">
|
||||
<div>
|
||||
<p class="chat-card-eyebrow">${game.i18n.localize("LESOUBLIES.welcome.eyebrow")}</p>
|
||||
<h3>${game.i18n.localize("LESOUBLIES.welcome.title")}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-card-body">
|
||||
<p>${game.i18n.localize("LESOUBLIES.welcome.intro")}</p>
|
||||
<p>${game.i18n.localize("LESOUBLIES.welcome.developerLabel")} <a href="${UBERWALD_URL}" target="_blank" rel="noopener noreferrer">Uberwald</a>.</p>
|
||||
<p>${game.i18n.localize("LESOUBLIES.welcome.publisherLabel")} <a href="${XII_SINGES_URL}" target="_blank" rel="noopener noreferrer">Les XII Singes</a>.</p>
|
||||
<p><strong>${game.i18n.localize("LESOUBLIES.welcome.helpLabel")}</strong> ${helpContent}</p>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
async function showWelcomeMessage() {
|
||||
const helpJournal = await getHelpJournalEntry()
|
||||
const content = await buildWelcomeMessageContent(helpJournal)
|
||||
|
||||
await ChatMessage.create({
|
||||
speaker: {
|
||||
alias: game.system.title,
|
||||
},
|
||||
content,
|
||||
whisper: [game.user.id],
|
||||
})
|
||||
}
|
||||
|
||||
Hooks.once("init", function () {
|
||||
console.info("Les Oubliés | Initialisation du système")
|
||||
ensureSystemStyles()
|
||||
@@ -77,6 +126,10 @@ Hooks.once("init", function () {
|
||||
LesOubliesUtility.registerHandlebarsHelpers()
|
||||
})
|
||||
|
||||
Hooks.once("ready", function () {
|
||||
showWelcomeMessage()
|
||||
})
|
||||
|
||||
Hooks.on("preCreateActor", function (actor, data) {
|
||||
if (actor.type !== "personnage") return
|
||||
if (!usesFoundryDefaultTokenTexture(actor, data)) return
|
||||
|
||||
Reference in New Issue
Block a user