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 { export class DialogChronologie extends Dialog {
static init() { static initSettings() {
game.settings.register(SYSTEM_RDD, LATEST_USED_JOURNAL_ID, { game.settings.register(SYSTEM_RDD, LATEST_USED_JOURNAL_ID, {
name: "Dernier article de journal utilisé pour enregistrer la chronologie", name: "Dernier article de journal utilisé pour enregistrer la chronologie",
scope: "client", scope: "client",

View File

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

View File

@ -79,8 +79,7 @@ export class RdDHotbar {
* Actor - open actor sheet * Actor - open actor sheet
* Journal - open journal sheet * Journal - open journal sheet
*/ */
static init() { static initHooks() {
Hooks.on('hotbarDrop', (bar, documentData, slot) => { Hooks.on('hotbarDrop', (bar, documentData, slot) => {
// Create item macro if rollable item - weapon, spell, prayer, trait, or skill // 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 { RdDItemInventaireSheet } from "./item/sheet-base-inventaire.js"
import { AppAstrologie } from "./sommeil/app-astrologie.js" import { AppAstrologie } from "./sommeil/app-astrologie.js"
import { RdDItemArmure } from "./item/armure.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 { RdDCreature } from "./actor/creature.js"
import { RdDTMRDialog } from "./rdd-tmr-dialog.js" import { RdDTMRDialog } from "./rdd-tmr-dialog.js"
import { OptionsAvancees } from "./settings/options-avancees.js" import { OptionsAvancees } from "./settings/options-avancees.js"
@ -80,7 +80,7 @@ export class SystemReveDeDragon {
const system = new SystemReveDeDragon() const system = new SystemReveDeDragon()
Hooks.once('init', async () => await system.onInit()) Hooks.once('init', async () => await system.onInit())
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d)) Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d))
Hooks.once('ready', () => system.onReady()) Hooks.once('ready', async () => await system.onReady())
} }
constructor() { constructor() {
@ -115,24 +115,31 @@ export class SystemReveDeDragon {
game.system.rdd = this game.system.rdd = this
this.AppAstrologie = AppAstrologie this.AppAstrologie = AppAstrologie
console.log(`Initializing Reve de Dragon System Settings`)
console.log(`Initializing Reve de Dragon System`)
// preload handlebars templates // preload handlebars templates
RdDUtility.preloadHandlebarsTemplates() RdDUtility.preloadHandlebarsTemplates()
AppPersonnageAleatoire.preloadHandlebars() 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 // Set an initiative formula for the system
CONFIG.Combat.initiative = { CONFIG.Combat.initiative = { formula: "1+(1d6/10)", decimals: 2 }
formula: "1+(1d6/10)",
decimals: 2
}
/* -------------------------------------------- */ /* -------------------------------------------- */
console.log(`Initializing Reve de Dragon Socket handlers`)
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => { game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
console.log(">>>>> MSG RECV", sockmsg) console.log(">>>>> MSG RECV", sockmsg)
try { try {
@ -147,6 +154,7 @@ export class SystemReveDeDragon {
/* -------------------------------------------- */ /* -------------------------------------------- */
// Define custom Entity classes // Define custom Entity classes
console.log(`Initializing Reve de Dragon Documents`)
CONFIG.Actor.documentClass = RdDBaseActor CONFIG.Actor.documentClass = RdDBaseActor
CONFIG.Item.documentClass = RdDItem CONFIG.Item.documentClass = RdDItem
CONFIG.RDD = { CONFIG.RDD = {
@ -192,16 +200,10 @@ export class SystemReveDeDragon {
"tarot", "extraitpoetique", "empoignade" "tarot", "extraitpoetique", "empoignade"
], makeDefault: true ], makeDefault: true
}) })
CONFIG.Combat.documentClass = RdDCombatManager
// préparation des différents modules // préparation des différents modules
AutoAdjustDarkness.init() console.log(`Initializing Reve de Dragon Hooks and handlers`)
RdDTimestamp.init() CONFIG.Combat.documentClass = RdDCombatManager
RdDCalendrier.init()
SystemCompendiums.init()
DialogChronologie.init()
ReglesOptionnelles.init()
OptionsAvancees.init()
RdDUtility.init() RdDUtility.init()
RdDDice.init() RdDDice.init()
RdDCommands.init() RdDCommands.init()
@ -211,15 +213,14 @@ export class SystemReveDeDragon {
RdDCompendiumOrganiser.init() RdDCompendiumOrganiser.init()
EffetsDraconiques.init() EffetsDraconiques.init()
TMRUtility.init() TMRUtility.init()
await RdDTMRDialog.init() RdDHotbar.initHooks()
RdDHotbar.init()
RdDPossession.init() RdDPossession.init()
TMRRencontres.init() TMRRencontres.init()
Environnement.init()
ExportScriptarium.init() ExportScriptarium.init()
} }
initSystemSettings() { initSettings() {
// TODO: déplacer vers les modules correspondants
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", { game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
name: "Accorder le rêve aux entités", name: "Accorder le rêve aux entités",
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar", 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() SystemReveDeDragon.start()

View File

@ -34,7 +34,7 @@ const TMR_DISPLAY_SIZE = {
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDTMRDialog extends Dialog { export class RdDTMRDialog extends Dialog {
static async init() { static initSettings() {
game.settings.register(SYSTEM_RDD, TMR_DISPLAY_SIZE.code, { game.settings.register(SYSTEM_RDD, TMR_DISPLAY_SIZE.code, {
name: 'Taille des cases des TMR', name: 'Taille des cases des TMR',
hint: "Taille en pixel des cases des TMR (réglable directement dans la fenêtre 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 { export class OptionsAvancees extends FormApplication {
static init() { static initSettings() {
for (const regle of OPTIONS_AVANCEES) { for (const regle of OPTIONS_AVANCEES) {
const name = regle.name const name = regle.name
const id = OptionsAvancees._getId(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); const uniquementJoueur = listeReglesOptionnelles.filter(it => it.uniquementJoueur).map(it=>it.name);
export class ReglesOptionnelles extends FormApplication { export class ReglesOptionnelles extends FormApplication {
static init() { static initSettings() {
for (const regle of listeReglesOptionnelles) { for (const regle of listeReglesOptionnelles) {
const name = regle.name; const name = regle.name;
const id = ReglesOptionnelles._getIdRegle(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) ======= * ======= Gestion des accès aux compendiums systèmes (ou surchargés) =======
*/ */
export class SystemCompendiums extends FormApplication { export class SystemCompendiums extends FormApplication {
static init() { static initSettings() {
Object.keys(CONFIGURABLE_COMPENDIUMS).forEach(compendium => { Object.keys(CONFIGURABLE_COMPENDIUMS).forEach(compendium => {
const definition = CONFIGURABLE_COMPENDIUMS[compendium]; const definition = CONFIGURABLE_COMPENDIUMS[compendium];
foundry.utils.mergeObject(definition, { foundry.utils.mergeObject(definition, {

View File

@ -4,7 +4,7 @@ export const AUTO_ADJUST_DARKNESS = "auto-adjust-darkness";
export class AutoAdjustDarkness { export class AutoAdjustDarkness {
static init() { static initSettings() {
game.settings.register(SYSTEM_RDD, AUTO_ADJUST_DARKNESS, { game.settings.register(SYSTEM_RDD, AUTO_ADJUST_DARKNESS, {
name: AUTO_ADJUST_DARKNESS, name: AUTO_ADJUST_DARKNESS,
scope: "world", 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 }; const INITIAL_CALENDAR_POS = { top: 200, left: 200, horlogeAnalogique: true };
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCalendrier extends Application { export class RdDCalendrier extends Application {
static init() { static initSettings() {
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", { game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
name: "liste-nombre-astral", name: "liste-nombre-astral",
scope: "world", scope: "world",

View File

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