Skip to content

Commit

Permalink
Finish up converting deprecated handlebars helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
In3luki committed May 1, 2024
1 parent 2a4c155 commit d41cdf4
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 91 deletions.
5 changes: 5 additions & 0 deletions src/module/item/base/sheet/rule-element-form/flat-modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class FlatModifierForm extends RuleElementForm<FlatModifierSource, FlatModifierR
types,
damageCategories: R.pick(CONFIG.PF2E.damageCategories, Array.from(DAMAGE_CATEGORIES_UNIQUE)),
isDamage: this.isDamage,
criticalOptions: [
{ value: "false", label: "PF2E.RuleEditor.General.CriticalBehavior.false" },
{ value: "true", label: "PF2E.RuleEditor.General.CriticalBehavior.true" },
],
};
}

Expand Down Expand Up @@ -73,6 +77,7 @@ interface FlatModifierFormSheetData extends RuleElementFormSheetData<FlatModifie
types: Record<ModifierType, string>;
damageCategories: Pick<ConfigPF2e["PF2E"]["damageCategories"], "persistent" | "precision" | "splash">;
isDamage: boolean;
criticalOptions: FormSelectOption[];
}

export { FlatModifierForm };
12 changes: 8 additions & 4 deletions src/module/item/deity/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SheetOptions, createSheetOptions } from "@module/sheet/helpers.ts";
import { ErrorPF2e, htmlClosest, htmlQuery, htmlQueryAll, tagify } from "@util";
import { UUIDUtils } from "@util/uuid.ts";
import * as R from "remeda";
import { DeitySanctification } from "./data.ts";
import { DEITY_SANCTIFICATIONS } from "./values.ts";

export class DeitySheetPF2e extends ItemSheetPF2e<DeityPF2e> {
Expand Down Expand Up @@ -33,15 +32,19 @@ export class DeitySheetPF2e extends ItemSheetPF2e<DeityPF2e> {
const modal = value.modal.capitalize();
const what = value.what.map((c) => c.capitalize()).join("");
return {
value,
value: JSON.stringify(value),
label: `PF2E.Item.Deity.Sanctification.${modal}.${what}`,
};
}),
{ value: null, label: "PF2E.Item.Deity.Sanctification.None" },
];

return {
...sheetData,
categories: [
{ value: "deity", label: "TYPES.Item.deity" },
{ value: "pantheon", label: "PF2E.Item.Deity.Category.Pantheon" },
{ value: "philosophy", label: "PF2E.Item.Deity.Category.Philosophy" },
],
sanctifications,
skills: CONFIG.PF2E.skillList,
divineFonts: createSheetOptions(
Expand Down Expand Up @@ -169,7 +172,8 @@ export class DeitySheetPF2e extends ItemSheetPF2e<DeityPF2e> {
}

interface DeitySheetData extends ItemSheetDataPF2e<DeityPF2e> {
sanctifications: { value: DeitySanctification | null; label: string }[];
categories: FormSelectOption[];
sanctifications: FormSelectOption[];
skills: Record<SkillLongForm, string>;
divineFonts: SheetOptions;
spells: SpellBrief[];
Expand Down
12 changes: 12 additions & 0 deletions src/module/item/effect/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export class EffectSheetPF2e extends ItemSheetPF2e<EffectPF2e> {
...(await super.getData(options)),
itemType: game.i18n.localize("PF2E.LevelLabel"),
badgeType: badge ? game.i18n.localize(`PF2E.Item.Effect.Badge.Type.${badge.type}`) : "",
expiryOptions: [
{ value: "turn-start", label: "PF2E.Item.Effect.Expiry.StartOfTurn" },
{ value: "turn-end", label: "PF2E.Item.Effect.Expiry.EndOfTurn" },
{ value: "round-end", label: "PF2E.Item.Effect.Expiry.EndOfRound" },
],
reevaluateOptions: [
{ value: "initiative-roll", label: "PF2E.Item.Effect.Badge.ReevaluateFormula.InitiativeRoll" },
{ value: "turn-start", label: "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnStart" },
{ value: "turn-end", label: "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnEnd" },
],
timeUnits: CONFIG.PF2E.timeUnits,
};
}
Expand Down Expand Up @@ -88,5 +98,7 @@ export class EffectSheetPF2e extends ItemSheetPF2e<EffectPF2e> {

interface EffectSheetData extends ItemSheetDataPF2e<EffectPF2e> {
badgeType: string;
expiryOptions: FormSelectOption[];
reevaluateOptions: FormSelectOption[];
timeUnits: ConfigPF2e["PF2E"]["timeUnits"];
}
15 changes: 15 additions & 0 deletions src/module/item/feat/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FeatSheetPF2e extends ItemSheetPF2e<FeatPF2e> {
itemType: game.i18n.localize(feat.isFeature ? "PF2E.LevelLabel" : "PF2E.Item.Feat.LevelLabel"),
actionsNumber: CONFIG.PF2E.actionsNumber,
actionTypes: CONFIG.PF2E.actionTypes,
acuityOptions: CONFIG.PF2E.senseAcuities,
attributes: CONFIG.PF2E.abilities,
canHaveKeyOptions: featCanHaveKeyOptions(feat),
categories: CONFIG.PF2E.featCategories,
Expand All @@ -61,8 +62,19 @@ class FeatSheetPF2e extends ItemSheetPF2e<FeatPF2e> {
hasProficiencies: Object.keys(subfeatures.proficiencies).length > 0,
hasSenses: Object.keys(subfeatures.senses).length > 0,
mandatoryTakeOnce: hasLineageTrait || sheetData.data.onlyLevel1,
maxTakableOptions: [
{ value: "1", label: "No" },
{ value: "2", label: "PF2E.Item.Feat.TakeMultiple.Two" },
{ value: "3", label: "PF2E.Item.Feat.TakeMultiple.Three" },
{ value: "4", label: "PF2E.Item.Feat.TakeMultiple.Four" },
{ value: "5", label: "PF2E.Item.Feat.TakeMultiple.Five" },
{ value: "Infinity", label: "PF2E.Item.Feat.TakeMultiple.NoLimit" },
],
languages: this.#getLanguageOptions(),
proficiencies: this.#getProficiencyOptions(),
proficiencyRankOptions: Object.fromEntries(
Object.values(CONFIG.PF2E.proficiencyRanks).map((label, i) => [`${i}`, label]),
),
selfEffect: createSelfEffectSheetData(sheetData.data.selfEffect),
senses: this.#getSenseOptions(),
showPrerequisites,
Expand Down Expand Up @@ -374,6 +386,7 @@ class FeatSheetPF2e extends ItemSheetPF2e<FeatPF2e> {
interface FeatSheetData extends ItemSheetDataPF2e<FeatPF2e> {
actionsNumber: typeof CONFIG.PF2E.actionsNumber;
actionTypes: typeof CONFIG.PF2E.actionTypes;
acuityOptions: typeof CONFIG.PF2E.senseAcuities;
attributes: typeof CONFIG.PF2E.abilities;
canHaveKeyOptions: boolean;
categories: typeof CONFIG.PF2E.featCategories;
Expand All @@ -384,7 +397,9 @@ interface FeatSheetData extends ItemSheetDataPF2e<FeatPF2e> {
hasSenses: boolean;
languages: LanguageOptions;
mandatoryTakeOnce: boolean;
maxTakableOptions: FormSelectOption[];
proficiencies: ProficiencyOptions;
proficiencyRankOptions: Record<string, string>;
selfEffect: SelfEffectReference | null;
senses: SenseOption[];
showPrerequisites: boolean;
Expand Down
25 changes: 21 additions & 4 deletions src/module/item/spell/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
htmlQuery,
htmlQueryAll,
objectHasKey,
ordinalString,
sortStringRecord,
tagify,
tupleHasValue,
Expand Down Expand Up @@ -110,9 +111,19 @@ export class SpellSheetPF2e extends ItemSheetPF2e<SpellPF2e> {
damageSubtypes: R.pick(CONFIG.PF2E.damageCategories, [...DAMAGE_CATEGORIES_UNIQUE]),
damageKinds,
materials: CONFIG.PF2E.materialDamageEffects,
heightenIntervals: [1, 2, 3, 4],
heightenIntervals: R.range(1, 5).map((i) => ({
value: `${i}`,
label: game.i18n.format("PF2E.SpellScalingInterval.Selection", { interval: i }),
})),
heightenOverlays: this.#prepareHeighteningLevels(),
canHeighten: this.isEditable && this.getAvailableHeightenLevels().length > 0,
defensePassiveOptions: [
{ value: "ac", label: "PF2E.Check.DC.Specific.armor" },
{ value: "fortitude-dc", label: "PF2E.Check.DC.Specific.fortitude" },
{ value: "reflex-dc", label: "PF2E.Check.DC.Specific.reflex" },
{ value: "will-dc", label: "PF2E.Check.DC.Specific.will" },
],
defenseSaveOptions: CONFIG.PF2E.saves,
};
}

Expand Down Expand Up @@ -454,6 +465,7 @@ export class SpellSheetPF2e extends ItemSheetPF2e<SpellPF2e> {
if (key in layer.system) continue;
missing.push({ key: key as keyof SpellSystemData, label });
}
const availableLevels = [layer.level, ...this.getAvailableHeightenLevels()].sort((a, b) => a - b);

return {
id: null,
Expand All @@ -463,7 +475,10 @@ export class SpellSheetPF2e extends ItemSheetPF2e<SpellPF2e> {
dataPath: base,
system: layer.system,
missing,
heightenLevels: [layer.level, ...this.getAvailableHeightenLevels()].sort(),
heightenLevels: availableLevels.map((l) => ({
value: `${l}`,
label: game.i18n.format("PF2E.SpellScalingOverlay.Selection", { level: ordinalString(l) }),
})),
traits: layer.system.traits?.value
? createTagifyTraits(layer.system.traits.value, { record: CONFIG.PF2E.spellTraits })
: null,
Expand All @@ -485,9 +500,11 @@ interface SpellSheetData extends ItemSheetDataPF2e<SpellPF2e> {
damageSubtypes: Pick<typeof CONFIG.PF2E.damageCategories, DamageCategoryUnique>;
damageKinds: Record<string, { value: string[]; label: string; selected: boolean; disabled: boolean }[]>;
areaShapes: Record<EffectAreaShape, string>;
heightenIntervals: number[];
heightenIntervals: FormSelectOption[];
heightenOverlays: SpellSheetHeightenOverlayData[];
canHeighten: boolean;
defensePassiveOptions: FormSelectOption[];
defenseSaveOptions: typeof CONFIG.PF2E.saves;
}

interface SpellSheetOverlayData {
Expand All @@ -503,7 +520,7 @@ interface SpellSheetOverlayData {

interface SpellSheetHeightenOverlayData extends SpellSheetOverlayData {
system: Partial<SpellSystemSource>;
heightenLevels: number[];
heightenLevels: FormSelectOption[];
missing: { key: keyof SpellSystemData; label: string }[];
traits?: TraitTagifyEntry[] | null;
}
12 changes: 10 additions & 2 deletions src/module/scene/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ export class SceneConfigPF2e<TDocument extends ScenePF2e> extends SceneConfig<TD
// Rules-based vision
const [tab, panel] = await (async (): Promise<HTMLTemplateElement[]> => {
const hbsPath = "systems/pf2e/templates/scene/sheet-partials.hbs";
const rbvWorldDefault = game.i18n.localize(
const worldDefault = game.i18n.localize(
game.pf2e.settings.rbv
? "PF2E.SETTINGS.EnabledDisabled.Enabled"
: "PF2E.SETTINGS.EnabledDisabled.Disabled",
);
const templates = await renderTemplate(hbsPath, { scene: this.scene, rbvWorldDefault });
const rbvOptions: FormSelectOption[] = [
{
value: "",
label: game.i18n.format("PF2E.SETTINGS.EnabledDisabled.Default", { worldDefault }),
},
{ value: "true", label: "PF2E.SETTINGS.EnabledDisabled.Enabled" },
{ value: "false", label: "PF2E.SETTINGS.EnabledDisabled.Disabled" },
];
const templates = await renderTemplate(hbsPath, { scene: this.scene, rbvOptions });

return htmlQueryAll(createHTMLElement("div", { innerHTML: templates }), "template");
})();
Expand Down
12 changes: 2 additions & 10 deletions static/templates/items/deity-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
<div class="form-group">
<label for="{{fieldIdPrefix}}category">{{localize "PF2E.Category"}}</label>
<select name="system.category" id="{{fieldIdPrefix}}category">
{{#select data.category}}
<option value="deity">{{localize "TYPES.Item.deity"}}</option>
<option value="pantheon">{{localize "PF2E.Item.Deity.Category.Pantheon"}}</option>
<option value="philosophy">{{localize "PF2E.Item.Deity.Category.Philosophy"}}</option>
{{/select}}
{{selectOptions categories selected=data.category localize=true}}
</select>
<p class="hint">{{localize "PF2E.Item.Deity.Category.Hint"}}</p>
</div>
Expand All @@ -17,11 +13,7 @@
<div class="form-group">
<label for="{{fieldIdPrefix}}sanctification">{{localize "PF2E.Item.Deity.Sanctification.Label"}}</label>
<select name="system.sanctification" id="{{fieldIdPrefix}}sanctification" data-dtype="JSON">
{{#select (json data.sanctification)}}
{{#each sanctifications as |sanctification|}}
<option value="{{json sanctification.value}}">{{localize sanctification.label}}</option>
{{/each}}
{{/select}}
{{selectOptions sanctifications selected=(json data.sanctification) blank="PF2E.Item.Deity.Sanctification.None" localize=true}}
</select>
</div>

Expand Down
13 changes: 2 additions & 11 deletions static/templates/items/effect-sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
<label for="{{item.uuid}}-duration-expiry">{{localize "PF2E.Item.Effect.Expiry.ExpiresOn"}}</label>
<div class="form-fields">
<select id="{{item.uuid}}-duration-expiry" name="system.duration.expiry">
{{#select data.duration.expiry}}
<option value="turn-start">{{localize "PF2E.Item.Effect.Expiry.StartOfTurn"}}</option>
<option value="turn-end">{{localize "PF2E.Item.Effect.Expiry.EndOfTurn"}}</option>
<option value="round-end">{{localize "PF2E.Item.Effect.Expiry.EndOfRound"}}</option>
{{/select}}
{{selectOptions expiryOptions selected=data.duration.expiry localize=true}}
</select>
</div>
</div>
Expand Down Expand Up @@ -64,12 +60,7 @@
<label for="{{item.uuid}}-badge-reevaluate">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.Label"}}</label>
<div class="form-fields">
<select id="{{item.uuid}}-badge-reevaluate" name="system.badge.reevaluate">
{{#select data.badge.reevaluate}}
<option value="">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.Never"}}</option>
<option value="initiative-roll">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.InitiativeRoll"}}</option>
<option value="turn-start">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnStart"}}</option>
<option value="turn-end">{{localize "PF2E.Item.Effect.Badge.ReevaluateFormula.TurnEnd"}}</option>
{{/select}}
{{selectOptions reevaluateOptions selected=data.badge.reevaluate blank="PF2E.Item.Effect.Badge.ReevaluateFormula.Never" localize=true}}
</select>
</div>
</div>
Expand Down
24 changes: 4 additions & 20 deletions static/templates/items/feat-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@
data-dtype="Number"
{{disabled mandatoryTakeOnce}}
>
{{#select data.maxTakable}}
<option value="1">{{localize "No"}}</option>
<option value="2">{{localize "PF2E.Item.Feat.TakeMultiple.Two"}}</option>
<option value="3">{{localize "PF2E.Item.Feat.TakeMultiple.Three"}}</option>
<option value="4">{{localize "PF2E.Item.Feat.TakeMultiple.Four"}}</option>
<option value="5">{{localize "PF2E.Item.Feat.TakeMultiple.Five"}}</option>
<option value="Infinity">{{localize "PF2E.Item.Feat.TakeMultiple.NoLimit"}}</option>
{{/select}}
{{selectOptions maxTakableOptions selected=data.maxTakable localize=true}}
</select>
{{#if mandatoryTakeOnce}}<input type="hidden" name="system.maxTakable" value="1" data-dtype="Number" />{{/if}}
</div>
Expand Down Expand Up @@ -110,7 +103,7 @@
</li>
</ul>
</div>

{{log this}}
<div class="form-group stacked proficiencies" data-proficiencies>
<label for="{{fieldIdPrefix}}add-proficiency">{{localize "PF2E.Item.Feat.Subfeatures.Proficiencies.Label"}}</label>
<ul{{#unless hasProficiencies}} class="empty"{{/unless}}>
Expand All @@ -125,12 +118,7 @@
id="{{@root.fieldIdPrefix}}{{option.slug}}"
data-dtype="Number"
>
{{#select option.rank}}
<option value="1">{{localize "PF2E.ProficiencyLevel1"}}</option>
<option value="2">{{localize "PF2E.ProficiencyLevel2"}}</option>
<option value="3">{{localize "PF2E.ProficiencyLevel3"}}</option>
<option value="4">{{localize "PF2E.ProficiencyLevel4"}}</option>
{{/select}}
{{selectOptions (omit @root.proficiencyRankOptions "0") selected=option.rank localize=true}}
</select>

{{#if (or option.attribute (eq option.attribute null))}}
Expand Down Expand Up @@ -219,11 +207,7 @@
id="{{@root.fieldIdPrefix}}{{option.slug}}"
{{disabled (not option.canSetAcuity)}}
>
{{#select option.acuity}}
<option value="precise">{{localize "PF2E.Actor.Creature.Sense.Acuity.Precise"}}</option>
<option value="imprecise">{{localize "PF2E.Actor.Creature.Sense.Acuity.Imprecise"}}</option>
<option value="vague">{{localize "PF2E.Actor.Creature.Sense.Acuity.Vague"}}</option>
{{/select}}
{{selectOptions @root.acuityOptions selected=option.acuity localize=true}}
</select>

<input
Expand Down
6 changes: 1 addition & 5 deletions static/templates/items/rules/flat-modifier.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
{{selectOptions damageCategories selected=rule.damageCategory blank="" localize=true}}
</select>
<select name="{{basePath}}.critical" class="short">
{{#select rule.critical}}
<option value="">{{localize "PF2E.RuleEditor.General.CriticalBehavior.null"}}</option>
<option value="false">{{localize "PF2E.RuleEditor.General.CriticalBehavior.false"}}</option>
<option value="true">{{localize "PF2E.RuleEditor.General.CriticalBehavior.true"}}</option>
{{/select}}
{{selectOptions criticalOptions selected=rule.critical blank="PF2E.RuleEditor.General.CriticalBehavior.null" localize=true}}
</select>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion static/templates/items/rules/partials/resolvable-value.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
</button>
{{#if (eq mode "primitive")}}
<input type="text" name="{{path}}" id="{{inputId}}" value="{{value}}" />
{{#if fileInput}}{{filePicker target=path value=value type="imagevideo"}}{{/if}}
{{#if fileInput}}
<file-picker name="{{path}}" value="{{value}}" type="imagevideo"></file-picker>
{{/if}}
{{else if (eq mode "brackets")}}
<input type="text" name="{{path}}.field" id="{{inputId}}" value="{{value.field}}" placeholder="Actor Level (Default)" />
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion static/templates/items/rules/token-image.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="form-group">
<label for="{{fieldIdPrefix}}tint" class="short">{{localize fields.tint.label}}</label>
<div class="form-fields">
{{colorPicker name=(concat "system.rules." index ".tint") id=(concat fieldIdPrefix "tint") value=object.tint}}
<color-picker name="{{concat "system.rules." index ".tint"}}" id="{{concat fieldIdPrefix "tint"}}" value="{{object.tint}}"></color-picker>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion static/templates/items/rules/token-light.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div class="form-group">
<label>{{ localize "LIGHT.Color" }}</label>
<div class="form-fields">
{{colorPicker name=(concat "system.rules." index ".value.color") value=light.color}}
<color-picker name="{{concat "system.rules." index ".value.color"}}" value="{{light.color}}"></color-picker>
</div>
</div>

Expand Down
Loading

0 comments on commit d41cdf4

Please sign in to comment.