mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Dialog created. Tokens not dragged(tbd).
This commit is contained in:
parent
f5e00dedb2
commit
506a17bd03
6 changed files with 66 additions and 77 deletions
|
|
@ -610,6 +610,10 @@
|
||||||
"title": "{name} Resource",
|
"title": "{name} Resource",
|
||||||
"rerollDice": "Reroll Dice"
|
"rerollDice": "Reroll Dice"
|
||||||
},
|
},
|
||||||
|
"Summon": {
|
||||||
|
"title": "Summon Tokens",
|
||||||
|
"hint": "Drag tokens from the list below into the scene to summon them."
|
||||||
|
},
|
||||||
"TagTeamSelect": {
|
"TagTeamSelect": {
|
||||||
"title": "Tag Team Roll",
|
"title": "Tag Team Roll",
|
||||||
"leaderTitle": "Initiating Character",
|
"leaderTitle": "Initiating Character",
|
||||||
|
|
|
||||||
|
|
@ -5,44 +5,46 @@ export default class DHSummonDialog extends HandlebarsApplicationMixin(Applicati
|
||||||
super(summonData);
|
super(summonData);
|
||||||
// Initialize summons and index
|
// Initialize summons and index
|
||||||
this.summons = summonData.summons || [];
|
this.summons = summonData.summons || [];
|
||||||
this.index = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_title() {
|
static PARTS = {
|
||||||
return game.i18n.localize("DAGGERHEART.DIALOGS.SUMMON.title");
|
main: { template: 'systems/daggerheart/templates/dialogs/summon/summonDialog.hbs' }
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
static DEFAULT_OPTIONS= {
|
static DEFAULT_OPTIONS= {
|
||||||
...super.DEFAULT_OPTIONS,
|
tag: 'form',
|
||||||
template: 'systems/daggerheart/module/applications/dialogs/summon/summonDialog.hbs',
|
window: {
|
||||||
width: 400,
|
title: "DAGGERHEART.APPLICATIONS.Summon.title",
|
||||||
height: 'auto',
|
resizable: false
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
width: 400,
|
||||||
|
height: 'auto'
|
||||||
|
},
|
||||||
classes: ['daggerheart', 'dialog', 'summon-dialog'],
|
classes: ['daggerheart', 'dialog', 'summon-dialog'],
|
||||||
dragDrop: [{ dragSelector: '.summon-token', dropSelector: null, handler:'onDrop'}]
|
dragDrop: [{dragSelector: '.summon-token'}],
|
||||||
};
|
};
|
||||||
|
|
||||||
async _prepareContext() {
|
async _prepareContext() {
|
||||||
const context = await super._prepareContext();
|
const context = await super._prepareContext();
|
||||||
context.summons=this.summons;
|
context.summons=await Promise.all(this.summons.map(async(entry)=>{
|
||||||
context.index=this.index;
|
const actor = await fromUuid(entry.actorUUID);
|
||||||
|
return {
|
||||||
|
...entry,
|
||||||
|
name: actor?.name || game.i18n.localize("DAGGERHEART.GENERAL.Unknown"),
|
||||||
|
img: actor?.img || 'icons/svg/mystery-man.svg',
|
||||||
|
};
|
||||||
|
}));
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(options={}) {
|
_onDragStart(event) {
|
||||||
const data = super.getData(options);
|
const uuid = event.currentTarget.dataset.uuid;
|
||||||
data.summons=this.summons;
|
if(!uuid) return;
|
||||||
data.index=this.index;
|
const dragData = { type: 'Actor', uuid: uuid };
|
||||||
return data;
|
event.dataTransfer.effectAllowed = 'all';
|
||||||
}
|
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||||
async prepareContext() {
|
|
||||||
const context = await super.prepareContext();
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onDrop(event) {//add to canvas
|
|
||||||
event.preventDefault();
|
|
||||||
const tokenData = JSON.parse(event.dataTransfer.getData('text/plain'));
|
|
||||||
const position = { x: event.clientX, y: event.clientY };
|
|
||||||
await canvas.scene.createEmbeddedDocuments("Token", [tokenData], { temporary: false, x: position.x, y: position.y });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,40 +2,4 @@ import DHBaseAction from './baseAction.mjs';
|
||||||
|
|
||||||
export default class DHSummonAction extends DHBaseAction {
|
export default class DHSummonAction extends DHBaseAction {
|
||||||
static extraSchemas = [...super.extraSchemas, 'summon'];
|
static extraSchemas = [...super.extraSchemas, 'summon'];
|
||||||
|
|
||||||
// get defaultValues() {
|
|
||||||
// return {
|
|
||||||
// summon: []
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async trigger(event, ...args) {
|
|
||||||
// if (!this.canSummon || !canvas.scene){
|
|
||||||
// ui.notifications.warn(game.i18n.localize("DAGGERHEART.ACTIONS.TYPES.summon.error"));
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// await this._performAction();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// get canSummon() {
|
|
||||||
// return game.user.can('TOKEN_CREATE');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async _performAction(event, ...args) {
|
|
||||||
// const validSummons = this.summon.filter(entry => entry.actorUUID);
|
|
||||||
// if (validSummons.length === 0) {
|
|
||||||
// ui.notifications.warn("No actors configured for this Summon action.");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// // FOR NOW: Just log the data to prove the schema working or not
|
|
||||||
// console.group("Summon Action Triggered");
|
|
||||||
|
|
||||||
// for (const entry of validSummons) {
|
|
||||||
// const actor = await fromUuid(entry.actorUUID);
|
|
||||||
// console.log(`- Ready to summon ${entry.count}x [${actor?.name || "Unknown Actor"}]`);
|
|
||||||
// }
|
|
||||||
// console.groupEnd();
|
|
||||||
|
|
||||||
// //Todo: Open Summon Dialog
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const fields = foundry.data.fields;
|
const fields = foundry.data.fields;
|
||||||
|
import DHSummonDialog from '../../../applications/dialogs/summonDialog.mjs';
|
||||||
|
|
||||||
export default class DHSummonField extends fields.ArrayField {
|
export default class DHSummonField extends fields.ArrayField {
|
||||||
/**
|
/**
|
||||||
|
|
@ -22,7 +23,27 @@ export default class DHSummonField extends fields.ArrayField {
|
||||||
super(summonFields, options, context);
|
super(summonFields, options, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async execute(config) {
|
static async execute() {
|
||||||
console.log('something');
|
if(!canvas.scene){
|
||||||
|
ui.notifications.warn(game.i18n.localize("DAGGERHEART.ACTIONS.TYPES.summon.error"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const validSummons = this.summon.filter(entry => entry.actorUUID);
|
||||||
|
if (validSummons.length === 0) {
|
||||||
|
console.log("No actors configured for this Summon action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// FOR NOW: Just log the data to prove the schema working or not
|
||||||
|
console.group("Summon Action Triggered");
|
||||||
|
for (const entry of validSummons) {
|
||||||
|
const actor = await fromUuid(entry.actorUUID);
|
||||||
|
console.log(`- Ready to summon ${entry.count}x [${actor?.name || "Unknown Actor"}]`);
|
||||||
|
}
|
||||||
|
console.groupEnd();
|
||||||
|
//Open Summon Dialog
|
||||||
|
const summonData = { summons: validSummons };
|
||||||
|
console.log(summonData);
|
||||||
|
const dialog = new DHSummonDialog(summonData);
|
||||||
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,6 @@
|
||||||
{{localize "DAGGERHEART.ACTIONS.TYPES.summon.name"}}
|
{{localize "DAGGERHEART.ACTIONS.TYPES.summon.name"}}
|
||||||
</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|}}
|
|
||||||
<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.count label="DAGGERHEART.ACTIONS.Settings.summon.count" value=entry.count name=(concat "summon." index ".count") localize=true}}
|
|
||||||
</div>
|
|
||||||
{{/each}} --}}
|
|
||||||
|
|
||||||
<div class="drag-area summon-actor-drop">
|
<div class="drag-area summon-actor-drop">
|
||||||
<div class="actors-list summon-entry">
|
<div class="actors-list summon-entry">
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,28 @@
|
||||||
<fieldset class="one-column" data-key="summon">
|
<fieldset class="one-column" data-key="summon">
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.DIALOGS.Summon.title"}}
|
{{localize "DAGGERHEART.APPLICATIONS.Summon.title"}}
|
||||||
</legend>
|
</legend>
|
||||||
<p class="hint">{{localize "DAGGERHEART.DIALOGS.Summon.hint"}}</p>
|
<p class="hint">{{localize "DAGGERHEART.APPLICATIONS.Summon.hint"}}</p>
|
||||||
|
|
||||||
<div class="summons-list">
|
<div class="summons-list">
|
||||||
{{#each summons as |entry index|}}
|
|
||||||
<ul class="actor-summon-item">
|
<ul class="actor-summon-item">
|
||||||
|
{{#each summons as |entry index|}}
|
||||||
|
<li class="summon-token" draggable="true" data-uuid="{{entry.actorUUID}}">
|
||||||
<div class="actor-summon-line">
|
<div class="actor-summon-line">
|
||||||
<img class="image" src="{{entry.img}}" />
|
<img class="image" src="{{entry.img}}" />
|
||||||
{{#if (gte entry.count 1)}}
|
{{#if (gte entry.count 1)}}
|
||||||
<h4 class="h4">
|
<h4 class="h4">
|
||||||
{{entry.name}} (x{{entry.count}})
|
{{entry.name}}
|
||||||
</h4>
|
</h4>
|
||||||
|
<span>Count: {{entry.count}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<h4 class="h4 disabled">
|
<h4 class="h4 disabled">
|
||||||
{{entry.name}}
|
{{entry.name}}
|
||||||
</h4>
|
</h4>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue