Compare commits

..

No commits in common. "de7c3f5fffdf2084717d8bd7b9c47e1b3cff83bd" and "4683cf249cb5a933d3d59d11dbada85cf068147f" have entirely different histories.

5 changed files with 23 additions and 32 deletions

View file

@ -457,6 +457,27 @@ export class DS4ActorSheet extends ActorSheet {
this.actor.updateEmbeddedDocuments("Item", updates); this.actor.updateEmbeddedDocuments("Item", updates);
} }
/**
* @param {DragEvent} event
* @param {object} data
* @override
*/
async _onDropItem(event, data) {
const item = await Item.implementation.fromDropData(data);
if (item && !this.actor.canOwnItemType(item.type)) {
notifications.warn(
getGame().i18n.format("DS4.WarningActorCannotOwnItem", {
actorName: this.actor.name,
actorType: this.actor.type,
itemName: item.name,
itemType: item.type,
}),
);
return false;
}
return super._onDropItem(event, data);
}
} }
/** /**

View file

@ -4,14 +4,12 @@
import { registerForHotbarDropHook } from "./hotbar-drop"; import { registerForHotbarDropHook } from "./hotbar-drop";
import { registerForInitHook } from "./init"; import { registerForInitHook } from "./init";
import { registerForPreCreateItemHook } from "./pre-create-item";
import { registerForReadyHook } from "./ready"; import { registerForReadyHook } from "./ready";
import { registerForRenderHooks } from "./render"; import { registerForRenderHooks } from "./render";
import { registerForSetupHook } from "./setup"; import { registerForSetupHook } from "./setup";
export function registerForHooks(): void { export function registerForHooks(): void {
registerForHotbarDropHook(); registerForHotbarDropHook();
registerForPreCreateItemHook();
registerForInitHook(); registerForInitHook();
registerForReadyHook(); registerForReadyHook();
registerForRenderHooks(); registerForRenderHooks();

View file

@ -1,28 +0,0 @@
// SPDX-FileCopyrightText: 2023 Johannes Loher
//
// SPDX-License-Identifier: MIT
import { notifications } from "../ui/notifications.js";
import { getGame } from "../utils/utils.js";
export function registerForPreCreateItemHook() {
Hooks.on("preCreateItem", preCreateItem);
}
/**
* @param {import('../documents/item/item.js').DS4Item} item
* @returns {void | false}
*/
function preCreateItem(item) {
if (item.parent instanceof Actor && !item.parent.canOwnItemType(item.type)) {
notifications.warn(
getGame().i18n.format("DS4.WarningActorCannotOwnItem", {
actorName: item.actor.name,
actorType: item.actor.type,
itemName: item.name,
itemType: item.type,
}),
);
return false;
}
}

View file

@ -9,7 +9,7 @@ SPDX-License-Identifier: MIT
!-- Render an effect list entry row. !-- Render an effect list entry row.
!-- @param effectData: The data of the item. !-- @param effectData: The data of the item.
--}} --}}
<li class="ds4-embedded-document-list__row effect" data-effect-uuid="{{effectData.uuid}}" data-effect-id="{{effectData.id}}"> <li class="ds4-embedded-document-list__row effect" data-effect-uuid="{{effectData.uuid}}">
{{!-- enabled --}} {{!-- enabled --}}
<input class="ds4-embedded-document-list__editable ds4-embedded-document-list__editable--checkbox change-effect" <input class="ds4-embedded-document-list__editable ds4-embedded-document-list__editable--checkbox change-effect"
type="checkbox" {{checked (ne effectData.disabled true)}} data-dtype="Boolean" data-property="disabled" type="checkbox" {{checked (ne effectData.disabled true)}} data-dtype="Boolean" data-property="disabled"

View file

@ -15,7 +15,7 @@ SPDX-License-Identifier: MIT
!-- @param hideDescription: A flag to disable the description column. !-- @param hideDescription: A flag to disable the description column.
!-- @param @partial-block: Custom column headers can be passed using the partial block. !-- @param @partial-block: Custom column headers can be passed using the partial block.
--}} --}}
<li class="ds4-embedded-document-list__row item" data-item-uuid="{{item.uuid}}" data-item-id="{{item.id}}"> <li class="ds4-embedded-document-list__row item" data-item-uuid="{{item.uuid}}">
{{!-- equipped --}} {{!-- equipped --}}
{{#if isEquipable}} {{#if isEquipable}}
<input class="ds4-embedded-document-list__editable ds4-embedded-document-list__editable--checkbox change-item" <input class="ds4-embedded-document-list__editable ds4-embedded-document-list__editable--checkbox change-item"