Finalisation du système
Release Creation / build (release) Successful in 1m24s

This commit is contained in:
2026-05-06 22:37:40 +02:00
parent 73a3381d2a
commit 9617005a5c
114 changed files with 778 additions and 221 deletions
+40
View File
@@ -47,6 +47,13 @@ export function registerSettings() {
type: Number,
default: 0,
})
game.settings.register(SYSTEM_ID, "welcomeSceneLoaded", {
scope: "world",
config: false,
type: Boolean,
default: false,
})
}
/**
@@ -56,3 +63,36 @@ export function registerSettings() {
export async function migrateIfNeeded() {
// No migrations required yet.
}
/**
* On first startup, import the "Accueil" scene from the cde-scenes compendium
* into the world and activate it. Only runs once (tracked via the
* `welcomeSceneLoaded` setting). GM-only.
*/
export 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
// Check if the scene already exists in the world (e.g. manually imported)
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)
}
}