mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[PR] [Feature] 652 Allow override range measurement settings (#1030)
* Look for rangeMeasurementSettingsOverride on the scene to switch off DH global range measurement settings. * Part progress on adding config tab to scene config * Hard coded template; no value applied/saved * Flag fix * Use the flags setting * Clean up * Remove import * Better initialisation of PARTS and TABS * Fix localisation --------- Co-authored-by: Chris Ryan <chrisr@blackhole> Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
7a6bbe3488
commit
60b55619e1
10 changed files with 82 additions and 15 deletions
|
|
@ -10,29 +10,41 @@ export default class DhMeasuredTemplate extends foundry.canvas.placeables.Measur
|
|||
const splitRulerText = this.ruler.text.split(' ');
|
||||
if (splitRulerText.length > 0) {
|
||||
const rulerValue = Number(splitRulerText[0]);
|
||||
const vagueLabel = this.constructor.getDistanceLabel(rulerValue, rangeMeasurementSettings);
|
||||
this.ruler.text = vagueLabel;
|
||||
const result = this.constructor.getRangeLabels(rulerValue, rangeMeasurementSettings);
|
||||
this.ruler.text = result.distance + result.units ? (' ' + result.units) : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static getDistanceLabel(distance, settings) {
|
||||
static getRangeLabels(distance, settings) {
|
||||
let result = { distance: '', units: null }
|
||||
const rangeMeasurementOverride = canvas.scene.flags.daggerheart?.rangeMeasurementOverride;
|
||||
|
||||
if (rangeMeasurementOverride === true) {
|
||||
result.distance = distance;
|
||||
result.units = canvas.scene?.grid?.units;
|
||||
return result
|
||||
}
|
||||
if (distance <= settings.melee) {
|
||||
return game.i18n.localize('DAGGERHEART.CONFIG.Range.melee.name');
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.melee.name');
|
||||
return result;
|
||||
}
|
||||
if (distance <= settings.veryClose) {
|
||||
return game.i18n.localize('DAGGERHEART.CONFIG.Range.veryClose.name');
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.veryClose.name');
|
||||
return result;
|
||||
}
|
||||
if (distance <= settings.close) {
|
||||
return game.i18n.localize('DAGGERHEART.CONFIG.Range.close.name');
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.close.name');
|
||||
return result;
|
||||
}
|
||||
if (distance <= settings.far) {
|
||||
return game.i18n.localize('DAGGERHEART.CONFIG.Range.far.name');
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.far.name');
|
||||
return result;
|
||||
}
|
||||
if (distance > settings.far) {
|
||||
return game.i18n.localize('DAGGERHEART.CONFIG.Range.veryFar.name');
|
||||
result.distance = game.i18n.localize('DAGGERHEART.CONFIG.Range.veryFar.name');
|
||||
}
|
||||
|
||||
return '';
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export default class DhpRuler extends foundry.canvas.interaction.Ruler {
|
|||
const range = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement;
|
||||
|
||||
if (range.enabled) {
|
||||
const distance = DhMeasuredTemplate.getDistanceLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
context.cost = { total: distance, units: null };
|
||||
context.distance = { total: distance, units: null };
|
||||
const result = DhMeasuredTemplate.getRangeLabels(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
context.cost = { total: result.distance, units: result.units };
|
||||
context.distance = { total: result.distance, units: result.units };
|
||||
}
|
||||
|
||||
return context;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export default class DhpTokenRuler extends foundry.canvas.placeables.tokens.Toke
|
|||
const range = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement;
|
||||
|
||||
if (range.enabled) {
|
||||
const distance = DhMeasuredTemplate.getDistanceLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
context.cost = { total: distance, units: null };
|
||||
context.distance = { total: distance, units: null };
|
||||
const result = DhMeasuredTemplate.getRangeLabels(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
context.cost = { total: result.distance, units: result.units };
|
||||
context.distance = { total: result.distance, units: result.units };
|
||||
}
|
||||
|
||||
return context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue