From 0b6b7118007f5489f4264913c430e3ccafbe6725 Mon Sep 17 00:00:00 2001 From: Zakkon Date: Mon, 29 Sep 2025 14:20:45 +0200 Subject: [PATCH] Added Journal tab on character sheet with input fields "notes", "allies", "enemies" --- lang/en.json | 7 ++++ .../applications/sheets/actors/character.mjs | 40 ++++++++++++++++++- module/data/actor/character.mjs | 6 +++ .../less/sheets/actors/character/journal.less | 38 ++++++++++++++++++ styles/less/sheets/index.less | 1 + system.json | 9 ++++- templates/sheets/actors/character/journal.hbs | 28 +++++++++++++ 7 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 styles/less/sheets/actors/character/journal.less create mode 100644 templates/sheets/actors/character/journal.hbs diff --git a/lang/en.json b/lang/en.json index 37e6cfff..6c7c0e71 100755 --- a/lang/en.json +++ b/lang/en.json @@ -177,6 +177,12 @@ "characteristics": "Characteristics", "connectionsTitle": "Connections" }, + "journal": { + "notesTitle": "Notes", + "alliesTitle": "Allies", + "enemiesTitle": "Enemies", + "organizationsTitle": "Organizations" + }, "experienceDataRemoveConfirmation": { "title": "Remove Experience Data", "text": "The experience you are about to remove has levelup data linked to it (assumably because you did levelups with the 'levelupAuto' automation setting on). Removing it will remove this automation data aswell. Do you want to proceed?" @@ -1870,6 +1876,7 @@ "heritage": "Heritage", "story": "Story", "biography": "Biography", + "journal": "Journal", "general": "General", "foundation": "Foundation", "specialization": "Specialization", diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index a140a7c9..c275ef45 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -92,6 +92,10 @@ export default class CharacterSheet extends DHBaseActorSheet { id: 'biography', template: 'systems/daggerheart/templates/sheets/actors/character/biography.hbs' }, + journal: { + id: 'journal', + template: 'systems/daggerheart/templates/sheets/actors/character/journal.hbs' + }, effects: { id: 'effects', template: 'systems/daggerheart/templates/sheets/actors/character/effects.hbs' @@ -103,7 +107,7 @@ export default class CharacterSheet extends DHBaseActorSheet { /** @inheritdoc */ static TABS = { primary: { - tabs: [{ id: 'features' }, { id: 'loadout' }, { id: 'inventory' }, { id: 'biography' }, { id: 'effects' }], + tabs: [{ id: 'features' }, { id: 'loadout' }, { id: 'inventory' }, { id: 'biography' }, { id: 'journal' }, { id: 'effects' }], initial: 'features', labelPrefix: 'DAGGERHEART.GENERAL.Tabs' } @@ -197,6 +201,9 @@ export default class CharacterSheet extends DHBaseActorSheet { case 'biography': await this._prepareBiographyContext(context, options); break; + case 'journal': + await this._prepareJournalContext(context, options); + break; } return context; @@ -252,6 +259,37 @@ export default class CharacterSheet extends DHBaseActorSheet { }; } } + + /** + * Prepare render context for the Journal part. + * @param {ApplicationRenderContext} context + * @param {ApplicationRenderOptions} options + * @returns {Promise} + * @protected + */ + async _prepareJournalContext(context, _options) { + const { system } = this.document; + const { TextEditor } = foundry.applications.ux; + + const paths = { + notes: 'journal.notes', + allies: 'journal.allies', + enemies: 'journal.enemies', + organizations: 'journal.organizations' + }; + + for (const [key, path] of Object.entries(paths)) { + const value = foundry.utils.getProperty(system, path); + context[key] = { + field: system.schema.getField(path), + value, + enriched: await TextEditor.implementation.enrichHTML(value, { + secrets: this.document.isOwner, + relativeTo: this.document + }) + }; + } + } /* -------------------------------------------- */ /* Context Menu */ diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index ddcc5bf5..ffd940c7 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -93,6 +93,12 @@ export default class DhCharacter extends BaseDataActor { faith: new fields.StringField({}) }) }), + journal: new fields.SchemaField({ + notes: new fields.HTMLField(), + allies: new fields.HTMLField(), + enemies: new fields.HTMLField(), + organizations: new fields.HTMLField() + }), attack: new ActionField({ initial: { name: 'DAGGERHEART.GENERAL.unarmedAttack', diff --git a/styles/less/sheets/actors/character/journal.less b/styles/less/sheets/actors/character/journal.less new file mode 100644 index 00000000..0579dc97 --- /dev/null +++ b/styles/less/sheets/actors/character/journal.less @@ -0,0 +1,38 @@ +@import '../../../utils/colors.less'; +@import '../../../utils/fonts.less'; + +.application.sheet.daggerheart.actor.dh-style.character { + .tab.journal { + .items-section { + display: flex; + flex-direction: column; + gap: 10px; + height: 100%; + overflow-y: auto; + mask-image: linear-gradient(0deg, transparent 0%, black 10%, black 98%, transparent 100%); + padding-bottom: 40px; + height: 100%; + + scrollbar-width: thin; + scrollbar-color: light-dark(@dark-blue, @golden) transparent; + + fieldset { + height: 100%; + } + .editor { + max-height: 100%; + overflow: auto; + } + .prosemirror { + min-height: 4rem; + } + .editor-content { + min-height: 4rem; + height: 100%; + overflow-y: auto; + word-break: break-word; + position: static; + } + } + } +} diff --git a/styles/less/sheets/index.less b/styles/less/sheets/index.less index a8f36a63..8022a568 100644 --- a/styles/less/sheets/index.less +++ b/styles/less/sheets/index.less @@ -6,6 +6,7 @@ @import './actors/adversary/sidebar.less'; @import './actors/character/biography.less'; +@import './actors/character/journal.less'; @import './actors/character/effects.less'; @import './actors/character/features.less'; @import './actors/character/header.less'; diff --git a/system.json b/system.json index 8e5a7610..8f356ed1 100644 --- a/system.json +++ b/system.json @@ -212,7 +212,14 @@ "documentTypes": { "Actor": { "character": { - "htmlFields": ["biography.background", "biography.connections"] + "htmlFields": [ + "biography.background", + "biography.connections", + "journal.notes", + "journal.allies", + "journal.enemies", + "journal.organizations" + ] }, "companion": {}, "adversary": { diff --git a/templates/sheets/actors/character/journal.hbs b/templates/sheets/actors/character/journal.hbs new file mode 100644 index 00000000..020e7fb2 --- /dev/null +++ b/templates/sheets/actors/character/journal.hbs @@ -0,0 +1,28 @@ +
+ + +
+
+ {{localize 'DAGGERHEART.ACTORS.Character.journal.notesTitle'}} + {{formInput notes.field value=notes.value enriched=notes.enriched toggled=true}} +
+
+ {{localize 'DAGGERHEART.ACTORS.Character.journal.alliesTitle'}} + {{formInput allies.field value=allies.value enriched=allies.enriched toggled=true}} +
+
+ {{localize 'DAGGERHEART.ACTORS.Character.journal.enemiesTitle'}} + {{formInput enemies.field value=enemies.value enriched=enemies.enriched toggled=true}} +
+
+ {{localize 'DAGGERHEART.ACTORS.Character.journal.organizationsTitle'}} + {{formInput organizations.field value=organizations.value enriched=organizations.enriched toggled=true}} +
+
+ + +
\ No newline at end of file