Compare commits

...

2 commits

Author SHA1 Message Date
Carlos Fernandez
0471bbc7d0 Refine logic for use action when hovering over item icon 2026-04-19 20:18:46 -04:00
Carlos Fernandez
6533b3edee Fix context menu detection for actions 2026-04-19 19:41:21 -04:00
5 changed files with 25 additions and 3 deletions

View file

@ -110,6 +110,11 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
return this._id;
}
/** Returns true if the current user is the owner of the containing item */
get isOwner() {
return this.item?.isOwner ?? true;
}
/**
* Return Item the action is attached too.
*/
@ -143,6 +148,12 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
: null;
}
/** Returns true if the action is usable */
get usable() {
const actor = this.actor;
return this.isOwner && actor?.type === 'character';
}
static getRollType(parent) {
return 'trait';
}

View file

@ -108,6 +108,8 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
}
get actionsList() {
// No actions on non-characters
if (this.actor && this.actor.type !== 'character') return [];
return this.actions;
}

View file

@ -99,7 +99,9 @@ export default class DHWeapon extends AttachableItem {
/* -------------------------------------------- */
get actionsList() {
return [this.attack, ...this.actions];
// No actions on non-characters
if (this.actor && this.actor.type !== 'character') return [];
return [this.attack, ...super.actionsList];
}
get customActions() {

View file

@ -76,6 +76,13 @@ export default class DHItem extends foundry.documents.Item {
return this.system.metadata.isInventoryItem ?? false;
}
/** Returns true if the item can be used */
get usable() {
const actor = this.actor;
const actionsList = this.system.actionsList;
return this.isOwner && actor?.type === 'character' && (actionsList?.size || actionsList?.length);
}
/** @inheritdoc */
static async createDialog(data = {}, createOptions = {}, options = {}) {
const { folders, types, template, context = {}, ...dialogOptions } = options;

View file

@ -25,11 +25,11 @@ Parameters:
>
<div class="inventory-item-header {{#if hideContextMenu}}padded{{/if}}" {{#unless noExtensible}}data-action="toggleExtended" {{/unless}}>
{{!-- Image --}}
<div class="img-portait" data-action='{{ifThen (or (hasProperty item "use") (eq type "attack")) "useItem" (ifThen
<div class="img-portait" data-action='{{ifThen item.usable "useItem" (ifThen
(hasProperty item "toChat" ) "toChat" "editDoc" ) }}' {{#unless hideTooltip}} {{#if (eq type 'attack' )}}
data-tooltip="#attack#{{item.actor.uuid}}" {{else}} data-tooltip="#item#{{item.uuid}}" {{/if}} {{/unless}} draggable="true">
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" />
{{#if (or item.system.actionsList.size item.system.actionsList.length item.actionType)}}
{{#if item.usable}}
{{#if @root.isNPC}}
<img class="roll-img d20" src="systems/daggerheart/assets/icons/dice/default/d20.svg" alt="d20">
{{else}}