From 21479ce0826a446237ce3b64338fb4fa17564c90 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 2 Oct 2025 17:45:52 +0200 Subject: [PATCH] Updates Rollables (Attributes, Skills) to include a ContextMenu to delete or adjust their values. Also added the capability to open SkillsSheets. --- src/module/sheets/characterSheet.mjs | 72 ++++++++++++++++++- src/style/_rollable.scss | 5 +- src/templates/item/item-skill-sheet.hbs | 8 ++- src/templates/ui/partial-attribute-button.hbs | 4 +- src/templates/ui/partial-rollable-button.hbs | 6 +- 5 files changed, 83 insertions(+), 12 deletions(-) diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 9bbbf59d..73f24e17 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -69,7 +69,8 @@ export class CharacterSheet extends ActorSheet { eigenschaft1: werte[0].name, eigenschaft2: werte[1].name, eigenschaft3: werte[2].name, - probe: `(${eigenschaften.join("/")})` + probe: `(${eigenschaften.join("/")})`, + id: item._id, }; context.skills[talentGruppe].push(obj); context.flatSkills.push(obj); @@ -123,7 +124,7 @@ export class CharacterSheet extends ActorSheet { }, { eigenschaft: "ch", - name: "IN", + name: "CH", tooltip: "Charisma", wert: actorData.system.attribute.ch.aktuell ?? 0, }, @@ -147,7 +148,7 @@ export class CharacterSheet extends ActorSheet { }, { eigenschaft: "kk", - name: "KO", + name: "KK", tooltip: "Körperkraft", wert: actorData.system.attribute.kk.aktuell ?? 0, }, @@ -261,6 +262,43 @@ export class CharacterSheet extends ActorSheet { } } + _onOpenSkill(documentId) { + console.log(this.object.items.get(documentId).sheet); + this.object.items.get(documentId).sheet.render(true) + } + + showAdjustAttributeDialog(attributeName, attributeField, previousValue) { + const thisActor = this; + const myContent = ` + Value: + + `; + + function updateAttribute(html) { + const value = html.find("input#attributeValue").val(); + const attribute = {} + attribute[attributeField.toLowerCase()] = { + aktuell: value + } + thisActor.object.update({ system: { attribute }}) + } + + new Dialog({ + title: `${attributeName} ändern auf`, + content: myContent, + buttons: { + button1: { + label: "Ändern", + callback: (html) => { + updateAttribute(html) + }, + icon: `` + } + } + }).render(true); + + } + activateListeners(html) { super.activateListeners(html); @@ -276,6 +314,34 @@ export class CharacterSheet extends ActorSheet { this._onRoll(evt); }); + html.on('click', '.talent .name', (evt) => { + this._onOpenSkill(evt.target.dataset.id); + evt.stopPropagation(); + }) + + new ContextMenu(html, '.talent.rollable', [ + { + name: "Entfernen", + icon: '', + callback: (event) => { + this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id]) + }, + condition: () => true + } + ]); + + + new ContextMenu(html, '.attribute.rollable', [ + { + name: "Anpassen", + icon: '', + callback: (event) => { + this.showAdjustAttributeDialog(event[0].dataset.name, event[0].dataset.label, event[0].dataset.value) + }, + condition: () => true + } + ]); + let handler = ev => this._onDragStart(ev); // Find all items on the character sheet. diff --git a/src/style/_rollable.scss b/src/style/_rollable.scss index 40c2d4fb..d0e71cf2 100644 --- a/src/style/_rollable.scss +++ b/src/style/_rollable.scss @@ -24,13 +24,13 @@ $rollable_colours: ( height: 32px; position: relative; margin: 4px; - z-index: 2; .die { width: 32px; height: 32px; display: inline-block; position: relative; + z-index: 1; .border { fill: #0000; @@ -64,7 +64,6 @@ $rollable_colours: ( left: 16px; top: 0; height: 32px; - z-index: -1; padding-left: 24px; span.name { @@ -205,4 +204,4 @@ $rollable_colours: ( @include coloring("Gesellschaft"); @include coloring("Wissen"); @include coloring("Sprachen"); -@include coloring("Handwerk"); \ No newline at end of file +@include coloring("Handwerk"); diff --git a/src/templates/item/item-skill-sheet.hbs b/src/templates/item/item-skill-sheet.hbs index 89449c4f..22cd7fd3 100644 --- a/src/templates/item/item-skill-sheet.hbs +++ b/src/templates/item/item-skill-sheet.hbs @@ -17,6 +17,12 @@ +
+ +