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
|
|
@ -5,6 +5,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taf": {
|
"taf": {
|
||||||
|
"settings": {
|
||||||
|
"canPlayersManageAttributes": {
|
||||||
|
"name": "Players Can Manage Attributes",
|
||||||
|
"hint": "This allows players who have edit access to a document to be able to edit what attributes those characters have via the attribute editor"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sheet-names": {
|
"sheet-names": {
|
||||||
"PlayerSheet": "Player Sheet"
|
"PlayerSheet": "Player Sheet"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,6 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
},
|
},
|
||||||
window: {
|
window: {
|
||||||
resizable: true,
|
resizable: true,
|
||||||
controls: [
|
|
||||||
{
|
|
||||||
icon: `fa-solid fa-at`,
|
|
||||||
label: `Manage Attributes`,
|
|
||||||
action: `manageAttributes`,
|
|
||||||
visible: () => {
|
|
||||||
return game.user.isGM;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
submitOnChange: true,
|
submitOnChange: true,
|
||||||
|
|
@ -46,6 +36,23 @@ export class PlayerSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
// #endregion Options
|
// #endregion Options
|
||||||
|
|
||||||
// #region Lifecycle
|
// #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
|
// #endregion Lifecycle
|
||||||
|
|
||||||
// #region Data Prep
|
// #region Data Prep
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ import { PlayerData } from "../data/Player.mjs";
|
||||||
import { TAFActor } from "../documents/Actor.mjs";
|
import { TAFActor } from "../documents/Actor.mjs";
|
||||||
import { TAFTokenDocument } from "../documents/Token.mjs";
|
import { TAFTokenDocument } from "../documents/Token.mjs";
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
import { registerWorldSettings } from "../settings/world.mjs";
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { __ID__ } from "../consts.mjs";
|
import { __ID__ } from "../consts.mjs";
|
||||||
import { Logger } from "../utils/Logger.mjs";
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
|
|
@ -28,4 +31,6 @@ Hooks.on(`init`, () => {
|
||||||
label: `taf.sheet-names.PlayerSheet`,
|
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