Cleanup init & start
- classe SystemReveDeDragon pour l'init/start - déplacement de la migration 1.5.34 dans les migrations
This commit is contained in:
parent
70b30b545b
commit
7bec249e8d
@ -29,6 +29,39 @@ class Migration {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _1_5_34_migrationPngWebp {
|
||||||
|
get code() { return "migrationPngWebp"; }
|
||||||
|
get version() { return "1.5.34"; }
|
||||||
|
async migrate() {
|
||||||
|
|
||||||
|
const regexOldPngJpg = /(systems\/foundryvtt-reve-de-dragon\/icons\/.*)\.(png|jpg)/;
|
||||||
|
const replaceWithWebp = '$1.webp';
|
||||||
|
function convertImgToWebp(img) {
|
||||||
|
return img.replace(regexOldPngJpg, replaceWithWebp);
|
||||||
|
}
|
||||||
|
function prepareDocumentsImgUpdate(documents) {
|
||||||
|
return documents.filter(it => it.img && it.img.match(regexOldPngJpg))
|
||||||
|
.map(it => {
|
||||||
|
return { _id: it.id, img: convertImgToWebp(it.img) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemsUpdates = prepareDocumentsImgUpdate(game.items);
|
||||||
|
const actorsUpdates = prepareDocumentsImgUpdate(game.actors);
|
||||||
|
//Migrate system png to webp
|
||||||
|
await Item.updateDocuments(itemsUpdates);
|
||||||
|
await Actor.updateDocuments(actorsUpdates);
|
||||||
|
game.actors.forEach(actor => {
|
||||||
|
if (actor.token?.img && actor.token.img.match(regexOldPngJpg)) {
|
||||||
|
actor.update({ "token.img": convertImgToWebp(actor.token.img) });
|
||||||
|
}
|
||||||
|
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
||||||
|
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class _10_0_16_MigrationSortsReserve extends Migration {
|
class _10_0_16_MigrationSortsReserve extends Migration {
|
||||||
get code() { return "creation-item-sort-reserve"; }
|
get code() { return "creation-item-sort-reserve"; }
|
||||||
get version() { return "10.0.16"; }
|
get version() { return "10.0.16"; }
|
||||||
@ -296,6 +329,7 @@ class _10_3_17_Monnaies extends Migration {
|
|||||||
export class Migrations {
|
export class Migrations {
|
||||||
static getMigrations() {
|
static getMigrations() {
|
||||||
return [
|
return [
|
||||||
|
new _1_5_34_migrationPngWebp(),
|
||||||
new _10_0_16_MigrationSortsReserve(),
|
new _10_0_16_MigrationSortsReserve(),
|
||||||
new _10_0_17_MigrationCompetenceCreature(),
|
new _10_0_17_MigrationCompetenceCreature(),
|
||||||
new _10_0_21_VehiculeStructureResistanceMax(),
|
new _10_0_21_VehiculeStructureResistanceMax(),
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { Misc } from "./misc.js";
|
|
||||||
|
|
||||||
export class RdDHotbar {
|
export class RdDHotbar {
|
||||||
|
|
||||||
|
@ -1,13 +1,3 @@
|
|||||||
/**
|
|
||||||
* RdD system
|
|
||||||
* Author: LeRatierBretonnien
|
|
||||||
* Software License: GNU GPLv3
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
// Import Modules
|
|
||||||
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
import { RdDActor } from "./actor.js";
|
import { RdDActor } from "./actor.js";
|
||||||
import { RdDItemSheet } from "./item-sheet.js";
|
import { RdDItemSheet } from "./item-sheet.js";
|
||||||
@ -45,25 +35,34 @@ import { RdDIngredientItemSheet } from "./item-ingredient-sheet.js";
|
|||||||
import { RdDFauneItemSheet } from "./item-faune-sheet.js";
|
import { RdDFauneItemSheet } from "./item-faune-sheet.js";
|
||||||
import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js";
|
import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RdD system
|
||||||
|
* Author: LeRatierBretonnien
|
||||||
|
* Software License: GNU GPLv3
|
||||||
|
*/
|
||||||
|
export class SystemReveDeDragon {
|
||||||
|
|
||||||
|
static start() {
|
||||||
|
const system = new SystemReveDeDragon();
|
||||||
|
Hooks.once('init', async () => await system.onInit());
|
||||||
|
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.RdDUtility = RdDUtility;
|
||||||
|
this.RdDHotbar = RdDHotbar;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
async onInit() {
|
||||||
|
game.system.rdd = this;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************/
|
|
||||||
Hooks.once("init", async function () {
|
|
||||||
console.log(`Initializing Reve de Dragon System`);
|
console.log(`Initializing Reve de Dragon System`);
|
||||||
|
|
||||||
// preload handlebars templates
|
// preload handlebars templates
|
||||||
RdDUtility.preloadHandlebarsTemplates();
|
RdDUtility.preloadHandlebarsTemplates();
|
||||||
// Create useful storage space
|
|
||||||
game.system.rdd = {
|
|
||||||
TMRUtility,
|
|
||||||
RdDUtility,
|
|
||||||
RdDHotbar,
|
|
||||||
RdDPossession,
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
||||||
@ -89,15 +88,6 @@ Hooks.once("init", async function () {
|
|||||||
type: Object
|
type: Object
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
game.settings.register(SYSTEM_RDD, "migration-png-webp-1.5.34", {
|
|
||||||
name: "calendrier",
|
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: false,
|
|
||||||
type: Boolean
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
||||||
name: "liste-nombre-astral",
|
name: "liste-nombre-astral",
|
||||||
@ -228,49 +218,21 @@ Hooks.once("init", async function () {
|
|||||||
RdDPossession.init();
|
RdDPossession.init();
|
||||||
TMRRencontres.init();
|
TMRRencontres.init();
|
||||||
Environnement.init();
|
Environnement.init();
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
Hooks.once('ready', () => this.onReady());
|
||||||
function messageDeBienvenue() {
|
|
||||||
if (game.user.isGM) {
|
|
||||||
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
|
||||||
ChatMessage.create({
|
|
||||||
user: game.user.id,
|
|
||||||
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
|
||||||
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
|
||||||
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
|
||||||
` });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
async onReady() {
|
||||||
// Register world usage statistics
|
|
||||||
async function registerUsageCount(registerKey) {
|
|
||||||
if (game.user.isGM) {
|
|
||||||
game.settings.register("world", "world-key", {
|
|
||||||
name: "Unique world key",
|
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: "NONE",
|
|
||||||
type: String
|
|
||||||
});
|
|
||||||
|
|
||||||
let worldKey = game.settings.get("world", "world-key")
|
|
||||||
if (worldKey == undefined || worldKey == "") {
|
|
||||||
worldKey = randomID(32)
|
|
||||||
game.settings.set("world", "world-key", worldKey)
|
|
||||||
}
|
|
||||||
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
|
||||||
$.ajax(regURL)
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
Hooks.once("ready", async function () {
|
// CSS patch for v9
|
||||||
await migrationPngWebp_1_5_34()
|
if (game.version) {
|
||||||
|
let sidebar = document.getElementById("sidebar");
|
||||||
|
sidebar.style.width = "min-content";
|
||||||
|
}
|
||||||
|
|
||||||
if (Misc.isUniqueConnectedGM()) {
|
if (Misc.isUniqueConnectedGM()) {
|
||||||
new Migrations().migrate();
|
new Migrations().migrate();
|
||||||
}
|
}
|
||||||
@ -297,49 +259,48 @@ Hooks.once("ready", async function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (Misc.isUniqueConnectedGM()) {
|
if (Misc.isUniqueConnectedGM()) {
|
||||||
messageDeBienvenue();
|
this.messageDeBienvenue();
|
||||||
registerUsageCount(SYSTEM_RDD);
|
this.registerUsageCount(SYSTEM_RDD);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
async function migrationPngWebp_1_5_34() {
|
|
||||||
if (!game.settings.get(SYSTEM_RDD, "migration-png-webp-1.5.34")) {
|
|
||||||
const regexOldPngJpg = /(systems\/foundryvtt-reve-de-dragon\/icons\/.*)\.(png|jpg)/;
|
|
||||||
const replaceWithWebp = '$1.webp';
|
|
||||||
function convertImgToWebp(img) {
|
|
||||||
return img.replace(regexOldPngJpg, replaceWithWebp);
|
|
||||||
}
|
|
||||||
function prepareDocumentsImgUpdate(documents) {
|
|
||||||
return documents.filter(it => it.img && it.img.match(regexOldPngJpg))
|
|
||||||
.map(it => {
|
|
||||||
return { _id: it.id, img: convertImgToWebp(it.img) }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const itemsUpdates = prepareDocumentsImgUpdate(game.items);
|
|
||||||
const actorsUpdates = prepareDocumentsImgUpdate(game.actors);
|
|
||||||
//Migrate system png to webp
|
|
||||||
await Item.updateDocuments(itemsUpdates);
|
|
||||||
await Actor.updateDocuments(actorsUpdates);
|
|
||||||
game.actors.forEach(actor => {
|
|
||||||
if (actor.token?.img && actor.token.img.match(regexOldPngJpg)) {
|
|
||||||
actor.update({ "token.img": convertImgToWebp(actor.token.img) });
|
|
||||||
}
|
|
||||||
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
|
||||||
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
|
||||||
});
|
|
||||||
game.settings.set(SYSTEM_RDD, "migration-png-webp-1.5.34", true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CSS patch for v9
|
|
||||||
if (game.version) {
|
|
||||||
let sidebar = document.getElementById("sidebar");
|
|
||||||
sidebar.style.width = "min-content";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Dice-so-nice ready */
|
messageDeBienvenue() {
|
||||||
/* -------------------------------------------- */
|
if (game.user.isGM) {
|
||||||
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
|
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
||||||
|
ChatMessage.create({
|
||||||
|
user: game.user.id,
|
||||||
|
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
||||||
|
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
||||||
|
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
||||||
|
` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
// Register world usage statistics
|
||||||
|
async registerUsageCount(registerKey) {
|
||||||
|
if (game.user.isGM) {
|
||||||
|
game.settings.register("world", "world-key", {
|
||||||
|
name: "Unique world key",
|
||||||
|
scope: "world",
|
||||||
|
config: false,
|
||||||
|
default: "NONE",
|
||||||
|
type: String
|
||||||
|
});
|
||||||
|
|
||||||
|
let worldKey = game.settings.get("world", "world-key")
|
||||||
|
if (worldKey == undefined || worldKey == "") {
|
||||||
|
worldKey = randomID(32)
|
||||||
|
game.settings.set("world", "world-key", worldKey)
|
||||||
|
}
|
||||||
|
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
||||||
|
$.ajax(regURL)
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemReveDeDragon.start();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user