diff --git a/lang/en.json b/lang/en.json index 81778a4a..3c161d38 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2345,7 +2345,8 @@ "pendingSaves": "Pending Reaction Rolls", "openSheetSettings": "Open Settings", "rulesOn": "Rules On", - "rulesOff": "Rules Off" + "rulesOff": "Rules Off", + "remainingUses": "Uses refresh on {type}" } } } diff --git a/module/applications/sheets/api/base-actor.mjs b/module/applications/sheets/api/base-actor.mjs index 56e48232..1c803eb4 100644 --- a/module/applications/sheets/api/base-actor.mjs +++ b/module/applications/sheets/api/base-actor.mjs @@ -22,7 +22,8 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { }, actions: { openSettings: DHBaseActorSheet.#openSettings, - sendExpToChat: DHBaseActorSheet.#sendExpToChat + sendExpToChat: DHBaseActorSheet.#sendExpToChat, + increaseActionUses: event => DHBaseActorSheet.#modifyActionUses(event, true) }, contextMenus: [ { @@ -70,6 +71,15 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { return context; } + /**@inheritdoc */ + _attachPartListeners(partId, htmlElement, options) { + super._attachPartListeners(partId, htmlElement, options); + + htmlElement.querySelectorAll('.item-button .action-uses-button').forEach(element => { + element.addEventListener('contextmenu', DHBaseActorSheet.#modifyActionUses); + }); + } + /** * Prepare render context for the Effect part. * @param {ApplicationRenderContext} context @@ -154,6 +164,20 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { cls.create(msg); } + /** + * + */ + static async #modifyActionUses(event, increase) { + event.stopPropagation(); + event.preventDefault(); + const actionId = event.target.dataset.itemUuid; + const action = await foundry.utils.fromUuid(actionId); + + const newValue = (action.uses.value ?? 0) + (increase ? 1 : -1); + await action.update({ 'uses.value': Math.min(Math.max(newValue, 0), action.uses.max ?? 0) }); + this.render(); + } + /* -------------------------------------------- */ /* Application Drag/Drop */ /* -------------------------------------------- */ diff --git a/module/data/fields/actionField.mjs b/module/data/fields/actionField.mjs index 00948f40..a31197b5 100644 --- a/module/data/fields/actionField.mjs +++ b/module/data/fields/actionField.mjs @@ -164,6 +164,12 @@ export function ActionMixin(Base) { return foundry.utils.getProperty(this.parent, this.systemPath) instanceof Collection; } + get remainingUses() { + if (!this.uses) return null; + + return Math.max((this.uses.max ?? 0) - (this.uses.value ?? 0), 0); + } + static async create(data, operation = {}) { const { parent, renderSheet } = operation; let { type } = data; diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 067b4c86..707e1d81 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -486,8 +486,43 @@ flex-wrap: wrap; margin-top: 2px; - button { - white-space: nowrap; + .item-button { + display: flex; + border: 1px solid light-dark(#18162e, #18162e); + color: light-dark(#18162e, #18162e); + outline: none; + box-shadow: none; + border-radius: 6px; + + button { + padding: 6px 6px 6px 10px; + border-radius: 3px 0px 0px 3px; + color: light-dark(@dark-blue, @dark-blue); + white-space: nowrap; + border: 0; + font-family: @font-body; + + &:hover { + color: light-dark(@dark-blue, @golden); + } + + &:last-child { + padding: 6px; + background: light-dark(@dark-blue-10, @golden-secondary); + border-radius: 0px 3px 3px 0px; + color: light-dark(@dark-blue, @dark-golden); + + &:hover { + background: light-dark(@light-black, @dark-blue); + color: light-dark(@dark-blue, @golden-secondary); + } + } + } + + .spacer { + border-right: 1px solid black; + content: ''; + } } } } diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index 0ca383d5..e79a88c7 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -24,13 +24,15 @@ width: 100%; list-style-type: none; - &:not(.single-img):hover { - .inventory-item-header .img-portait { - .roll-img { - opacity: 1; - } - .item-img { - opacity: 0; + &:not(.single-img) { + .inventory-item-header:hover { + .img-portait { + .roll-img { + opacity: 1; + } + .item-img { + opacity: 0; + } } } } diff --git a/styles/less/utils/colors.less b/styles/less/utils/colors.less index 0b87e18c..ae13650b 100755 --- a/styles/less/utils/colors.less +++ b/styles/less/utils/colors.less @@ -5,6 +5,7 @@ @golden-10: #f3c26710; @golden-40: #f3c26740; @golden-bg: #f3c2671a; +@golden-secondary: #eaaf42; @chat-blue: #8f87ee; @chat-blue-10: #8f87ee10; diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index e49ad1b5..c79430ad 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -146,9 +146,17 @@ Parameters: {{#if (and showActions (eq item.type 'feature'))}}
{{#each item.system.actions as | action |}} - +
+ + {{#if action.uses.max}} +
+ + {{/if}} +
{{/each}}
{{/if}}