Skip to content

Commit

Permalink
Localize and Set
Browse files Browse the repository at this point in the history
- Add localization support
- Add setting support
    - `cone` internal angle is now configurable
  • Loading branch information
FolkvangrForgent committed Aug 3, 2024
1 parent 018f327 commit 06c9d30
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 43 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.4.2

- Add localization support
- Add setting support
- `cone` internal angle is now configurable

# 1.4.1

- Add toolclips to measurement tools
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ This module aims to enhance the use of hex grids while using the PF2e system.
- `hex` does not display distance
- `emanation`, `burst`,`cone`, and `hex` do not render outline shape
- Emulate `gridTemplates` behavior when on hex grids
- Buttons for `emanation`, `burst`, `cone`, `line`, `hex`, and `rectangle` in `Measurement Controls`
- Buttons for `emanation`, `burst`, `cone`, `line`, `hex`, and `rectangle` in `Measurement Controls`
- Settings
- `cone` internal angle can be configured (defaults to 60 degree)
39 changes: 23 additions & 16 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@
"name": "FolkvangrForgent"
}
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "src/lang/en.json"
}
],
"relationships": {
"systems": [
{
"id": "pf2e",
"type": "system",
"compatibility": {
"minimum": "6.2.0",
"verified": "6.2.0"
}
}
],
{
"id": "pf2e",
"type": "system",
"compatibility": {
"minimum": "6.2.0",
"verified": "6.2.0"
}
}
],
"requires": [
{
"id": "lib-wrapper",
"type": "module",
"compatibility": {
"minimum": "1.0.0.0",
"verified": "1.12.14.0"
}
{
"id": "lib-wrapper",
"type": "module",
"compatibility": {
"minimum": "1.0.0.0",
"verified": "1.12.14.0"
}
}
]
},
"esmodules": [
Expand Down
16 changes: 16 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"pf2e-hex": {
"template": {
"hex": "Hex Template",
"emanation": "Emanation Template",
"burst": "Burst Template",
"cone": "Cone Template",
"line": "Line Template",
"rect": "Rectangle Template"
},
"setting": {
"cone-template-angle-name": "Cone Template Angle",
"cone-template-angle-hint": "The internal angle to use for the cone template."
}
}
}
Binary file renamed src/burst.webm → src/media/burst.webm
Binary file not shown.
Binary file renamed src/cone.webm → src/media/cone.webm
Binary file not shown.
Binary file renamed src/emanation.webm → src/media/emanation.webm
Binary file not shown.
Binary file renamed src/hex.webm → src/media/hex.webm
Binary file not shown.
Binary file renamed src/line.webm → src/media/line.webm
Binary file not shown.
Binary file renamed src/rect.webm → src/media/rect.webm
Binary file not shown.
64 changes: 38 additions & 26 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ Hooks.once("libWrapper.Ready", () => {
const M = CONST.GRID_SNAPPING_MODES;
let snappingMode = 0;
switch (this.areaShape) {
case "burst":
snappingMode = M.VERTEX;
case "hex":
snappingMode = M.CENTER;
break;
case "emanation":
snappingMode = M.CENTER | M.VERTEX;
break;
case "burst":
snappingMode = M.VERTEX;
break;
case "cone":
snappingMode = M.CENTER | M.EDGE_MIDPOINT | M.VERTEX;
break;
case "hex":
snappingMode = M.CENTER;
break;
case "line":
default:
break;
Expand Down Expand Up @@ -247,61 +247,61 @@ Hooks.on("getSceneControlButtons", (controls) => {
measureControls.tools = [
{
name: "hex",
title: "Hex Template",
title: "pf2e-hex.template.hex",
icon: "fa-solid fa-hexagon",
toolclip: {
src: "/modules/pf2e-hex/src/hex.webm",
heading: "Hex Template",
src: "/modules/pf2e-hex/src/media/hex.webm",
heading: "pf2e-hex.template.hex",
items: buildItems("create", "move", "edit", "hide", "delete")
}
},
{
name: "emanation",
title: "Emanation Template",
title: "pf2e-hex.template.emanation",
icon: "fa-regular fa-hexagon-xmark",
toolclip: {
src: "/modules/pf2e-hex/src/emanation.webm",
heading: "Emanation Template",
src: "/modules/pf2e-hex/src/media/emanation.webm",
heading: "pf2e-hex.template.emanation",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "burst",
title: "Burst Template",
title: "pf2e-hex.template.burst",
icon: "fa-regular fa-hexagon",
toolclip: {
src: "/modules/pf2e-hex/src/burst.webm",
heading: "Burst Template",
items: buildItems("create", "move", "edit", "hide", "delete")
src: "/modules/pf2e-hex/src/media/burst.webm",
heading: "pf2e-hex.template.burst",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "cone",
title: "Cone Template",
title: "pf2e-hex.template.cone",
icon: "fa-regular fa-rotate-270 fa-triangle",
toolclip: {
src: "/modules/pf2e-hex/src/cone.webm",
heading: "Cone Template",
src: "/modules/pf2e-hex/src/media/cone.webm",
heading: "pf2e-hex.template.cone",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "line",
title: "Line Template",
title: "pf2e-hex.template.line",
icon: "fa-regular fa-rotate-90 fa-pipe",
toolclip: {
src: "/modules/pf2e-hex/src/line.webm",
heading: "Line Template",
src: "/modules/pf2e-hex/src/media/line.webm",
heading: "pf2e-hex.template.line",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
{
name: "rect",
title: "CONTROLS.MeasureRect",
title: "pf2e-hex.template.rect",
icon: "fa-regular fa-square",
toolclip: {
src: "/modules/pf2e-hex/src/rect.webm",
heading: "CONTROLS.MeasureRect",
src: "/modules/pf2e-hex/src/media/rect.webm",
heading: "pf2e-hex.template.rect",
items: buildItems("create", "move", "edit", "hide", "delete", "rotate")
}
},
Expand Down Expand Up @@ -352,7 +352,7 @@ Hooks.once("libWrapper.Ready", () => {
}
};
if ( tool === "cone") {
previewData.angle = 60;
previewData.angle = game.settings.get('pf2e-hex', 'cone-template-angle');
} else if ( tool === "line" ) {
previewData.width = (CONFIG.MeasuredTemplate.defaults.width * canvas.dimensions.distance);
}
Expand Down Expand Up @@ -428,4 +428,16 @@ Hooks.once("libWrapper.Ready", () => {
// return rotation based on snap
return template.rotate(template.document.direction + delta, snap);
}, 'MIXED');
});
});

// SETTINGS
Hooks.once('init', () => {
game.settings.register("pf2e-hex", "cone-template-angle", {
name: "pf2e-hex.setting.cone-template-angle-name",
hint: "pf2e-hex.setting.cone-template-angle-hint",
scope: "world",
config: true,
type: Number,
default: 60
});
})

0 comments on commit 06c9d30

Please sign in to comment.