diff --git a/src/module/sheets/character/equipment.mjs b/src/module/sheets/character/equipment.mjs index 8c34b1c8..d32c63b4 100644 --- a/src/module/sheets/character/equipment.mjs +++ b/src/module/sheets/character/equipment.mjs @@ -1,5 +1,3 @@ -import {PlayerCharacterDataModel} from "../../data/character.mjs"; - export default { _prepareContext: (context, actor, thisObject) => { @@ -52,9 +50,11 @@ export default { for (let setIndex = 0; setIndex < maxSets; setIndex++) { context.sets.push({ - tab: "set" + (setIndex + 1), + tab: "pane" + (setIndex + 1), label: romanNumerals[setIndex], index: setIndex, + actorId: actorData.id, + setEquipped: actorData.system.setEquipped === setIndex, slots: [ { target: "links", @@ -131,6 +131,8 @@ export default { ] }) } + context.selectedTab = thisObject.selectedTab ?? context.sets[0].tab + context.setEquipped = actorData.system.setEquipped return context }, @@ -150,9 +152,51 @@ export default { } }).bind(thisObject.element); + const tabs = new foundry.applications.ux.Tabs({ + navSelector: ".set .tabs.sets", + contentSelector: ".set .tab", + initial: thisObject.actor.system.setEquipped ? "pane" + (thisObject.actor.system.setEquipped + 1) : "pane1", + group: "set-tabs", + callback: (event, tab, tabName) => { + console.log(event, tab, tabName) + thisObject.selectedTab = tabName + thisObject.element.querySelectorAll(tab._contentSelector).forEach( + (tab) => { + if (tab.dataset["tab"] === tabName) { + tab.classList.add("active") + } else { + tab.classList.remove("active") + } + } + ) + } + }) + + tabs.bind(thisObject.element) + new ContextMenu( thisObject.element, - ".equipment", + ".paperdoll .equipped", + [ + { + name: "Abrüsten", + icon: '', + callback: (targetElement) => { + const {setId, target} = targetElement.dataset + const updateObject = thisObject.document.getEquipmentSetUpdateObject() + delete updateObject[`system.heldenausruestung.${setId}.${target}`] + thisObject.document.update(updateObject) + }, + condition: (target) => { + const {itemId} = target.dataset + return thisObject.document.isWorn(itemId) + } + }, + ], {jQuery: false}) + + new ContextMenu( + thisObject.element, + ".inventory-table .equipment", [ { name: "Abrüsten", diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 46331c88..72823853 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -70,6 +70,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { openStandaloneLiturgies: CharacterSheet.#openStandaloneLiturgies, openStandaloneHealth: CharacterSheet.#openStandaloneHealth, setWounds: CharacterSheet.#setWounds, + switchSet: CharacterSheet.#switchSet } } @@ -115,15 +116,6 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { effects: { template: Effects.template }, - set1: { - template: "systems/DSA_4-1/templates/actor/character/tab-set.hbs" - }, - set2: { - template: "systems/DSA_4-1/templates/actor/character/tab-set.hbs" - }, - set3: { - template: "systems/DSA_4-1/templates/actor/character/tab-set.hbs" - }, } @@ -329,6 +321,12 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { this.render(true) } + static async #switchSet(event, target) { + const {id} = target.dataset + this.document.update({"system.setEquipped": id}) + this.render(true) + } + _configureRenderOptions(options) { super._configureRenderOptions(options) @@ -719,11 +717,24 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { return true } - async _onDrop(event) { const data = TextEditor.implementation.getDragEventData(event) const targetDocument = this.actor.itemTypes["Equipment"].find(p => p._id === event.target.dataset['itemId']) + if (event.target.dataset["target"] && event.target.dataset["setId"]) { + + const documentClass = foundry.utils.getDocumentClass(data.type) + if (documentClass) { + const document = await documentClass.fromDropData(data) + + const {setId, target} = event.target.dataset + const updateObject = this.actor.getEquipmentSetUpdateObject() + updateObject[`system.heldenausruestung.${setId}.${target}`] = document.id + await this.actor.update(updateObject) + } + return + } + // Dropped Documents const documentClass = foundry.utils.getDocumentClass(data.type) if (documentClass) { diff --git a/src/style/molecules/_paperdoll.scss b/src/style/molecules/_paperdoll.scss index fa984834..28315811 100644 --- a/src/style/molecules/_paperdoll.scss +++ b/src/style/molecules/_paperdoll.scss @@ -1,35 +1,4 @@ -.dsa41.sheet.actor.character .window-content { - .sheet-tabs.paperdoll-tabs.tabs { - - position: absolute; - top: 30px; - left: 0; - right: 0; - height: 26px; - - .item.active[data-tab] { - padding-left: 12px; - padding-right: 12px; - padding-top: 8px; - padding-bottom: 3px; - - } - } - - .sheet-body.paperdoll-sets { - left: 0; - top: 55px; - bottom: 0; - right: 0; - overflow: hidden; - - div.tab { - overflow: hidden; - } - - } - - .paperdoll { +.paperdoll { grid-area: equipment; position: relative; @@ -110,5 +79,3 @@ } } - -} diff --git a/src/style/molecules/_tabs.scss b/src/style/molecules/_tabs.scss index cfcaf2bf..5d6d12e2 100644 --- a/src/style/molecules/_tabs.scss +++ b/src/style/molecules/_tabs.scss @@ -73,6 +73,57 @@ } } + nav.tabs:not(.sheet-tabs) { + border: unset; + border-bottom: 1px solid black; + gap: 0; + height: 24px; + + a.item { + flex: 1; + position: relative; + height: 24px; + line-height: 24px; + + span { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + line-height: 24px; + vertical-align: middle; + text-align: center; + } + } + + a.item:not(.active) { + border: unset; + } + + a.item.active { + border: 1px solid black; + border-bottom: none; + + span { + left: -2px; + top: -2px; + height: 28px; + + &:after { + content: ''; + position: absolute; + left: 2px; + right: 0; + bottom: 3px; + height: 2px; + background: assets.$tab-background; + } + } + } + + } + } // darkmode diff --git a/src/templates/actor/character/tab-equipment.hbs b/src/templates/actor/character/tab-equipment.hbs index f289a702..4d725738 100644 --- a/src/templates/actor/character/tab-equipment.hbs +++ b/src/templates/actor/character/tab-equipment.hbs @@ -29,18 +29,20 @@

Ausrüstung

-
\ No newline at end of file diff --git a/src/templates/actor/character/tab-set.hbs b/src/templates/actor/character/tab-set.hbs index cde2bd41..ef59c810 100644 --- a/src/templates/actor/character/tab-set.hbs +++ b/src/templates/actor/character/tab-set.hbs @@ -1,25 +1,24 @@
- + {{#each this.slots}} -
{{/each}} - {{!-- - {{#if (eq ../actor.system.setEquipped @index)}} + + {{#if setEquipped}} {{else}} {{/if}} - --}}
\ No newline at end of file