mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
.
This commit is contained in:
parent
cb65266c43
commit
451f99bf05
5 changed files with 27 additions and 32 deletions
|
|
@ -33,9 +33,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
removeResource: DHBaseItemSheet.#removeResource
|
||||
},
|
||||
dragDrop: [
|
||||
{ dragSelector: null, dropSelector: '.tab.features .drop-section' },
|
||||
{ dragSelector: null, dropSelector: '.drop-section' },
|
||||
{ dragSelector: '.feature-item', dropSelector: null },
|
||||
{ dragSelector: '.action-item', dropSelector: null }
|
||||
{ dragSelector: '.inventory-item', dropSelector: null }
|
||||
],
|
||||
contextMenus: [
|
||||
{
|
||||
|
|
@ -242,37 +242,30 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
* @param {DragEvent} event - The drag event
|
||||
*/
|
||||
async _onDragStart(event) {
|
||||
/* Can prolly be improved a lot, but I don't wanna >_< */
|
||||
const featureItem = event.currentTarget.closest('.feature-item');
|
||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||
const lineItem = event.currentTarget.closest('.item-line');
|
||||
const dragItemData = featureItem ?? inventoryItem ?? lineItem;
|
||||
|
||||
if (featureItem) {
|
||||
const feature = this.document.system.features.find(x => x?.id === featureItem.id);
|
||||
if (!feature) {
|
||||
const dragItem = await foundry.utils.fromUuid(dragItemData.dataset.itemUuid);
|
||||
if (dragItem) {
|
||||
if (!dragItem) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.featureIsMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
const featureData = { type: 'Item', data: { ...feature.toObject(), _id: null }, fromInternal: true };
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(featureData));
|
||||
event.dataTransfer.setDragImage(featureItem.querySelector('img'), 60, 0);
|
||||
} else {
|
||||
const actionItem = event.currentTarget.closest('.action-item');
|
||||
if (actionItem) {
|
||||
const action = this.document.system.actions[actionItem.dataset.index];
|
||||
if (!action) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.actionIsMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
const actionData = {
|
||||
type: 'Action',
|
||||
data: { ...action.toObject(), id: action.id, itemUuid: this.document.uuid },
|
||||
fromInternal: true
|
||||
let dragData = {};
|
||||
if (dragItemData.dataset.type === 'effect')
|
||||
dragData = {
|
||||
type: 'ActiveEffect',
|
||||
fromInternal: this.document.uuid,
|
||||
data: { ...dragItem, uuid: dragItem.uuid, id: dragItem.id }
|
||||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(actionData));
|
||||
event.dataTransfer.setDragImage(actionItem.querySelector('img'), 60, 0);
|
||||
} else {
|
||||
super._onDragStart(event);
|
||||
}
|
||||
else dragData = { type: 'Item', uuid: dragItem.uuid, id: dragItem.id, fromInternal: this.document.id };
|
||||
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
event.dataTransfer.setDragImage(dragItemData.querySelector('img'), 60, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +277,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
|
|||
super._onDrop(event);
|
||||
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
if (data.fromInternal) return;
|
||||
if (data.fromInternal === this.document.id) return;
|
||||
|
||||
const target = event.target.closest('fieldset.drop-section');
|
||||
let item = await fromUuid(data.uuid);
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ export default class ClassSheet extends DHBaseItemSheet {
|
|||
async _onDrop(event) {
|
||||
event.stopPropagation();
|
||||
const data = TextEditor.getDragEventData(event);
|
||||
const item = data.data ?? (await fromUuid(data.uuid));
|
||||
const itemType = data.data ? data.type : item.type;
|
||||
const item = await fromUuid(data.uuid);
|
||||
const itemType = data.type === 'ActiveEffect' ? data.type : item.type;
|
||||
const target = event.target.closest('fieldset.drop-section');
|
||||
if (itemType === 'subclass') {
|
||||
if (item.system.linkedClass) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<li class='feature-item' data-item-uuid='{{feature.uuid}}' data-type="{{type}}">
|
||||
<li class='feature-item' data-item-uuid='{{feature.uuid}}' id="{{feature._id}}" data-type="{{type}}">
|
||||
<div class='feature-line'>
|
||||
<img class='image' src='{{feature.img}}' />
|
||||
<h4>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
data-action="editDoc"
|
||||
data-item-uuid="{{document.system.primaryFeature.uuid}}"
|
||||
data-type="primary"
|
||||
id="{{document.system.primaryFeature._id}}"
|
||||
>
|
||||
<img class="image" src="{{document.system.primaryFeature.img}}" />
|
||||
<span>{{document.system.primaryFeature.name}}</span>
|
||||
|
|
@ -36,6 +37,7 @@
|
|||
data-action="editDoc"
|
||||
data-item-uuid="{{document.system.secondaryFeature.uuid}}"
|
||||
data-type="secondary"
|
||||
id="{{document.system.secondaryFeature._id}}"
|
||||
>
|
||||
<img class="image" src="{{document.system.secondaryFeature.img}}" />
|
||||
<span>{{document.system.secondaryFeature.name}}</span>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<input type="text" name="system.characterGuide.suggestedTraits.knowledge" value="{{source.system.characterGuide.suggestedTraits.knowledge}}" />
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="one-column">
|
||||
<fieldset class="one-column {{#if (eq document.parent.type 'character')}}disabled{{/if}}">
|
||||
<legend>{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedEquipment"}}</legend>
|
||||
<fieldset class="one-column drop-section primary-weapon-section {{#if (eq document.parent.type 'character')}}inactive{{/if}}">
|
||||
<legend>{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedPrimaryWeaponTitle"}}</legend>
|
||||
|
|
@ -86,7 +86,7 @@
|
|||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="one-column">
|
||||
<fieldset class="one-column {{#if (eq document.parent.type 'character')}}disabled{{/if}}">
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.inventory"}}</legend>
|
||||
<fieldset class="one-column drop-section take-section {{#if (eq document.parent.type 'character')}}inactive{{/if}}">
|
||||
<legend>{{localize "DAGGERHEART.GENERAL.take"}}</legend>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue