From 6d366188ead2a6cc461fd1a1d6d97967bdaec461 Mon Sep 17 00:00:00 2001 From: macniel Date: Thu, 13 Nov 2025 22:40:48 +0100 Subject: [PATCH] begins implementing sidebar elements for pinned Items --- src/module/setup/partials.mjs | 7 ++- src/module/sheets/character/advsf.mjs | 7 ++- src/module/sheets/character/liturgies.mjs | 1 + src/module/sheets/character/skills.mjs | 3 +- src/module/sheets/character/spells.mjs | 1 + src/module/sheets/characterSheet.mjs | 59 ++++++++++++++++++- src/style/molecules/_rollable.scss | 48 +++++++++------ src/templates/actor/character/main-sheet.hbs | 7 +++ src/templates/actor/character/tab-spells.hbs | 11 +++- src/templates/item/spell/tab-commonality.hbs | 4 +- src/templates/item/spell/tab-meta.hbs | 10 ++-- src/templates/item/spell/tab-variants.hbs | 4 +- .../ui/partial-mini-rollable-button.hbs | 3 + .../partial-mini-rollable-language-button.hbs | 3 + .../partial-mini-rollable-liturgy-button.hbs | 3 + .../ui/partial-mini-rollable-spell-button.hbs | 3 + ...rtial-mini-rollable-weaponskill-button.hbs | 7 +++ src/templates/ui/partial-rollable-button.hbs | 7 +++ .../ui/partial-rollable-language-button.hbs | 7 +++ .../partial-rollable-weaponskill-button.hbs | 7 +++ 20 files changed, 170 insertions(+), 32 deletions(-) create mode 100644 src/templates/ui/partial-mini-rollable-button.hbs create mode 100644 src/templates/ui/partial-mini-rollable-language-button.hbs create mode 100644 src/templates/ui/partial-mini-rollable-liturgy-button.hbs create mode 100644 src/templates/ui/partial-mini-rollable-spell-button.hbs create mode 100644 src/templates/ui/partial-mini-rollable-weaponskill-button.hbs diff --git a/src/module/setup/partials.mjs b/src/module/setup/partials.mjs index f589948e..ce3115dd 100644 --- a/src/module/setup/partials.mjs +++ b/src/module/setup/partials.mjs @@ -16,7 +16,12 @@ function loadPartials(hbs) { 'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs', 'systems/DSA_4-1/templates/ui/partial-array-editor.hbs', 'systems/DSA_4-1/templates/actor/character/tab-set.hbs', - 'systems/DSA_4-1/templates/dialog/liturgy-dialog.hbs' + 'systems/DSA_4-1/templates/dialog/liturgy-dialog.hbs', + 'systems/DSA_4-1/templates/ui/partial-mini-rollable-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-mini-rollable-liturgy-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-mini-rollable-weaponskill-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-mini-rollable-language-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-mini-rollable-spell-button.hbs', ]).then(resolve); }) diff --git a/src/module/sheets/character/advsf.mjs b/src/module/sheets/character/advsf.mjs index f0074d84..2bd10a79 100644 --- a/src/module/sheets/character/advsf.mjs +++ b/src/module/sheets/character/advsf.mjs @@ -21,7 +21,8 @@ export default { description: item.system.description, isAdvantage: !item.system.nachteil, isDisadvantage: item.system.nachteil, - isBadAttribute: item.system.schlechteEigenschaft + isBadAttribute: item.system.schlechteEigenschaft, + fav: item.getFlag("DSA_4-1", "favourite") }) } else { context.flaws.push({ @@ -32,7 +33,8 @@ export default { description: item.system.description, isAdvantage: !item.system.nachteil, isDisadvantage: item.system.nachteil, - isBadAttribute: item.system.schlechteEigenschaft + isBadAttribute: item.system.schlechteEigenschaft, + fav: item.getFlag("DSA_4-1", "favourite") }) } } @@ -43,6 +45,7 @@ export default { context.specialAbilities.push({ id: item._id, name: item.system.value ? item.system.value : item.name, + fav: item.getFlag("DSA_4-1", "favourite") }); } ); diff --git a/src/module/sheets/character/liturgies.mjs b/src/module/sheets/character/liturgies.mjs index c5293522..ac5022c8 100644 --- a/src/module/sheets/character/liturgies.mjs +++ b/src/module/sheets/character/liturgies.mjs @@ -68,6 +68,7 @@ export default { lkpReq: lkp, lkpMod: mod, costKaP, + fav: item.getFlag("DSA_4-1", "favourite"), rank: index, // get effective liturgy rank based on deity liturgiekenntnis: deity, }) diff --git a/src/module/sheets/character/skills.mjs b/src/module/sheets/character/skills.mjs index 9cf1d9d5..8c868d44 100644 --- a/src/module/sheets/character/skills.mjs +++ b/src/module/sheets/character/skills.mjs @@ -51,7 +51,8 @@ export default { id: item._id, at: item.system.at, pa: item.system.pa, - komplexität: item.system.komplexität + komplexität: item.system.komplexität, + fav: item.getFlag("DSA_4-1", "favourite") }; if (talentGruppe === "Kampf") { diff --git a/src/module/sheets/character/spells.mjs b/src/module/sheets/character/spells.mjs index 917679be..db409ba5 100644 --- a/src/module/sheets/character/spells.mjs +++ b/src/module/sheets/character/spells.mjs @@ -42,6 +42,7 @@ export default { eigenschaft1: werte[0].name, eigenschaft2: werte[1].name, eigenschaft3: werte[2].name, + fav: item.getFlag("DSA_4-1", "favourite") }) }) diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 2c8a6064..fad3b1de 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -47,6 +47,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { openSpeciesDocument: CharacterSheet.#openSpeciesDocument, openCombatAction: CharacterSheet.#openCombatAction, openLiturgyDialog: CharacterSheet.#openLiturgyDialog, + openSpellDialog: CharacterSheet.#openSpellDialog, progressCooldown: CharacterSheet.#progressCooldown, cancelCooldown: CharacterSheet.#cancelCooldown, activateCooldown: CharacterSheet.#activateCooldown, @@ -54,7 +55,8 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { removeEffect: CharacterSheet.#removeEffect, rollDamage: CharacterSheet.#rollDamage, openItemBrowser: CharacterSheet.#openItemBrowser, - newItem: CharacterSheet.#addNewItem + newItem: CharacterSheet.#addNewItem, + toggleFav: CharacterSheet.#toggleFav, } } @@ -233,6 +235,12 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { new LiturgyDialog(this.document, lkp, id, deity).render(true) } + static #openSpellDialog(event, target) { + const {itemId} = target.dataset + console.log(itemId) + this.document.itemTypes["Spell"]?.find(p => p.id === itemId)?.sheet.render(true) + } + static #startResting(event, target) { const dialog = new RestingDialog(this.document) @@ -267,6 +275,16 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { items[0].sheet.render(true) } + static async #toggleFav(event, target) { + const {itemId} = target.dataset + const doc = this.document.items.find(p => p.id === itemId) + + if (doc) { + const previous = doc.getFlag("DSA_4-1", "favourite") ?? false + doc.setFlag("DSA_4-1", "favourite", !previous) + } + } + _configureRenderOptions(options) { super._configureRenderOptions(options) @@ -277,6 +295,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { return options } + /** * Handle form submission * @this {AdvantageSheet} @@ -485,6 +504,44 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { }) } + context.favourites = actorData.items.filter(item => item.getFlag("DSA_4-1", "favourite") === true).map(item => { + let id = item.id + let t = null + switch (item.type) { + case "Spell": + t = "systems/DSA_4-1/templates/ui/partial-mini-rollable-spell-button.hbs" + break; + case "Skill": + switch (item.system.gruppe) { + case "Kampf": + t = "systems/DSA_4-1/templates/ui/partial-mini-rollable-weaponskill-button.hbs" + break; + case "Sprachen": + t = "systems/DSA_4-1/templates/ui/partial-mini-rollable-language-button.hbs" + break; + default: + t = "systems/DSA_4-1/templates/ui/partial-mini-rollable-button.hbs" + } + break; + case "Liturgy": + t = "systems/DSA_4-1/templates/ui/partial-mini-rollable-liturgy-button.hbs" + break; + default: + t = null + } + + let obj = Object.assign({}, item) + + obj.fav = item.getFlag("DSA_4-1", "favourite") + obj.id = id + + if (t) { + obj.template = t + } + + return obj + }) + context.cooldowns = actorData.system.cooldowns ?? [] context.cooldowns.forEach(cooldown => { let weapon = null diff --git a/src/style/molecules/_rollable.scss b/src/style/molecules/_rollable.scss index 642d23bd..69b30a92 100644 --- a/src/style/molecules/_rollable.scss +++ b/src/style/molecules/_rollable.scss @@ -36,7 +36,7 @@ $rollable_colours_font: ( display: block; height: 32px; position: relative; - margin: 4px; + margin: 4px 32px 4px 4px; .die { width: 32px; @@ -69,6 +69,24 @@ $rollable_colours_font: ( top: 6px; } } + + &:active { + + + scale: 0.8; + + .value { + + img { + position: absolute; + width: 20px; + height: 20px; + left: 4px; + top: 7px; + } + } + + } } .container { @@ -122,6 +140,18 @@ $rollable_colours_font: ( } } } + + .outside { + position: absolute; + right: -24px; + top: 8px; + bottom: 8px; + z-index: 3; + + &:hover { + text-shadow: 0 0 10px rgb(255 0 0); + } + } } // interactivity @@ -135,23 +165,7 @@ $rollable_colours_font: ( } - &:active { - .die { - scale: 0.8; - - .value { - - img { - position: absolute; - width: 20px; - height: 20px; - left: 4px; - top: 7px; - } - } - } - } } } diff --git a/src/templates/actor/character/main-sheet.hbs b/src/templates/actor/character/main-sheet.hbs index 0af055ff..386fc6b9 100644 --- a/src/templates/actor/character/main-sheet.hbs +++ b/src/templates/actor/character/main-sheet.hbs @@ -99,6 +99,13 @@ {{/each}} +
+

Angepinnt

+ {{#each this.favourites}} + {{> (lookup this "template") this}} + {{/each}} +
+

Abklingzeiten

{{#each this.cooldowns}} diff --git a/src/templates/actor/character/tab-spells.hbs b/src/templates/actor/character/tab-spells.hbs index 46ec9463..1b6e8a1e 100644 --- a/src/templates/actor/character/tab-spells.hbs +++ b/src/templates/actor/character/tab-spells.hbs @@ -33,7 +33,7 @@ {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} - + {{this.name}} {{this.eigenschaft1}} {{this.eigenschaft2}} @@ -43,6 +43,15 @@ + +
+ {{#if this.fav}} + + {{else}} + + {{/if}} +
+ {{/each}} diff --git a/src/templates/item/spell/tab-commonality.hbs b/src/templates/item/spell/tab-commonality.hbs index 351998d0..89a6a8d5 100644 --- a/src/templates/item/spell/tab-commonality.hbs +++ b/src/templates/item/spell/tab-commonality.hbs @@ -1,7 +1,7 @@
- +
- +
\ No newline at end of file diff --git a/src/templates/item/spell/tab-meta.hbs b/src/templates/item/spell/tab-meta.hbs index 7dc4079b..211cdaee 100644 --- a/src/templates/item/spell/tab-meta.hbs +++ b/src/templates/item/spell/tab-meta.hbs @@ -1,11 +1,11 @@
- +
@@ -14,7 +14,7 @@ value="{{system.probe.[0]}}"/> -
@@ -44,5 +44,5 @@
- +
\ No newline at end of file diff --git a/src/templates/item/spell/tab-variants.hbs b/src/templates/item/spell/tab-variants.hbs index 334d3786..c382c66d 100644 --- a/src/templates/item/spell/tab-variants.hbs +++ b/src/templates/item/spell/tab-variants.hbs @@ -1,7 +1,7 @@
- +
- +
\ No newline at end of file diff --git a/src/templates/ui/partial-mini-rollable-button.hbs b/src/templates/ui/partial-mini-rollable-button.hbs new file mode 100644 index 00000000..7dd171ee --- /dev/null +++ b/src/templates/ui/partial-mini-rollable-button.hbs @@ -0,0 +1,3 @@ +
+ {{this.name}} +
\ No newline at end of file diff --git a/src/templates/ui/partial-mini-rollable-language-button.hbs b/src/templates/ui/partial-mini-rollable-language-button.hbs new file mode 100644 index 00000000..7fb3506c --- /dev/null +++ b/src/templates/ui/partial-mini-rollable-language-button.hbs @@ -0,0 +1,3 @@ +
+ {{this.name}} +
\ No newline at end of file diff --git a/src/templates/ui/partial-mini-rollable-liturgy-button.hbs b/src/templates/ui/partial-mini-rollable-liturgy-button.hbs new file mode 100644 index 00000000..e032c98a --- /dev/null +++ b/src/templates/ui/partial-mini-rollable-liturgy-button.hbs @@ -0,0 +1,3 @@ +
+ {{this.name}} +
\ No newline at end of file diff --git a/src/templates/ui/partial-mini-rollable-spell-button.hbs b/src/templates/ui/partial-mini-rollable-spell-button.hbs new file mode 100644 index 00000000..da472975 --- /dev/null +++ b/src/templates/ui/partial-mini-rollable-spell-button.hbs @@ -0,0 +1,3 @@ +
+ {{this.name}} +
\ No newline at end of file diff --git a/src/templates/ui/partial-mini-rollable-weaponskill-button.hbs b/src/templates/ui/partial-mini-rollable-weaponskill-button.hbs new file mode 100644 index 00000000..aabced0f --- /dev/null +++ b/src/templates/ui/partial-mini-rollable-weaponskill-button.hbs @@ -0,0 +1,7 @@ +
+
+ {{this.name}} +
+
\ No newline at end of file diff --git a/src/templates/ui/partial-rollable-button.hbs b/src/templates/ui/partial-rollable-button.hbs index ee575a8c..dcfe6edc 100644 --- a/src/templates/ui/partial-rollable-button.hbs +++ b/src/templates/ui/partial-rollable-button.hbs @@ -21,4 +21,11 @@ {{/each}} +
+ {{#if this.fav}} + + {{else}} + + {{/if}} +
diff --git a/src/templates/ui/partial-rollable-language-button.hbs b/src/templates/ui/partial-rollable-language-button.hbs index 27c0e810..b4196107 100644 --- a/src/templates/ui/partial-rollable-language-button.hbs +++ b/src/templates/ui/partial-rollable-language-button.hbs @@ -23,4 +23,11 @@ {{/each}} +
+ {{#if this.fav}} + + {{else}} + + {{/if}} +
diff --git a/src/templates/ui/partial-rollable-weaponskill-button.hbs b/src/templates/ui/partial-rollable-weaponskill-button.hbs index 5225fbc8..fe7648dd 100644 --- a/src/templates/ui/partial-rollable-weaponskill-button.hbs +++ b/src/templates/ui/partial-rollable-weaponskill-button.hbs @@ -24,4 +24,11 @@ {{/if}} +
+ {{#if this.fav}} + + {{else}} + + {{/if}} +