diff --git a/src/main.mjs b/src/main.mjs index 1e3261c6..d4b0b9d7 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -198,13 +198,14 @@ Hooks.once("init", () => { }) Hooks.on('dropActorSheetData', (actor, sheet, data) => { - if (data.uuid) { + /*if (data.uuid) { if (actor.type === "character") { - return CharacterSheet.onDroppedData(actor, sheet, data); + return true } else { return GroupSheet.onDroppedData(actor, sheet, data); } - } + }*/ + return true }) Hooks.once("ready", async function () { diff --git a/src/module/sheets/character/equipment.mjs b/src/module/sheets/character/equipment.mjs index 8406eba8..ff08ad0b 100644 --- a/src/module/sheets/character/equipment.mjs +++ b/src/module/sheets/character/equipment.mjs @@ -35,7 +35,7 @@ export default { // worn items are halved weight let effectiveWeight = item.system.weight ?? 0 - if (isWorn(item._id, object)) { + if (isWorn(item._id, context.document)) { effectiveWeight = item.system.weight ? item.system.weight / 2 : 0 } @@ -46,7 +46,7 @@ export default { name: item.name, icon: item.img ?? "", weight: item.system.weight, - worn: isWorn(item._id, object) + worn: isWorn(item._id, context.document) }) context.carryingweight += item.system.quantity * effectiveWeight; @@ -142,57 +142,20 @@ export default { return context }, - _onRender: (context, options, element) => { - const mapAllSets = () => { - const updateObject = {} - Array.from(context.document.system.heldenausruestung).forEach((equipmentSet, index) => { - updateObject[`system.heldenausruestung.${index}.links`] = equipmentSet.links; - updateObject[`system.heldenausruestung.${index}.rechts`] = equipmentSet.rechts; - updateObject[`system.heldenausruestung.${index}.brust`] = equipmentSet.brust; - updateObject[`system.heldenausruestung.${index}.bauch`] = equipmentSet.bauch; - updateObject[`system.heldenausruestung.${index}.ruecken`] = equipmentSet.ruecken; - updateObject[`system.heldenausruestung.${index}.kopf`] = equipmentSet.kopf; - updateObject[`system.heldenausruestung.${index}.fernkampf`] = equipmentSet.fernkampf; - updateObject[`system.heldenausruestung.${index}.munition`] = equipmentSet.munition; - updateObject[`system.heldenausruestung.${index}.armlinks`] = equipmentSet.armlinks; - updateObject[`system.heldenausruestung.${index}.armrechts`] = equipmentSet.armrechts; - updateObject[`system.heldenausruestung.${index}.beinlinks`] = equipmentSet.beinlinks; - updateObject[`system.heldenausruestung.${index}.beinrechts`] = equipmentSet.beinrechts; + _onRender: (context, options, thisObject) => { - }) - return updateObject; - } - - new foundry.applications.ux.ContextMenu(element, '.equipped', [ - { - name: "Gegenstand vom Set entfernen", - callback: (event) => { - const {setId, target, actor} = event[0].dataset - - const updateObject = mapAllSets() - updateObject[`system.heldenausruestung.${setId}.${target}`] = null; - - object.update(updateObject); - }, - condition: () => true + new foundry.applications.ux.DragDrop.implementation({ + dragSelector: ".inventory-table .equipment", + dropSelector: ".inventory-table", + permissions: { + dragstart: thisObject._canDragStart.bind(thisObject), + drop: thisObject._canDragDrop.bind(thisObject) + }, + callbacks: { + dragstart: thisObject._onDragStart.bind(thisObject), + drop: thisObject._onDrop.bind(thisObject) } - ], { - jQuery: false - }); - - new foundry.applications.ux.ContextMenu(element, '.equipment', [ - { - name: "Aus dem Inventar entfernen", - icon: '', - callback: (event) => { - // TODO find id on heldenausruestung to remove the worn items as well - object.deleteEmbeddedDocuments('Item', [event[0].dataset.id]) - }, - condition: () => true - } - ], { - jQuery: false - }); + }).bind(thisObject.element); }, _getTabConfig: (group) => { group.tabs.push({id: "equipment", group: "sheet", label: "Ausrüstung"}) diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 92992f52..4e832082 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -369,212 +369,32 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { Attributes._onRender(context, options, this.element) Combat._onRender(context, options, this.element) Effects._onRender(context, options, this.element) - Equipment._onRender(context, options, this.element) + Equipment._onRender(context, options, this) Liturgies._onRender(context, options, this.element) Skills._onRender(context, options, this.element) Spells._onRender(context, options, this.element) } - /* showAdjustAttributeDialog(attributeName, attributeField, previousValue) { - const thisActor = this; - const myContent = ` - Value: - - `; + // TODO needs to be fixed once Character Sheet is migrated to ActorSheetV2 + async _onDrop(event) { + const data = TextEditor.implementation.getDragEventData(event); + const actor = this.actor; + const allowed = Hooks.call("dropActorSheetData", actor, this, data); + if (allowed === false) return; - function updateAttribute(html) { - const value = html.find("input#attributeValue").val(); - const attribute = {} - attribute[attributeField.toLowerCase()] = { - aktuell: value - } - thisActor.object.update({system: {attribute}}) + // Dropped Documents + const documentClass = foundry.utils.getDocumentClass(data.type); + if (documentClass) { + const document = await documentClass.fromDropData(data); + await this._onDropDocument(event, document); + + // No duplication by moving items from one actor to another + if (document.parent) { + document.parent.items.get(document._id).delete() } - - new Dialog({ - title: `${attributeName} ändern auf`, - content: myContent, - buttons: { - button1: { - label: "Ändern", - callback: (html) => { - updateAttribute(html) - }, - icon: `` - } - } - }).render(true); - - }*/ - - /* - activateListeners(html) { - super.activateListeners(html); - - const tabs = new foundry.applications.ux.Tabs({ - navSelector: ".paperdoll-tabs.tabs", - contentSelector: ".sheet-body.paperdoll-sets", - initial: "set" + (this.object.system.setEquipped + 1) - }); - tabs.bind(html[0]); - - html.on('click', '.attribute.rollable', (evt) => { - this._onAttributeRoll(evt); - }); - - html.on('click', '[data-operation="switchSet"]', (evt) => { - const {id} = evt.currentTarget.dataset; - console.log(id); - this.object.update({"system.setEquipped": id}) - }) - - html.on('click', '[data-operation="removeEffect"]', (evt) => { - const {actorId, effectId} = evt.currentTarget.dataset; - if (game.user.isGM) { - this.object.items.get(effectId).delete(); - } - }) - - html.on('click', '.talent.rollable', (evt) => { - this._onTalentRoll(evt); - }); - - html.on('click', '.sidebar-element.rollable', (evt) => { - this._onRoll(evt); - }); - - // TODO: merge into click.clickable handler - html.on('click', '.talent .name', (evt) => { - this.openEmbeddedDocument(evt.target.dataset.id); - evt.stopPropagation(); - }) - - // TODO: merge into click.clickable handler - html.on('click', '.advantage .name', (evt) => { - this.openEmbeddedDocument(evt.target.dataset.id); - evt.stopPropagation(); - }) - - // TODO: merge into click.clickable handler - html.on('click', '.equipment', (evt) => { - this.openEmbeddedDocument(evt.target.parentElement.dataset.id); - evt.stopPropagation(); - }) - - html.on('click', '.clickable', async (evt) => { - const {id, operation} = evt.currentTarget.dataset; - if (operation === "openActorSheet") { - this.openEmbeddedDocument(id); - evt.stopPropagation(); - } - }) - - new foundry.applications.ux.ContextMenu(html[0], '.talent.rollable', [ - { - name: "Entfernen", - icon: '', - callback: (event) => { - this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id]) - }, - condition: () => true - } - ], { - jQuery: false - }); - - - new foundry.applications.ux.ContextMenu(html[0], '.attribute.rollable', [ - { - name: "Anpassen", - icon: '', - callback: (event) => { - this.showAdjustAttributeDialog(event[0].dataset.name, event[0].dataset.label, event[0].dataset.value) - }, - condition: () => true - } - ], { - jQuery: false - }); - - let handler = evt => { - const talentId = evt.target.dataset.id - evt.dataTransfer.setData("application/json", JSON.stringify({ - talentId - })); - this._onDragStart(evt) - } - - // Find all items on the character sheet. - html.find('.talent.rollable').each((i, li) => { - // Add draggable attribute and dragstart listener. - li.setAttribute("draggable", true); - li.addEventListener("dragstart", handler, false); - }); - - html.on('click', '[data-operation="addWounds"]', async (evt) => { - const {value} = evt.currentTarget.dataset - this.object.update({"system.wunden.aktuell": value}) - }) - - html.on('click', '[data-operation="reduceWounds"]', async (evt) => { - const {value} = evt.currentTarget.dataset - this.object.update({"system.wunden.aktuell": value}) - }) - - html.on('click', '.liturgy.rollable', async (evt) => { - - evt.stopPropagation(); - - const {id, rank, lkp, deity} = evt.currentTarget.dataset; - const document = await this.object.items.get(id) - - const data = {}; - - data.rank = rank; - data.lkp = lkp; - data.deity = deity; - data.variations = []; - const ranks = LiturgyData.ranks - ranks.forEach(rank => { - if (document.system.auswirkung[rank]) { - data.variations.push({ - rank, - effect: document.system.auswirkung[rank] - }) - } - }) - data.mods = []; - - const htmlContent = await renderTemplate('systems/DSA_4-1/templates/dialog/modify-liturgy.hbs', data); - - const dialogData = { - title: document.name, - content: htmlContent, - data: {}, - buttons: { - submit: { - label: "Wirken", - icon: '', - callback: (html) => { - }, - }, - }, - } - dialogData.render = new ModifyLiturgy(data).handleRender - - const dialog = new Dialog(dialogData, { - classes: ['dsa41', 'dialog', 'liturgy'], - height: 480 - }) - - dialog.render(true); - - return false; - }) - - } - */ + } + } export default CharacterSheet diff --git a/src/module/sheets/groupSheet.mjs b/src/module/sheets/groupSheet.mjs index b3ed1427..74fe6912 100644 --- a/src/module/sheets/groupSheet.mjs +++ b/src/module/sheets/groupSheet.mjs @@ -311,7 +311,6 @@ export class GroupSheet extends HandlebarsApplicationMixin(ActorSheetV2) { if (document.parent) { document.parent.items.get(document._id).delete() } - await this._onDropDocument(event, document); } } diff --git a/src/style/organisms/_character-sheet.scss b/src/style/organisms/_character-sheet.scss index a18205f7..f04ae439 100644 --- a/src/style/organisms/_character-sheet.scss +++ b/src/style/organisms/_character-sheet.scss @@ -82,7 +82,7 @@ @include attributes.tab; } - .inventory.active { + .tab.equipment.active { @include inventory.tab; } diff --git a/src/style/organisms/character-tabs/_inventory.scss b/src/style/organisms/character-tabs/_inventory.scss index 94846cef..de57c16e 100644 --- a/src/style/organisms/character-tabs/_inventory.scss +++ b/src/style/organisms/character-tabs/_inventory.scss @@ -1,41 +1,44 @@ @mixin tab { - display: grid; - grid-template-columns: 1fr 320px; - grid-template-rows: 74px 1fr; - gap: 10px; - height: 100%; - grid-template-areas: + + & > div { + display: grid; + grid-template-columns: 1fr 320px; + grid-template-rows: 74px 1fr; + gap: 10px; + height: 100%; + grid-template-areas: "capacity capacity" "inventory equipment"; - .capacity { + .capacity { - grid-area: capacity; + grid-area: capacity; - .resource { + .resource { - position: relative; - border: 1px inset #ccc; - background-color: rgba(0, 0, 0, 0.2); - height: 8px; + 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%); } - } - } - .inventory { - grid-area: inventory; + .inventory { + grid-area: inventory; - .equipment:hover { - .item-name { - text-shadow: 0 0 10px rgb(255 0 0); + .equipment:hover { + .item-name { + text-shadow: 0 0 10px rgb(255 0 0); + } } } } diff --git a/src/templates/actor/character/tab-equipment.hbs b/src/templates/actor/character/tab-equipment.hbs index 99b1c335..8b6a83e4 100644 --- a/src/templates/actor/character/tab-equipment.hbs +++ b/src/templates/actor/character/tab-equipment.hbs @@ -16,47 +16,25 @@ {{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" equipments}} - + \ No newline at end of file diff --git a/src/templates/actor/character/tab-set.hbs b/src/templates/actor/character/tab-set.hbs new file mode 100644 index 00000000..43b5bb2c --- /dev/null +++ b/src/templates/actor/character/tab-set.hbs @@ -0,0 +1,29 @@ +
+ + +
+ + + + + {{#each this.slots}} +
+ {{/each}} + {{#if (eq ../actor.system.setEquipped @index)}} + + {{else}} + + {{/if}} + +
+ +
\ No newline at end of file