Skip to content

Commit

Permalink
[foundryvtt#1858] Add optgroups to range & distance units
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Jan 25, 2023
1 parent 1f1b423 commit 26f5f79
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
"DND5E.DistSelf": "Self",
"DND5E.DistTouch": "Touch",
"DND5E.Duration": "Duration",
"DND5E.DurationTime": "Time",
"DND5E.DurationType": "Duration Type",
"DND5E.DurationUnits": "Duration Units",
"DND5E.DurationValue": "Duration Value",
Expand Down Expand Up @@ -810,6 +811,7 @@
"DND5E.Race": "Race",
"DND5E.RacialTraits": "Racial Traits",
"DND5E.Range": "Range",
"DND5E.RangeDistance": "Distance",
"DND5E.RangeLong": "Long Range",
"DND5E.RangeNormal": "Normal Range",
"DND5E.RangeUnits": "Range Type or Units",
Expand Down
18 changes: 15 additions & 3 deletions module/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,31 @@ DND5E.scalarTimePeriods = {
month: "DND5E.TimeMonth",
year: "DND5E.TimeYear"
};
preLocalize("scalarTimePeriods");

/* -------------------------------------------- */

/**
* The various lengths of time over which effects can occur.
* Time periods that don't accept a numeric value.
* @enum {string}
*/
DND5E.timePeriods = {
DND5E.specialTimePeriods = {
inst: "DND5E.TimeInst",
...DND5E.scalarTimePeriods,
perm: "DND5E.TimePerm",
spec: "DND5E.Special"
};
preLocalize("specialTimePeriods");

/* -------------------------------------------- */

/**
* The various lengths of time over which effects can occur.
* @enum {string}
*/
DND5E.timePeriods = {
...DND5E.specialTimePeriods,
...DND5E.scalarTimePeriods
};
preLocalize("timePeriods");

/* -------------------------------------------- */
Expand Down
19 changes: 13 additions & 6 deletions templates/items/parts/item-activation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@
placeholder="{{localize 'DND5E.Long'}}" data-tooltip="DND5E.RangeLong">
{{/if}}
<select name="system.range.units" data-tooltip="DND5E.RangeUnits">
{{selectOptions config.distanceUnits selected=system.range.units blank=(localize "DND5E.None")}}
{{#select system.range.units}}
<option value="">{{localize "DND5E.None"}}</option>
{{selectOptions config.rangeTypes}}
<optgroup label="{{localize 'DND5E.RangeDistance'}}">
{{selectOptions config.movementUnits}}
</optgroup>
{{/select}}
</select>
</div>
</div>
Expand All @@ -98,10 +104,11 @@
{{/if}}
<select name="system.duration.units" data-tooltip="DND5E.DurationType">
{{#select system.duration.units}}
<option value=""></option>
{{#each config.timePeriods as |name key|}}
<option value="{{key}}">{{name}}</option>
{{/each}}
<option value="">{{localize "DND5E.None"}}</option>
{{selectOptions config.specialTimePeriods}}
<optgroup label="{{localize 'DND5E.DurationTime'}}">
{{selectOptions config.scalarTimePeriods}}
</optgroup>
{{/select}}
</select>
</div>
Expand Down Expand Up @@ -144,7 +151,7 @@
</select>
{{/if}}
<select name="system.consume.type" data-tooltip="DND5E.ConsumeType">
{{selectOptions config.abilityConsumptionTypes selected=system.consume.type blank=""}}
{{selectOptions config.abilityConsumptionTypes selected=system.consume.type blank=(localize "DND5E.None")}}
</select>
</div>
</div>
Expand Down

0 comments on commit 26f5f79

Please sign in to comment.