Skip to content

Commit

Permalink
Merge pull request #3258 from foundryvtt/summoning-hide-options
Browse files Browse the repository at this point in the history
[#893] Hide options in ability use dialog when summoning from chat
  • Loading branch information
arbron authored Mar 18, 2024
2 parents d18b7bc + bdb5c02 commit 104905c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 11 additions & 7 deletions module/applications/item/ability-use-dialog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export default class AbilityUseDialog extends Dialog {
*
* @typedef {object} AbilityUseDialogOptions
* @property {object} [button]
* @property {string} [button.icon] Icon used for the activation button.
* @property {string} [button.label] Label used for the activation button.
* @property {string} [button.icon] Icon used for the activation button.
* @property {string} [button.label] Label used for the activation button.
* @property {string} [disableScaling] Should spell or resource scaling be disabled?
*/

/**
Expand Down Expand Up @@ -64,14 +65,14 @@ export default class AbilityUseDialog extends Dialog {
options: concentrationOptions,
optional: (concentrationOptions.length < limit) ? "—" : null
},
scaling: item.usageScaling,
scaling: options.disableScaling ? null : item.usageScaling,
note: this._getAbilityUseNote(item, config),
title: game.i18n.format("DND5E.AbilityUseHint", {
type: game.i18n.localize(CONFIG.Item.typeLabels[item.type]),
name: item.name
})
};
this._getAbilityUseWarnings(data);
this._getAbilityUseWarnings(data, options);

// Render the ability usage template
const html = await renderTemplate("systems/dnd5e/templates/apps/ability-use.hbs", data);
Expand Down Expand Up @@ -124,6 +125,8 @@ export default class AbilityUseDialog extends Dialog {
}, []);
}

/* -------------------------------------------- */

/**
* Create an array of spell slot options for a select.
* @param {Actor5e} actor The actor with spell slots.
Expand Down Expand Up @@ -308,14 +311,15 @@ export default class AbilityUseDialog extends Dialog {

/**
* Get the ability usage warnings to display.
* @param {object} data Template data for the AbilityUseDialog. **Will be mutated**
* @param {object} data Template data for the AbilityUseDialog. **Will be mutated**
* @param {AbilityUseDialogOptions} [options={}] Additional options for displaying the dialog.
* @private
*/
static _getAbilityUseWarnings(data) {
static _getAbilityUseWarnings(data, options={}) {
const warnings = [];
const item = data.item;
const { quantity, level, consume, preparation } = item.system;
const scale = item.usageScaling;
const scale = options.disableScaling ? null : item.usageScaling;
const levels = [level];

if ( item.type === "spell" ) {
Expand Down
4 changes: 3 additions & 1 deletion module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,7 @@ export default class Item5e extends SystemDocumentMixin(Item) {
// Otherwise show the item use dialog to get the profile
else {
const config = await AbilityUseDialog.create(item, {
beginConcentrating: null,
consumeResource: null,
consumeSpellSlot: null,
consumeUsage: null,
Expand All @@ -2135,7 +2136,8 @@ export default class Item5e extends SystemDocumentMixin(Item) {
button: {
icon: '<i class="fa-solid fa-spaghetti-monster-flying"></i>',
label: game.i18n.localize("DND5E.Summoning.Action.Summon")
}
},
disableScaling: true
});
if ( !config?.summonsProfile ) return;
summonsProfile = config.summonsProfile;
Expand Down

0 comments on commit 104905c

Please sign in to comment.