Skip to content

Commit 1fd8d87

Browse files
committed
fix: Move Add to behavior roll to contextmenu
1 parent 6aaa302 commit 1fd8d87

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

module/sheets/actor-standard-sheet.mjs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -824,20 +824,27 @@ export class FUStandardActorSheet extends ActorSheet {
824824
},
825825
];
826826

827-
// TODO: Deal with multiple behaviors spawning
828-
// html.on('click', '.item-option', (jq) => {
829-
// const itemId = jq.currentTarget.dataset.itemId;
830-
// if (this.actor.type === 'npc' && game.settings.get('projectfu', 'optionBehaviorRoll')) {
831-
// const item = this.actor.items.get(itemId);
832-
// const behaviorClass = item?.system.isBehavior.value ? 'fas active' : 'far';
833-
// contextMenuOptions.push({
834-
// name: game.i18n.localize('FU.Behavior'),
835-
// icon: `<i class="${behaviorClass} fa-address-book"></i>`,
836-
// callback: this._onItemBehavior.bind(this),
837-
// condition: (jq) => !!jq.data('itemId'),
838-
// });
839-
// }
840-
// });
827+
html.on('click', '.item-option', (jq) => {
828+
const itemId = jq.currentTarget.dataset.itemId;
829+
830+
// Check for the Behavior option before adding it
831+
const behaviorOptionExists = contextMenuOptions.some((option) => option.name === game.i18n.localize('FU.Behavior'));
832+
833+
if (this.actor.type === 'npc' && game.settings.get('projectfu', 'optionBehaviorRoll') && !behaviorOptionExists) {
834+
const item = this.actor.items.get(itemId);
835+
836+
if (item?.system?.isBehavior) {
837+
const behaviorClass = item.system.isBehavior.value ? 'fas active' : 'far';
838+
839+
contextMenuOptions.push({
840+
name: game.i18n.localize('FU.Behavior'),
841+
icon: `<i class="${behaviorClass} fa-address-book"></i>`,
842+
callback: this._onItemBehavior.bind(this),
843+
condition: (jq) => !!jq.data('itemId'),
844+
});
845+
}
846+
}
847+
});
841848

842849
// Context
843850
// eslint-disable-next-line no-undef

templates/actor/partials/actor-control.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="item-sm end">
22
{{!-- remove after fixing contextmenu --}}
3-
{{#if (eq @root.actor.type "npc")}}
3+
{{!-- {{#if (eq @root.actor.type "npc")}}
44
{{#if (eq (getGameSetting 'optionBehaviorRoll') true)}}
55
<a class="item-control item-behavior" data-item-id="{{item._id}}"
66
data-tooltip="{{#if item.system.isBehavior.value}}{{localize 'FU.BehaviorRemove'}}{{else}}{{localize
@@ -9,7 +9,7 @@
99
<i class="{{#if item.system.isBehavior.value}}fas active{{else}}far{{/if}} fa-address-book button-style"></i>
1010
</a>
1111
{{/if}}
12-
{{/if}}
12+
{{/if}} --}}
1313

1414
<a class="item-control item-favored" data-item-id="{{item._id}}"
1515
data-tooltip="{{#if item.system.isFavored.value}}{{ localize 'FU.FavoriteRemove' }}{{else}}{{ localize

0 commit comments

Comments
 (0)