From 848a54fa1e9e581e72149a83785dbc39577238e0 Mon Sep 17 00:00:00 2001 From: litasa Date: Thu, 17 Aug 2023 22:06:53 +0200 Subject: [PATCH] Adding the ability to have a different name on the custom-compendium. This also have the positive effect that you can easily switch between the clean git version and your own --- system/scripts/hooks.js | 2 +- system/scripts/settings.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/system/scripts/hooks.js b/system/scripts/hooks.js index 0cbd528..f1d61c7 100644 --- a/system/scripts/hooks.js +++ b/system/scripts/hooks.js @@ -6,7 +6,7 @@ export default class HooksL5r5e { // Enable embed Babele compendiums only if custom compendium is not found or disabled if ( typeof Babele !== "undefined" && - Babele.get().modules.every((module) => module.module !== "l5r5e-custom-compendiums") + Babele.get().modules.every((module) => module.module !== game.settings.get(CONFIG.l5r5e.namespace, "babele-custom-compendium-name")) ) { Babele.get().setSystemTranslationsDir("babele"); // Since Babele v2.0.7 } diff --git a/system/scripts/settings.js b/system/scripts/settings.js index d3a4cb2..7e2d4a8 100644 --- a/system/scripts/settings.js +++ b/system/scripts/settings.js @@ -125,4 +125,24 @@ export const RegisterSettings = function () { default: [], onChange: () => game.l5r5e.HelpersL5r5e.refreshLocalAndSocket("l5r5e-gm-monitor"), }); + + /* ------------------------------------ */ + /* Babele */ + /* ------------------------------------ */ + const showCustomCompendiumSetting = (typeof Babele !== "undefined"); + game.settings.register(CONFIG.l5r5e.namespace, "babele-custom-compendium-name", { + name: "Custom Compendium Name", + hint: "For advanced users that want to change the name of custom compendiums", + scope: "world", + config: showCustomCompendiumSetting, + requiresReload: true, + type: String, + default: "l5r5e-custom-compendiums", + onChange: (value) => { + if(!Babele.get().modules.find((module) => module.module === value)) + { + ui.notifications.warn("Unable set Custom Compendium: \"" + value + "\". Is it activated and registered with Babele?", {permanent: true}); + } + } + }); };