mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
[V14] Effect Stacking (#1667)
* Added the ability for effects to have stacks * Fixed effect stacking * Improved token overlay spacing * Compendium updaetes * Simplify effect click event (#1748) * Fixed a bunch of deprecations * Corrected AgileScout Beastform json data * Updated TokenHUD to the new v14 * Removed DestroyOnEmpty from consumables * Fixed so that tooltips don't get stuck (#1745) * [Feature] TagTeam Partial Rendering (#1735) * I done did it, I think * Think I fixed the partial rendering bug for gm->player * [V14] 1743 - Damage Update Error (#1746) * Fixed DamageParts causing errors on update * Fixed ActionBaseConfig error when no damage present on the action * Fix removal of damage field * Removed unneccessary default value function for parts --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com> * Simplify effect click event --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> Co-authored-by: WBHarry <89362246+WBHarry@users.noreply.github.com> * Fixed stacking-value pointer event * Set the stacking value in EffectsDisplay to be tabular-nums for monospacing * Made baseEffect.stacking nullable instead of having an enabled property * . * Fixed so that actor._onUpdateDescantDocuments re-renders the EffectDisplay if effects were updated --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
This commit is contained in:
parent
64ce615116
commit
aa1d117c43
21 changed files with 349 additions and 204 deletions
|
|
@ -151,6 +151,10 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
});
|
||||
});
|
||||
|
||||
htmlElement
|
||||
.querySelector('.stacking-change-checkbox')
|
||||
?.addEventListener('change', this.stackingChangeToggle.bind(this));
|
||||
|
||||
htmlElement
|
||||
.querySelector('.armor-change-checkbox')
|
||||
?.addEventListener('change', this.armorChangeToggle.bind(this));
|
||||
|
|
@ -209,6 +213,16 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
return partContext;
|
||||
}
|
||||
|
||||
stackingChangeToggle(event) {
|
||||
const stackingFields = this.document.system.schema.fields.stacking.fields;
|
||||
const systemData = {
|
||||
stacking: event.target.checked
|
||||
? { value: stackingFields.value.initial, max: stackingFields.max.initial }
|
||||
: null
|
||||
};
|
||||
return this.submit({ updateData: { system: systemData } });
|
||||
}
|
||||
|
||||
armorChangeToggle(event) {
|
||||
if (event.target.checked) {
|
||||
this.addArmorChange();
|
||||
|
|
|
|||
|
|
@ -49,11 +49,9 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
if (this.element) {
|
||||
this.element.querySelectorAll('.effect-container a').forEach(element => {
|
||||
element.addEventListener('contextmenu', this.removeEffect.bind(this));
|
||||
});
|
||||
for (const element of this.element?.querySelectorAll('.effect-container a') ?? []) {
|
||||
element.addEventListener('click', e => this.#onClickEffect(e));
|
||||
element.addEventListener('contextmenu', e => this.#onClickEffect(e, -1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,11 +85,21 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
this.render();
|
||||
}
|
||||
|
||||
async removeEffect(event) {
|
||||
async #onClickEffect(event, delta = 1) {
|
||||
const element = event.target.closest('.effect-container');
|
||||
const effects = DhEffectsDisplay.getTokenEffects();
|
||||
const effect = effects.find(x => x.id === element.dataset.effectId);
|
||||
await effect.delete();
|
||||
if (!effect || (delta >= 0 && !effect.system.stacking)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const maxValue = effect.system.stacking?.max ?? Infinity;
|
||||
const newValue = Math.clamp((effect.system.stacking?.value ?? 1) + delta, 0, maxValue);
|
||||
if (newValue > 0) {
|
||||
await effect.update({ 'system.stacking.value': newValue });
|
||||
} else {
|
||||
await effect.delete();
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +1,3 @@
|
|||
/**
|
||||
* @typedef ContextMenuEntry
|
||||
* @property {string} name The context menu label. Can be localized.
|
||||
* @property {string} [icon] A string containing an HTML icon element for the menu item.
|
||||
* @property {string} [classes] Additional CSS classes to apply to this menu item.
|
||||
* @property {string} [group] An identifier for a group this entry belongs to.
|
||||
* @property {ContextMenuJQueryCallback} callback The function to call when the menu item is clicked.
|
||||
* @property {ContextMenuCondition|boolean} [condition] A function to call or boolean value to determine if this entry
|
||||
* appears in the menu.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ContextMenuCondition
|
||||
* @param {jQuery|HTMLElement} html The element of the context menu entry.
|
||||
* @returns {boolean} Whether the entry should be rendered in the context menu.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ContextMenuCallback
|
||||
* @param {HTMLElement} target The element that the context menu has been triggered for.
|
||||
* @returns {unknown}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback ContextMenuJQueryCallback
|
||||
* @param {HTMLElement|jQuery} target The element that the context menu has been triggered for. Will
|
||||
* either be a jQuery object or an HTMLElement instance, depending
|
||||
* on how the ContextMenu was configured.
|
||||
* @returns {unknown}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef ContextMenuOptions
|
||||
* @property {string} [eventName="contextmenu"] Optionally override the triggering event which can spawn the menu. If
|
||||
* the menu is using fixed positioning, this event must be a MouseEvent.
|
||||
* @property {ContextMenuCallback} [onOpen] A function to call when the context menu is opened.
|
||||
* @property {ContextMenuCallback} [onClose] A function to call when the context menu is closed.
|
||||
* @property {boolean} [fixed=false] If true, the context menu is given a fixed position rather than being
|
||||
* injected into the target.
|
||||
* @property {boolean} [jQuery=true] If true, callbacks will be passed jQuery objects instead of HTMLElement
|
||||
* instances.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef ContextMenuRenderOptions
|
||||
* @property {Event} [event] The event that triggered the context menu opening.
|
||||
* @property {boolean} [animate=true] Animate the context menu opening.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A subclass of ContextMenu.
|
||||
* @extends {foundry.applications.ux.ContextMenu}
|
||||
*/
|
||||
export default class DHContextMenu extends foundry.applications.ux.ContextMenu {
|
||||
/**
|
||||
* Trigger a context menu event in response to a normal click on a additional options button.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue