From 894cdba28b4ceeaa30329a5d3e6d4114e039a694 Mon Sep 17 00:00:00 2001 From: Vlyan Date: Fri, 22 Jul 2022 11:03:08 +0200 Subject: [PATCH] Working on Compatibility for FVTT v10 modified some actor-id to uuid : dragndrop-actor-id -> dragndrop-actor-uuid open-sheet-actor-id -> open-sheet-from-uuid --- system/scripts/helpers.js | 22 ++++++++++++------- system/scripts/item.js | 5 ++--- system/scripts/items/army-cohort-sheet.js | 5 +---- system/templates/actors/army-sheet.html | 2 +- system/templates/actors/army/army.html | 4 ++-- system/templates/actors/character-sheet.html | 2 +- system/templates/actors/npc-sheet.html | 2 +- system/templates/gm/gm-monitor.html | 12 +++++----- .../items/army-cohort/army-cohort-entry.html | 6 ++--- .../items/army-cohort/army-cohort-sheet.html | 4 ++-- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/system/scripts/helpers.js b/system/scripts/helpers.js index b980d4d..63b6630 100644 --- a/system/scripts/helpers.js +++ b/system/scripts/helpers.js @@ -470,16 +470,18 @@ export class HelpersL5r5e { }); // Ability to drag n drop an actor - html.find(".dragndrop-actor-id").on("dragstart", (event) => { + html.find(".dragndrop-actor-uuid").on("dragstart", (event) => { + // Compatibility actor-id (armies sheets) const actorId = $(event.currentTarget).data("actor-id"); - if (!actorId) { + const actorUuid = $(event.currentTarget).data("actor-uuid"); + if (!actorId && !actorUuid) { return; } event.originalEvent.dataTransfer.setData( "text/plain", JSON.stringify({ type: "Actor", - id: actorId, + uuid: actorUuid ? actorUuid : `Actor.${actorId}`, // TODO fix for v10 uuid required, remove use of id in futur }) ); }); @@ -494,15 +496,19 @@ export class HelpersL5r5e { }); // Open actor sheet - html.find(".open-sheet-actor-id").on("click", (event) => { + html.find(".open-sheet-from-uuid").on("click", async (event) => { event.preventDefault(); event.stopPropagation(); - - const id = $(event.currentTarget).data("actor-id"); - if (!id) { + const uuid = $(event.currentTarget).data("uuid"); + const actorId = $(event.currentTarget).data("actor-id"); + if (!uuid && !actorId) { return; } - game.actors.get(id)?.sheet?.render(true); + if (actorId) { + // Compatibility actor-id (armies sheets) + game.actors.get(actorId)?.sheet?.render(true); + } + (await fromUuid(uuid))?.sheet?.render(true); }); } diff --git a/system/scripts/item.js b/system/scripts/item.js index a287eb2..8c7513f 100644 --- a/system/scripts/item.js +++ b/system/scripts/item.js @@ -48,7 +48,6 @@ export class ItemL5r5e extends Item { // Merge (DocumentData cannot be set) const result = foundry.utils.mergeObject(this, foundry.utils.expandObject(data)); - console.log(result); // TODO TMP if (result.name) { this.name = result.name; @@ -56,8 +55,8 @@ export class ItemL5r5e extends Item { if (result.img) { this.img = result.img; } - if (result.data) { - this.data = result.data; // todo tmp check this! + if (result.system) { + this.system = result.system; } // Update diff --git a/system/scripts/items/army-cohort-sheet.js b/system/scripts/items/army-cohort-sheet.js index 1d3cc11..b89b91b 100644 --- a/system/scripts/items/army-cohort-sheet.js +++ b/system/scripts/items/army-cohort-sheet.js @@ -85,10 +85,7 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e { html.find(".actor-remove-control").on("click", (event) => { event.preventDefault(); event.stopPropagation(); - const id = $(event.currentTarget).data("actor-id"); - if (id) { - this._removeLinkedActor(); - } + this._removeLinkedActor(); }); } diff --git a/system/templates/actors/army-sheet.html b/system/templates/actors/army-sheet.html index 1de6001..f31d971 100644 --- a/system/templates/actors/army-sheet.html +++ b/system/templates/actors/army-sheet.html @@ -7,7 +7,7 @@ {{!-- Sheet Header --}}
- +

