Gestion de paquetage, aide intégrée et message de bienvenue
Release Creation / build (release) Successful in 59s

This commit is contained in:
2026-05-01 00:37:01 +02:00
parent 06b0ff7f78
commit 7d218f4a0a
41 changed files with 1524 additions and 54 deletions
+100 -1
View File
@@ -19,6 +19,31 @@ import * as models from "./models/index.mjs";
import * as sheets from "./applications/sheets/_module.mjs";
import { DonjonEtCieRollDialog } from "./applications/donjon-et-cie-roll-dialog.mjs";
import { DonjonEtCieRolls } from "./donjon-et-cie-rolls.mjs";
import { DonjonEtCieMacros } from "./donjon-et-cie-macros.mjs";
const WELCOME_MESSAGE_SETTING = "welcomeMessageVersion";
function injectActorDirectoryMissionPackButton(app, element) {
if (!game.user.isGM) return;
const root = app?.element ?? element?.[0] ?? element;
if (!(root instanceof HTMLElement)) return;
const headerActions = root.querySelector(".directory-header .header-actions");
if (!(headerActions instanceof HTMLElement)) return;
if (headerActions.querySelector(".dnc-mission-pack-button")) return;
const button = document.createElement("button");
button.type = "button";
button.className = "dnc-mission-pack-button";
button.title = game.i18n.localize("DNC.Macro.MissionPack.SidebarButton");
button.setAttribute("aria-label", game.i18n.localize("DNC.Macro.MissionPack.SidebarButton"));
button.innerHTML = `<i class="fa-solid fa-box-open" inert></i><span>${game.i18n.localize("DNC.Macro.MissionPack.SidebarButton")}</span>`;
button.addEventListener("click", () => {
void game.system.donjonEtCie.macros.openMissionPackDialog();
});
headerActions.append(button);
}
function onChatActionClick(event) {
const button = event.target.closest("[data-action='rollChatDamage'], [data-action='rollSpellChaos'], [data-action='applyDamage']");
@@ -64,6 +89,73 @@ function onChatActionClick(event) {
})();
}
function registerSystemSettings() {
game.settings.register("fvtt-donjon-et-cie", WELCOME_MESSAGE_SETTING, {
name: "Version du message de bienvenue",
hint: "Usage interne pour eviter de republier le message de bienvenue a chaque chargement.",
scope: "world",
config: false,
type: String,
default: ""
});
}
async function getHelpJournalLink() {
const pack = [...game.packs.values()].find((candidate) => candidate.metadata.name === "system-help");
if (!pack) return null;
const index = await pack.getIndex();
const entry = index.find((document) => document.name === "Aide du systeme");
if (!entry?._id) return null;
const journal = await pack.getDocument(entry._id);
if (!journal?.uuid) return null;
return `@UUID[${journal.uuid}]{${game.i18n.localize("DNC.Welcome.HelpLinkLabel")}}`;
}
async function maybeCreateWelcomeMessage() {
if (!game.user.isGM) return;
const currentVersion = String(game.system.version ?? "");
const shownVersion = String(game.settings.get("fvtt-donjon-et-cie", WELCOME_MESSAGE_SETTING) ?? "");
if (shownVersion === currentVersion) return;
const helpJournalLink = await getHelpJournalLink();
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-donjon-et-cie/templates/chat/welcome-card.hbs",
{
title: game.i18n.localize("DNC.Welcome.Title"),
subtitle: game.i18n.format("DNC.Welcome.Subtitle", { version: currentVersion }),
intro: game.i18n.localize("DNC.Welcome.Intro"),
bullets: [
game.i18n.localize("DNC.Welcome.BulletActors"),
game.i18n.localize("DNC.Welcome.BulletItems"),
game.i18n.localize("DNC.Welcome.BulletMissionPack")
],
helpLabel: game.i18n.localize("DNC.Welcome.HelpLabel"),
helpLink: helpJournalLink,
helpFallback: game.i18n.localize("DNC.Welcome.HelpFallback"),
footer: game.i18n.localize("DNC.Welcome.Footer"),
creditsLabel: game.i18n.localize("DNC.Welcome.CreditsLabel"),
creditsText: game.i18n.localize("DNC.Welcome.CreditsText"),
officialLabel: game.i18n.localize("DNC.Welcome.OfficialLabel"),
officialUrl: "https://johndoe-rpg.com/catalogue/donjon-cie/",
officialLinkText: game.i18n.localize("DNC.Welcome.OfficialLinkText")
}
);
await ChatMessage.create({
speaker: {
alias: game.system.title
},
user: game.user.id,
content: await TextEditor.enrichHTML(content, { async: true })
});
await game.settings.set("fvtt-donjon-et-cie", WELCOME_MESSAGE_SETTING, currentVersion);
}
Hooks.once("init", async () => {
const startupBanner =
`▗▄▄▄ ▗▄▖ ▗▖ ▗▖ ▗▖ ▗▄▖ ▗▖ ▗▖ ▗▄▄▄▖▗▄▄▄▖ ▗▄▄▖▗▄▄▄▖▗▞▀▚▖
@@ -75,6 +167,7 @@ Hooks.once("init", async () => {
console.log(`%c${startupBanner}`, "font-family: monospace; white-space: pre; line-height: 1.1;");
console.log("Initialisation du systeme Donjon & Cie");
registerSystemSettings();
await DonjonEtCieUtility.preloadHandlebarsTemplates();
CONFIG.Combat.initiative = {
@@ -107,7 +200,8 @@ Hooks.once("init", async () => {
sheets,
rolls: DonjonEtCieRolls,
dialogs: DonjonEtCieRollDialog,
utility: DonjonEtCieUtility
utility: DonjonEtCieUtility,
macros: DonjonEtCieMacros
};
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet);
@@ -122,4 +216,9 @@ Hooks.once("init", async () => {
Hooks.once("ready", () => {
document.addEventListener("click", onChatActionClick);
void maybeCreateWelcomeMessage();
});
Hooks.on("renderActorDirectory", (app, element) => {
injectActorDirectoryMissionPackButton(app, element);
});