Skip to content

Commit

Permalink
Add invisible option
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed Aug 17, 2023
1 parent 31f24c6 commit 370e5c7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"email": "[email protected]"
}
],
"version": "2.0.11",
"version": "2.1.0",
"compatibility": {
"minimum": "10",
"verified": "11"
Expand All @@ -28,8 +28,8 @@
},
"url": "https://github.com/dev7355608/advanced-drawing-tools",
"manifest": "https://raw.githubusercontent.com/dev7355608/advanced-drawing-tools/main/module.json",
"download": "https://github.com/dev7355608/advanced-drawing-tools/releases/download/v2.0.11/module.zip",
"changelog": "https://github.com/dev7355608/advanced-drawing-tools/releases/tag/v2.0.11",
"download": "https://github.com/dev7355608/advanced-drawing-tools/releases/download/v2.1.0/module.zip",
"changelog": "https://github.com/dev7355608/advanced-drawing-tools/releases/tag/v2.1.0",
"bugs": "https://github.com/dev7355608/advanced-drawing-tools/issues",
"readme": "https://raw.githubusercontent.com/dev7355608/advanced-drawing-tools/main/README.md",
"license": "https://raw.githubusercontent.com/dev7355608/advanced-drawing-tools/main/LICENSE"
Expand Down
10 changes: 10 additions & 0 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ Hooks.on("renderDrawingConfig", (app, html) => {
const fs = document.getFlag(MODULE_ID, "fillStyle") ?? {};
const ts = document.getFlag(MODULE_ID, "textStyle") ?? {};

html.find(`.tab[data-tab="position"]`).append(`
<div class="form-group">
<label>Invisible</label>
<div class="form-fields">
<input type="checkbox" name="flags.${MODULE_ID}.invisible" ${document.getFlag(MODULE_ID, "invisible") ? "checked" : ""}>
</div>
<p class="notes">Invisible drawings are visible to their authors and GMs if the drawings layer is active. Otherwise they are not visible to anyone.</p>
</div>
`);

html.find(`input[name="text"]`).replaceWith(`
<textarea name="text" style="font-family: var(--font-primary); min-height: calc(var(--form-field-height) + 3px); height: 0; border-color: var(--color-border-light-tertiary);">${document.text ?? ""}</textarea>
`);
Expand Down
1 change: 1 addition & 0 deletions scripts/const.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const MODULE_ID = "advanced-drawing-tools";
export const MODULE_NAME = "Advanced Drawing Tools";
export const DEFAULT_FLAGS = Object.freeze({
[`flags.${MODULE_ID}.invisible`]: false,
[`flags.${MODULE_ID}.fillStyle.texture.height`]: null,
[`flags.${MODULE_ID}.fillStyle.texture.width`]: null,
[`flags.${MODULE_ID}.fillStyle.transform.pivot.x`]: 0,
Expand Down
5 changes: 5 additions & 0 deletions scripts/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Hooks.on("refreshDrawing", drawing => {
}

const document = drawing.document;

if (document.getFlag(MODULE_ID, "invisible") && !(drawing.layer.active && (game.user.isGM || game.user === document.author))) {
drawing.shape.visible = false;
}

const { lineStyle, fillStyle } = drawing.shape.geometry?.graphicsData?.[0] ?? {};

if (lineStyle && document.strokeWidth) {
Expand Down

0 comments on commit 370e5c7

Please sign in to comment.