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

New unlinked display setting #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"grayscale": "Greyscale",
"sepia": "Sepia"
},
"showUnlikedTokens": {
"name": "Show Unlinked Tokens",
"hint": "Check this to display the unlinked tokens in the Unit Frame."
},
"showResourceValues": {
"name": "Show Resource Values",
"hint": "Check this to display resource values on Unit Frame bars for all players."
Expand Down
7 changes: 5 additions & 2 deletions src/modules/apps/UnitFramesBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class UnitFramesBox extends RepositionableApplication {
options.skin = game.settings.get(constants.moduleName, 'skin');
options.filter = game.settings.get(constants.moduleName, 'filter');
options.displayValues = game.settings.get(constants.moduleName, 'showResourceValues');
options.displayUnliked = game.settings.get(constants.moduleName, 'showUnlikedTokens');

return options;
}
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class UnitFramesBox extends RepositionableApplication {
}

getTokens() {
let showUnlikedTokens = game.settings.get(constants.moduleName, 'showUnlikedTokens');
const tokens = new Map();

// first linked character
Expand All @@ -96,10 +98,11 @@ export default class UnitFramesBox extends RepositionableApplication {
tokens.set(linked.id, linked);
}
}

// then all owned, sorted alphabetically
canvas.tokens.placeables.filter(t => t.owner && this.canSeeBars(t)).sort(this._sortNames).forEach(t => tokens.set(t.id, t));
canvas.tokens.placeables.filter(t => t.owner && this.canSeeBars(t) && (showUnlikedTokens || (!showUnlikedTokens && t.data.actorLink))).sort(this._sortNames).forEach(t => tokens.set(t.id, t));
// then rest, sorted alphabetically
canvas.tokens.placeables.filter(t => this.canSeeBars(t)).sort(this._sortNames).forEach(t => tokens.set(t.id, t));
canvas.tokens.placeables.filter(t => this.canSeeBars(t) && (showUnlikedTokens || (!showUnlikedTokens && t.data.actorLink))).sort(this._sortNames).forEach(t => tokens.set(t.id, t));

return tokens;
}
Expand Down
10 changes: 10 additions & 0 deletions src/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export default function registerSettings() {
}
});

game.settings.register(constants.moduleName, "showUnlikedTokens", {
name: "WorkshopPUF.Settings.showUnlikedTokens.name",
hint: "WorkshopPUF.Settings.showUnlikedTokens.hint",
scope: "world",
config: true,
default: true,
type: Boolean,
onChange: value => ui.unitFrames?.render()
});

game.settings.register(constants.moduleName, "showResourceValues", {
name: "WorkshopPUF.Settings.showResourceValues.name",
hint: "WorkshopPUF.Settings.showResourceValues.hint",
Expand Down