Hooks.on("init", () => {
game.settings.register("theripper-premium-hub", "autoCheck", {
name: "Check for Updates on Startup",
hint: "Automatically check on world load if any of my premium modules have updates.",
scope: "world",
config: true,
type: Boolean,
default: true,
});
game.settings.register("theripper-premium-hub", "checkDisabled", {
name: "Check Modules not Enabled",
hint: "Check for updates on modules that are installed but not enabled.",
scope: "world",
config: true,
type: Boolean,
default: true,
});
game.settings.register("theripper-premium-hub", "viewedAnnouncements", {
scope: "world",
config: false,
type: String,
default: "",
});
game.settings.register("theripper-premium-hub", "viewedUpdates", {
scope: "world",
config: false,
type: Object,
default: {},
});
game.settings.register("theripper-premium-hub", "prevEnabledModules", {
scope: "world",
config: false,
type: Array,
default: [],
});
const prevEnabledModules = game.settings.get("theripper-premium-hub", "prevEnabledModules");
async function reEnableModules() {
if (game.user.isGM && prevEnabledModules.length > 0) {
const confirm = await Dialog.confirm({
title: "TheRipper93 Premium HUB",
content: "Would you like to re-enable your previously enabled modules?
Choose 'No' to disable this prompt, you will have to manually re-enable modules in the module management menu.
Close this prompt to be asked again on next refresh.",
yes: () => {
return true;
},
no: () => {
return false;
},
defaultYes: true,
});
if(confirm === false) await game.settings.set("theripper-premium-hub", "prevEnabledModules", []);
if (!confirm) return;
const modulesSetting = game.settings.get("core", ModuleManagement.CONFIG_SETTING);
for (const [k, v] of Object.entries(modulesSetting)) {
if (prevEnabledModules.includes(k)) {
modulesSetting[k] = true;
}
}
await game.settings.set("theripper-premium-hub", "prevEnabledModules", []);
await game.settings.set("core", ModuleManagement.CONFIG_SETTING, modulesSetting);
debouncedReload();
}
}
Hooks.once("ready", () => {
reEnableModules();
});
});
Hooks.on("renderSettingsConfig", (app, html, data) => {
if (!game.user.isGM) return;
function generateSupportReport(moduleId) {
const supportInfo = SupportDetails.generateSupportReport();
const supportOutput = {
"Core Version": supportInfo.coreVersion,
System: supportInfo.systemVersion,
Client: supportInfo.client,
GPU: supportInfo.gpu,
"Module Count": supportInfo.activeModuleCount,
};
const module = game.modules.get(moduleId);
supportOutput[module.title] = module.version;
const dependencies = game.theripperpremiumhub.getDependencies(moduleId);
dependencies.forEach((m) => {
supportOutput[m.title] = m.version;
});
const tableHtml = Object.keys(supportOutput)
.map((key) => {
return `