From 3f364f465b329e04b493ea55ec87a65c0c399ee1 Mon Sep 17 00:00:00 2001 From: mclemente Date: Tue, 5 Jul 2022 20:40:44 -0300 Subject: [PATCH] Filter: Selected PCs Fix https://github.com/mclemente/party-overview/issues/43 --- lang/en.json | 10 +++++++--- lang/ja.json | 3 --- lang/pt-BR.json | 3 --- module/logic.js | 26 ++++++++++++++++++++------ templates/parts/FilterButton.html | 11 ++++++----- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lang/en.json b/lang/en.json index 987c6b2..9fa3626 100644 --- a/lang/en.json +++ b/lang/en.json @@ -12,6 +12,13 @@ "system": "System {name}" } }, + "filter": { + "0": "All (Scene, Unfilted)", + "1": "All (Scene)", + "2": "Hidden (Scene)", + "3": "All Owned", + "4": "All Selected" + }, "keybinds": { "open": { "name": "Open Party Overview", @@ -38,9 +45,6 @@ "DND5E": { "Traits": "Traits" - }, - "PF2E": { - "EncumberedAt": "Encumbered At" } } } diff --git a/lang/ja.json b/lang/ja.json index 43c854a..fff268b 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -35,9 +35,6 @@ "WEALTH": "財産", "DND5E": { "Traits": "特徴" - }, - "PF2E": { - "EncumberedAt": "荷重境界" } } } diff --git a/lang/pt-BR.json b/lang/pt-BR.json index a9f0ee6..586c42d 100644 --- a/lang/pt-BR.json +++ b/lang/pt-BR.json @@ -35,9 +35,6 @@ "WEALTH": "Riqueza", "DND5E": { "Traits": "Traços" - }, - "PF2E": { - "EncumberedAt": "Sobrecarregado em" } } } diff --git a/module/logic.js b/module/logic.js index 9b4bc5b..0f4efb5 100644 --- a/module/logic.js +++ b/module/logic.js @@ -1,10 +1,11 @@ import { currentSystemProvider } from "./api.js"; const DISPLAY_MODE = { - SHOW_ALL: 0, - SHOW_VISIBLE: 1, - SHOW_HIDDEN: 2, - SHOW_MORE: 3, + SHOW_ALL: 0, //Scene, Ulfiltered + SHOW_VISIBLE: 1, //Scene, Filtered + SHOW_HIDDEN: 2, //Scene, Hidden + SHOW_MORE: 3, //Player Controlled + SHOW_PC_ONLY: 4, //Selected PCs }; class PartyOverviewApp extends Application { @@ -13,14 +14,17 @@ class PartyOverviewApp extends Application { this.hiddenActors = []; this.state = {}; - this.displayMode = DISPLAY_MODE.SHOW_VISIBLE; + this.displayMode = DISPLAY_MODE.SHOW_PC_ONLY; this.activeTab = "general"; this.rendering = false; } update() { let actors = game.actors.contents.filter((a) => a.hasPlayerOwner); - if (this.displayMode != DISPLAY_MODE.SHOW_MORE) { + if (this.displayMode == DISPLAY_MODE.SHOW_PC_ONLY) { + let users = game.users.filter((u) => u.data.character).map((u) => u.data.character); + actors = actors.filter((playerActor) => users.includes(playerActor.data._id)); + } else if (this.displayMode != DISPLAY_MODE.SHOW_MORE) { actors = actors .map((playerActor) => playerActor.getActiveTokens()) .flat(1) @@ -115,12 +119,22 @@ class PartyOverviewApp extends Application { this.hiddenActors = this.hiddenActors.includes(actorId) ? this.hiddenActors.filter((id) => id !== actorId) : [...this.hiddenActors, actorId]; 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]; + this.render(false); + }); $(".btn-filter").on("click", (event) => { this.displayMode += 1; if (this.displayMode > Object.keys(DISPLAY_MODE).length - 1) this.displayMode = 0; this.render(false); }); + $(".btn-filter").on("contextmenu", (event) => { + this.displayMode -= 1; + if (this.displayMode < 0) this.displayMode = Object.keys(DISPLAY_MODE).length - 1; + this.render(false); + }); $('span[name="hpCurrent"], span[name="hpMax"]', html).hover( function () { diff --git a/templates/parts/FilterButton.html b/templates/parts/FilterButton.html index a8c8911..429001f 100644 --- a/templates/parts/FilterButton.html +++ b/templates/parts/FilterButton.html @@ -1,9 +1,10 @@
-