From 3eaf69f5587c4ab16cf0337a7e67cde742cae2d0 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Mon, 28 Jul 2025 21:55:06 +0200 Subject: [PATCH 1/5] fix: remove duplicate action handlers and improve template action generation - Remove duplicate action handlers (edititem, deleteitem, createitem, etc.) from DS4ActorSheet and DS4ItemSheet - Fix editImage method reference from static to prototype in DS4ActorSheet - Add capitalize helper to handlebars-helpers.ts for dynamic action name generation - Update control-button-group.hbs and add-button.hbs templates to use concat and capitalize helpers - Ensure consistent camelCase naming for all action handlers (editItem, deleteItem, createItem, etc.) This resolves action handler conflicts and improves maintainability by using dynamic template generation instead of hardcoded conditional logic. --- src/apps/actor/base-sheet.js | 9 +-------- src/apps/item-sheet.js | 3 --- src/handlebars/handlebars-helpers.ts | 5 +++++ templates/sheets/shared/components/add-button.hbs | 2 +- .../sheets/shared/components/control-button-group.hbs | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/apps/actor/base-sheet.js b/src/apps/actor/base-sheet.js index 55e2163a..fabdb67d 100644 --- a/src/apps/actor/base-sheet.js +++ b/src/apps/actor/base-sheet.js @@ -41,14 +41,7 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio changeEffect: DS4ActorSheet.prototype._onChangeEffect, sortItems: DS4ActorSheet.prototype._onSortItems, changeTab: DS4ActorSheet.prototype._onChangeTab, - edititem: DS4ActorSheet.prototype._onEditItem, - deleteitem: DS4ActorSheet.prototype._onDeleteItem, - createitem: DS4ActorSheet.prototype._onCreateItem, - editeffect: DS4ActorSheet.prototype._onEditEffect, - deleteeffect: DS4ActorSheet.prototype._onDeleteEffect, - createeffect: DS4ActorSheet.prototype._onCreateEffect, - editImage: DS4ActorSheet._onEditImage, - + editImage: DS4ActorSheet.prototype._onEditImage, }, }; diff --git a/src/apps/item-sheet.js b/src/apps/item-sheet.js index 004b3ab9..5a05dfb4 100644 --- a/src/apps/item-sheet.js +++ b/src/apps/item-sheet.js @@ -26,11 +26,8 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication actions: { controlEffect: DS4ItemSheet.prototype._onControlEffect, createEffect: DS4ItemSheet.prototype._onCreateEffect, - createeffect: DS4ItemSheet.prototype._onCreateEffect, editEffect: DS4ItemSheet.prototype._onEditEffect, - editeffect: DS4ItemSheet.prototype._onEditEffect, deleteEffect: DS4ItemSheet.prototype._onDeleteEffect, - deleteeffect: DS4ItemSheet.prototype._onDeleteEffect, changeTab: DS4ItemSheet.prototype._onChangeTab, editImage: DS4ItemSheet.prototype._onEditImage, }, diff --git a/src/handlebars/handlebars-helpers.ts b/src/handlebars/handlebars-helpers.ts index 015064a4..8f94b065 100644 --- a/src/handlebars/handlebars-helpers.ts +++ b/src/handlebars/handlebars-helpers.ts @@ -14,6 +14,11 @@ const helpers = { isEmpty: (input: Array | null | undefined): boolean => (input?.length ?? 0) === 0, + capitalize: (str: string): string => { + if (typeof str !== 'string') return ''; + return str.charAt(0).toUpperCase() + str.slice(1); + }, + toRomanNumerals, }; diff --git a/templates/sheets/shared/components/add-button.hbs b/templates/sheets/shared/components/add-button.hbs index 585d9659..da5a7e58 100644 --- a/templates/sheets/shared/components/add-button.hbs +++ b/templates/sheets/shared/components/add-button.hbs @@ -13,7 +13,7 @@ SPDX-License-Identifier: MIT }} {{#if @root/editable}}
- {{localize "DS4.UserInteractionAdd"}} diff --git a/templates/sheets/shared/components/control-button-group.hbs b/templates/sheets/shared/components/control-button-group.hbs index 268b94ef..a2099d21 100644 --- a/templates/sheets/shared/components/control-button-group.hbs +++ b/templates/sheets/shared/components/control-button-group.hbs @@ -14,9 +14,9 @@ SPDX-License-Identifier: MIT --}} From f807b59c9a50a5fc2d08317e43a1a101690a791d Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Mon, 28 Jul 2025 22:01:00 +0200 Subject: [PATCH 2/5] fix: add missing localization keys for sheet titles - Add DS4.ActorSheet localization key ("Aktorbogen" / "Actor Sheet") - Add DS4.ItemSheet localization key ("Itembogen" / "Item Sheet") These keys are used in the get title() methods of DS4ActorSheet and DS4ItemSheet to display properly localized sheet window titles instead of showing the raw localization key strings. Both keys are placed logically near other Actor/Item-related localization entries for consistency. --- lang/de.json | 2 ++ lang/en.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lang/de.json b/lang/de.json index 3f7208c1..c5176813 100644 --- a/lang/de.json +++ b/lang/de.json @@ -184,7 +184,9 @@ "DS4.EffectFactor": "Faktor (wie oft der Effekt angewendet wird)", "DS4.EffectFactorAbbr": "F", "DS4.ActorName": "Name", + "DS4.ActorSheet": "Aktorbogen", "DS4.ActorImageAltText": "Bild des Aktors", + "DS4.ItemSheet": "Itembogen", "DS4.ActorTypeCharacter": "Charakter", "DS4.ActorTypeCreature": "Kreatur", "DS4.Attribute": "Attribut", diff --git a/lang/en.json b/lang/en.json index e58b6caf..8b032343 100644 --- a/lang/en.json +++ b/lang/en.json @@ -184,7 +184,9 @@ "DS4.EffectFactor": "Factor (the number of times the effect is being applied)", "DS4.EffectFactorAbbr": "F", "DS4.ActorName": "Name", + "DS4.ActorSheet": "Actor Sheet", "DS4.ActorImageAltText": "Image of the Actor", + "DS4.ItemSheet": "Item Sheet", "DS4.ActorTypeCharacter": "Character", "DS4.ActorTypeCreature": "Creature", "DS4.Attribute": "Attribute", From 7fcdcf8a5cd7545889baf22cfe65ce032898d852 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Mon, 28 Jul 2025 22:14:41 +0200 Subject: [PATCH 3/5] fix: correct effects display in item sheet template - Fix item sheet effects template to use enrichedEffects instead of data.effects - Ensures effects are properly displayed in the item sheet effects tab - Aligns with actor sheet implementation for consistency The template was referencing data.effects but the context preparation creates enrichedEffects array with additional metadata (id, uuid, sourceName). --- src/apps/item-sheet.js | 2 ++ templates/sheets/item/tabs/effects.hbs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apps/item-sheet.js b/src/apps/item-sheet.js index 5a05dfb4..fc2251e4 100644 --- a/src/apps/item-sheet.js +++ b/src/apps/item-sheet.js @@ -96,6 +96,8 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication } } + + // Enrich description content for display if (this.item.system.description) { context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML( diff --git a/templates/sheets/item/tabs/effects.hbs b/templates/sheets/item/tabs/effects.hbs index 0e76c5ef..070057c7 100644 --- a/templates/sheets/item/tabs/effects.hbs +++ b/templates/sheets/item/tabs/effects.hbs @@ -5,10 +5,10 @@ SPDX-License-Identifier: MIT --}}
- {{#unless (isEmpty data.effects)}} + {{#unless (isEmpty enrichedEffects)}}
    {{> systems/ds4/templates/sheets/item/components/effect-list-header.hbs}} - {{#each data.effects as |effectData id| }} + {{#each enrichedEffects as |effectData id| }} {{> systems/ds4/templates/sheets/item/components/effect-list-entry.hbs effectData=effectData}} {{/each}}
From e021fedcdff27e3ddf624b864c554b21d8cf42f9 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Mon, 28 Jul 2025 22:18:44 +0200 Subject: [PATCH 4/5] style: fix code formatting inconsistencies - Remove excessive blank lines (triple+ newlines reduced to double) - Fix EditorConfig indent_size from 4 to 2 spaces to match Prettier - Ensure consistent whitespace formatting across JavaScript/TypeScript files - Clean up formatting in templates (HBS files) Files affected: - src/apps/actor/base-sheet.js: Remove 6 instances of triple+ blank lines - src/apps/item-sheet.js: Remove 4 instances of triple+ blank lines - src/apps/ruler/token-ruler.js: Remove 1 instance of triple+ blank lines - src/hooks/hooks.ts: Remove 1 instance of triple+ blank lines - templates/sheets/actor/*.hbs: Remove excessive blank lines - .editorconfig: Fix indent_size to match Prettier tabWidth (2 spaces) --- .editorconfig | 2 +- scss/components/shared/_ruler.scss | 3 +- scss/utils/_variables.scss | 1 - src/apps/actor/base-sheet.js | 35 +++++--------- src/apps/actor/character-sheet.js | 2 +- src/apps/actor/creature-sheet.js | 2 +- src/apps/dialog-with-listeners.js | 2 +- src/apps/item-sheet.js | 37 ++++++-------- src/apps/ruler/token-ruler.js | 59 +++++++++++------------ src/dice/check-factory.js | 5 +- src/documents/actor/actor.js | 51 +++++++++++--------- src/documents/item/weapon/weapon.js | 21 ++++---- src/handlebars/handlebars-helpers.ts | 2 +- src/hooks/hooks.ts | 2 - src/hooks/render.js | 4 +- src/utils/utils.js | 5 +- templates/sheets/actor/creature-sheet.hbs | 1 - templates/sheets/actor/limited-sheet.hbs | 1 - templates/sheets/actor/tabs/spells.hbs | 2 - 19 files changed, 113 insertions(+), 124 deletions(-) diff --git a/.editorconfig b/.editorconfig index ba4931db..12b53f83 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,6 +8,6 @@ root = true end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 4 +indent_size = 2 charset = utf-8 trim_trailing_whitespace = true diff --git a/scss/components/shared/_ruler.scss b/scss/components/shared/_ruler.scss index 3fdb0065..ebbb188d 100644 --- a/scss/components/shared/_ruler.scss +++ b/scss/components/shared/_ruler.scss @@ -53,7 +53,8 @@ /* Icon animations */ @keyframes pulse { - 0%, 100% { + 0%, + 100% { opacity: 1; } 50% { diff --git a/scss/utils/_variables.scss b/scss/utils/_variables.scss index f01f73be..9909c4ed 100644 --- a/scss/utils/_variables.scss +++ b/scss/utils/_variables.scss @@ -6,7 +6,6 @@ @use "./colors"; - $padding-sm: 5px; $padding-md: 10px; $padding-lg: 20px; diff --git a/src/apps/actor/base-sheet.js b/src/apps/actor/base-sheet.js index fabdb67d..285a023a 100644 --- a/src/apps/actor/base-sheet.js +++ b/src/apps/actor/base-sheet.js @@ -6,12 +6,12 @@ // // SPDX-License-Identifier: MIT - - /** * The base sheet class for DS4 Actor Sheets */ -export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2) { +export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicationMixin( + foundry.applications.sheets.ActorSheetV2, +) { static DEFAULT_OPTIONS = { classes: ["sheet", "ds4-actor-sheet", "themed"], tag: "form", @@ -58,14 +58,14 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio /** @override */ get template() { - const templatePath = !game.user?.isGM && this.document.limited - ? "systems/ds4/templates/sheets/actor/limited-sheet.hbs" - : `systems/ds4/templates/sheets/actor/${this.document.type}-sheet.hbs`; + const templatePath = + !game.user?.isGM && this.document.limited + ? "systems/ds4/templates/sheets/actor/limited-sheet.hbs" + : `systems/ds4/templates/sheets/actor/${this.document.type}-sheet.hbs`; return templatePath; } - /** @override */ async _renderHTML(context) { return await foundry.applications.handlebars.renderTemplate(this.template, context); @@ -76,8 +76,6 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio content.innerHTML = result; } - - /** @override */ async _prepareContext(options) { const context = await super._prepareContext(options); @@ -87,8 +85,6 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio throw new Error("Document not available for sheet rendering"); } - - // Add document data context.data = this.document; context.system = this.document.system; @@ -104,8 +100,6 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio showSlayerPoints: game.settings.get("ds4", "showSlayerPoints") || false, }; - - // Add items organized by type context.itemsByType = {}; if (this.document.items && this.document.items.size > 0) { @@ -345,7 +339,6 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio } } - /** * Handle changing an item property * @param {Event} event - The triggering event @@ -477,8 +470,6 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio } } - - /** * Handle sorting items * @param {Event} event - The triggering event @@ -490,7 +481,7 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio if (!dataPath || !itemType) return; - const items = this.document.items.filter(item => item.type === itemType); + const items = this.document.items.filter((item) => item.type === itemType); const sortedItems = this.sortItems(items, dataPath); const updates = sortedItems.map((item, index) => ({ @@ -542,13 +533,13 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio if (!nav || !sheet) return; // Update navigation active state - nav.querySelectorAll(".ds4-sheet-tab-nav__item").forEach(item => { + nav.querySelectorAll(".ds4-sheet-tab-nav__item").forEach((item) => { item.classList.remove("active"); }); target.classList.add("active"); // Update tab content visibility - sheet.querySelectorAll(".ds4-sheet-tab").forEach(tabContent => { + sheet.querySelectorAll(".ds4-sheet-tab").forEach((tabContent) => { tabContent.classList.remove("active"); }); @@ -582,8 +573,8 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio const tabContents = sheet.querySelectorAll(".ds4-sheet-tab"); // Remove active class from all items first - navItems.forEach(item => item.classList.remove("active")); - tabContents.forEach(content => content.classList.remove("active")); + navItems.forEach((item) => item.classList.remove("active")); + tabContents.forEach((content) => content.classList.remove("active")); // Find the currently active tab or default to first let targetTab = this.activeTab; @@ -619,7 +610,7 @@ export class DS4ActorSheet extends foundry.applications.api.HandlebarsApplicatio const fp = new foundry.applications.apps.FilePicker({ type: "image", current: current, - callback: (path) => this.document.update({ [field]: path }) + callback: (path) => this.document.update({ [field]: path }), }); return fp.browse(); diff --git a/src/apps/actor/character-sheet.js b/src/apps/actor/character-sheet.js index 1e25b487..715b345d 100644 --- a/src/apps/actor/character-sheet.js +++ b/src/apps/actor/character-sheet.js @@ -25,7 +25,7 @@ export class DS4CharacterActorSheet extends DS4ActorSheet { { async: true, relativeTo: this.document, - } + }, ); } diff --git a/src/apps/actor/creature-sheet.js b/src/apps/actor/creature-sheet.js index 9bd8cd1f..3c68de8e 100644 --- a/src/apps/actor/creature-sheet.js +++ b/src/apps/actor/creature-sheet.js @@ -25,7 +25,7 @@ export class DS4CreatureActorSheet extends DS4ActorSheet { { async: true, relativeTo: this.document, - } + }, ); } diff --git a/src/apps/dialog-with-listeners.js b/src/apps/dialog-with-listeners.js index 5eba545d..b495b867 100644 --- a/src/apps/dialog-with-listeners.js +++ b/src/apps/dialog-with-listeners.js @@ -25,7 +25,7 @@ export class DialogWithListeners extends foundry.applications.api.DialogV2 { await super._onRender(context, options); // Attach additional listeners if provided - if (this.activateAdditionalListeners && typeof this.activateAdditionalListeners === 'function') { + if (this.activateAdditionalListeners && typeof this.activateAdditionalListeners === "function") { this.activateAdditionalListeners(this.element, this); } } diff --git a/src/apps/item-sheet.js b/src/apps/item-sheet.js index fc2251e4..8ff85ee7 100644 --- a/src/apps/item-sheet.js +++ b/src/apps/item-sheet.js @@ -8,7 +8,9 @@ /** * The Sheet class for DS4 Items */ -export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) { +export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplicationMixin( + foundry.applications.sheets.ItemSheetV2, +) { static DEFAULT_OPTIONS = { classes: ["sheet", "ds4-item-sheet", "themed"], tag: "form", @@ -33,8 +35,6 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication }, }; - - static TABS = {}; constructor(options = {}) { @@ -96,22 +96,19 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication } } - - // Enrich description content for display if (this.item.system.description) { context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML( this.item.system.description, { secrets: this.item.isOwner, - relativeTo: this.item - } + relativeTo: this.item, + }, ); } else { context.enrichedDescription = ""; } - return context; } @@ -182,10 +179,12 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication const effect = this.item.effects.get(effectId); if (!effect) { - throw new Error(game.i18n.format("DS4.ErrorItemDoesNotHaveEffect", { - id: effectId, - item: this.item.name - })); + throw new Error( + game.i18n.format("DS4.ErrorItemDoesNotHaveEffect", { + id: effectId, + item: this.item.name, + }), + ); } await effect.sheet.render(true); @@ -234,13 +233,13 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication if (!nav || !sheet) return; // Update navigation active state - nav.querySelectorAll(".ds4-sheet-tab-nav__item").forEach(item => { + nav.querySelectorAll(".ds4-sheet-tab-nav__item").forEach((item) => { item.classList.remove("active"); }); target.classList.add("active"); // Update tab content visibility - sheet.querySelectorAll(".ds4-sheet-tab").forEach(tabContent => { + sheet.querySelectorAll(".ds4-sheet-tab").forEach((tabContent) => { tabContent.classList.remove("active"); }); @@ -262,7 +261,7 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication const fp = new foundry.applications.apps.FilePicker({ type: "image", current: current, - callback: (path) => this.item.update({ [field]: path }) + callback: (path) => this.item.update({ [field]: path }), }); return fp.browse(); } @@ -275,8 +274,6 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication this._initializeTabs(); } - - /** @override */ async _onClose(options) { await super._onClose(options); @@ -298,8 +295,8 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication const tabContents = sheet.querySelectorAll(".ds4-sheet-tab"); // Remove active class from all items first - navItems.forEach(item => item.classList.remove("active")); - tabContents.forEach(content => content.classList.remove("active")); + navItems.forEach((item) => item.classList.remove("active")); + tabContents.forEach((content) => content.classList.remove("active")); // Find the currently active tab or default to first let targetTab = this.activeTab; @@ -311,8 +308,6 @@ export class DS4ItemSheet extends foundry.applications.api.HandlebarsApplication targetTab = targetNavItem?.dataset.tab; } - - // Set target tab navigation as active if (targetNavItem && targetTab) { targetNavItem.classList.add("active"); diff --git a/src/apps/ruler/token-ruler.js b/src/apps/ruler/token-ruler.js index 3d48362a..467ffa0d 100644 --- a/src/apps/ruler/token-ruler.js +++ b/src/apps/ruler/token-ruler.js @@ -7,41 +7,38 @@ * Based on actor movement combat value */ export class DS4TokenRuler extends foundry.canvas.placeables.tokens.TokenRuler { + static WAYPOINT_LABEL_TEMPLATE = "systems/ds4/templates/partials/waypoint-label.hbs"; - static WAYPOINT_LABEL_TEMPLATE = "systems/ds4/templates/partials/waypoint-label.hbs"; + /** + * Enhance waypoint label context with movement range information + * @param {object} waypoint - The waypoint data + * @param {object} state - The current ruler state + * @returns {object} Enhanced context with range class + */ + _getWaypointLabelContext(waypoint, state) { + const context = super._getWaypointLabelContext(waypoint, state); + // Only apply movement coloring for distance measurements in meters + if (context?.cost?.units === "m" || context?.distance?.units === "m") { + const movement = this.token?.actor?.system?.combatValues?.movement?.total; + if (movement) { + const total = Number(context.cost?.total || context.distance?.total || 0); - /** - * Enhance waypoint label context with movement range information - * @param {object} waypoint - The waypoint data - * @param {object} state - The current ruler state - * @returns {object} Enhanced context with range class - */ - _getWaypointLabelContext(waypoint, state) { - const context = super._getWaypointLabelContext(waypoint, state); - - // Only apply movement coloring for distance measurements in meters - if (context?.cost?.units === "m" || context?.distance?.units === "m") { - const movement = this.token?.actor?.system?.combatValues?.movement?.total; - - if (movement) { - const total = Number(context.cost?.total || context.distance?.total || 0); - - // DS4 movement rules: - // - Normal movement: up to movement value - // - Dash: up to 2x movement value (requires action) - // - Beyond 2x: impossible in single turn - if (total > 2 * movement) { - context.rangeClass = "out-of-range"; - } else if (total <= movement) { - context.rangeClass = "move-range"; - } else { - context.rangeClass = "dash-range"; - } - } + // DS4 movement rules: + // - Normal movement: up to movement value + // - Dash: up to 2x movement value (requires action) + // - Beyond 2x: impossible in single turn + if (total > 2 * movement) { + context.rangeClass = "out-of-range"; + } else if (total <= movement) { + context.rangeClass = "move-range"; + } else { + context.rangeClass = "dash-range"; } - - return context; + } } + + return context; + } } diff --git a/src/dice/check-factory.js b/src/dice/check-factory.js index d5a64c10..250dcd83 100644 --- a/src/dice/check-factory.js +++ b/src/dice/check-factory.js @@ -212,7 +212,10 @@ async function askForInteractiveRollData(checkTargetNumber, options = {}, { temp if (checkModifierSelect) { checkModifierSelect.addEventListener("change", (event) => { - if (event.currentTarget.value === "custom" && checkModifierCustomFormGroup?.classList.contains("ds4-hidden")) { + if ( + event.currentTarget.value === "custom" && + checkModifierCustomFormGroup?.classList.contains("ds4-hidden") + ) { checkModifierCustomFormGroup.classList.remove("ds4-hidden"); app.setPosition({ height: "auto" }); } else if (checkModifierCustomFormGroup && !checkModifierCustomFormGroup.classList.contains("ds4-hidden")) { diff --git a/src/documents/actor/actor.js b/src/documents/actor/actor.js index a7d0b2c3..0725a444 100644 --- a/src/documents/actor/actor.js +++ b/src/documents/actor/actor.js @@ -466,30 +466,33 @@ export class DS4Actor extends Actor { const traitIdentifier = "attribute-trait-selection-trait"; return foundry.applications.api.DialogV2.prompt({ window: { title: getGame().i18n.localize("DS4.DialogAttributeTraitSelection") }, - content: await foundry.applications.handlebars.renderTemplate("systems/ds4/templates/dialogs/simple-select-form.hbs", { - selects: [ - { - label: getGame().i18n.localize("DS4.Attribute"), - identifier: attributeIdentifier, - options: Object.fromEntries( - Object.entries(DS4.i18n.attributes).map(([attribute, translation]) => [ - attribute, - `${translation} (${this.system.attributes[attribute].total})`, - ]), - ), - }, - { - label: getGame().i18n.localize("DS4.Trait"), - identifier: traitIdentifier, - options: Object.fromEntries( - Object.entries(DS4.i18n.traits).map(([trait, translation]) => [ - trait, - `${translation} (${this.system.traits[trait].total})`, - ]), - ), - }, - ], - }), + content: await foundry.applications.handlebars.renderTemplate( + "systems/ds4/templates/dialogs/simple-select-form.hbs", + { + selects: [ + { + label: getGame().i18n.localize("DS4.Attribute"), + identifier: attributeIdentifier, + options: Object.fromEntries( + Object.entries(DS4.i18n.attributes).map(([attribute, translation]) => [ + attribute, + `${translation} (${this.system.attributes[attribute].total})`, + ]), + ), + }, + { + label: getGame().i18n.localize("DS4.Trait"), + identifier: traitIdentifier, + options: Object.fromEntries( + Object.entries(DS4.i18n.traits).map(([trait, translation]) => [ + trait, + `${translation} (${this.system.traits[trait].total})`, + ]), + ), + }, + ], + }, + ), ok: { label: getGame().i18n.localize("DS4.GenericOkButton"), callback: (_event, button) => { diff --git a/src/documents/item/weapon/weapon.js b/src/documents/item/weapon/weapon.js index b125966f..0fb723fb 100644 --- a/src/documents/item/weapon/weapon.js +++ b/src/documents/item/weapon/weapon.js @@ -86,15 +86,18 @@ export class DS4Weapon extends DS4Item { const identifier = `attack-type-selection-${foundry.utils.randomID()}`; return foundry.applications.api.DialogV2.prompt({ window: { title: getGame().i18n.localize("DS4.DialogAttackTypeSelection") }, - content: await foundry.applications.handlebars.renderTemplate("systems/ds4/templates/dialogs/simple-select-form.hbs", { - selects: [ - { - label: getGame().i18n.localize("DS4.AttackType"), - identifier, - options: { melee, ranged }, - }, - ], - }), + content: await foundry.applications.handlebars.renderTemplate( + "systems/ds4/templates/dialogs/simple-select-form.hbs", + { + selects: [ + { + label: getGame().i18n.localize("DS4.AttackType"), + identifier, + options: { melee, ranged }, + }, + ], + }, + ), ok: { label: getGame().i18n.localize("DS4.GenericOkButton"), callback: (_event, button, _dialog) => { diff --git a/src/handlebars/handlebars-helpers.ts b/src/handlebars/handlebars-helpers.ts index 8f94b065..5f9dcbc9 100644 --- a/src/handlebars/handlebars-helpers.ts +++ b/src/handlebars/handlebars-helpers.ts @@ -15,7 +15,7 @@ const helpers = { isEmpty: (input: Array | null | undefined): boolean => (input?.length ?? 0) === 0, capitalize: (str: string): string => { - if (typeof str !== 'string') return ''; + if (typeof str !== "string") return ""; return str.charAt(0).toUpperCase() + str.slice(1); }, diff --git a/src/hooks/hooks.ts b/src/hooks/hooks.ts index 684a04db..b69fbb1f 100644 --- a/src/hooks/hooks.ts +++ b/src/hooks/hooks.ts @@ -9,8 +9,6 @@ import { registerForReadyHook } from "./ready"; import { registerForRenderHooks } from "./render"; import { registerForSetupHook } from "./setup"; - - export function registerForHooks(): void { registerForHotbarDropHook(); registerForPreCreateItemHook(); diff --git a/src/hooks/render.js b/src/hooks/render.js index 1c8c580a..ad5224c3 100644 --- a/src/hooks/render.js +++ b/src/hooks/render.js @@ -21,12 +21,12 @@ export function registerForRenderHooks() { */ function selectTargetInputOnFocus(app, element) { // V13: element is always a plain DOM element - if (!element || typeof element.querySelectorAll !== 'function') { + if (!element || typeof element.querySelectorAll !== "function") { return; } const inputs = element.querySelectorAll("input"); - inputs.forEach(input => { + inputs.forEach((input) => { input.addEventListener("focus", (ev) => { ev.currentTarget.select(); }); diff --git a/src/utils/utils.js b/src/utils/utils.js index 1849eb6e..b7979b64 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -30,7 +30,10 @@ export function enforce(value, message) { * @returns {Canvas} */ export function getCanvas() { - enforce(canvas instanceof foundry.canvas.Canvas && canvas.ready, getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized")); + enforce( + canvas instanceof foundry.canvas.Canvas && canvas.ready, + getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"), + ); return canvas; } diff --git a/templates/sheets/actor/creature-sheet.hbs b/templates/sheets/actor/creature-sheet.hbs index afa35ba0..cfa20a7e 100644 --- a/templates/sheets/actor/creature-sheet.hbs +++ b/templates/sheets/actor/creature-sheet.hbs @@ -12,7 +12,6 @@ SPDX-License-Identifier: MIT {{> systems/ds4/templates/sheets/actor/components/creature-properties.hbs}} {{/systems/ds4/templates/sheets/actor/components/actor-header.hbs}} - {{!-- Sheet Tab Navigation --}}