import { ACTOR_TYPES, ITEM_TYPES, MAGICS, SUBTYPES, SYSTEM_ID } from "./config/constants.js" import { preLocalizeConfig } from "./config/localize.js" import { configureRuntime } from "./config/runtime.js" import { CharacterDataModel, LoksyuDataModel, NpcDataModel, TinjiDataModel } from "./data/actors/index.js" import { EquipmentDataModel, KungfuDataModel, SpellDataModel, SupernaturalDataModel, WeaponDataModel, ArmorDataModel, SanheiDataModel, IngredientDataModel } from "./data/items/index.js" import { CDEMessage } from "./documents/chat-message.js" import { CDEActor } from "./documents/actor.js" import { CDEItem } from "./documents/item.js" import { registerDice } from "./ui/dice.js" import { registerHandlebarsHelpers } from "./ui/helpers.js" import { preloadPartials } from "./ui/templates.js" import { CDELoksyuSheet, CDECharacterSheet, CDENpcSheet, CDETinjiSheet } from "./ui/sheets/actors/index.js" import { CDEItemSheet, CDEKungfuSheet, CDESpellSheet, CDESupernaturalSheet, CDEWeaponSheet, CDEArmorSheet, CDESanheiSheet, CDEIngredientSheet } from "./ui/sheets/items/index.js" import { CDELoksyuApp } from "./ui/apps/loksyu-app.js" import { CDETinjiApp } from "./ui/apps/tinji-app.js" import { migrateIfNeeded, registerSettings } from "./migration.js" Hooks.once("i18nInit", preLocalizeConfig) Hooks.once("init", async () => { console.info(`CHRONIQUESDELETRANGE | Initializing ${SYSTEM_ID}`) registerSettings() game.system.CONST = { MAGICS, SUBTYPES } CONFIG.Actor.dataModels = { [ACTOR_TYPES.character]: CharacterDataModel, [ACTOR_TYPES.npc]: NpcDataModel, [ACTOR_TYPES.tinji]: TinjiDataModel, [ACTOR_TYPES.loksyu]: LoksyuDataModel, } CONFIG.Item.dataModels = { [ITEM_TYPES.item]: EquipmentDataModel, [ITEM_TYPES.kungfu]: KungfuDataModel, [ITEM_TYPES.spell]: SpellDataModel, [ITEM_TYPES.supernatural]: SupernaturalDataModel, [ITEM_TYPES.weapon]: WeaponDataModel, [ITEM_TYPES.armor]: ArmorDataModel, [ITEM_TYPES.sanhei]: SanheiDataModel, [ITEM_TYPES.ingredient]: IngredientDataModel, } CONFIG.Actor.documentClass = CDEActor CONFIG.Item.documentClass = CDEItem CONFIG.ChatMessage.documentClass = CDEMessage configureRuntime() foundry.applications.apps.DocumentSheetConfig.unregisterSheet(Actor, "core", ActorSheet) foundry.applications.apps.DocumentSheetConfig.unregisterSheet(Item, "core", ItemSheet) foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, SYSTEM_ID, CDECharacterSheet, { types: [ACTOR_TYPES.character], makeDefault: true, label: "CDE Character Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, SYSTEM_ID, CDENpcSheet, { types: [ACTOR_TYPES.npc], makeDefault: true, label: "CDE NPC Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, SYSTEM_ID, CDETinjiSheet, { types: [ACTOR_TYPES.tinji], makeDefault: true, label: "CDE Tinji Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Actor, SYSTEM_ID, CDELoksyuSheet, { types: [ACTOR_TYPES.loksyu], makeDefault: true, label: "CDE Loksyu Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDEItemSheet, { types: [ITEM_TYPES.item], makeDefault: true, label: "CDE Item Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDEKungfuSheet, { types: [ITEM_TYPES.kungfu], makeDefault: true, label: "CDE KungFu Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDESpellSheet, { types: [ITEM_TYPES.spell], makeDefault: true, label: "CDE Spell Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDESupernaturalSheet, { types: [ITEM_TYPES.supernatural], makeDefault: true, label: "CDE Supernatural Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDEWeaponSheet, { types: [ITEM_TYPES.weapon], makeDefault: true, label: "CDE Weapon Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDEArmorSheet, { types: [ITEM_TYPES.armor], makeDefault: true, label: "CDE Armor Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDESanheiSheet, { types: [ITEM_TYPES.sanhei], makeDefault: true, label: "CDE Sanhei Sheet (V2)", }) foundry.applications.apps.DocumentSheetConfig.registerSheet(Item, SYSTEM_ID, CDEIngredientSheet, { types: [ITEM_TYPES.ingredient], makeDefault: true, label: "CDE Ingredient Sheet (V2)", }) await preloadPartials() registerHandlebarsHelpers() registerDice() Hooks.on("renderSettings", (_app, html) => injectCompendiumLink(html)) console.info(`CHRONIQUESDELETRANGE | Initialized`) }) Hooks.once("ready", async () => { await migrateIfNeeded() }) /** Add Loksyu + Tin Ji quick-access buttons to the chat footer */ Hooks.on("renderChatLog", (_app, html) => { const el = html instanceof HTMLElement ? html : html[0] const controls = el?.querySelector?.(".chat-controls") if (!controls) return const wrapper = document.createElement("div") wrapper.classList.add("cde-chat-app-buttons") wrapper.innerHTML = ` ${game.i18n.localize("CDE.Loksyu")} ${game.i18n.localize("CDE.TinJi2")} ` controls.appendChild(wrapper) wrapper.querySelector(".cde-chat-btn--loksyu")?.addEventListener("click", () => CDELoksyuApp.open()) wrapper.querySelector(".cde-chat-btn--tinji")?.addEventListener("click", () => CDETinjiApp.open()) }) function injectCompendiumLink(html) { const header = html[0]?.querySelector?.("h4.divider") if (!header) return const section = document.createElement("section") section.classList.add("settings", "flexcol") section.innerHTML = ` Lien utile Compendium pour Les CdE Guide d'installation Rendez-vous sur le site de l'éditeur, téléchargez les PDF contenant les liens vers les compendia, puis ajoutez leurs manifestes dans Foundry. ` section.querySelector("button[data-action='open-cde-link']")?.addEventListener("click", () => { window.open("https://antre-monde.com/les-chroniques-de-letrange/", "_blank") }) header.parentNode.insertBefore(section, header) }
Rendez-vous sur le site de l'éditeur, téléchargez les PDF contenant les liens vers les compendia, puis ajoutez leurs manifestes dans Foundry.