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)
}
}
+5 -1
View File
@@ -12,7 +12,7 @@
*/
import { ACTOR_TYPES, ITEM_TYPES, MAGICS, SUBTYPES, SYSTEM_ID } from "./config/constants.js"
import { registerSettings, migrateIfNeeded } from "./config/settings.js"
import { registerSettings, migrateIfNeeded, loadWelcomeSceneIfNeeded } from "./config/settings.js"
import { preLocalizeConfig } from "./config/localize.js"
import { configureRuntime } from "./config/runtime.js"
import { CharacterDataModel, NpcDataModel } from "./data/actors/index.js"
@@ -30,6 +30,7 @@ import { CDETinjiApp } from "./ui/apps/tinji-app.js"
import { CDEWheelApp } from "./ui/apps/wheel-app.js"
import { injectRollActions, refreshAllRollActions } from "./ui/roll-actions.js"
import { CDECombat } from "./documents/combat.js"
import { showWelcomeMessage, injectWelcomeActions } from "./ui/apps/welcome.js"
Hooks.once("i18nInit", preLocalizeConfig)
@@ -130,7 +131,9 @@ Hooks.once("init", async () => {
Hooks.once("ready", async () => {
await migrateIfNeeded()
await loadWelcomeSceneIfNeeded()
CDEWheelApp.registerHooks()
if (game.user.isGM) showWelcomeMessage()
})
/** Add Loksyu + Tin Ji quick-access buttons to the chat panel (FoundryVTT v13) */
@@ -173,6 +176,7 @@ Hooks.on("renderChatLog", (_app, html) => {
/** Inject Loksyu / TinJi action buttons into roll-result chat messages */
Hooks.on("renderChatMessageHTML", (message, html) => {
injectRollActions(message, html)
if (message.flags?.[SYSTEM_ID]?.welcome) injectWelcomeActions(message, html)
})
/** Refresh all visible roll-result buttons whenever Loksyu or TinJi settings change */
+1
View File
@@ -16,3 +16,4 @@ export { CDETinjiApp } from "./tinji-app.js"
export { updateLoksyuFromRoll, updateTinjiFromRoll } from "./singletons.js"
export { CDEWheelApp } from "./wheel-app.js"
export { CDEMigrationApp } from "./migration-app.js"
export { showWelcomeMessage, injectWelcomeActions } from "./welcome.js"
+61
View File
@@ -0,0 +1,61 @@
/**
* Chroniques de l'Étrange — Système FoundryVTT
*
* Chroniques de l'Étrange est un jeu de rôle édité par Antre-Monde Éditions.
* Ce système FoundryVTT est une implémentation indépendante et n'est pas
* affilié à Antre-Monde Éditions,
* mais a été réalisé avec l'autorisation d'Antre-Monde Éditions.
*
* @author LeRatierBretonnien
* @copyright 20242026 LeRatierBretonnien
* @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
*/
import { SYSTEM_ID } from "../../config/constants.js"
const HELP_JOURNAL_UUID = `Compendium.${SYSTEM_ID}.cde-help.JournalEntry.CDEGuideMain0001`
/** Post a styled welcome chat message. Called once per session by the GM. */
export 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'Étrange" />
<h2 class="cde-welcome-title">Les Chroniques de l'Étrange</h2>
<p class="cde-welcome-links">
Un jeu de rôle édité par
<a href="https://antre-monde.com/les-chroniques-de-letrengae/" target="_blank" rel="noopener">Antre-Monde Éditions</a>
</p>
<p class="cde-welcome-links">
Système FoundryVTT réalisé 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'Étrange" },
flags: { [SYSTEM_ID]: { welcome: true } },
})
}
/** Attach the help-open click handler to a welcome chat message HTML node. */
export 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 {
// Pack not yet loaded — open the compendium browser as fallback
game.packs.get(`${SYSTEM_ID}.cde-help`)?.render(true)
}
})
}