diff --git a/daggerheart.mjs b/daggerheart.mjs index 7e77fbb3..61570b22 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -72,6 +72,16 @@ Hooks.once('init', () => { Actors.registerSheet(SYSTEM.id, applications.DhpAdversarySheet, { types: ['adversary'], makeDefault: true }); Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true }); + CONFIG.ActiveEffect.documentClass = documents.DhActiveEffect; + DocumentSheetConfig.unregisterSheet( + CONFIG.ActiveEffect.documentClass, + 'core', + foundry.applications.sheets.ActiveEffectConfig + ); + DocumentSheetConfig.registerSheet(CONFIG.ActiveEffect.documentClass, SYSTEM.id, applications.DhActiveEffectConfig, { + makeDefault: true + }); + CONFIG.Combat.dataModels = { base: models.DhCombat }; diff --git a/module/applications/_module.mjs b/module/applications/_module.mjs index 5c031db0..7eeeab61 100644 --- a/module/applications/_module.mjs +++ b/module/applications/_module.mjs @@ -12,3 +12,4 @@ export { default as DhpWeapon } from './sheets/items/weapon.mjs'; export { default as DhpArmor } from './sheets/items/armor.mjs'; export { default as DhpChatMessage } from './chatMessage.mjs'; export { default as DhpEnvironment } from './sheets/environment.mjs'; +export { default as DhActiveEffectConfig } from './sheets/activeEffectConfig.mjs'; diff --git a/module/applications/sheets/activeEffectConfig.mjs b/module/applications/sheets/activeEffectConfig.mjs new file mode 100644 index 00000000..585086a1 --- /dev/null +++ b/module/applications/sheets/activeEffectConfig.mjs @@ -0,0 +1,62 @@ +export default class DhActiveEffectConfig extends ActiveEffectConfig { + static DEFAULT_OPTIONS = { + classes: ['daggerheart', 'sheet', 'dh-style'] + }; + + static PARTS = { + header: { template: 'systems/daggerheart/templates/sheets/activeEffect/header.hbs' }, + tabs: { template: 'templates/generic/tab-navigation.hbs' }, + details: { template: 'systems/daggerheart/templates/sheets/activeEffect/details.hbs', scrollable: [''] }, + duration: { template: 'systems/daggerheart/templates/sheets/activeEffect/duration.hbs' }, + changes: { + template: 'systems/daggerheart/templates/sheets/activeEffect/changes.hbs', + scrollable: ['ol[data-changes]'] + }, + footer: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-form-footer.hbs' } + }; + + static TABS = { + sheet: { + tabs: [ + { id: 'details', icon: 'fa-solid fa-book' }, + { id: 'duration', icon: 'fa-solid fa-clock' }, + { id: 'changes', icon: 'fa-solid fa-gears' } + ], + initial: 'details', + labelPrefix: 'EFFECT.TABS' + } + }; + + async _preparePartContext(partId, context) { + const partContext = await super._preparePartContext(partId, context); + switch (partId) { + case 'changes': + const fieldPaths = []; + const validFieldPath = fieldPath => this.validFieldPath(fieldPath, this.#unapplicablePaths); + context.document.parent.system.schema.apply(function () { + if (!(this instanceof foundry.data.fields.SchemaField)) { + if (validFieldPath(this.fieldPath)) { + fieldPaths.push(this.fieldPath); + } + } + }); + + context.fieldPaths = fieldPaths; + + break; + } + + return partContext; + } + + #unapplicablePaths = ['story', 'pronouns', 'description']; + validFieldPath(fieldPath, unapplicablePaths) { + const splitPath = fieldPath.split('.'); + if (splitPath.length > 1 && unapplicablePaths.includes(splitPath[1])) return false; + + /* The current value of a resource should not be modified */ + if (new RegExp(/resources.*\.value/).exec(fieldPath)) return false; + + return true; + } +} diff --git a/module/documents/_module.mjs b/module/documents/_module.mjs index f374372d..03237ee5 100644 --- a/module/documents/_module.mjs +++ b/module/documents/_module.mjs @@ -1,3 +1,4 @@ export { default as DhpActor } from './actor.mjs'; export { default as DhpItem } from './item.mjs'; export { default as DhpCombat } from './combat.mjs'; +export { default as DhActiveEffect } from './activeEffect.mjs'; diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs new file mode 100644 index 00000000..d6671501 --- /dev/null +++ b/module/documents/activeEffect.mjs @@ -0,0 +1,14 @@ +export default class DhActiveEffect extends ActiveEffect { + async _preCreate(data, options, user) { + const update = {}; + if (!data.img) { + update.img = 'icons/magic/life/heart-cross-blue.webp'; + } + + if (Object.keys(update).length > 0) { + await this.updateSource(update); + } + + await super._preCreate(data, options, user); + } +} diff --git a/styles/daggerheart.css b/styles/daggerheart.css index 63c4266f..2a18d877 100755 --- a/styles/daggerheart.css +++ b/styles/daggerheart.css @@ -2593,6 +2593,9 @@ div.daggerheart.views.multiclass { width: 40px; background: white; } +.application.sheet.daggerheart.dh-style.active-effect-config label { + white-space: nowrap; +} .daggerheart.sheet .title-container { display: flex; gap: 8px; @@ -3385,6 +3388,14 @@ div.daggerheart.views.multiclass { font-weight: bold; font-size: smaller; } +.application.sheet.dh-style .two-columns { + display: grid; + grid-template-columns: 1fr 2fr; + gap: 10px; +} +.application.sheet.dh-style .two-columns.even { + grid-template-columns: 1fr 1fr; +} .application.sheet.dh-style line-div { display: block; height: 1px; @@ -3592,6 +3603,16 @@ div.daggerheart.views.multiclass { text-shadow: none; font-family: 'Montserrat', sans-serif; } +.sheet.daggerheart.dh-style .tab-form-footer { + display: flex; + padding: 0 10px; + position: relative; + bottom: -32px; +} +.sheet.daggerheart.dh-style .tab-form-footer button { + flex: 1; + border-width: 2px; +} .sheet.daggerheart.dh-style .tab.actions .actions-list { display: flex; flex-direction: column; diff --git a/styles/daggerheart.less b/styles/daggerheart.less index 6869e316..09d58666 100755 --- a/styles/daggerheart.less +++ b/styles/daggerheart.less @@ -23,6 +23,7 @@ @import './less/global/sheet.less'; @import './less/global/elements.less'; @import './less/global/tab-navigation.less'; +@import './less/global/tab-form-footer.less'; @import './less/global/tab-actions.less'; @import './less/global/item-header.less'; @import './less/global/feature-section.less'; diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 077d2226..e1b7f88a 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -143,6 +143,16 @@ } } + .two-columns { + display: grid; + grid-template-columns: 1fr 2fr; + gap: 10px; + + &.even { + grid-template-columns: 1fr 1fr; + } + } + line-div { display: block; height: 1px; diff --git a/styles/less/global/tab-form-footer.less b/styles/less/global/tab-form-footer.less new file mode 100644 index 00000000..3607d463 --- /dev/null +++ b/styles/less/global/tab-form-footer.less @@ -0,0 +1,13 @@ +.sheet.daggerheart.dh-style { + .tab-form-footer { + display: flex; + padding: 0 10px; + position: relative; + bottom: -32px; + + button { + flex: 1; + border-width: 2px; + } + } +} diff --git a/styles/sheets/activeEffect.less b/styles/sheets/activeEffect.less new file mode 100644 index 00000000..86a29244 --- /dev/null +++ b/styles/sheets/activeEffect.less @@ -0,0 +1,5 @@ +.application.sheet.daggerheart.dh-style.active-effect-config { + label { + white-space: nowrap; + } +} diff --git a/styles/sheets/sheets.less b/styles/sheets/sheets.less index 19c76980..ba784225 100644 --- a/styles/sheets/sheets.less +++ b/styles/sheets/sheets.less @@ -1,6 +1,7 @@ @import './heritage.less'; @import './class.less'; @import './adversary.less'; +@import './activeEffect.less'; .daggerheart.sheet { .title-container { diff --git a/templates/sheets/activeEffect/changes.hbs b/templates/sheets/activeEffect/changes.hbs new file mode 100644 index 00000000..c1047206 --- /dev/null +++ b/templates/sheets/activeEffect/changes.hbs @@ -0,0 +1,36 @@ +
+
+
{{localize "EFFECT.ChangeKey"}}
+
{{localize "EFFECT.ChangeMode"}}
+
{{localize "EFFECT.ChangeValue"}}
+
{{localize "EFFECT.ChangePriority"}}
+
+
+
    + {{#each source.changes as |change i|}} + {{#with ../fields.changes.element.fields as |changeFields|}} +
  1. +
    + + + {{#each @root.fieldPaths}} + + {{/each}} + +
    +
    + {{formInput changeFields.mode name=(concat "changes." i ".mode") value=change.mode choices=@root.modes}} +
    +
    + {{formInput changeFields.value name=(concat "changes." i ".value") value=change.value}} +
    +
    + {{formInput changeFields.priority name=(concat "changes." i ".priority") value=change.priority + placeholder=(lookup ../../priorities change.mode)}} +
    +
    +
  2. + {{/with}} + {{/each}} +
+
\ No newline at end of file diff --git a/templates/sheets/activeEffect/details.hbs b/templates/sheets/activeEffect/details.hbs new file mode 100644 index 00000000..8ff72b98 --- /dev/null +++ b/templates/sheets/activeEffect/details.hbs @@ -0,0 +1,14 @@ +
+ {{formGroup fields.tint value=source.tint rootId=rootId placeholder="#ffffff"}} + {{formGroup fields.description value=source.description rootId=rootId}} + {{formGroup fields.disabled value=source.disabled rootId=rootId}} + + {{#if isActorEffect}} + {{formGroup fields.origin value=source.origin rootId=rootId disabled=true}} + {{/if}} + {{#if isItemEffect}} + {{formGroup fields.transfer value=source.transfer rootId=rootId label=legacyTransfer.label hint=legacyTransfer.hint}} + {{/if}} + + {{formGroup fields.statuses value=source.statuses options=statuses rootId=rootId classes="statuses"}} +
diff --git a/templates/sheets/activeEffect/duration.hbs b/templates/sheets/activeEffect/duration.hbs new file mode 100644 index 00000000..824439e6 --- /dev/null +++ b/templates/sheets/activeEffect/duration.hbs @@ -0,0 +1,31 @@ +
+
+ {{formGroup fields.duration.fields.seconds value=source.duration.seconds rootId=rootId}} + {{formGroup fields.duration.fields.startTime value=source.duration.startTime rootId=rootId}} +
+ +
+
+ +
+ + {{formInput fields.duration.fields.rounds value=source.duration.rounds + id=(concat rootId "-duration.rounds")}} + + {{formInput fields.duration.fields.turns value=source.duration.turns + id=(concat rootId "-duration.turns")}} +
+
+
+ +
+ + {{formInput fields.duration.fields.startRound value=source.duration.startRound + id=(concat rootId "-duration.startRound")}} + + {{formInput fields.duration.fields.startTurn value=source.duration.startTurn + id=(concat rootId "-duration.startTurn")}} +
+
+
+
diff --git a/templates/sheets/activeEffect/header.hbs b/templates/sheets/activeEffect/header.hbs new file mode 100644 index 00000000..ce64c0b0 --- /dev/null +++ b/templates/sheets/activeEffect/header.hbs @@ -0,0 +1,7 @@ +
+ {{localize +
+

+
+
\ No newline at end of file diff --git a/templates/sheets/global/tabs/tab-form-footer.hbs b/templates/sheets/global/tabs/tab-form-footer.hbs new file mode 100644 index 00000000..96babf82 --- /dev/null +++ b/templates/sheets/global/tabs/tab-form-footer.hbs @@ -0,0 +1,3 @@ + \ No newline at end of file