Skip to content

Commit

Permalink
fix token hud not closing when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
reonZ committed Aug 29, 2024
1 parent 2bc5680 commit af55d40
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/hud/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ class PF2eHudToken extends makeAdvancedHUD(
this.#canvasTearDownHook.toggle(enabled);
this.#renderTokenHudHook.toggle(enabled);
this.#renderActorSheetHook.toggle(enabled);

if (!enabled && this.rendered) {
this.close();
}
}

_onSetToken(token: TokenPF2e | null): void {
Expand Down
4 changes: 4 additions & 0 deletions src/hud/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ class PF2eHudTooltip extends PF2eHudBaseToken<TooltipSettings, ActorPF2e, Toolti
const enableDraw = enabled && this.getSetting("drawDistance") > 0;
this.#tokenRefreshWrapper.toggle(enableDraw);
this.#canvasTearDownHook.toggle(enableDraw);

if (!enabled && this.rendered) {
this.close();
}
}

_tokenCleanup() {
Expand Down
7 changes: 5 additions & 2 deletions src/hud/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ class PF2eHudTracker extends PF2eHudBase<TrackerSettings, any, TrackerRenderOpti
this.#combatTrackerHook.toggle(enabled);
this.#renderEffectsHook.toggle(enabled);

if (enabled && this.combat) this.render(true);
else if (!enabled && this.rendered) this.close();
if (enabled && this.combat) {
this.render(true);
} else if (!enabled && this.rendered) {
this.close();
}

// toggleControlTool("pf2e-hud-tracker", enabled);

Expand Down

0 comments on commit af55d40

Please sign in to comment.