GM Monitor : added the ability to dnd an image actor to map
This commit is contained in:
@@ -82,8 +82,6 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
return;
|
||||
}
|
||||
|
||||
html.find(".entity-link").on("dragstart", this._onDragEntityLink.bind(this));
|
||||
|
||||
// Delete the linked Actor (warlord/commander)
|
||||
html.find(".actor-remove-control").on("click", this._removeLinkedActor.bind(this));
|
||||
}
|
||||
@@ -117,24 +115,6 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback actions which occur at the beginning of a drag start workflow.
|
||||
* @param {DragEvent} event The originating DragEvent
|
||||
*/
|
||||
_onDragEntityLink(event) {
|
||||
const actorId = $(event.currentTarget).data("actor-id");
|
||||
if (!actorId) {
|
||||
return;
|
||||
}
|
||||
event.originalEvent.dataTransfer.setData(
|
||||
"text/plain",
|
||||
JSON.stringify({
|
||||
type: "Actor",
|
||||
id: actorId,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle dropped Item data on the Actor sheet (cohort, fortification)
|
||||
* @param {DragEvent} event
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<tbody>
|
||||
{{#each data.actors as |actor|}}
|
||||
<tr>
|
||||
<td><img class="profile actor-profile" title="{{actor.name}}" src="{{actor.img}}"></td>
|
||||
<td><img data-actor-id="{{actor.id}}" draggable="true" class="profile actor-profile dragndrop-actor-id pointer" title="{{actor.name}}" src="{{actor.img}}"></td>
|
||||
<td>
|
||||
<a data-actor-id="{{actor.id}}" class="open-sheet-actor-id">{{actor.name}}</a>
|
||||
{{#if actor.data.data.attitude}}<p>({{actor.data.data.attitude}})</p>{{/if}}
|
||||
@@ -91,7 +91,7 @@
|
||||
<tbody>
|
||||
{{#each data.actors as |actor|}}
|
||||
<tr>
|
||||
<td><img class="profile actor-profile" title="{{actor.name}}" src="{{actor.img}}"></td>
|
||||
<td><img data-actor-id="{{actor.id}}" draggable="true" class="profile actor-profile dragndrop-actor-id pointer" title="{{actor.name}}" src="{{actor.img}}"></td>
|
||||
<td><a data-actor-id="{{actor.id}}" class="open-sheet-actor-id">{{actor.name}}</a></td>
|
||||
<td>
|
||||
{{#if actor.data.data.warlord_actor_id}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<li class="item cohort flexcol entity-link actor" {{#if cohort.data.leader_actor_id}}draggable="true" data-actor-id="{{cohort.data.leader_actor_id}}"{{/if}}>
|
||||
<li class="item cohort flexcol dragndrop-actor-id actor">
|
||||
<ul class="item-header item-control">
|
||||
<li class="item-img"><img src="{{cohort.img}}" title="{{cohort.name}}" width="32px" height="32px"/></li>
|
||||
<li class="item-img"><img src="{{cohort.img}}" title="{{cohort.name}}" width="32px" height="32px" {{#if cohort.data.leader_actor_id}}draggable="true" class="dragndrop-actor-id pointer" data-actor-id="{{cohort.data.leader_actor_id}}"{{/if}}/></li>
|
||||
<li class="item-name l5r5e-tooltip" data-item-id="{{cohort._id}}">{{cohort.name}}</li>
|
||||
<li class="icon-stat-container">
|
||||
<i class="fas fa-user-injured" title="{{localize 'l5r5e.army.battle_readiness.casualties'}}"> {{cohort.data.battle_readiness.casualties_strength.value}}</i>
|
||||
|
||||
Reference in New Issue
Block a user