Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "display" option to item context menu #4802

Closed
roth-michael opened this issue Nov 28, 2024 · 2 comments · Fixed by #5021
Closed

Add a "display" option to item context menu #4802

roth-michael opened this issue Nov 28, 2024 · 2 comments · Fixed by #5021
Assignees
Milestone

Comments

@roth-michael
Copy link
Contributor

With the (welcome) addition of automatically triggering actions upon activity use, there's no workflow for just displaying an item as a chat card. Adding a "display in chat" type option to the item context menu which calls Item#displayCard would add that functionality with minimal code impact.

@roth-michael
Copy link
Contributor Author

Almost made a PR with just the following in InventoryElement#_getContextOptions:

options.push({
  name: "DND5E.DisplayCard",
  icon: '<i class="fas fa-message"></i>',
  callback: () => item.displayCard(),
  group: "action"
});

This does currently result in still showing the effect application tray if relevant (see below, first just a displayCard then an actual use), so I'm not sure whether that'd be intended functionality if this feature were to be implemented.
image

@thatlonelybugbear
Copy link
Contributor

thatlonelybugbear commented Jan 19, 2025

async function showItemInfo(item) {
  const itemDiplayMessageData = await item.displayCard({createMessage: false});
  const getIndex = itemDiplayMessageData.content.indexOf('<div class="card-buttons">');
  itemDiplayMessageData.content = itemDiplayMessageData.content.slice(0, getIndex);
  return ChatMessage.create(itemDiplayMessageData);
}

could be a way to do so with some extra checks maybe

Or add a parameter for options.hideButtons in the

async displayCard(options={}) {
//...
 const hasButtons = !options.hideButtons && (this.hasAttack || this.hasDamage || this.isVersatile || this.hasSave || this.system.formula
      || this.hasAreaTarget || (this.type === "tool") || this.hasAbilityCheck || this.system.hasSummoning
      || consumeUsage || consumeResource);
//...

edit: caffeine needed... the above is not for v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants