From 497756e8b17569c7291182074560f7c98f38beeb Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 26 Jan 2025 14:28:55 -0700 Subject: [PATCH] Add a setting to make it so that range can be condensed on the Weapon sheet --- langs/en-ca.json | 4 ++++ module/data/Item/Weapon.mjs | 29 ++++++++++++++++++++++++++--- module/settings/userSettings.mjs | 10 ++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/langs/en-ca.json b/langs/en-ca.json index d04708a..ba1d8f7 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -76,6 +76,10 @@ "abbrAccess": { "name": "Abbreviate Access Names", "hint": "Shortens the Access level names the way the book does. (e.g. \"Common\" becomes \"C\")" + }, + "condensedRange": { + "name": "Condense Weapon Range Input", + "hint": "With this enabled, the weapon range will be displayed as \"X / Y\" when editing a weapon. While disabled it will be as displayed as two different rows, one for Short Range and one for Long Range" } }, "Apps": { diff --git a/module/data/Item/Weapon.mjs b/module/data/Item/Weapon.mjs index 2ef659b..a81b951 100644 --- a/module/data/Item/Weapon.mjs +++ b/module/data/Item/Weapon.mjs @@ -77,7 +77,27 @@ export class WeaponData extends CommonItemData { path: `system.traits`, value: this.traitString, }, - { + ]; + + // Add the range inputs depending on whether the user wants condensed range + // or not. + if (game.settings.get(`ripcrypt`, `condensedRange`)) { + fields.push({ + type: `bar`, + label: `RipCrypt.common.range`, + value: { + label: `RipCrypt.Apps.short-range`, + path: `system.range.short`, + value: this.range.short, + }, + max: { + label: `RipCrypt.Apps.long-range`, + path: `system.range.long`, + value: this.range.long, + }, + }); + } else { + fields.push({ id: `short-range`, type: `integer`, label: `RipCrypt.Apps.short-range`, @@ -92,7 +112,10 @@ export class WeaponData extends CommonItemData { path: `system.range.long`, value: this.range.long ?? ``, min: 0, - }, + }); + }; + + fields.push( { id: `damage`, type: `integer`, @@ -135,7 +158,7 @@ export class WeaponData extends CommonItemData { })), ], }, - ]; + ); if (this.parent.isEmbedded) { fields.push({ diff --git a/module/settings/userSettings.mjs b/module/settings/userSettings.mjs index 18757f4..6dca4c4 100644 --- a/module/settings/userSettings.mjs +++ b/module/settings/userSettings.mjs @@ -10,4 +10,14 @@ export function registerUserSettings() { default: false, requiresReload: false, }); + + game.settings.register(`ripcrypt`, `condensedRange`, { + name: `RipCrypt.setting.condensedRange.name`, + hint: `RipCrypt.setting.condensedRange.hint`, + scope: userScope, + type: Boolean, + config: true, + default: true, + requiresReload: false, + }); };