Skip to content

Commit

Permalink
add channel elements variant
Browse files Browse the repository at this point in the history
  • Loading branch information
reonZ committed Jun 23, 2024
1 parent 070e361 commit 3c9ad96
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@
"draw": {
"title": "{type} - {name}",
"message": "Are you sure you want to {type} <strong>{name}</strong>?"
}
},
"noChannelElements": "Could not find the <strong>Channel Elements</strong> action on this character."
}
}
},
Expand Down
20 changes: 17 additions & 3 deletions src/hud/persistent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class PF2eHudPersistent extends makeAdvancedHUD(
return {
...shortcut,
isDisabled: expended || isBroken,
isFadedOut: expended || isBroken,
isFadedOut: expended || isBroken || notCarried,
rank: ROMAN_RANKS[castRank],
img: spell.img,
categoryIcon,
Expand Down Expand Up @@ -701,6 +701,7 @@ class PF2eHudPersistent extends makeAdvancedHUD(
...shortcut,
isDisabled: disabled,
isFadedOut: disabled,
isBlast: true,
blast,
} satisfies AttackShortcut as T;
} else {
Expand All @@ -716,7 +717,7 @@ class PF2eHudPersistent extends makeAdvancedHUD(
return {
...shortcut,
isDisabled: disabled,
isFadedOut: disabled,
isFadedOut: disabled || !strike.ready,
strike,
img: img ?? shortcut.img,
name: strike
Expand Down Expand Up @@ -1143,6 +1144,17 @@ class PF2eHudPersistent extends makeAdvancedHUD(
strike?.auxiliaryActions?.at(auxiliaryActionIndex)?.execute();
break;
}

case "channel-elements": {
const action = actor.itemTypes.action.find((x) => x.slug === "channel-elements");

if (!action) {
warn("persistent.main.shortcut.noChannelElements");
return;
}

return useAction(action);
}
}
}

Expand Down Expand Up @@ -1393,7 +1405,8 @@ type ShortcutActionEvent =
| "strike-attack"
| "strike-damage"
| "strike-critical"
| "auxiliary-action";
| "auxiliary-action"
| "channel-elements";

type ShortcutType = "action" | "attack" | "consumable" | "spell" | "toggle";

Expand Down Expand Up @@ -1516,6 +1529,7 @@ type BaseAttackShortcut = BaseShortCut<"attack"> &
};

type BlastShortcut = BaseAttackShortcut & {
isBlast: true;
blast: ActionBlast | undefined;
};

Expand Down
9 changes: 6 additions & 3 deletions styles/_persistent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,17 @@ $bottom-width: 542px;
border-color: var(--variant-border-color);
padding-block: 0.05em;
padding-inline: 0.2em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

.action-glyph {
display: none;
}

&:not(.wrap) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

&.attack {
background: var(--attack-background);
border-color: var(--attack-border-color);
Expand Down
2 changes: 1 addition & 1 deletion styles/pf2e-hud.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion styles/pf2e-hud.css.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions templates/persistent/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,19 @@
{{/inline}}

{{#*inline 'attack'}}
{{#unless attack.isDisabled}}
<div class="background"></div>
{{/unless}}
{{!-- blast --}}
{{#if attack.isBlast}}
{{#if attack.blast}}
{{> (@root.partial 'action_blast-row') blast=attack.blast melee=true}}
{{> (@root.partial 'action_blast-row') blast=attack.blast melee=false}}
{{else}}
<div class="variants">
<div class="variant wrap" data-action="channel-elements">Channel Elements</div>
</div>
{{/if}}
{{!-- strike --}}
{{else}}
{{!-- strike ready --}}
Expand Down

0 comments on commit 3c9ad96

Please sign in to comment.