Skip to content

Commit

Permalink
Filter: Selected PCs
Browse files Browse the repository at this point in the history
Fix #43
  • Loading branch information
mclemente committed Jul 5, 2022
1 parent 4823839 commit 3f364f4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
10 changes: 7 additions & 3 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -38,9 +45,6 @@

"DND5E": {
"Traits": "Traits"
},
"PF2E": {
"EncumberedAt": "Encumbered At"
}
}
}
3 changes: 0 additions & 3 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
"WEALTH": "財産",
"DND5E": {
"Traits": "特徴"
},
"PF2E": {
"EncumberedAt": "荷重境界"
}
}
}
3 changes: 0 additions & 3 deletions lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
"WEALTH": "Riqueza",
"DND5E": {
"Traits": "Traços"
},
"PF2E": {
"EncumberedAt": "Sobrecarregado em"
}
}
}
26 changes: 20 additions & 6 deletions module/logic.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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 () {
Expand Down
11 changes: 6 additions & 5 deletions templates/parts/FilterButton.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div class="button">
<!-- prettier-ignore -->
<button class="btn-filter">
{{#if (eq mode 0)}}<i class="fas fa-filter"></i>{{/if}}
{{#if (eq mode 1) }}<i class="fas fa-eye"></i>{{/if}}
{{#if (eq mode 2) }}<i class="fas fa-eye-slash"></i>{{/if}}
{{#if (eq mode 3) }}<i class="fas fa-users"></i>{{/if}}
<button class="btn-filter"
{{#if (eq mode 0)}}title="{{localize "party-overview.filter.0"}}"><i class="fas fa-map"></i>{{/if}}
{{#if (eq mode 1) }}title="{{localize "party-overview.filter.1"}}"><i class="fas fa-eye"></i>{{/if}}
{{#if (eq mode 2) }}title="{{localize "party-overview.filter.2"}}"><i class="fas fa-eye-slash"></i>{{/if}}
{{#if (eq mode 4) }}title="{{localize "party-overview.filter.4"}}"><i class="fas fa-users"></i>{{/if}}
{{#if (eq mode 3) }}title="{{localize "party-overview.filter.3"}}">All{{/if}}
</button>
</div>

0 comments on commit 3f364f4

Please sign in to comment.