From e07d0204b232a8bf7911deb629dea1ede2bfbce2 Mon Sep 17 00:00:00 2001 From: Nikhil Nagarajan Date: Tue, 6 Jan 2026 14:04:48 -0500 Subject: [PATCH] drag drop implemented (css tbd) --- .../sheets-configs/action-base-config.mjs | 20 ++++++++- styles/less/global/global.less | 20 +++++++++ templates/actionTypes/summon.hbs | 44 +++++++++++++++++-- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index a2a08c39..c75bc585 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -36,7 +36,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) submitOnChange: true, closeOnSubmit: false }, - dragDrop: [{ dragSelector: null, dropSelector: '.summon-actor-drop'}] + dragDrop: [{ dragSelector: null, dropSelector: '.summon-entry', handlers: ['_onDrop'] }] }; static PARTS = { @@ -100,6 +100,20 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) async _prepareContext(_options) { const context = await super._prepareContext(_options, 'action'); context.source = this.action.toObject(true); + // Resolving summon entries so actions can read entry.name / entry.img / entry.uuid + if (Array.isArray(context.source.summon)) { + context.source.summon = await Promise.all(context.source.summon.map(async entry => { + if (!entry) return entry; + const uuid = entry.actorUUID ?? entry.uuid; + entry.uuid = uuid; + try { + const doc = await foundry.utils.fromUuid(uuid); + entry.name = entry.name ?? doc?.name; + entry.img = entry.img ?? (doc?.img ?? doc?.prototypeToken?.texture?.src ?? null); + } catch (_) {} + return entry; + })); + } context.openSection = this.openSection; context.tabs = this._getTabs(this.constructor.TABS); context.config = CONFIG.DH; @@ -243,6 +257,10 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) ui.notifications.warn(game.i18n.localize("DAGGERHEART.ACTIONS.TYPES.summon.invalidDrop")); return; } + //Add to summon array + const actionData = this.action.toObject(); // Get current action data + actionData.summon.push({ actorUUID: data.uuid, count: 1 });// Add new summon entry + await this.constructor.updateForm.bind(this)(null, null, { object: foundry.utils.flattenObject(actionData) }); // Update the form with new data } } diff --git a/styles/less/global/global.less b/styles/less/global/global.less index 6cc63c2a..8abaddee 100644 --- a/styles/less/global/global.less +++ b/styles/less/global/global.less @@ -9,6 +9,26 @@ border-radius: 3px; color: light-dark(@dark-blue-50, @beige-50); font-family: @font-body; + &.summon-actor-drop { + height: fit-content; + min-height: inherit; + display: flex; + justify-content: center; + .actors-list.summon-entry .actor-summon-item .actor-summon-line { + display: flex; + justify-content: flex-end; + align-items: center; + .image{ + max-width: 10%; + } + .h4{ + width: --webkit-fill-available; + } + .controls.effect-control{ + padding:3px; + } + } + } } .daggerheart.dh-style { diff --git a/templates/actionTypes/summon.hbs b/templates/actionTypes/summon.hbs index f32486be..278037fb 100644 --- a/templates/actionTypes/summon.hbs +++ b/templates/actionTypes/summon.hbs @@ -1,13 +1,51 @@
{{localize "DAGGERHEART.ACTIONS.TYPES.summon.name"}} -

{{localize "DAGGERHEART.ACTIONS.Settings.summon.hint"}}

- {{#each source as |entry index|}} + {{!-- {{#each source as |entry index|}}
{{formField ../fields.actorUUID label="DAGGERHEART.ACTIONS.Settings.summon.actor" value=entry.actorUUID name=(concat "summon." index ".actorUUID") localize=true classes="summon-actor-drop"}} {{formField ../fields.count label="DAGGERHEART.ACTIONS.Settings.summon.count" value=entry.count name=(concat "summon." index ".count") localize=true}}
- {{/each}} + {{/each}} --}} + +
+
+ + {{#each source as |entry index|}} +
    +
    + +

    + {{entry.name}} +

    + {{formField ../fields.count label="DAGGERHEART.ACTIONS.Settings.summon.count" value=entry.count name=(concat "summon." index ".count") localize=true}} + +
    +
+ {{/each}} + {{#unless source.length}} + {{localize "DAGGERHEART.GENERAL.dropActorsHere"}} + {{/unless}} +
+
\ No newline at end of file