Skip to content

Commit

Permalink
Unset and Clip
Browse files Browse the repository at this point in the history
- Add toolclips to measurement tools
- Fix error when switching to square with a custom measurement tool
  • Loading branch information
FolkvangrForgent committed Aug 3, 2024
1 parent df43fad commit b4f7cba
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 54 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.4.1

- Add toolclips to measurement tools
- Fix error when switching to square with a custom measurement tool

# 1.4.0

- Add `hex` template shape that highlights a single hex
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

# PF2e Hex Enhancements

This module aims to enhance the use of hex grids while using the PF2e system. Verified for FVTT 12.330 and PF2e 6.2.0.
This module aims to enhance the use of hex grids while using the PF2e system.

**WARNING** - This module uses a lot of function patching and so it is suggested to run it on the exact version of FoundryVTT and PF2e that it is verified for.
**WARNING** - This module uses a lot of function patching and so it is suggested to run it on the exact version of FoundryVTT that it is verified for. Verified for FVTT 12.330.

**NOTE** - There are no official area rules for rectangles in pf2e, as such I will try my best to leave their functionality as open as possible.

Expand Down
Binary file added src/burst.webm
Binary file not shown.
Binary file added src/cone.webm
Binary file not shown.
Binary file added src/emanation.webm
Binary file not shown.
Binary file added src/hex.webm
Binary file not shown.
Binary file added src/line.webm
Binary file not shown.
118 changes: 66 additions & 52 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,23 @@ Hooks.once("libWrapper.Ready", () => {
// MEASUREMENT CONTROLS
// TODO add toolclips
Hooks.on("getSceneControlButtons", (controls) => {
// only override logic on hexagonal grid
if (!canvas || !canvas.ready || !canvas.grid.isHexagonal) {
return;
// ensure canvas is ready (otherwise page refresh will cause error)
if (!canvas || !canvas.ready) {
return;
}
// if not hexagon unset weird and custom tools then return
if (!canvas.grid.isHexagonal) {
const measure= ui.controls.controls.find(c => c.name === "measure");
const tool = measure.tools.find(t => t.name === "ray");
if (game.activeTool === "burst" || game.activeTool === "emanation" || game.activeTool === "hex") {
let tool = "circle";
canvas[measure.layer].activate({tool});
}
if (game.activeTool === "line") {
let tool = "ray";
canvas[measure.layer].activate({tool});
}
return;
}
// find measureControls
const measureControls = controls.find((c) => c.name === "measure");
Expand All @@ -236,68 +250,68 @@ Hooks.on("getSceneControlButtons", (controls) => {
title: "Hex Template",
icon: "fa-solid fa-hexagon",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "Hex Template",
items: buildItems("create", "move", "edit", "hide", "delete")
src: "/modules/pf2e-hex/src/hex.webm",
heading: "Hex Template",
items: buildItems("create", "move", "edit", "hide", "delete")
}
},
{
name: "emanation",
title: "Emanation Template",
icon: "fa-regular fa-hexagon-xmark",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "Emanation Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
name: "emanation",
title: "Emanation Template",
icon: "fa-regular fa-hexagon-xmark",
toolclip: {
src: "/modules/pf2e-hex/src/emanation.webm",
heading: "Emanation Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "burst",
title: "Burst Template",
icon: "fa-regular fa-hexagon",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "Burst Template",
items: buildItems("create", "move", "edit", "hide", "delete")
}
name: "burst",
title: "Burst Template",
icon: "fa-regular fa-hexagon",
toolclip: {
src: "/modules/pf2e-hex/src/burst.webm",
heading: "Burst Template",
items: buildItems("create", "move", "edit", "hide", "delete")
}
},
{
name: "cone",
title: "Cone Template",
icon: "fa-regular fa-rotate-270 fa-triangle",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "Cone Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
name: "cone",
title: "Cone Template",
icon: "fa-regular fa-rotate-270 fa-triangle",
toolclip: {
src: "/modules/pf2e-hex/src/cone.webm",
heading: "Cone Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "line",
title: "Ray Template",
icon: "fa-regular fa-rotate-90 fa-pipe",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "Ray Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
name: "line",
title: "Line Template",
icon: "fa-regular fa-rotate-90 fa-pipe",
toolclip: {
src: "/modules/pf2e-hex/src/line.webm",
heading: "Line Template",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "rect",
title: "CONTROLS.MeasureRect",
icon: "fa-regular fa-square",
toolclip: {
// src: "toolclips/tools/measure-rect.webm",
heading: "CONTROLS.MeasureRect",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
name: "rect",
title: "CONTROLS.MeasureRect",
icon: "fa-regular fa-square",
toolclip: {
src: "/modules/pf2e-hex/src/rect.webm",
heading: "CONTROLS.MeasureRect",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "clear",
title: "CONTROLS.MeasureClear",
icon: "fa-solid fa-trash",
visible: game.user.isGM,
onClick: () => canvas.templates.deleteAll(),
button: true
name: "clear",
title: "CONTROLS.MeasureClear",
icon: "fa-solid fa-trash",
visible: game.user.isGM,
onClick: () => canvas.templates.deleteAll(),
button: true
}
]
});
Expand Down
Binary file added src/rect.webm
Binary file not shown.

0 comments on commit b4f7cba

Please sign in to comment.