From 4bed84358b47dc7f8cbc29431008e83c210200a3 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 24 May 2025 00:13:41 +0200 Subject: [PATCH] Enhance actor sheet --- css/fvtt-hellborn.css | 50 ++++++++++++++++-- lang/en.json | 7 ++- .../applications/sheets/character-sheet.mjs | 34 +++++++++--- styles/character.less | 52 +++++++++++++++++-- templates/character-biography.hbs | 36 +++++++++++++ templates/character-main.hbs | 11 +++- 6 files changed, 173 insertions(+), 17 deletions(-) diff --git a/css/fvtt-hellborn.css b/css/fvtt-hellborn.css index 723576f..3c54f9a 100644 --- a/css/fvtt-hellborn.css +++ b/css/fvtt-hellborn.css @@ -216,6 +216,12 @@ i.fvtt-hellborn { max-width: 16rem; margin-bottom: auto; } +.fvtt-hellborn .character-main .character-pc .character-right .character-definition .trait { + min-width: 13rem; + max-width: 13rem; + margin-right: 1rem; + margin-bottom: auto; +} .fvtt-hellborn .character-main .character-pc .character-right .character-name { display: flex; } @@ -579,6 +585,38 @@ i.fvtt-hellborn { .fvtt-hellborn .tab.character-biography .main-div .splitted-text fieldset { width: 100%; } +.fvtt-hellborn .tab.character-biography .main-div .deals { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 4px; +} +.fvtt-hellborn .tab.character-biography .main-div .deals .deal { + display: flex; + align-items: center; + gap: 4px; + margin-left: 4px; + min-width: 12rem; + max-width: 12rem; +} +.fvtt-hellborn .tab.character-biography .main-div .deals .deal .rollable:hover, +.fvtt-hellborn .tab.character-biography .main-div .deals .deal .rollable:focus { + text-shadow: 0 0 8px var(--color-shadow-primary); + cursor: pointer; +} +.fvtt-hellborn .tab.character-biography .main-div .deals .deal .controls { + font-size: 0.7rem; + min-width: 1.8rem; + max-width: 1.8rem; +} +.fvtt-hellborn .tab.character-biography .main-div .deals .deal .name { + min-width: 10rem; + max-width: 10rem; +} +.fvtt-hellborn .tab.character-biography .main-div .deals .deal .item-img { + width: 24px; + height: 24px; + margin: 4px 0 0 0; +} .fvtt-hellborn .tab.character-biography .main-div .biodata { display: grid; grid-template-columns: repeat(3, 1fr); @@ -597,16 +635,20 @@ i.fvtt-hellborn { align-items: center; gap: 4px; margin-left: 4px; - min-width: 12rem; - max-width: 12rem; + min-width: 14rem; + max-width: 14rem; } .fvtt-hellborn .tab.character-biography .main-div .biodata .form-group label { min-width: 6rem; max-width: 6rem; } +.fvtt-hellborn .tab.character-biography .main-div .biodata input .tarot { + min-width: 8rem; + max-width: 8rem; +} .fvtt-hellborn .tab.character-biography .main-div .biodata input { - min-width: 4rem; - max-width: 4rem; + min-width: 8rem; + max-width: 8rem; } .fvtt-hellborn .tab.character-biography .main-div prose-mirror.inactive { min-height: 40px; diff --git a/lang/en.json b/lang/en.json index 5690667..5c0681a 100644 --- a/lang/en.json +++ b/lang/en.json @@ -315,6 +315,8 @@ } }, "Label": { + "deals": "Deals", + "tarot": "Tarot", "backstory": "Backstory", "scars": "Scars", "likes": "Likes", @@ -444,7 +446,10 @@ } } }, - "Notifications": {}, + "Notifications": { + "tarotDeleted": "Previous Tarot card deleted : ", + "speciesTraitDeleted": "Previous Species Trait deleted : " + }, "Perk": { "FIELDS": { "description": { diff --git a/module/applications/sheets/character-sheet.mjs b/module/applications/sheets/character-sheet.mjs index 0ae8e75..6ee6d98 100644 --- a/module/applications/sheets/character-sheet.mjs +++ b/module/applications/sheets/character-sheet.mjs @@ -71,6 +71,9 @@ export default class HellbornCharacterSheet extends HellbornActorSheet { const context = await super._prepareContext() context.tabs = this.#getTabs() + const doc = this.document + context.trait = doc.itemTypes['species-trait']?.[0] + return context } @@ -106,7 +109,7 @@ export default class HellbornCharacterSheet extends HellbornActorSheet { context.tab = context.tabs.biography context.deals = doc.itemTypes.deal context.deals.sort((a, b) => a.name.localeCompare(b.name)) - context.tarot = doc.itemTypes.tarot + context.tarot = doc.itemTypes.tarot?.[0] context.enrichedBackstory = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.backstory, { async: true }) context.enrichedAppearance = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.appearance, { async: true }) context.enrichedScars = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.scars, { async: true }) @@ -121,6 +124,7 @@ export default class HellbornCharacterSheet extends HellbornActorSheet { context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true }) break } + console.log("context", context) return context } @@ -188,14 +192,32 @@ export default class HellbornCharacterSheet extends HellbornActorSheet { async _onDrop(event) { if (!this.isEditable || !this.isEditMode) return - const data = TextEditor.getDragEventData(event) + const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event) // Handle different data types - switch (data.type) { - case "Item": - const item = await fromUuid(data.uuid) - return super._onDropItem(item) + if (data.type === "Item") { + const item = await fromUuid(data.uuid) + if (item.type === "tarot") { + // Delete the existing tarot item + const existingTarot = this.document.items.find(i => i.type === "tarot") + if (existingTarot) { + await existingTarot.delete() + // Display info message + ui.notifications.info(game.i18n.localize("HELLBORN.Notifications.tarotDeleted") + existingTarot.name) + } + } + if (item.type === "species-trait") { + // Check if the item is already in the actor + const existingTrait = this.document.items.find(i => i.type === "species-trait" && i.name === item.name) + if (existingTrait) { + await existingTrait.delete() + // Display info message + ui.notifications.info(game.i18n.localize("HELLBORN.Notifications.speciesTraitDeleted")+ existingTrait.name) + } + } + return super._onDropItem(item) } + } } diff --git a/styles/character.less b/styles/character.less index 5d2ca1b..4920e81 100644 --- a/styles/character.less +++ b/styles/character.less @@ -78,6 +78,12 @@ max-width: 16rem; margin-bottom: auto; } + .trait{ + min-width: 13rem; + max-width: 13rem; + margin-right: 1rem; + margin-bottom: auto; + } } .character-name { display: flex; @@ -470,6 +476,38 @@ width: 100%; } } + .deals { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 4px; + .deal { + display: flex; + align-items: center; + gap: 4px; + margin-left: 4px; + min-width: 12rem; + max-width: 12rem; + .rollable:hover, + .rollable:focus { + text-shadow: 0 0 8px var(--color-shadow-primary); + cursor: pointer; + } + .controls { + font-size: 0.7rem; + min-width: 1.8rem; + max-width: 1.8rem; + } + .name { + min-width: 10rem; + max-width: 10rem; + } + .item-img { + width: 24px; + height: 24px; + margin: 4px 0 0 0; + } + } + } .biodata { display: grid; grid-template-columns: repeat(3, 1fr); @@ -491,13 +529,17 @@ align-items: center; gap: 4px; margin-left: 4px; - min-width: 12rem; - max-width: 12rem; + min-width: 14rem; + max-width: 14rem; + } + input .tarot { + min-width: 8rem; + max-width: 8rem; } input { - min-width: 4rem; - max-width: 4rem; - } + min-width: 8rem; + max-width: 8rem; + } } prose-mirror.inactive { diff --git a/templates/character-biography.hbs b/templates/character-biography.hbs index 5c7e4b2..1658f41 100644 --- a/templates/character-biography.hbs +++ b/templates/character-biography.hbs @@ -41,8 +41,44 @@ {{formField systemFields.biodata.fields.birthplace value=system.biodata.birthplace rootId=partId disabled=isPlayMode}} +
+
+ + +
+ + +
+
+
+
+ {{localize "HELLBORN.Label.deals"}}{{#if isEditMode}} + {{/if}} + +
+ {{#each deals as |item|}} +
+ +
+ {{item.name}} +
+
+ + +
+
+ {{/each}} +
+
+ +
{{localize "HELLBORN.Label.backstory"}} {{formInput systemFields.backstory enriched=enrichedBackstory value=system.backstory name="system.backstory" toggled=true}} diff --git a/templates/character-main.hbs b/templates/character-main.hbs index a99dd08..5b986f5 100644 --- a/templates/character-main.hbs +++ b/templates/character-main.hbs @@ -26,7 +26,16 @@ {{formField systemFields.species value=system.species rootId=partId disabled=isPlayMode}}
- {{formField systemFields.trait value=system.trait rootId=partId disabled=isPlayMode}} +
+ + +
+ + +
+