GM Monitor : added the ability to dnd an image actor to map

This commit is contained in:
Vlyan
2021-12-06 12:47:39 +01:00
parent f6cc3015cb
commit c11b39112c
4 changed files with 23 additions and 30 deletions

View File

@@ -70,12 +70,10 @@ export class HelpersL5r5e {
* @return {Promise<null>}
*/
static async getDragnDropTargetObject(event) {
const json = event.dataTransfer?.getData("text/plain");
if (!json) {
return null;
}
const data = JSON.parse(json);
if (!data) {
let data;
try {
data = JSON.parse(event.dataTransfer?.getData("text/plain"));
} catch (err) {
return null;
}
return await HelpersL5r5e.getObjectGameOrPack(data);
@@ -419,6 +417,21 @@ export class HelpersL5r5e {
}
});
// Ability to drag n drop an actor
html.find(".dragndrop-actor-id").on("dragstart", (event) => {
const actorId = $(event.currentTarget).data("actor-id");
if (!actorId) {
return;
}
event.originalEvent.dataTransfer.setData(
"text/plain",
JSON.stringify({
type: "Actor",
id: actorId,
})
);
});
// Item detail tooltips
this.popupManager(html.find(".l5r5e-tooltip"), async (event) => {
const item = await HelpersL5r5e.getEmbedItemByEvent(event, actor);