mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 20:21:06 +01:00
Merge branch 'development' into feature/party-sheet
This commit is contained in:
commit
d15feabfc5
210 changed files with 4152 additions and 861 deletions
|
|
@ -10,7 +10,9 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
position: { width: 660, height: 766 },
|
||||
window: { resizable: true },
|
||||
actions: {
|
||||
reactionRoll: AdversarySheet.#reactionRoll
|
||||
reactionRoll: AdversarySheet.#reactionRoll,
|
||||
toggleResourceDice: AdversarySheet.#toggleResourceDice,
|
||||
handleResourceDice: AdversarySheet.#handleResourceDice
|
||||
},
|
||||
window: {
|
||||
resizable: true,
|
||||
|
|
@ -25,6 +27,10 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
};
|
||||
|
||||
static PARTS = {
|
||||
limited: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/adversary/limited.hbs',
|
||||
scrollable: ['.limited-container']
|
||||
},
|
||||
sidebar: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/adversary/sidebar.hbs',
|
||||
scrollable: ['.shortcut-items-section']
|
||||
|
|
@ -52,6 +58,18 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const applicationOptions = super._initializeApplicationOptions(options);
|
||||
|
||||
if (applicationOptions.document.testUserPermission(game.user, 'LIMITED', { exact: true })) {
|
||||
applicationOptions.position.width = 360;
|
||||
applicationOptions.position.height = 'auto';
|
||||
}
|
||||
|
||||
return applicationOptions;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
|
@ -65,6 +83,7 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
context = await super._preparePartContext(partId, context, options);
|
||||
switch (partId) {
|
||||
case 'header':
|
||||
case 'limited':
|
||||
await this._prepareHeaderContext(context, options);
|
||||
|
||||
const adversaryTypes = CONFIG.DH.ACTOR.allAdversaryTypes();
|
||||
|
|
@ -156,6 +175,40 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
this.actor.diceRoll(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the used state of a resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #toggleResourceDice(event, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
|
||||
const { dice } = event.target.closest('.item-resource').dataset;
|
||||
const diceState = item.system.resource.diceStates[dice];
|
||||
|
||||
await item.update({
|
||||
[`system.resource.diceStates.${dice}.used`]: diceState ? !diceState.used : true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the roll values of resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #handleResourceDice(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
|
||||
const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create(item, this.document);
|
||||
if (!rollValues) return;
|
||||
|
||||
await item.update({
|
||||
'system.resource.diceStates': rollValues.reduce((acc, state, index) => {
|
||||
acc[index] = { value: state.value, used: state.used };
|
||||
return acc;
|
||||
}, {})
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Listener Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
|
||||
/**@override */
|
||||
static PARTS = {
|
||||
limited: {
|
||||
id: 'limited',
|
||||
scrollable: ['.limited-container'],
|
||||
template: 'systems/daggerheart/templates/sheets/actors/character/limited.hbs'
|
||||
},
|
||||
sidebar: {
|
||||
id: 'sidebar',
|
||||
scrollable: ['.shortcut-items-section'],
|
||||
|
|
@ -141,23 +146,37 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const applicationOptions = super._initializeApplicationOptions(options);
|
||||
|
||||
if (applicationOptions.document.testUserPermission(game.user, 'LIMITED', { exact: true })) {
|
||||
applicationOptions.position.width = 360;
|
||||
applicationOptions.position.height = 'auto';
|
||||
}
|
||||
|
||||
return applicationOptions;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
||||
this.element
|
||||
.querySelector('.level-value')
|
||||
?.addEventListener('change', event => this.document.updateLevel(Number(event.currentTarget.value)));
|
||||
if (!this.document.testUserPermission(game.user, 'LIMITED', { exact: true })) {
|
||||
this.element
|
||||
.querySelector('.level-value')
|
||||
?.addEventListener('change', event => this.document.updateLevel(Number(event.currentTarget.value)));
|
||||
|
||||
const observer = this.document.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER, {
|
||||
exact: true
|
||||
});
|
||||
if (observer) {
|
||||
this.element.querySelector('.window-content').classList.add('viewMode');
|
||||
const observer = this.document.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER, {
|
||||
exact: true
|
||||
});
|
||||
if (observer) {
|
||||
this.element.querySelector('.window-content').classList.add('viewMode');
|
||||
}
|
||||
|
||||
this._createFilterMenus();
|
||||
this._createSearchFilter();
|
||||
}
|
||||
|
||||
this._createFilterMenus();
|
||||
this._createSearchFilter();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ export default class DhCompanionSheet extends DHBaseActorSheet {
|
|||
};
|
||||
|
||||
static PARTS = {
|
||||
limited: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/companion/limited.hbs',
|
||||
scrollable: ['.limited-container']
|
||||
},
|
||||
header: { template: 'systems/daggerheart/templates/sheets/actors/companion/header.hbs' },
|
||||
details: { template: 'systems/daggerheart/templates/sheets/actors/companion/details.hbs' },
|
||||
effects: {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { getDocFromElement } from '../../../helpers/utils.mjs';
|
||||
import DHBaseActorSheet from '../api/base-actor.mjs';
|
||||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
|
@ -20,12 +21,19 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
}
|
||||
]
|
||||
},
|
||||
actions: {},
|
||||
actions: {
|
||||
toggleResourceDice: DhpEnvironment.#toggleResourceDice,
|
||||
handleResourceDice: DhpEnvironment.#handleResourceDice
|
||||
},
|
||||
dragDrop: [{ dragSelector: '.action-section .inventory-item', dropSelector: null }]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
static PARTS = {
|
||||
limited: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/environment/limited.hbs',
|
||||
scrollable: ['.limited-container']
|
||||
},
|
||||
header: { template: 'systems/daggerheart/templates/sheets/actors/environment/header.hbs' },
|
||||
features: {
|
||||
template: 'systems/daggerheart/templates/sheets/actors/environment/features.hbs',
|
||||
|
|
@ -47,6 +55,18 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
}
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
_initializeApplicationOptions(options) {
|
||||
const applicationOptions = super._initializeApplicationOptions(options);
|
||||
|
||||
if (applicationOptions.document.testUserPermission(game.user, 'LIMITED', { exact: true })) {
|
||||
applicationOptions.position.width = 360;
|
||||
applicationOptions.position.height = 'auto';
|
||||
}
|
||||
|
||||
return applicationOptions;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
context = await super._preparePartContext(partId, context, options);
|
||||
|
|
@ -118,4 +138,44 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
event.dataTransfer.setDragImage(item, 60, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the used state of a resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #toggleResourceDice(event, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
|
||||
const { dice } = event.target.closest('.item-resource').dataset;
|
||||
const diceState = item.system.resource.diceStates[dice];
|
||||
|
||||
await item.update({
|
||||
[`system.resource.diceStates.${dice}.used`]: diceState ? !diceState.used : true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the roll values of resource dice.
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #handleResourceDice(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
|
||||
const rollValues = await game.system.api.applications.dialogs.ResourceDiceDialog.create(item, this.document);
|
||||
if (!rollValues) return;
|
||||
|
||||
await item.update({
|
||||
'system.resource.diceStates': rollValues.reduce((acc, state, index) => {
|
||||
acc[index] = { value: state.value, used: state.used };
|
||||
return acc;
|
||||
}, {})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
return (this.#settingSheet ??= SheetClass ? new SheetClass({ document: this.document }) : null);
|
||||
}
|
||||
|
||||
get isVisible() {
|
||||
const viewPermission = this.document.testUserPermission(game.user, this.options.viewPermission);
|
||||
const limitedOnly = this.document.testUserPermission(game.user, this.options.viewPermission, { exact: true });
|
||||
return limitedOnly ? this.document.system.metadata.hasLimitedView : viewPermission;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Prepare Context */
|
||||
/* -------------------------------------------- */
|
||||
|
|
@ -72,6 +78,31 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
return context;
|
||||
}
|
||||
|
||||
_configureRenderParts(options) {
|
||||
const parts = super._configureRenderParts(options);
|
||||
if (!this.document.system.metadata.hasLimitedView) return parts;
|
||||
|
||||
if (this.document.testUserPermission(game.user, 'LIMITED', { exact: true })) return { limited: parts.limited };
|
||||
|
||||
return Object.keys(parts).reduce((acc, key) => {
|
||||
if (key !== 'limited') acc[key] = parts[key];
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
|
||||
if (
|
||||
this.document.system.metadata.hasLimitedView &&
|
||||
this.document.testUserPermission(game.user, 'LIMITED', { exact: true })
|
||||
) {
|
||||
this.element.classList = `${this.element.classList} limited`;
|
||||
}
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue