fix dragging items from compendium to actor sheet
This commit is contained in:
parent
04dde7c84c
commit
afbe0cb8f1
2 changed files with 15 additions and 20 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -2718,7 +2718,7 @@
|
|||
}
|
||||
},
|
||||
"foundry-pc-types": {
|
||||
"version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#5fcca4e4327b558d5eeeb962f05470c994a394be",
|
||||
"version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#ac45653fdec5fb935bf7db72889cb40cd6b80b20",
|
||||
"from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
|
@ -208,25 +208,20 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async _onDrop(event: DragEvent): Promise<boolean | unknown> {
|
||||
const data = JSON.parse(event.dataTransfer?.getData("text/plain")) as { type?: string };
|
||||
if (data.type === "Item") {
|
||||
const item = await Item.fromDropData(data as Parameters<typeof DS4Item.fromDropData>[0]);
|
||||
if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) {
|
||||
ui.notifications.warn(
|
||||
game.i18n.format("DS4.WarningActorCannotOwnItem", {
|
||||
actorName: this.actor.name,
|
||||
actorType: this.actor.data.type,
|
||||
itemName: item.name,
|
||||
itemType: item.data.type,
|
||||
}),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
/** @override */
|
||||
async _onDropItem(event: DragEvent, data: Parameters<typeof DS4Item.fromDropData>[0]): Promise<unknown> {
|
||||
const item = await Item.fromDropData(data);
|
||||
if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) {
|
||||
ui.notifications.warn(
|
||||
game.i18n.format("DS4.WarningActorCannotOwnItem", {
|
||||
actorName: this.actor.name,
|
||||
actorType: this.actor.data.type,
|
||||
itemName: item.name,
|
||||
itemType: item.data.type,
|
||||
}),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return super._onDrop(event);
|
||||
return super["_onDropItem"](event, data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue