From 4186fca28b908906bdb667b7750dfe6445215312 Mon Sep 17 00:00:00 2001 From: Matheus Clemente Date: Wed, 21 Dec 2022 14:37:35 -0300 Subject: [PATCH] Persistence: Display Mode & Hidden Actors --- module/logic.js | 8 ++++++-- module/settings.js | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/module/logic.js b/module/logic.js index 6fb3375..c92edd5 100644 --- a/module/logic.js +++ b/module/logic.js @@ -12,9 +12,9 @@ class PartyOverviewApp extends Application { constructor(options) { super(options); - this.hiddenActors = []; + this.hiddenActors = game.settings.get("party-overview", "hiddenActors"); this.state = {}; - this.displayMode = DISPLAY_MODE.SHOW_PC_ONLY; + this.displayMode = game.settings.get("party-overview", "displayMode"); this.activeTab = "general"; this.rendering = false; } @@ -117,22 +117,26 @@ class PartyOverviewApp extends Application { $(".btn-toggle-visibility").on("click", (event) => { const actorId = event.currentTarget.dataset.actor; this.hiddenActors = this.hiddenActors.includes(actorId) ? this.hiddenActors.filter((id) => id !== actorId) : [...this.hiddenActors, actorId]; + game.settings.set("party-overview", "hiddenActors", this.hiddenActors); this.render(false); }); $(".btn-toggle-visibility").on("contextmenu", (event) => { const actorId = event.currentTarget.dataset.actor; this.hiddenActors = this.hiddenActors.includes(actorId) ? this.hiddenActors.filter((id) => id !== actorId) : [...this.hiddenActors, actorId]; + game.settings.set("party-overview", "hiddenActors", this.hiddenActors); this.render(false); }); $(".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); 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); this.render(false); }); diff --git a/module/settings.js b/module/settings.js index 211ba85..92c8d6e 100644 --- a/module/settings.js +++ b/module/settings.js @@ -23,6 +23,18 @@ 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, + type: Array, + default: [], + }); } export function registerApiSettings() {