Minor fixes

This commit is contained in:
WBHarry 2026-03-07 15:05:17 +01:00
parent 800eefbddf
commit 0adf1c5463
5 changed files with 51 additions and 21 deletions

View file

@ -78,6 +78,8 @@
"transform": { "transform": {
"name": "Transform", "name": "Transform",
"tooltip": "Transform one actor into another", "tooltip": "Transform one actor into another",
"noTransformActor": "There is no assigned actor to transform into",
"transformActorMissing": "The assigned actor to transform into does not exist. It was probably deleted or moved in/out of a compendium",
"canvasError": "There is no active scene.", "canvasError": "There is no active scene.",
"prototypeError": "You can only use a transform action from a Token" "prototypeError": "You can only use a transform action from a Token"
} }
@ -138,6 +140,7 @@
}, },
"transform": { "transform": {
"dropTransformHere": "Drop Transform Here", "dropTransformHere": "Drop Transform Here",
"actorIsMissing": "The linked actor is missing. You should delete this link.",
"clearHitPoints": "Clear Hitpoints", "clearHitPoints": "Clear Hitpoints",
"clearStress": "Clear Stress" "clearStress": "Clear Stress"
} }

View file

@ -139,9 +139,14 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
} }
if (context.source.transform) { if (context.source.transform) {
const actor = await foundry.utils.fromUuid(context.source.transform.actorUUID);
context.transform = { context.transform = {
...context.source.transform, ...context.source.transform,
actor: await foundry.utils.fromUuid(context.source.transform.actorUUID) actor:
actor ??
(context.source.transform.actorUUID && !actor
? { error: game.i18n.localize('DAGGERHEART.ACTIONS.Settings.transform.actorIsMissing') }
: null)
}; };
} }

View file

@ -21,6 +21,17 @@ export default class DHSummonField extends fields.SchemaField {
} }
static async execute() { static async execute() {
if (!this.transform.actorUUID) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.noTransformActor'));
return false;
}
const baseActor = await foundry.utils.fromUuid(this.transform.actorUUID);
if (!baseActor) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.transformActorMissing'));
return false;
}
if (!canvas.scene) { if (!canvas.scene) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.canvasError')); ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.transform.canvasError'));
return false; return false;
@ -31,7 +42,7 @@ export default class DHSummonField extends fields.SchemaField {
return false; return false;
} }
const actor = await DHSummonField.getWorldActor(await foundry.utils.fromUuid(this.transform.actorUUID)); const actor = await DHSummonField.getWorldActor(baseActor);
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes; const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
const tokenSize = actor?.system.metadata.usesSize ? tokenSizes[actor.system.size] : actor.prototypeToken.width; const tokenSize = actor?.system.metadata.usesSize ? tokenSizes[actor.system.size] : actor.prototypeToken.width;

View file

@ -14,11 +14,11 @@
.transform-resources { .transform-resources {
display: flex; display: flex;
justify-content: space-between; flex-direction: column;
.transform-resource { .transform-resource {
display: flex; display: flex;
flex-direction: column; align-items: center;
gap: 2px; gap: 2px;
.resource-title { .resource-title {
@ -60,6 +60,10 @@
gap: 5px; gap: 5px;
} }
} }
.actor-drop-hint {
flex: none;
}
} }
.drop-dragger { .drop-dragger {

View file

@ -6,15 +6,20 @@
<div class="transform-container"> <div class="transform-container">
{{#if transform.actor}} {{#if transform.actor}}
<div class="actor-drop-line"> <div class="actor-drop-line">
{{#if transform.actor.error}}
<div class="hint actor-drop-hint">{{transform.actor.error}}</div>
{{else}}
<div class="actor-drop-name"> <div class="actor-drop-name">
<img class="image" src="{{transform.actor.img}}" /> <img class="image" src="{{transform.actor.img}}" />
<h4 class="h4"> <h4 class="h4">
{{transform.actor.name}} {{transform.actor.name}}
</h4> </h4>
</div> </div>
{{/if}}
<div class="actor-drop-controls transform"> <div class="actor-drop-controls transform">
<div class="controls"> <div class="controls">
{{#unless transform.actor.error}}
<a <a
class='effect-control' class='effect-control'
data-action='editDoc' data-action='editDoc'
@ -23,6 +28,7 @@
> >
<i class="fa-solid fa-globe"></i> <i class="fa-solid fa-globe"></i>
</a> </a>
{{/unless}}
<a <a
class='effect-control' class='effect-control'
data-action='removeTransformActor' data-action='removeTransformActor'
@ -33,6 +39,7 @@
</div> </div>
</div> </div>
</div> </div>
<line-div></line-div>
{{/if}} {{/if}}
{{#unless transform.actor}} {{#unless transform.actor}}
@ -43,12 +50,12 @@
<div class="transform-resources"> <div class="transform-resources">
<div class="transform-resource"> <div class="transform-resource">
<span class="resource-title">{{localize "DAGGERHEART.ACTIONS.Settings.transform.clearHitPoints"}}</span>
<input type="checkbox" data-resource="hitPoints" {{checked transform.resourceRefresh.hitPoints}}/> <input type="checkbox" data-resource="hitPoints" {{checked transform.resourceRefresh.hitPoints}}/>
<span class="resource-title">{{localize "DAGGERHEART.ACTIONS.Settings.transform.clearHitPoints"}}</span>
</div> </div>
<div class="transform-resource"> <div class="transform-resource">
<span>{{localize "DAGGERHEART.ACTIONS.Settings.transform.clearStress"}}</span>
<input type="checkbox" data-resource="stress" {{checked transform.resourceRefresh.stress}}/> <input type="checkbox" data-resource="stress" {{checked transform.resourceRefresh.stress}}/>
<span class="resource-title">{{localize "DAGGERHEART.ACTIONS.Settings.transform.clearStress"}}</span>
</div> </div>
</div> </div>
</div> </div>