From 5352b494ec75d36577a4c58116d9d31d04885be6 Mon Sep 17 00:00:00 2001 From: Matheus Clemente Date: Thu, 28 Sep 2023 17:39:45 -0300 Subject: [PATCH] Change setting to user flag Fix #72. --- module/logic.js | 6 +++--- module/settings.js | 6 ------ party-overview.js | 5 ++--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/module/logic.js b/module/logic.js index 5fc13b3..279b1ea 100644 --- a/module/logic.js +++ b/module/logic.js @@ -14,7 +14,7 @@ class PartyOverviewApp extends Application { this.hiddenActors = game.settings.get("party-overview", "hiddenActors"); this.state = {}; - this.displayMode = game.settings.get("party-overview", "displayMode"); + this.displayMode = game.user.getFlag("party-overview", "displayMode") ?? 4; this.activeTab = "general"; this.rendering = false; } @@ -134,13 +134,13 @@ class PartyOverviewApp extends Application { $(".btn-filter").on("click", (event) => { this.displayMode += 1; if (this.displayMode > Object.keys(DISPLAY_MODE).length - 1) this.displayMode = 0; - game.settings.set("party-overview", "displayMode", this.displayMode); + game.user.setFlag("party-overview", "displayMode", this.displayMode); this.render(false); }); $(".btn-filter").on("contextmenu", (event) => { this.displayMode -= 1; if (this.displayMode < 0) this.displayMode = Object.keys(DISPLAY_MODE).length - 1; - game.settings.set("party-overview", "displayMode", this.displayMode); + game.user.setFlag("party-overview", "displayMode", this.displayMode); this.render(false); }); diff --git a/module/settings.js b/module/settings.js index 92c8d6e..e9fa7b4 100644 --- a/module/settings.js +++ b/module/settings.js @@ -23,12 +23,6 @@ export function registerSettings() { default: getDefaultSystemProvider(), onChange: updateSystemProvider, }); - game.settings.register("party-overview", "displayMode", { - scope: "world", - config: false, - type: Number, - default: 4, - }); game.settings.register("party-overview", "hiddenActors", { scope: "world", config: false, diff --git a/party-overview.js b/party-overview.js index f615234..b9642c1 100644 --- a/party-overview.js +++ b/party-overview.js @@ -6,7 +6,6 @@ Hooks.once("init", () => { registerSettings(); initApi(); registerApiSettings(); - game.partyOverview = new PartyOverviewApp(); if (game.keybindings) { game.keybindings.register("party-overview", "openPartyOverview", { @@ -48,7 +47,7 @@ Hooks.once("init", () => { }); Hooks.on("ready", () => { - if (!game.partyOverview) game.partyOverview = new PartyOverviewApp(); + game.partyOverview = new PartyOverviewApp(); if (game.modules.get("stream-view")?.active && game?.user?.id === game.settings.get("stream-view", "user-id")) game.partyOverview.render(true); }); @@ -94,7 +93,7 @@ Hooks.on("deleteToken", (token, options, userId) => { }); Hooks.on("canvasInit", (canvas) => { - if (game.partyOverview.rendering) { + if (game.partyOverview?.rendering) { // what a hack! the hook is fired when the scene switch is not yet activated, so we need // to wait a tiny bit. The combat tracker is rendered last, so the scene should be available Hooks.once("renderCombatTracker", (app, html, data) => {