Init settings before sheets

Eviter que le chargement d'acteurs ait lieu avant le chargement
des settings
This commit is contained in:
Vincent Vandemeulebrouck 2024-10-14 03:46:09 +02:00
parent 174ef4256a
commit 90d46c6a78
11 changed files with 40 additions and 41 deletions

View File

@ -8,7 +8,7 @@ const LATEST_USED_JOURNAL_ID = "chronologie-dernier-journal";
export class DialogChronologie extends Dialog {
static init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, LATEST_USED_JOURNAL_ID, {
name: "Dernier article de journal utilisé pour enregistrer la chronologie",
scope: "client",

View File

@ -7,7 +7,7 @@ import { CompendiumTableHelpers, CompendiumTable, SystemCompendiums } from "./se
const COMPENDIUMS_RECHERCHE = 'compendiums-recherche';
export class Environnement {
static init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, COMPENDIUMS_RECHERCHE, {
name: COMPENDIUMS_RECHERCHE,
default: [

View File

@ -79,8 +79,7 @@ export class RdDHotbar {
* Actor - open actor sheet
* Journal - open journal sheet
*/
static init() {
static initHooks() {
Hooks.on('hotbarDrop', (bar, documentData, slot) => {
// Create item macro if rollable item - weapon, spell, prayer, trait, or skill

View File

@ -61,7 +61,7 @@ import { RdDSigneDraconiqueItemSheet } from "./item/sheet-signedraconique.js"
import { RdDItemInventaireSheet } from "./item/sheet-base-inventaire.js"
import { AppAstrologie } from "./sommeil/app-astrologie.js"
import { RdDItemArmure } from "./item/armure.js"
import { AutoAdjustDarkness as AutoAdjustDarkness } from "./time/auto-adjust-darkness.js"
import { AutoAdjustDarkness } from "./time/auto-adjust-darkness.js"
import { RdDCreature } from "./actor/creature.js"
import { RdDTMRDialog } from "./rdd-tmr-dialog.js"
import { OptionsAvancees } from "./settings/options-avancees.js"
@ -80,7 +80,7 @@ export class SystemReveDeDragon {
const system = new SystemReveDeDragon()
Hooks.once('init', async () => await system.onInit())
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d))
Hooks.once('ready', () => system.onReady())
Hooks.once('ready', async () => await system.onReady())
}
constructor() {
@ -115,24 +115,31 @@ export class SystemReveDeDragon {
game.system.rdd = this
this.AppAstrologie = AppAstrologie
console.log(`Initializing Reve de Dragon System`)
console.log(`Initializing Reve de Dragon System Settings`)
// preload handlebars templates
RdDUtility.preloadHandlebarsTemplates()
AppPersonnageAleatoire.preloadHandlebars()
/* -------------------------------------------- */
this.initSystemSettings()
ReglesOptionnelles.initSettings()
OptionsAvancees.initSettings()
AutoAdjustDarkness.initSettings()
RdDTimestamp.initSettings()
RdDCalendrier.initSettings()
SystemCompendiums.initSettings()
DialogChronologie.initSettings()
RdDTMRDialog.initSettings()
Environnement.initSettings()
this.initSettings()
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1+(1d6/10)",
decimals: 2
}
CONFIG.Combat.initiative = { formula: "1+(1d6/10)", decimals: 2 }
/* -------------------------------------------- */
console.log(`Initializing Reve de Dragon Socket handlers`)
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
console.log(">>>>> MSG RECV", sockmsg)
try {
@ -144,9 +151,10 @@ export class SystemReveDeDragon {
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e)
}
})
/* -------------------------------------------- */
// Define custom Entity classes
console.log(`Initializing Reve de Dragon Documents`)
CONFIG.Actor.documentClass = RdDBaseActor
CONFIG.Item.documentClass = RdDItem
CONFIG.RDD = {
@ -155,7 +163,7 @@ export class SystemReveDeDragon {
ajustementsConditions: RdDUtility.getAjustementsConditions(),
difficultesLibres: RdDUtility.getDifficultesLibres()
}
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet)
@ -166,7 +174,7 @@ export class SystemReveDeDragon {
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true })
Items.unregisterSheet("core", ItemSheet)
await RdDActorExportSheet.init()
RdDItemSheet.register(RdDSigneDraconiqueItemSheet)
RdDItemSheet.register(RdDRencontreItemSheet)
RdDItemSheet.register(RdDConteneurItemSheet)
@ -176,7 +184,7 @@ export class SystemReveDeDragon {
RdDItemSheet.register(RdDIngredientItemSheet)
RdDItemSheet.register(RdDServiceItemSheet)
RdDItemSheet.register(RdDBlessureItemSheet)
Items.registerSheet(SYSTEM_RDD, RdDItemInventaireSheet, {
types: [
"objet", "arme", "armure", "livre", "potion", "munition",
@ -192,16 +200,10 @@ export class SystemReveDeDragon {
"tarot", "extraitpoetique", "empoignade"
], makeDefault: true
})
CONFIG.Combat.documentClass = RdDCombatManager
// préparation des différents modules
AutoAdjustDarkness.init()
RdDTimestamp.init()
RdDCalendrier.init()
SystemCompendiums.init()
DialogChronologie.init()
ReglesOptionnelles.init()
OptionsAvancees.init()
console.log(`Initializing Reve de Dragon Hooks and handlers`)
CONFIG.Combat.documentClass = RdDCombatManager
RdDUtility.init()
RdDDice.init()
RdDCommands.init()
@ -211,15 +213,14 @@ export class SystemReveDeDragon {
RdDCompendiumOrganiser.init()
EffetsDraconiques.init()
TMRUtility.init()
await RdDTMRDialog.init()
RdDHotbar.init()
RdDHotbar.initHooks()
RdDPossession.init()
TMRRencontres.init()
Environnement.init()
ExportScriptarium.init()
}
initSystemSettings() {
initSettings() {
// TODO: déplacer vers les modules correspondants
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
name: "Accorder le rêve aux entités",
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar",
@ -318,4 +319,3 @@ export class SystemReveDeDragon {
}
SystemReveDeDragon.start()

View File

@ -34,7 +34,7 @@ const TMR_DISPLAY_SIZE = {
/* -------------------------------------------- */
export class RdDTMRDialog extends Dialog {
static async init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, TMR_DISPLAY_SIZE.code, {
name: 'Taille des cases des TMR',
hint: "Taille en pixel des cases des TMR (réglable directement dans la fenêtre des TMR)",

View File

@ -8,7 +8,7 @@ const OPTIONS_AVANCEES = [
]
export class OptionsAvancees extends FormApplication {
static init() {
static initSettings() {
for (const regle of OPTIONS_AVANCEES) {
const name = regle.name
const id = OptionsAvancees._getId(name)

View File

@ -46,7 +46,7 @@ const listeReglesOptionnelles = [
const uniquementJoueur = listeReglesOptionnelles.filter(it => it.uniquementJoueur).map(it=>it.name);
export class ReglesOptionnelles extends FormApplication {
static init() {
static initSettings() {
for (const regle of listeReglesOptionnelles) {
const name = regle.name;
const id = ReglesOptionnelles._getIdRegle(name);

View File

@ -25,7 +25,7 @@ const CONFIGURABLE_COMPENDIUMS = {
* ======= Gestion des accès aux compendiums systèmes (ou surchargés) =======
*/
export class SystemCompendiums extends FormApplication {
static init() {
static initSettings() {
Object.keys(CONFIGURABLE_COMPENDIUMS).forEach(compendium => {
const definition = CONFIGURABLE_COMPENDIUMS[compendium];
foundry.utils.mergeObject(definition, {

View File

@ -4,7 +4,7 @@ export const AUTO_ADJUST_DARKNESS = "auto-adjust-darkness";
export class AutoAdjustDarkness {
static init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, AUTO_ADJUST_DARKNESS, {
name: AUTO_ADJUST_DARKNESS,
scope: "world",

View File

@ -15,7 +15,7 @@ const TEMPLATE_CALENDRIER = "systems/foundryvtt-reve-de-dragon/templates/time/ca
const INITIAL_CALENDAR_POS = { top: 200, left: 200, horlogeAnalogique: true };
/* -------------------------------------------- */
export class RdDCalendrier extends Application {
static init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
name: "liste-nombre-astral",
scope: "world",

View File

@ -49,7 +49,7 @@ const FORMULES_PERIODE = [
export class RdDTimestamp {
static init() {
static initSettings() {
game.settings.register(SYSTEM_RDD, WORLD_TIMESTAMP_SETTING, {
name: WORLD_TIMESTAMP_SETTING,
scope: "world",