mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Support drag and drop in adversary and environment sheets
This commit is contained in:
parent
2bae7900fe
commit
a4705f4204
5 changed files with 20 additions and 50 deletions
|
|
@ -25,7 +25,8 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
action: 'editAttribution'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
dragDrop: [{ dragSelector: '[data-item-id][draggable="true"]', dropSelector: null }]
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
|
|
@ -163,14 +164,6 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
_onDropItem(event, item) {
|
||||
if (this.document.uuid !== item.parent?.uuid) {
|
||||
return null; // block all drag drop except internal ones
|
||||
}
|
||||
|
||||
return super._onDropItem(event, item);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -877,21 +877,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
async _onDragStart(event) {
|
||||
const item = await getDocFromElement(event.target);
|
||||
|
||||
const dragData = {
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
async _onDropItem(event, item) {
|
||||
if (this.document.uuid === item.parent?.uuid) {
|
||||
return this._onSortItem(event, item);
|
||||
|
|
|
|||
|
|
@ -130,23 +130,16 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
/* -------------------------------------------- */
|
||||
|
||||
async _onDragStart(event) {
|
||||
const item = event.currentTarget.closest('.inventory-item');
|
||||
|
||||
const item = event.currentTarget.closest('.inventory-item[data-type=adversary]');
|
||||
if (item) {
|
||||
const adversaryData = { type: 'Actor', uuid: item.dataset.itemUuid };
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(adversaryData));
|
||||
event.dataTransfer.setDragImage(item, 60, 0);
|
||||
} else {
|
||||
return super._onDragStart(event);
|
||||
}
|
||||
}
|
||||
|
||||
_onDropItem(event, item) {
|
||||
if (this.document.uuid !== item.parent?.uuid) {
|
||||
return null; // block all drag drop except internal ones
|
||||
}
|
||||
|
||||
return super._onDropItem(event, item);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -419,18 +419,6 @@ export default class Party extends DHBaseActorSheet {
|
|||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDragStart(event) {
|
||||
const item = await getDocFromElement(event.target);
|
||||
const dragData = {
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
async _onDropActor(event, document) {
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { itemIsIdentical } from '../../../helpers/utils.mjs';
|
||||
import { getDocFromElement, itemIsIdentical } from '../../../helpers/utils.mjs';
|
||||
import DHBaseActorSettings from './actor-setting.mjs';
|
||||
import DHApplicationMixin from './application-mixin.mjs';
|
||||
|
||||
|
|
@ -301,7 +301,6 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
*/
|
||||
async _onDragStart(event) {
|
||||
const attackItem = event.currentTarget.closest('.inventory-item[data-type="attack"]');
|
||||
|
||||
if (attackItem) {
|
||||
const attackData = {
|
||||
type: 'Attack',
|
||||
|
|
@ -311,8 +310,20 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(attackData));
|
||||
event.dataTransfer.setDragImage(attackItem.querySelector('img'), 60, 0);
|
||||
} else if (this.document.type !== 'environment') {
|
||||
super._onDragStart(event);
|
||||
return;
|
||||
}
|
||||
|
||||
const item = await getDocFromElement(event.target);
|
||||
if (item) {
|
||||
const dragData = {
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
}
|
||||
|
||||
super._onDragStart(event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue