mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
[PR][Feature] 798 - Attribution (#986)
* Added attribution for items, adversary and environment * Added Attribution to all adversaries * Added attribution to environments * Added attribution for class and subclass * Added Attribution to Ancestry/Community * Added Attribution for Beastforms * Added Attribution to DomainCards * Added Attribution for wepaons * Attribution for Armor/Loot/Consumables * Added a setting to hide attribution
This commit is contained in:
parent
495575fba4
commit
8c84edddad
982 changed files with 9082 additions and 3996 deletions
|
|
@ -85,6 +85,8 @@ export default function DHApplicationMixin(Base) {
|
|||
this._dragDrop = this._createDragDropHandlers();
|
||||
}
|
||||
|
||||
#nonHeaderAttribution = ['environment', 'ancestry', 'community', 'domainCard'];
|
||||
|
||||
/**
|
||||
* The default options for the sheet.
|
||||
* @type {DHSheetV2Configuration}
|
||||
|
|
@ -101,7 +103,8 @@ export default function DHApplicationMixin(Base) {
|
|||
toggleEffect: DHSheetV2.#toggleEffect,
|
||||
toggleExtended: DHSheetV2.#toggleExtended,
|
||||
addNewItem: DHSheetV2.#addNewItem,
|
||||
browseItem: DHSheetV2.#browseItem
|
||||
browseItem: DHSheetV2.#browseItem,
|
||||
editAttribution: DHSheetV2.#editAttribution
|
||||
},
|
||||
contextMenus: [
|
||||
{
|
||||
|
|
@ -125,6 +128,43 @@ export default function DHApplicationMixin(Base) {
|
|||
tagifyConfigs: []
|
||||
};
|
||||
|
||||
/**@inheritdoc */
|
||||
async _renderFrame(options) {
|
||||
const frame = await super._renderFrame(options);
|
||||
|
||||
const hideAttribution = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||
).hideAttribution;
|
||||
const headerAttribution = !this.#nonHeaderAttribution.includes(this.document.type);
|
||||
if (!hideAttribution && this.document.system.metadata.hasAttribution && headerAttribution) {
|
||||
const { source, page } = this.document.system.attribution;
|
||||
const attribution = [source, page ? `pg ${page}.` : null].filter(x => x).join('. ');
|
||||
const element = `<label class="attribution-header-label">${attribution}</label>`;
|
||||
this.window.controls.insertAdjacentHTML('beforebegin', element);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the custom parts of the application frame
|
||||
*/
|
||||
refreshFrame() {
|
||||
const hideAttribution = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||
).hideAttribution;
|
||||
const headerAttribution = !this.#nonHeaderAttribution.includes(this.document.type);
|
||||
if (!hideAttribution && this.document.system.metadata.hasAttribution && headerAttribution) {
|
||||
const { source, page } = this.document.system.attribution;
|
||||
const attribution = [source, page ? `pg ${page}.` : null].filter(x => x).join('. ');
|
||||
|
||||
const label = this.window.header.querySelector('.attribution-header-label');
|
||||
label.innerHTML = attribution;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Related documents that should cause a rerender of this application when updated.
|
||||
*/
|
||||
|
|
@ -548,6 +588,14 @@ export default function DHApplicationMixin(Base) {
|
|||
return new ItemBrowser({ presets }).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the attribution dialog
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #editAttribution() {
|
||||
new game.system.api.applications.dialogs.AttributionDialog(this.document).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an embedded document.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.isNPC = this.document.isNPC;
|
||||
context.showAttribution = !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
|
||||
.hideAttribution;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,16 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
static DEFAULT_OPTIONS = {
|
||||
classes: ['item'],
|
||||
position: { width: 600 },
|
||||
window: { resizable: true },
|
||||
window: {
|
||||
resizable: true,
|
||||
controls: [
|
||||
{
|
||||
icon: 'fa-solid fa-signature',
|
||||
label: 'DAGGERHEART.UI.Tooltip.configureAttribution',
|
||||
action: 'editAttribution'
|
||||
}
|
||||
]
|
||||
},
|
||||
form: {
|
||||
submitOnChange: true
|
||||
},
|
||||
|
|
@ -55,6 +64,15 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
/* Prepare Context */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = super._prepareContext(options);
|
||||
context.showAttribution = !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
|
||||
.hideAttribution;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
await super._preparePartContext(partId, context, options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue