mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
.
This commit is contained in:
parent
ae211cda30
commit
47b9be0f01
4 changed files with 37 additions and 5 deletions
|
|
@ -2827,7 +2827,8 @@
|
|||
"deleteItem": "Delete Item",
|
||||
"immune": "Immune",
|
||||
"middleClick": "[Middle Click] Keep tooltip view",
|
||||
"tokenSize": "The token size used on the canvas"
|
||||
"tokenSize": "The token size used on the canvas",
|
||||
"previewTokenHelp": "Left-click to place, right-click to cancel"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,12 @@
|
|||
export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
||||
/** @inheritdoc */
|
||||
async _draw(options) {
|
||||
await super._draw(options);
|
||||
|
||||
if (this.document.flags.daggerheart?.createPlacement)
|
||||
this.previewHelp ||= this.addChild(this.#drawPreviewHelp());
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
async _drawEffects() {
|
||||
this.effects.renderable = false;
|
||||
|
|
@ -69,4 +77,25 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
bar.position.set(0, posY);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a helptext for previews as a text object
|
||||
* @returns {PreciseText} The Text object for the preview helper
|
||||
*/
|
||||
#drawPreviewHelp() {
|
||||
const { uiScale } = canvas.dimensions;
|
||||
|
||||
const textStyle = CONFIG.canvasTextStyle.clone();
|
||||
textStyle.fontSize = 18;
|
||||
textStyle.wordWrapWidth = this.w * 2.5;
|
||||
textStyle.fontStyle = 'italic';
|
||||
|
||||
const helpText = new PreciseText(
|
||||
`(${game.i18n.localize('DAGGERHEART.UI.Tooltip.previewTokenHelp')})`,
|
||||
textStyle
|
||||
);
|
||||
helpText.anchor.set(helpText.width / 900, 1);
|
||||
helpText.scale.set(uiScale, uiScale);
|
||||
return helpText;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export default class DHSummonField extends fields.ArrayField {
|
|||
return;
|
||||
}
|
||||
|
||||
this.actor.sheet?.minimize();
|
||||
const summonData = [];
|
||||
for (const summon of this.summon) {
|
||||
/* Possibly check for any available instances in the world with prepared images */
|
||||
|
|
@ -53,12 +54,12 @@ export default class DHSummonField extends fields.ArrayField {
|
|||
const result = await CONFIG.ux.TokenManager.createPreviewAsync(summon.actor, {
|
||||
name: `${summon.actor.prototypeToken.name}${summon.count > 1 ? ` (${summon.count}x)` : ''}`
|
||||
});
|
||||
if (!result) return;
|
||||
if (!result) return this.actor.sheet?.maximize();
|
||||
|
||||
summon.count--;
|
||||
if (summon.count === 0) {
|
||||
summonIndex++;
|
||||
if (summonIndex === summonData.length) return;
|
||||
if (summonIndex === summonData.length) return this.actor.sheet?.maximize();
|
||||
}
|
||||
|
||||
handleSummon(summonIndex);
|
||||
|
|
|
|||
|
|
@ -39,10 +39,11 @@ export default class DhTokenManager {
|
|||
canvas.app.view.addEventListener('contextmenu', this.#activePreview.events.contextmenu);
|
||||
}
|
||||
|
||||
async createPreviewAsync(actor, tokenData) {
|
||||
/* Currently intended for using as a preview of where to create a token. (note the flag) */
|
||||
async createPreviewAsync(actor, tokenData = {}) {
|
||||
return new Promise(resolve => {
|
||||
this.#resolve = resolve;
|
||||
this.createPreview(actor, tokenData);
|
||||
this.createPreview(actor, { ...tokenData, flags: { daggerheart: { createPlacement: true } } });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue