From f5248c57aaf3510a785fd50845441f78ff612da9 Mon Sep 17 00:00:00 2001 From: macniel Date: Fri, 3 Oct 2025 23:45:17 +0200 Subject: [PATCH] introduces a paperdoll for equipment handling --- src/main.mjs | 10 +- src/module/data/character.mjs | 7 ++ src/module/sheets/characterSheet.mjs | 75 +++++++++++++++ src/style/_character-sheet.scss | 94 +++++++++++++++---- src/system.json | 22 ++++- src/templates/actor/actor-character-sheet.hbs | 24 +++++ src/templates/ui/partial-equipment-button.hbs | 2 +- 7 files changed, 209 insertions(+), 25 deletions(-) diff --git a/src/main.mjs b/src/main.mjs index 11fe8153..3ea748a5 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -91,10 +91,12 @@ Hooks.once("init", () => { }) Hooks.on('dropActorSheetData', (actor, sheet, data) => { - if (actor.type === "character") { - return CharacterSheet.onDroppedData(actor, sheet, data); - } else { - return GroupSheet.onDroppedData(actor, sheet, data); + if (data.id) { + if (actor.type === "character") { + return CharacterSheet.onDroppedData(actor, sheet, data); + } else { + return GroupSheet.onDroppedData(actor, sheet, data); + } } } ) diff --git a/src/module/data/character.mjs b/src/module/data/character.mjs index 7c86ddc0..ed203d49 100644 --- a/src/module/data/character.mjs +++ b/src/module/data/character.mjs @@ -131,6 +131,13 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { key: new StringField(), notiz: new StringField(), })), + + heldenausruestung: new SchemaField({ + links: new DocumentIdField(), + rechts: new DocumentIdField(), + ruestung: new DocumentIdField(), + munition: new DocumentIdField() + }) } } diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index c0fe7aaf..bcd71d4e 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -170,6 +170,29 @@ export class CharacterSheet extends ActorSheet { }) context.maxcarryingcapacity = actorData.system.attribute.kk.aktuell context.carryingpercentage = Math.min((context.carryingweight / context.maxcarryingcapacity)*100, 100); + + context.heldenausruestung = { + links: { + id: this.object.system.heldenausruestung.links, + name: this.object.items.get(actorData.system.heldenausruestung.links)?.name, + icon: this.object.items.get(actorData.system.heldenausruestung.links)?.img + }, + rechts: { + id: this.object.system.heldenausruestung.rechts, + name: this.object.items.get(actorData.system.heldenausruestung.rechts)?.name, + icon: this.object.items.get(actorData.system.heldenausruestung.rechts)?.img + }, + ruestung: { + id: this.object.system.heldenausruestung.ruestung, + name: this.object.items.get(actorData.system.heldenausruestung.ruestung)?.name, + icon: this.object.items.get(actorData.system.heldenausruestung.ruestung)?.img + }, + munition: { + id: this.object.system.heldenausruestung.munition, + name: this.object.items.get(actorData.system.heldenausruestung.munition)?.name, + icon: this.object.items.get(actorData.system.heldenausruestung.munition)?.img + } + } } prepareEigenschaftRoll(actorData, name) { @@ -331,6 +354,58 @@ export class CharacterSheet extends ActorSheet { evt.stopPropagation(); }) + html.on('dragstart', '.equipment', (evt) => { + evt.originalEvent.dataTransfer.setData("text/plain", evt.currentTarget.dataset.id); + }) + + html.on('drop', '.equipped', async (evt) => { + const {actor, target} = evt.currentTarget.dataset; + const documentId = evt.originalEvent.dataTransfer.getData("text"); + + if (actor === this.object._id && documentId) { // managing equipped items + switch(target) { + case "links": + this.object.update({ + system: { + heldenausruestung: { + links: documentId + } + } + }) + break; + case "rechts": + this.object.update({ + system: { + heldenausruestung: { + rechts: documentId + } + } + }) + break; + case "ruestung": + this.object.update({ + system: { + heldenausruestung: { + ruestung: documentId + } + } + }) + break; + case "munition": + this.object.update({ + system: { + heldenausruestung: { + munition: documentId + } + } + }) + break; + } + } + + evt.stopPropagation(); + }) + new ContextMenu(html, '.talent.rollable', [ { name: "Entfernen", diff --git a/src/style/_character-sheet.scss b/src/style/_character-sheet.scss index 4ad0709c..34a39fec 100644 --- a/src/style/_character-sheet.scss +++ b/src/style/_character-sheet.scss @@ -52,36 +52,96 @@ overflow: auto; } - .backpack { - position: absolute; + .backpack.active { + position: relative; left: 0; top: 0; bottom: 0; right: 0; padding: 8px; + display: grid; + grid-template-columns: 1fr 280px; + grid-template-rows: 64px 1fr; + gap: 0px 0px; + grid-template-areas: + "capacity capacity" + "inventory equipment"; - .resource { + .capacity { - position: relative; - border: 1px inset #ccc; - background-color: rgba(0,0,0,0.2); - height: 8px; + grid-area: capacity; + + .resource { + + position: relative; + border: 1px inset #ccc; + background-color: rgba(0, 0, 0, 0.2); + height: 8px; + + span.fill { + position: absolute; + left: 0; + top: 0; + bottom: 0; + background: linear-gradient(to bottom, #0bad29 0%, #11f128 50%, #0cde24 51%, #6ff77b 100%); + } - span.fill { - position:absolute; - left: 0; - top: 0; - bottom: 0; - background: linear-gradient(to bottom, #0bad29 0%,#11f128 50%,#0cde24 51%,#6ff77b 100%); } - } - .equipment:hover { - .item-name { - text-shadow: 0 0 10px rgb(255 0 0); + .inventory { + grid-area: inventory; + + .equipment:hover { + .item-name { + text-shadow: 0 0 10px rgb(255 0 0); + } } } + + .paperdoll { + + grid-area: equipment; + position: relative; + + .paperdoll-image { + fill: rgba(0,0,0,0.5); + } + + .equipped { + + background-color: rgba(0,0,0,0.2); + + border: 1px inset #ccc; + width: 34px; + height: 34px; + + &.links { + position: absolute; + top: 230px; + left: 250px; + } + + &.rechts { + position: absolute; + top: 230px; + left: 20px; + } + + &.ruestung { + position: absolute; + top: 180px; + left: 130px; + } + + &.munition { + position: absolute; + top: 270px; + left: 20px; + } + } + + } } diff --git a/src/system.json b/src/system.json index 1f222c2c..baa3832d 100644 --- a/src/system.json +++ b/src/system.json @@ -62,11 +62,27 @@ "private": false }, { - "name": "Equipment", - "label": "Ausrüstung", + "name": "Weapons", + "label": "Waffen", "system": "DSA_4-1", "type": "Item", - "path": "packs/ausruestung", + "path": "packs/waffen", + "private": false + }, + { + "name": "Armor", + "label": "Rüstzeug", + "system": "DSA_4-1", + "type": "Item", + "path": "packs/ruestzeug", + "private": false + }, + { + "name": "Ammunition", + "label": "Munition", + "system": "DSA_4-1", + "type": "Item", + "path": "packs/munition", "private": false } ], diff --git a/src/templates/actor/actor-character-sheet.hbs b/src/templates/actor/actor-character-sheet.hbs index d80b6bdc..33795879 100644 --- a/src/templates/actor/actor-character-sheet.hbs +++ b/src/templates/actor/actor-character-sheet.hbs @@ -153,9 +153,33 @@ + + +
+

Inventar

{{#each equipments}} {{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" this}} {{/each}} +
+ +
+

Ausrüstung

+
+ + + + + + + + +
+
diff --git a/src/templates/ui/partial-equipment-button.hbs b/src/templates/ui/partial-equipment-button.hbs index 9dc4bffc..66f3b77a 100644 --- a/src/templates/ui/partial-equipment-button.hbs +++ b/src/templates/ui/partial-equipment-button.hbs @@ -1,4 +1,4 @@ -
+
{{this.quantity}} {{this.name}}