Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted "Show Actors" setting to include all actors that are owned by players #455

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions apps/tokenbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,51 @@ export class TokenBar extends Application {
}
});

// add actors without tokens that are owned by users, if setting is enabled
if (setting("include-actor")) {
for (let user of game.users) {
if ((user.active || setting("show-offline")) && !user.isGM && user.character && !this.entries.find(t => t.actor?.id === user.character?.id)) {
this.entries.push({
id: user.character.id,
token: null,
actor: user.character,
img: null,
thumb: null,
stats: {},
resource1: {},
resource2: {},
cssClass: "only-actor"
});
}
// iterate through all actors and if they belong to a player, add them to contention, pending other checks
for (let actor of game.actors) {
let t = actor.prototypeToken;

if (actor.hasPlayerOwner) {
// exclude actors that are explicitly excluded
let include = t.getFlag("monks-tokenbar", "include");
if (include === "exclude") continue;

// show offline users, if setting is enabled
let showOnline =
setting("show-offline") ||
game.users.find(
(u) => u.active && u.character?.id == t.actor?.id
);

if (!showOnline) continue;

// exclude actors that don't pass the ownership/ permissions threshold
let canView =
game.user.isGM ||
t.actor?.isOwner ||
t.actor?.testUserPermission(
game.user,
setting("minimum-ownership") || "LIMITED"
);

if (!canView) continue;

debug("Adding actor", actor.name);
if (!this.entries.find((a) => a.actor?.id === actor.id))
this.entries.push({
id: actor.id,
token: null,
actor: actor,
img: null,
thumb: null,
stats: {},
resource1: {},
resource2: {},
cssClass: "only-actor",
});
}
}
}

Expand Down