diff --git a/system/templates/actors/army/army.html b/system/templates/actors/army/army.html index a2e0725..e463566 100644 --- a/system/templates/actors/army/army.html +++ b/system/templates/actors/army/army.html @@ -4,7 +4,7 @@

{{#if data.system.warlord_actor_id}}

{{#if data.system.commander_actor_id}}
{{!-- Sheet Header --}}
- +

{{> 'systems/l5r5e/templates/actors/character/identity.html'}} diff --git a/system/templates/actors/npc-sheet.html b/system/templates/actors/npc-sheet.html index d7ffbe2..5f9d77f 100644 --- a/system/templates/actors/npc-sheet.html +++ b/system/templates/actors/npc-sheet.html @@ -8,7 +8,7 @@ {{!-- Sheet Header --}}
- +

{{> 'systems/l5r5e/templates/actors/npc/identity.html'}}
diff --git a/system/templates/gm/gm-monitor.html b/system/templates/gm/gm-monitor.html index f92211d..779d19c 100644 --- a/system/templates/gm/gm-monitor.html +++ b/system/templates/gm/gm-monitor.html @@ -20,9 +20,9 @@ {{#each data.actors as |actor|}} - + - {{actor.name}} + {{actor.name}} {{#if actor.system.attitude}}

({{actor.system.attitude}})

{{/if}} @@ -99,11 +99,11 @@ {{#each data.actors as |actor|}} - - {{actor.name}} + + {{actor.name}} {{#if actor.system.warlord_actor_id}} - {{actor.system.warlord}} + {{actor.system.warlord}} {{else}} {{actor.system.warlord}} {{/if}} @@ -122,7 +122,7 @@ {{#if actor.system.commander_actor_id}} - {{actor.system.commander}} + {{actor.system.commander}} {{else}} {{actor.system.commander}} {{/if}} diff --git a/system/templates/items/army-cohort/army-cohort-entry.html b/system/templates/items/army-cohort/army-cohort-entry.html index 6b7ef17..43f02ad 100644 --- a/system/templates/items/army-cohort/army-cohort-entry.html +++ b/system/templates/items/army-cohort/army-cohort-entry.html @@ -1,6 +1,6 @@ -
  • +
    • -
    • +
    • {{cohort.name}}
    • {{cohort.system.battle_readiness.casualties_strength.value}} @@ -14,7 +14,7 @@ {{/if}}
      - {{#if cohort.system.leader}}
    • {{localize 'l5r5e.army.cohort.leader'}} : {{#if cohort.system.leader_actor_id}}{{cohort.system.leader}}{{else}}{{cohort.system.leader}}{{/if}}
    • {{/if}} + {{#if cohort.system.leader}}
    • {{localize 'l5r5e.army.cohort.leader'}} : {{#if cohort.system.leader_actor_id}}{{cohort.system.leader}}{{else}}{{cohort.system.leader}}{{/if}}
    • {{/if}} {{#if cohort.system.equipment}}
    • {{localize 'l5r5e.sheets.equipment'}} : {{cohort.system.equipment}}
    • {{/if}}
  • diff --git a/system/templates/items/army-cohort/army-cohort-sheet.html b/system/templates/items/army-cohort/army-cohort-sheet.html index aa928f2..565850a 100644 --- a/system/templates/items/army-cohort/army-cohort-sheet.html +++ b/system/templates/items/army-cohort/army-cohort-sheet.html @@ -29,8 +29,8 @@ {{^if data.system.leader_actor_id}} {{/if}}{{localize 'l5r5e.army.cohort.leader'}} {{#if data.system.leader_actor_id}} {{else}}