diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b11e2eaf..392f80d3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,14 @@ +# v1.7.2 + +## Bugfixes + +* [#650] New hotbar support breaks standard document drag to hotbar support + +## Enhancements + +* [#649] Apply compendium source filtering to selectors on Item sheets as well as player Sheets +* [#653] Allow spell items to be dragged from character sheet to hotbar + # v1.7.1 ## Bugfixes diff --git a/system/src/apps/ShadowdarklingImporterSD.mjs b/system/src/apps/ShadowdarklingImporterSD.mjs index 9b88d9a6..fafe1ab5 100644 --- a/system/src/apps/ShadowdarklingImporterSD.mjs +++ b/system/src/apps/ShadowdarklingImporterSD.mjs @@ -199,7 +199,7 @@ export default class ShadowdarklingImporterSD extends FormApplication { // Ancestry if (json.ancestry) { - const ancestries = await shadowdark.compendiums.ancestries(); + const ancestries = await shadowdark.compendiums.ancestries(false); const ancestry = ancestries.find( i => i.name.toLowerCase() === json.ancestry.toLowerCase() ); @@ -207,21 +207,21 @@ export default class ShadowdarklingImporterSD extends FormApplication { } // Background - const backgrounds = await shadowdark.compendiums.backgrounds(); + const backgrounds = await shadowdark.compendiums.backgrounds(false); const background = backgrounds.find( i => i.name.toLowerCase() === json.background.toLowerCase() ); importedActor.system.background = background?.uuid ?? ""; // Class - const classes = await shadowdark.compendiums.classes(); + const classes = await shadowdark.compendiums.classes(false); const characterClass = classes.find( i => i.name.toLowerCase() === json.class.toLowerCase() ); importedActor.system.class = characterClass?.uuid ?? ""; // Deity - const deities = await shadowdark.compendiums.deities(); + const deities = await shadowdark.compendiums.deities(false); const deity = deities.find( i => i.name.toLowerCase() === json.deity.toLowerCase() ); @@ -229,7 +229,7 @@ export default class ShadowdarklingImporterSD extends FormApplication { // Languages const jsonLanguages = json.languages.toLowerCase().split(", "); - const allLanguages = await shadowdark.compendiums.languages(); + const allLanguages = await shadowdark.compendiums.languages([], false); for (const jsonLanguage of jsonLanguages) { const language = allLanguages.find(l => l.name.toLowerCase() === jsonLanguage); if (language) importedActor.system.languages.push(language.uuid); diff --git a/system/src/documents/ItemSD.mjs b/system/src/documents/ItemSD.mjs index 6ee6f49f..503dc800 100644 --- a/system/src/documents/ItemSD.mjs +++ b/system/src/documents/ItemSD.mjs @@ -1,5 +1,15 @@ export default class ItemSD extends Item { + get isRollable() { + return [ + "Potion", + "Scroll", + "Spell", + "Wand", + "Weapon", + ].includes(this.type); + } + /* Set the start time and initiative roll of newly created effect */ /** @override */ async _preCreate(data, options, user) { diff --git a/system/src/hooks/hotbar.mjs b/system/src/hooks/hotbar.mjs index 757ecf5d..98aff321 100644 --- a/system/src/hooks/hotbar.mjs +++ b/system/src/hooks/hotbar.mjs @@ -1,10 +1,11 @@ export const hotbarHooks = { attach: () => { Hooks.on("hotbarDrop", (bar, data, slot) => { - if (data.type === "Item") { - shadowdark.utils.createHotbarMacro(data, slot); - return false; - } + if (data.type !== "Item") return true; + if (data.type === "Macro" || data.type === "RollTable") return true; + + shadowdark.utils.createHotbarMacro(data, slot); + return false; }); }, }; diff --git a/system/src/migrations/updates/Update_230916_1.mjs b/system/src/migrations/updates/Update_230916_1.mjs index 83d0aeb6..d80b57c2 100644 --- a/system/src/migrations/updates/Update_230916_1.mjs +++ b/system/src/migrations/updates/Update_230916_1.mjs @@ -20,7 +20,7 @@ export default class Update_230916_1 extends UpdateBaseSD { if (currentValue !== "") { const itemLut = {}; - (await shadowdark.compendiums.ancestries()).forEach( + (await shadowdark.compendiums.ancestries(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); diff --git a/system/src/migrations/updates/Update_230920_1.mjs b/system/src/migrations/updates/Update_230920_1.mjs index 762d6352..f606406d 100644 --- a/system/src/migrations/updates/Update_230920_1.mjs +++ b/system/src/migrations/updates/Update_230920_1.mjs @@ -21,7 +21,7 @@ export default class Update_230920_1 extends UpdateBaseSD { if (currentValue !== "") { const itemLut = {}; - (await shadowdark.compendiums.classes()).forEach( + (await shadowdark.compendiums.classes(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); @@ -58,7 +58,7 @@ export default class Update_230920_1 extends UpdateBaseSD { if (currentValues.length > 0) { const itemLut = {}; - (await shadowdark.compendiums.spellcastingClasses()).forEach( + (await shadowdark.compendiums.spellcastingClasses(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); diff --git a/system/src/migrations/updates/Update_230923_1.mjs b/system/src/migrations/updates/Update_230923_1.mjs index 56169ddd..fe5ece5e 100644 --- a/system/src/migrations/updates/Update_230923_1.mjs +++ b/system/src/migrations/updates/Update_230923_1.mjs @@ -20,7 +20,7 @@ export default class Update_230923_1 extends UpdateBaseSD { if (currentValue !== "") { const itemLut = {}; - (await shadowdark.compendiums.backgrounds()).forEach( + (await shadowdark.compendiums.backgrounds(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); diff --git a/system/src/migrations/updates/Update_230923_2.mjs b/system/src/migrations/updates/Update_230923_2.mjs index 62ab2ead..64a66f5c 100644 --- a/system/src/migrations/updates/Update_230923_2.mjs +++ b/system/src/migrations/updates/Update_230923_2.mjs @@ -20,7 +20,7 @@ export default class Update_230923_2 extends UpdateBaseSD { if (currentValue !== "") { const itemLut = {}; - (await shadowdark.compendiums.deities()).forEach( + (await shadowdark.compendiums.deities(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); diff --git a/system/src/migrations/updates/Update_231025_1.mjs b/system/src/migrations/updates/Update_231025_1.mjs index 3bc8f5e4..0fad8766 100644 --- a/system/src/migrations/updates/Update_231025_1.mjs +++ b/system/src/migrations/updates/Update_231025_1.mjs @@ -14,7 +14,7 @@ export default class Update_231025_1 extends UpdateBaseSD { const spellcasterClass = itemData.system.class; if (typeof spellcasterClass === "string") { const itemLut = {}; - (await shadowdark.compendiums.spellcastingClasses()).forEach( + (await shadowdark.compendiums.spellcastingClasses(false)).forEach( item => itemLut[item.name.slugify()] = item.uuid ); diff --git a/system/src/sheets/ItemSheetSD.mjs b/system/src/sheets/ItemSheetSD.mjs index 7ff6a363..85652e88 100644 --- a/system/src/sheets/ItemSheetSD.mjs +++ b/system/src/sheets/ItemSheetSD.mjs @@ -89,7 +89,7 @@ export default class ItemSheetSD extends ItemSheet { async getAncestrySelectorConfigs(context) { const [selectedLanguages, availableLanguages] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.languages([], false), + await shadowdark.compendiums.languages(), this.item.system.languages.fixed ?? [] ); @@ -105,7 +105,7 @@ export default class ItemSheetSD extends ItemSheet { const [selectedTalents, availableTalents] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.ancestryTalents(false), + await shadowdark.compendiums.ancestryTalents(), this.item.system.talents ?? [] ); @@ -123,7 +123,7 @@ export default class ItemSheetSD extends ItemSheet { async getClassSelectorConfigs(context) { const [selectedArmor, availableArmor] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.baseArmor(false), + await shadowdark.compendiums.baseArmor(), this.item.system.armor ?? [] ); @@ -138,10 +138,10 @@ export default class ItemSheetSD extends ItemSheet { }; context.classTalentTables = - await shadowdark.compendiums.classTalentTables(false); + await shadowdark.compendiums.classTalentTables(); const classTalentTables = - await shadowdark.compendiums.classTalentTables(false); + await shadowdark.compendiums.classTalentTables(); context.classTalentTables = {}; for (const classTalentTable of classTalentTables) { @@ -152,7 +152,7 @@ export default class ItemSheetSD extends ItemSheet { const [selectedLanguages, availableLanguages] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.languages([], false), + await shadowdark.compendiums.languages(), this.item.system.languages.selectOptions ?? [] ); @@ -166,7 +166,7 @@ export default class ItemSheetSD extends ItemSheet { selectedItems: selectedLanguages, }; - const classTalents = await shadowdark.compendiums.talents([], false); + const classTalents = await shadowdark.compendiums.talents(); const [selectedTalents, availableTalents] = await shadowdark.utils.getDedupedSelectedItems( @@ -201,7 +201,7 @@ export default class ItemSheetSD extends ItemSheet { }; const spellcastingClasses = - await shadowdark.compendiums.spellcastingClasses(false); + await shadowdark.compendiums.spellcastingClasses(); context.spellcastingClasses = {}; for (const spellcastingClass of spellcastingClasses) { @@ -212,7 +212,7 @@ export default class ItemSheetSD extends ItemSheet { const [selectedWeapons, availableWeapons] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.baseWeapons(false), + await shadowdark.compendiums.baseWeapons(), this.item.system.weapons ?? [] ); @@ -230,7 +230,7 @@ export default class ItemSheetSD extends ItemSheet { async getSpellSelectorConfigs(context) { const [selectedClasses, availableClasses] = await shadowdark.utils.getDedupedSelectedItems( - await shadowdark.compendiums.spellcastingClasses(false), + await shadowdark.compendiums.spellcastingClasses(), this.item.system.class ?? [] ); @@ -331,14 +331,14 @@ export default class ItemSheetSD extends ItemSheet { if (item.type === "Armor") { context.baseArmor = await shadowdark.utils.getSlugifiedItemList( - await shadowdark.compendiums.baseArmor(false) + await shadowdark.compendiums.baseArmor() ); delete context.baseArmor[mySlug]; } if (item.type === "Weapon") { context.baseWeapons = await shadowdark.utils.getSlugifiedItemList( - await shadowdark.compendiums.baseWeapons(false) + await shadowdark.compendiums.baseWeapons() ); delete context.baseWeapons[mySlug]; diff --git a/system/src/utils/UtilitySD.mjs b/system/src/utils/UtilitySD.mjs index de2342f5..8e2d1c18 100644 --- a/system/src/utils/UtilitySD.mjs +++ b/system/src/utils/UtilitySD.mjs @@ -16,13 +16,26 @@ export default class UtilitySD { ); } + let command = `await Hotbar.toggleDocumentSheet("${itemData.uuid}");`; + let flags = {}; + let name = itemData.name; + + if (itemData.isRollable) { + command = `shadowdark.macro.rollItemMacro("${itemData.name}")`; + flags = {"shadowdark.itemMacro": true}; + name = `${game.i18n.localize("Roll")} ${name}`; + } + else { + name = `${game.i18n.localize("Display")} ${name}`; + } + const macroData = { - command: `shadowdark.macro.rollItemMacro("${itemData.name}")`, - flags: {"shadowdark.itemMacro": true}, + command, + flags, img: itemData.img, - name: itemData.name, + name, scope: "actor", - type: "script", + type: CONST.MACRO_TYPES.SCRIPT, }; // Assign the macro to the hotbar diff --git a/system/system.json b/system/system.json index a6dff55b..ca91f2fc 100644 --- a/system/system.json +++ b/system/system.json @@ -2,7 +2,7 @@ "id": "shadowdark", "title": "Shadowdark RPG", "desciption": "A system for playing the Shadowdark RPG from Arcane Library", - "version": "1.7.1", + "version": "1.7.2", "compatibility": { "minimum": "11", "verified": "11" diff --git a/system/templates/actors/player/spells.hbs b/system/templates/actors/player/spells.hbs index 4fe01b1a..69ca9c9c 100644 --- a/system/templates/actors/player/spells.hbs +++ b/system/templates/actors/player/spells.hbs @@ -26,6 +26,7 @@