mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
In Front Template (#299)
* Added confirm dialogs to delete * Localization fix * Changed Cone template to be 'In Front', acting as a 180 degree cone * Changed to keep the original Cone function
This commit is contained in:
parent
9189a95ea3
commit
e6ec486072
6 changed files with 123 additions and 3 deletions
|
|
@ -120,6 +120,7 @@ Hooks.once('init', () => {
|
||||||
CONFIG.ChatMessage.documentClass = documents.DhChatMessage;
|
CONFIG.ChatMessage.documentClass = documents.DhChatMessage;
|
||||||
|
|
||||||
CONFIG.Canvas.rulerClass = placeables.DhRuler;
|
CONFIG.Canvas.rulerClass = placeables.DhRuler;
|
||||||
|
CONFIG.Canvas.layers.templates.layerClass = placeables.DhTemplateLayer;
|
||||||
CONFIG.Combat.documentClass = documents.DhpCombat;
|
CONFIG.Combat.documentClass = documents.DhpCombat;
|
||||||
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
CONFIG.ui.combat = applications.ui.DhCombatTracker;
|
||||||
CONFIG.ui.chat = applications.ui.DhChatLog;
|
CONFIG.ui.chat = applications.ui.DhChatLog;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
||||||
"environment": "Environment"
|
"environment": "Environment"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"CONTROLS": {
|
||||||
|
"inFront": "In Front"
|
||||||
|
},
|
||||||
"DAGGERHEART": {
|
"DAGGERHEART": {
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"Config": {
|
"Config": {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
export { default as DhMeasuredTemplate } from './measuredTemplate.mjs';
|
||||||
export { default as DhRuler } from './ruler.mjs';
|
export { default as DhRuler } from './ruler.mjs';
|
||||||
|
export { default as DhTemplateLayer } from './templateLayer.mjs';
|
||||||
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
export { default as DhTokenRuler } from './tokenRuler.mjs';
|
||||||
|
|
|
||||||
116
module/canvas/placeables/templateLayer.mjs
Normal file
116
module/canvas/placeables/templateLayer.mjs
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
export default class DhTemplateLayer extends foundry.canvas.layers.TemplateLayer {
|
||||||
|
static prepareSceneControls() {
|
||||||
|
const sc = foundry.applications.ui.SceneControls;
|
||||||
|
return {
|
||||||
|
name: 'templates',
|
||||||
|
order: 2,
|
||||||
|
title: 'CONTROLS.GroupMeasure',
|
||||||
|
icon: 'fa-solid fa-ruler-combined',
|
||||||
|
visible: game.user.can('TEMPLATE_CREATE'),
|
||||||
|
onChange: (event, active) => {
|
||||||
|
if (active) canvas.templates.activate();
|
||||||
|
},
|
||||||
|
onToolChange: () => canvas.templates.setAllRenderFlags({ refreshState: true }),
|
||||||
|
tools: {
|
||||||
|
circle: {
|
||||||
|
name: 'circle',
|
||||||
|
order: 1,
|
||||||
|
title: 'CONTROLS.MeasureCircle',
|
||||||
|
icon: 'fa-regular fa-circle',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-circle.webm',
|
||||||
|
heading: 'CONTROLS.MeasureCircle',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cone: {
|
||||||
|
name: 'cone',
|
||||||
|
order: 2,
|
||||||
|
title: 'CONTROLS.MeasureCone',
|
||||||
|
icon: 'fa-solid fa-angle-left',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-cone.webm',
|
||||||
|
heading: 'CONTROLS.MeasureCone',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
inFront: {
|
||||||
|
name: 'inFront',
|
||||||
|
order: 3,
|
||||||
|
title: 'CONTROLS.inFront',
|
||||||
|
icon: 'fa-solid fa-eye',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-cone.webm',
|
||||||
|
heading: 'CONTROLS.inFront',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rect: {
|
||||||
|
name: 'rect',
|
||||||
|
order: 4,
|
||||||
|
title: 'CONTROLS.MeasureRect',
|
||||||
|
icon: 'fa-regular fa-square',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-rect.webm',
|
||||||
|
heading: 'CONTROLS.MeasureRect',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ray: {
|
||||||
|
name: 'ray',
|
||||||
|
order: 5,
|
||||||
|
title: 'CONTROLS.MeasureRay',
|
||||||
|
icon: 'fa-solid fa-up-down',
|
||||||
|
toolclip: {
|
||||||
|
src: 'toolclips/tools/measure-ray.webm',
|
||||||
|
heading: 'CONTROLS.MeasureRay',
|
||||||
|
items: sc.buildToolclipItems(['create', 'move', 'edit', 'hide', 'delete', 'rotate'])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: {
|
||||||
|
name: 'clear',
|
||||||
|
order: 6,
|
||||||
|
title: 'CONTROLS.MeasureClear',
|
||||||
|
icon: 'fa-solid fa-trash',
|
||||||
|
visible: game.user.isGM,
|
||||||
|
onChange: () => canvas.templates.deleteAll(),
|
||||||
|
button: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
activeTool: 'circle'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
_onDragLeftStart(event) {
|
||||||
|
const interaction = event.interactionData;
|
||||||
|
|
||||||
|
// Snap the origin to the grid
|
||||||
|
if (!event.shiftKey) interaction.origin = this.getSnappedPoint(interaction.origin);
|
||||||
|
|
||||||
|
// Create a pending MeasuredTemplateDocument
|
||||||
|
const tool = game.activeTool === 'inFront' ? 'cone' : game.activeTool;
|
||||||
|
const previewData = {
|
||||||
|
user: game.user.id,
|
||||||
|
t: tool,
|
||||||
|
x: interaction.origin.x,
|
||||||
|
y: interaction.origin.y,
|
||||||
|
sort: Math.max(this.getMaxSort() + 1, 0),
|
||||||
|
distance: 1,
|
||||||
|
direction: 0,
|
||||||
|
fillColor: game.user.color || '#FF0000',
|
||||||
|
hidden: event.altKey
|
||||||
|
};
|
||||||
|
const defaults = CONFIG.MeasuredTemplate.defaults;
|
||||||
|
if (game.activeTool === 'cone') previewData.angle = defaults.angle;
|
||||||
|
else if (game.activeTool === 'inFront') previewData.angle = 180;
|
||||||
|
else if (game.activeTool === 'ray') previewData.width = defaults.width * canvas.dimensions.distance;
|
||||||
|
const cls = foundry.utils.getDocumentClass('MeasuredTemplate');
|
||||||
|
const doc = new cls(previewData, { parent: canvas.scene });
|
||||||
|
|
||||||
|
// Create a preview MeasuredTemplate object
|
||||||
|
const template = new this.constructor.placeableClass(doc);
|
||||||
|
doc._object = template;
|
||||||
|
interaction.preview = this.preview.addChild(template);
|
||||||
|
template.draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { burden } from '../../config/generalConfig.mjs';
|
import { burden } from '../../config/generalConfig.mjs';
|
||||||
import ActionField from '../fields/actionField.mjs';
|
|
||||||
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs';
|
||||||
import DhLevelData from '../levelData.mjs';
|
import DhLevelData from '../levelData.mjs';
|
||||||
import BaseDataActor from './base.mjs';
|
import BaseDataActor from './base.mjs';
|
||||||
|
|
@ -29,7 +28,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
return foundry.utils.mergeObject(super.metadata, {
|
return foundry.utils.mergeObject(super.metadata, {
|
||||||
label: 'TYPES.Actor.character',
|
label: 'TYPES.Actor.character',
|
||||||
type: 'character',
|
type: 'character',
|
||||||
isNPC: false,
|
isNPC: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager {
|
export default class DhTooltipManager extends foundry.helpers.interaction.TooltipManager {
|
||||||
async activate(element, options = {}) {
|
async activate(element, options = {}) {
|
||||||
let html = options.html;
|
let html = options.html;
|
||||||
if (element.dataset.tooltip.startsWith('#item#')) {
|
if (element.dataset.tooltip?.startsWith('#item#')) {
|
||||||
const item = await foundry.utils.fromUuid(element.dataset.tooltip.slice(6));
|
const item = await foundry.utils.fromUuid(element.dataset.tooltip.slice(6));
|
||||||
if (item) {
|
if (item) {
|
||||||
html = await foundry.applications.handlebars.renderTemplate(
|
html = await foundry.applications.handlebars.renderTemplate(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue