LIen vers le guide depuis le message de bienvenu
This commit is contained in:
@@ -110,7 +110,44 @@ Hooks.once("init", async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
function welcomeMessage() {
|
async function getGuideFoundryJournalLink() {
|
||||||
|
const isGuideFoundryJournal = name => {
|
||||||
|
const normalizedName = name?.toLowerCase() ?? "";
|
||||||
|
return normalizedName.includes("guide de jeu") && normalizedName.includes("foundry");
|
||||||
|
};
|
||||||
|
|
||||||
|
let journal = game.journal.find(j => isGuideFoundryJournal(j.name));
|
||||||
|
|
||||||
|
if (!journal) {
|
||||||
|
for (const pack of game.packs) {
|
||||||
|
if (pack.documentName !== "JournalEntry") continue;
|
||||||
|
const entry = pack.index.find(e => isGuideFoundryJournal(e.name));
|
||||||
|
if (!entry) continue;
|
||||||
|
journal = await pack.getDocument(entry._id ?? entry.id);
|
||||||
|
if (journal) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!journal) return "";
|
||||||
|
|
||||||
|
return foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||||
|
`@UUID[${journal.uuid}]{${journal.name}}`,
|
||||||
|
{ async: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async function welcomeMessage() {
|
||||||
|
const guideFoundryLink = await getGuideFoundryJournalLink();
|
||||||
|
const guideFoundrySection = guideFoundryLink
|
||||||
|
? `
|
||||||
|
<div class="welcome-section">
|
||||||
|
<i class="fas fa-book"></i>
|
||||||
|
<p>Consultez aussi le ${guideFoundryLink}.</p>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
: "";
|
||||||
|
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
user: game.user.id,
|
user: game.user.id,
|
||||||
whisper: [game.user.id],
|
whisper: [game.user.id],
|
||||||
@@ -142,6 +179,7 @@ function welcomeMessage() {
|
|||||||
<p>Système développé par <strong>LeRatierBretonnien</strong></p>
|
<p>Système développé par <strong>LeRatierBretonnien</strong></p>
|
||||||
<p>Support sur le <a href="https://discord.gg/pPSDNJk" target="_blank"><i class="fab fa-discord"></i> Discord FR de Foundry</a></p>
|
<p>Support sur le <a href="https://discord.gg/pPSDNJk" target="_blank"><i class="fab fa-discord"></i> Discord FR de Foundry</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
${guideFoundrySection}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@@ -163,7 +201,7 @@ async function importDefaultScene() {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
Hooks.once("ready", function () {
|
Hooks.once("ready", async function () {
|
||||||
|
|
||||||
HeritiersUtility.ready()
|
HeritiersUtility.ready()
|
||||||
|
|
||||||
@@ -182,7 +220,7 @@ Hooks.once("ready", function () {
|
|||||||
}).catch(err =>
|
}).catch(err =>
|
||||||
console.log("No stats available, giving up.")
|
console.log("No stats available, giving up.")
|
||||||
)
|
)
|
||||||
welcomeMessage();
|
await welcomeMessage();
|
||||||
importDefaultScene();
|
importDefaultScene();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user