mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
drag drop implemented (css tbd)
This commit is contained in:
parent
ad1dee313f
commit
e07d0204b2
3 changed files with 80 additions and 4 deletions
|
|
@ -36,7 +36,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
submitOnChange: true,
|
submitOnChange: true,
|
||||||
closeOnSubmit: false
|
closeOnSubmit: false
|
||||||
},
|
},
|
||||||
dragDrop: [{ dragSelector: null, dropSelector: '.summon-actor-drop'}]
|
dragDrop: [{ dragSelector: null, dropSelector: '.summon-entry', handlers: ['_onDrop'] }]
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
|
|
@ -100,6 +100,20 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
|
||||||
async _prepareContext(_options) {
|
async _prepareContext(_options) {
|
||||||
const context = await super._prepareContext(_options, 'action');
|
const context = await super._prepareContext(_options, 'action');
|
||||||
context.source = this.action.toObject(true);
|
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.openSection = this.openSection;
|
||||||
context.tabs = this._getTabs(this.constructor.TABS);
|
context.tabs = this._getTabs(this.constructor.TABS);
|
||||||
context.config = CONFIG.DH;
|
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"));
|
ui.notifications.warn(game.i18n.localize("DAGGERHEART.ACTIONS.TYPES.summon.invalidDrop"));
|
||||||
return;
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,26 @@
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
color: light-dark(@dark-blue-50, @beige-50);
|
color: light-dark(@dark-blue-50, @beige-50);
|
||||||
font-family: @font-body;
|
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 {
|
.daggerheart.dh-style {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,51 @@
|
||||||
<fieldset class="one-column" data-key="summon">
|
<fieldset class="one-column" data-key="summon">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.ACTIONS.TYPES.summon.name"}}
|
{{localize "DAGGERHEART.ACTIONS.TYPES.summon.name"}}
|
||||||
<a><i class="fa-solid fa-plus icon-button" data-action="addElement"></i></a>
|
|
||||||
</legend>
|
</legend>
|
||||||
<p class="hint">{{localize "DAGGERHEART.ACTIONS.Settings.summon.hint"}}</p>
|
<p class="hint">{{localize "DAGGERHEART.ACTIONS.Settings.summon.hint"}}</p>
|
||||||
{{#each source as |entry index|}}
|
{{!-- {{#each source as |entry index|}}
|
||||||
<div class="nest-inputs summon-entry">
|
<div class="nest-inputs summon-entry">
|
||||||
{{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.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}}
|
{{formField ../fields.count label="DAGGERHEART.ACTIONS.Settings.summon.count" value=entry.count name=(concat "summon." index ".count") localize=true}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}} --}}
|
||||||
|
|
||||||
|
<div class="drag-area summon-actor-drop">
|
||||||
|
<div class="actors-list summon-entry">
|
||||||
|
|
||||||
|
{{#each source as |entry index|}}
|
||||||
|
<ul class="actor-summon-item">
|
||||||
|
<div class="actor-summon-line">
|
||||||
|
<img class="image" src="{{entry.img}}" />
|
||||||
|
<h4 class="h4">
|
||||||
|
{{entry.name}}
|
||||||
|
</h4>
|
||||||
|
{{formField ../fields.count label="DAGGERHEART.ACTIONS.Settings.summon.count" value=entry.count name=(concat "summon." index ".count") localize=true}}
|
||||||
|
<div class="controls">
|
||||||
|
<a
|
||||||
|
class='effect-control'
|
||||||
|
data-action='editDoc'
|
||||||
|
data-item-uuid="{{entry.uuid}}"
|
||||||
|
data-tooltip='{{localize "DAGGERHEART.UI.Tooltip.openItemWorld"}}'
|
||||||
|
>
|
||||||
|
<i class="fa-solid fa-globe"></i>
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class='effect-control'
|
||||||
|
data-action='removeElement'
|
||||||
|
data-target="summon"
|
||||||
|
data-uuid="{{entry.uuid}}"
|
||||||
|
data-tooltip='{{localize "CONTROLS.CommonDelete"}}'
|
||||||
|
>
|
||||||
|
<i class='fas fa-trash'></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
{{/each}}
|
||||||
|
{{#unless source.length}}
|
||||||
|
<span>{{localize "DAGGERHEART.GENERAL.dropActorsHere"}}</span>
|
||||||
|
{{/unless}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue