Added Journal tab on character sheet with input fields "notes", "allies", "enemies"

This commit is contained in:
Zakkon 2025-09-29 14:20:45 +02:00
parent fd92540792
commit 0b6b711800
7 changed files with 127 additions and 2 deletions

View file

@ -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",

View file

@ -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<void>}
* @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 */

View file

@ -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',

View file

@ -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;
}
}
}
}

View file

@ -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';

View file

@ -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": {

View file

@ -0,0 +1,28 @@
<section
class='tab {{tabs.journal.cssClass}} {{tabs.journal.id}}'
data-tab='{{tabs.journal.id}}'
data-group='{{tabs.journal.group}}'
>
<div class="items-section">
<fieldset>
<legend>{{localize 'DAGGERHEART.ACTORS.Character.journal.notesTitle'}}</legend>
{{formInput notes.field value=notes.value enriched=notes.enriched toggled=true}}
</fieldset>
<fieldset>
<legend>{{localize 'DAGGERHEART.ACTORS.Character.journal.alliesTitle'}}</legend>
{{formInput allies.field value=allies.value enriched=allies.enriched toggled=true}}
</fieldset>
<fieldset>
<legend>{{localize 'DAGGERHEART.ACTORS.Character.journal.enemiesTitle'}}</legend>
{{formInput enemies.field value=enemies.value enriched=enemies.enriched toggled=true}}
</fieldset>
<fieldset>
<legend>{{localize 'DAGGERHEART.ACTORS.Character.journal.organizationsTitle'}}</legend>
{{formInput organizations.field value=organizations.value enriched=organizations.enriched toggled=true}}
</fieldset>
</div>
</section>