mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-07 21:34:16 +02:00
Compare commits
No commits in common. "94efbeada3e89155d434fc50d09445f9dd221b73" and "b374070809c1bf262b3305022b3f54b3c92d2785" have entirely different histories.
94efbeada3
...
b374070809
7 changed files with 28 additions and 94 deletions
|
|
@ -2405,14 +2405,6 @@
|
|||
"hideAttribution": {
|
||||
"label": "Hide Attribution"
|
||||
},
|
||||
"showTokenDistance": {
|
||||
"label": "Show Token Distance on Hover",
|
||||
"choices": {
|
||||
"always": "Always",
|
||||
"encounters": "Encounters",
|
||||
"never": "Never"
|
||||
}
|
||||
},
|
||||
"expandedTitle": "Auto-expand Descriptions",
|
||||
"extendCharacterDescriptions": {
|
||||
"label": "Characters"
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ export default class DhMeasuredTemplate extends foundry.canvas.placeables.Measur
|
|||
|
||||
static getRangeLabels(distanceValue, settings) {
|
||||
let result = { distance: distanceValue, units: '' };
|
||||
if (!settings.enabled) return result;
|
||||
|
||||
const sceneRangeMeasurement = canvas.scene.flags.daggerheart?.rangeMeasurement;
|
||||
|
||||
const { disable, custom } = CONFIG.DH.GENERAL.sceneRangeMeasurementSetting;
|
||||
if (sceneRangeMeasurement?.setting === disable.id) {
|
||||
result.distance = distanceValue;
|
||||
|
|
@ -28,9 +27,31 @@ export default class DhMeasuredTemplate extends foundry.canvas.placeables.Measur
|
|||
return result;
|
||||
}
|
||||
|
||||
const ranges = sceneRangeMeasurement?.setting === custom.id ? sceneRangeMeasurement : settings;
|
||||
const distanceKey = ['melee', 'veryClose', 'close', 'far'].find(r => ranges[r] >= distanceValue);
|
||||
result.distance = game.i18n.localize(`DAGGERHEART.CONFIG.Range.${distanceKey ?? 'veryFar'}.name`);
|
||||
const melee = sceneRangeMeasurement?.setting === custom.id ? sceneRangeMeasurement.melee : settings.melee;
|
||||
const veryClose =
|
||||
sceneRangeMeasurement?.setting === custom.id ? sceneRangeMeasurement.veryClose : settings.veryClose;
|
||||
const close = sceneRangeMeasurement?.setting === custom.id ? sceneRangeMeasurement.close : settings.close;
|
||||
const far = sceneRangeMeasurement?.setting === custom.id ? sceneRangeMeasurement.far : settings.far;
|
||||
if (distanceValue <= melee) {
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.melee.name');
|
||||
return result;
|
||||
}
|
||||
if (distanceValue <= veryClose) {
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.veryClose.name');
|
||||
return result;
|
||||
}
|
||||
if (distanceValue <= close) {
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.close.name');
|
||||
return result;
|
||||
}
|
||||
if (distanceValue <= far) {
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.far.name');
|
||||
return result;
|
||||
}
|
||||
if (distanceValue > far) {
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.veryFar.name');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import DhMeasuredTemplate from "./measuredTemplate.mjs";
|
||||
|
||||
export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
||||
/** @inheritdoc */
|
||||
async _draw(options) {
|
||||
|
|
@ -80,60 +78,6 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
return canvas.grid.measurePath([adjustedOriginPoint, adjustDestinationPoint]).distance;
|
||||
}
|
||||
|
||||
_onHoverIn(event, options) {
|
||||
super._onHoverIn(event, options);
|
||||
|
||||
// Check if the setting is enabled
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).showTokenDistance;
|
||||
if (setting === "never" || (setting === "encounters" && !game.combat?.started)) return;
|
||||
|
||||
// Check if this token isn't invisible and is actually being hovered
|
||||
const isTokenValid =
|
||||
this.visible &&
|
||||
this.hover &&
|
||||
!this.isPreview &&
|
||||
!this.document.isSecret &&
|
||||
!this.controlled &&
|
||||
!this.animation;
|
||||
if (!isTokenValid) return;
|
||||
|
||||
// Ensure we have a single controlled token
|
||||
const originToken = canvas.tokens.controlled[0];
|
||||
if (!originToken || canvas.tokens.controlled.length > 1) return;
|
||||
|
||||
// Determine the actual range
|
||||
const ranges = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement;
|
||||
const distanceNum = originToken.distanceTo(this);
|
||||
const distanceResult = DhMeasuredTemplate.getRangeLabels(distanceNum, ranges);
|
||||
const distanceLabel = `${distanceResult.distance} ${distanceResult.units}`.trim();
|
||||
|
||||
// Create the element
|
||||
const element = document.createElement('div');
|
||||
element.id = 'token-hover-distance';
|
||||
element.classList.add('waypoint-label', 'last');
|
||||
const ruler = document.createElement('i');
|
||||
ruler.classList.add('fa-solid', 'fa-ruler');
|
||||
element.appendChild(ruler);
|
||||
const labelEl = document.createElement('span');
|
||||
labelEl.classList.add('total-measurement');
|
||||
labelEl.textContent = distanceLabel;
|
||||
element.appendChild(labelEl);
|
||||
|
||||
// Position the element and add to the DOM
|
||||
const center = this.getCenterPoint();
|
||||
element.style.setProperty('--transformY', 'calc(-100% - 10px)');
|
||||
element.style.setProperty('--position-y', `${this.y}px`);
|
||||
element.style.setProperty('--position-x', `${center.x}px`);
|
||||
element.style.setProperty('--ui-scale', String(canvas.dimensions.uiScale));
|
||||
document.querySelector('#token-hover-distance')?.remove();
|
||||
document.querySelector('#measurement').appendChild(element);
|
||||
}
|
||||
|
||||
_onHoverOut(...args) {
|
||||
super._onHoverOut(...args);
|
||||
document.querySelector('#token-hover-distance')?.remove();
|
||||
}
|
||||
|
||||
/** Returns the point at which a line starting at origin and ending at destination intersects the edge of the bounds */
|
||||
#getEdgeBoundary(bounds, originPoint, destinationPoint) {
|
||||
const points = [
|
||||
|
|
|
|||
|
|
@ -42,25 +42,6 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
|||
damage: new BooleanField(),
|
||||
target: new BooleanField()
|
||||
}),
|
||||
showTokenDistance: new StringField({
|
||||
required: true,
|
||||
choices: {
|
||||
always: {
|
||||
value: 'always',
|
||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.showTokenDistance.choices.always'
|
||||
},
|
||||
encounters: {
|
||||
value: 'encounters',
|
||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.showTokenDistance.choices.encounters'
|
||||
},
|
||||
never: {
|
||||
value: 'never',
|
||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.showTokenDistance.choices.never'
|
||||
}
|
||||
},
|
||||
nullable: false,
|
||||
initial: 'always'
|
||||
}),
|
||||
hideAttribution: new BooleanField(),
|
||||
showGenericStatusEffects: new BooleanField({ initial: true })
|
||||
};
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
|||
|
||||
// Hexagon symmetry
|
||||
if (columns) {
|
||||
const rowData = DHToken.#getHexagonalShape(height, width, shape, false);
|
||||
const rowData = BaseToken.#getHexagonalShape(height, width, shape, false);
|
||||
if (!rowData) return null;
|
||||
|
||||
// Transpose the offsets/points of the shape in row orientation
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "daggerheart",
|
||||
"title": "Daggerheart",
|
||||
"description": "An unofficial implementation of the Daggerheart system",
|
||||
"version": "1.6.2",
|
||||
"version": "1.6.1",
|
||||
"compatibility": {
|
||||
"minimum": "13.346",
|
||||
"verified": "13.351",
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@
|
|||
value=setting.showGenericStatusEffects
|
||||
localize=true}}
|
||||
{{formGroup
|
||||
fields.showTokenDistance
|
||||
value=setting.showTokenDistance
|
||||
localize=true}}
|
||||
{{formGroup
|
||||
fields.hideAttribution
|
||||
value=setting.hideAttribution
|
||||
localize=true}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue