Add ability to let players who own a document edit the attributes for it via the UI
This commit is contained in:
parent
0cc202e48d
commit
e1f173dde7
4 changed files with 40 additions and 10 deletions
|
|
@ -18,16 +18,6 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
controls: [
|
||||
{
|
||||
icon: `fa-solid fa-at`,
|
||||
label: `Manage Attributes`,
|
||||
action: `manageAttributes`,
|
||||
visible: () => {
|
||||
return game.user.isGM;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true,
|
||||
|
|
@ -46,6 +36,23 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
// #endregion Options
|
||||
|
||||
// #region Lifecycle
|
||||
_getHeaderControls() {
|
||||
const controls = super._getHeaderControls();
|
||||
|
||||
controls.push({
|
||||
icon: `fa-solid fa-at`,
|
||||
label: `Manage Attributes`,
|
||||
action: `manageAttributes`,
|
||||
visible: () => {
|
||||
const isGM = game.user.isGM;
|
||||
const allowPlayerEdits = game.settings.get(__ID__, `canPlayersManageAttributes`);
|
||||
const editable = this.isEditable;
|
||||
return isGM || (allowPlayerEdits && editable);
|
||||
},
|
||||
});
|
||||
|
||||
return controls;
|
||||
};
|
||||
// #endregion Lifecycle
|
||||
|
||||
// #region Data Prep
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import { PlayerData } from "../data/Player.mjs";
|
|||
import { TAFActor } from "../documents/Actor.mjs";
|
||||
import { TAFTokenDocument } from "../documents/Token.mjs";
|
||||
|
||||
// Settings
|
||||
import { registerWorldSettings } from "../settings/world.mjs";
|
||||
|
||||
// Utils
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
|
@ -28,4 +31,6 @@ Hooks.on(`init`, () => {
|
|||
label: `taf.sheet-names.PlayerSheet`,
|
||||
},
|
||||
);
|
||||
|
||||
registerWorldSettings();
|
||||
});
|
||||
|
|
|
|||
12
module/settings/world.mjs
Normal file
12
module/settings/world.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
|
||||
export function registerWorldSettings() {
|
||||
game.settings.register(__ID__, `canPlayersManageAttributes`, {
|
||||
name: `taf.settings.canPlayersManageAttributes.name`,
|
||||
hint: `taf.settings.canPlayersManageAttributes.hint`,
|
||||
config: true,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
scope: `world`,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue