This commit is contained in:
Vendored
+71
@@ -602,9 +602,36 @@ function registerSettings() {
|
||||
type: Number,
|
||||
default: 0
|
||||
});
|
||||
game.settings.register(SYSTEM_ID, "welcomeSceneLoaded", {
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: false
|
||||
});
|
||||
}
|
||||
async function migrateIfNeeded() {
|
||||
}
|
||||
async function loadWelcomeSceneIfNeeded() {
|
||||
if (!game.user.isGM) return;
|
||||
if (game.settings.get(SYSTEM_ID, "welcomeSceneLoaded")) return;
|
||||
try {
|
||||
const pack = game.packs.get(`${SYSTEM_ID}.cde-scenes`);
|
||||
if (!pack) return;
|
||||
const index = await pack.getIndex();
|
||||
const entry = index.find((e) => e.name === "Accueil");
|
||||
if (!entry) return;
|
||||
const existing = game.scenes.find((s) => s.name === "Accueil");
|
||||
let scene = existing;
|
||||
if (!scene) {
|
||||
const doc = await pack.getDocument(entry._id);
|
||||
[scene] = await Scene.createDocuments([doc.toObject()]);
|
||||
}
|
||||
await game.settings.set(SYSTEM_ID, "welcomeSceneLoaded", true);
|
||||
await scene.activate();
|
||||
} catch (err) {
|
||||
console.error("CHRONIQUESDELETRANGE | loadWelcomeSceneIfNeeded failed:", err);
|
||||
}
|
||||
}
|
||||
|
||||
// src/config/localize.js
|
||||
function preLocalizeConfig() {
|
||||
@@ -3018,6 +3045,47 @@ function refreshAllRollActions() {
|
||||
});
|
||||
}
|
||||
|
||||
// src/ui/apps/welcome.js
|
||||
var HELP_JOURNAL_UUID = `Compendium.${SYSTEM_ID}.cde-help.JournalEntry.CDEGuideMain0001`;
|
||||
async function showWelcomeMessage() {
|
||||
const logo = `systems/${SYSTEM_ID}/images/logo_jeu.webp`;
|
||||
const content = `
|
||||
<div class="cde-welcome-message">
|
||||
<img class="cde-welcome-logo" src="${logo}" alt="Les Chroniques de l'\xC9trange" />
|
||||
<h2 class="cde-welcome-title">Les Chroniques de l'\xC9trange</h2>
|
||||
<p class="cde-welcome-links">
|
||||
Un jeu de r\xF4le \xE9dit\xE9 par
|
||||
<a href="https://antre-monde.com/les-chroniques-de-letrengae/" target="_blank" rel="noopener">Antre-Monde \xC9ditions</a>
|
||||
</p>
|
||||
<p class="cde-welcome-links">
|
||||
Syst\xE8me FoundryVTT r\xE9alis\xE9 par
|
||||
<a href="https://www.uberwald.me" target="_blank" rel="noopener">LeRatierBretonnien</a>
|
||||
</p>
|
||||
<button type="button" class="cde-welcome-help-btn" data-action="open-cde-help">
|
||||
<i class="fas fa-book-open"></i>
|
||||
${game.i18n.localize("CDE.WelcomeOpenHelp")}
|
||||
</button>
|
||||
</div>`;
|
||||
await ChatMessage.create({
|
||||
content,
|
||||
speaker: { alias: "Les Chroniques de l'\xC9trange" },
|
||||
flags: { [SYSTEM_ID]: { welcome: true } }
|
||||
});
|
||||
}
|
||||
function injectWelcomeActions(_message, html) {
|
||||
const el = html instanceof HTMLElement ? html : html[0] ?? html;
|
||||
const btn = el?.querySelector?.("[data-action='open-cde-help']");
|
||||
if (!btn) return;
|
||||
btn.addEventListener("click", async () => {
|
||||
try {
|
||||
const doc = await fromUuid(HELP_JOURNAL_UUID);
|
||||
doc?.sheet?.render(true);
|
||||
} catch {
|
||||
game.packs.get(`${SYSTEM_ID}.cde-help`)?.render(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// src/system.js
|
||||
Hooks.once("i18nInit", preLocalizeConfig);
|
||||
Hooks.once("init", async () => {
|
||||
@@ -3103,7 +3171,9 @@ Hooks.once("init", async () => {
|
||||
});
|
||||
Hooks.once("ready", async () => {
|
||||
await migrateIfNeeded();
|
||||
await loadWelcomeSceneIfNeeded();
|
||||
CDEWheelApp.registerHooks();
|
||||
if (game.user.isGM) showWelcomeMessage();
|
||||
});
|
||||
Hooks.on("renderChatLog", (_app, html) => {
|
||||
const el = html instanceof HTMLElement ? html : html[0] ?? html;
|
||||
@@ -3133,6 +3203,7 @@ Hooks.on("renderChatLog", (_app, html) => {
|
||||
});
|
||||
Hooks.on("renderChatMessageHTML", (message, html) => {
|
||||
injectRollActions(message, html);
|
||||
if (message.flags?.[SYSTEM_ID]?.welcome) injectWelcomeActions(message, html);
|
||||
});
|
||||
Hooks.on("updateSetting", (setting) => {
|
||||
if (!setting.key) return;
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user