From 8448bb64ba7fe0b0abb0aae9febf947229d03efa Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Mon, 28 Jul 2025 07:14:16 +0300 Subject: [PATCH 01/10] use DialogV2 for SkillImprovements --- module/sheets/agent-sheet.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index a13f10f..32cc86c 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -214,16 +214,17 @@ export default class DGAgentSheet extends DGActorSheet { }, ); - return Dialog.wait({ + return foundry.applications.api.DialogV2.wait({ content, - title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title"), - default: "apply", - buttons: { - apply: { + window: { title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title") }, + buttons: [ + { + action: "apply", label: game.i18n.localize("DG.Skills.Apply"), - icon: "", - }, - }, + icon: "" + } + ], + default: "apply" }); } From c835eafde15d94553e12e83ceba50611b5e938d1 Mon Sep 17 00:00:00 2001 From: reyzor1991 Date: Mon, 28 Jul 2025 18:41:31 +0300 Subject: [PATCH 02/10] Apply suggestions from code review Co-authored-by: Jalen <72114365+jalensailin@users.noreply.github.com> --- module/sheets/agent-sheet.js | 1 + 1 file changed, 1 insertion(+) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index 32cc86c..f939235 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -219,6 +219,7 @@ export default class DGAgentSheet extends DGActorSheet { window: { title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title") }, buttons: [ { + default: true, action: "apply", label: game.i18n.localize("DG.Skills.Apply"), icon: "" From b349149047392859e8ee9cbf633efc4c4ba7da2e Mon Sep 17 00:00:00 2001 From: reyzor1991 Date: Mon, 28 Jul 2025 18:42:00 +0300 Subject: [PATCH 03/10] Apply suggestions from code review Co-authored-by: Jalen <72114365+jalensailin@users.noreply.github.com> --- module/sheets/agent-sheet.js | 1 - 1 file changed, 1 deletion(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index f939235..2767f11 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -225,7 +225,6 @@ export default class DGAgentSheet extends DGActorSheet { icon: "" } ], - default: "apply" }); } From c2d3634e212cbc4d1cf60baa4e0e654723278455 Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Mon, 28 Jul 2025 19:53:19 +0300 Subject: [PATCH 04/10] fix code style issue --- module/sheets/agent-sheet.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index 2767f11..03e96ae 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -216,14 +216,16 @@ export default class DGAgentSheet extends DGActorSheet { return foundry.applications.api.DialogV2.wait({ content, - window: { title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title") }, + window: { + title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title"), + }, buttons: [ { default: true, action: "apply", label: game.i18n.localize("DG.Skills.Apply"), - icon: "" - } + icon: "", + }, ], }); } From 0f0c76bff5dca342311dbc13e8790f85880e77ef Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Tue, 29 Jul 2025 14:15:53 +0300 Subject: [PATCH 05/10] dialog v2 for roll modification --- css/dialogue.css | 16 +- module/roll/roll.js | 182 +++++++++++-------- templates/dialog/modify-percentile-roll.html | 4 +- 3 files changed, 124 insertions(+), 78 deletions(-) diff --git a/css/dialogue.css b/css/dialogue.css index 552126e..700f773 100644 --- a/css/dialogue.css +++ b/css/dialogue.css @@ -8,9 +8,19 @@ grid-gap: 10px 15px; } -.numeric-label-field { - width: 50px !important; - text-align: center !important; +.plusMinusNumberFieldBox { + + display: flex; + gap: 10px; + + select[name="plusOrMinus"] { + flex: 1; + } + + .numeric-label-field { + flex: 1; + text-align: center !important; + } } .damage-modify-label-grid { diff --git a/module/roll/roll.js b/module/roll/roll.js index a02a969..41121e2 100644 --- a/module/roll/roll.js +++ b/module/roll/roll.js @@ -142,7 +142,9 @@ export class DGPercentileRoll extends DGRoll { customModifierTarget = parseInt( this.actor.system.settings.rolling.defaultPercentileModifier, ); - } catch {} + } catch { + /* empty */ + } } const backingData = { @@ -158,23 +160,31 @@ export class DGPercentileRoll extends DGRoll { "systems/deltagreen/templates/dialog/modify-percentile-roll.html"; const content = await renderTemplate(template, backingData); return new Promise((resolve, reject) => { - new Dialog({ + new foundry.applications.api.DialogV2({ content, - title: DGUtils.localizeWithFallback( - "DG.ModifySkillRollDialogue.Title", - "Modify Roll", - ), - default: "roll", - buttons: { - roll: { + window: { + title: DGUtils.localizeWithFallback( + "DG.ModifySkillRollDialogue.Title", + "Modify Roll", + ), + }, + buttons: [ + { + default: true, + action: "roll", label: DGUtils.localizeWithFallback("DG.Roll.Roll", "Roll"), - callback: (html) => { + callback: (event, button, dialog) => { try { - let targetModifier = html.find("[name='targetModifier']").val(); // this is text as a heads up + let targetModifier = dialog.element.querySelector( + "[name='targetModifier']", + )?.value; // this is text as a heads up - const rollMode = html.find("[name='rollMode']").val(); + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; - const plusMinus = html.find("[name='plusOrMinus']").val(); + const plusMinus = dialog.element.querySelector( + "[name='plusOrMinus']", + )?.value; if ( targetModifier.trim() !== "" && @@ -200,11 +210,13 @@ export class DGPercentileRoll extends DGRoll { } }, }, - roll40Negative: { + { + action: "roll40Negative", label: "-40", - callback: (html) => { + callback: (event, button, dialog) => { try { - const rollMode = html.find("[name='rollMode']").val(); + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; const targetModifier = -40; resolve({ targetModifier, rollMode }); } catch (ex) { @@ -212,11 +224,13 @@ export class DGPercentileRoll extends DGRoll { } }, }, - roll20Negative: { + { + action: "roll20Negative", label: "-20", - callback: (html) => { + callback: (event, button, dialog) => { try { - const rollMode = html.find("[name='rollMode']").val(); + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; const targetModifier = -20; resolve({ targetModifier, rollMode }); } catch (ex) { @@ -224,11 +238,13 @@ export class DGPercentileRoll extends DGRoll { } }, }, - roll20Positive: { + { + action: "roll20Positive", label: "+20", - callback: (html) => { + callback: (event, button, dialog) => { try { - const rollMode = html.find("[name='rollMode']").val(); + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; const targetModifier = 20; resolve({ targetModifier, rollMode }); } catch (ex) { @@ -236,11 +252,13 @@ export class DGPercentileRoll extends DGRoll { } }, }, - roll40Positive: { + { + action: "roll40Positive", label: "+40", - callback: (html) => { + callback: (event, button, dialog) => { try { - const rollMode = html.find("[name='rollMode']").val(); + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; const targetModifier = 40; resolve({ targetModifier, rollMode }); } catch (ex) { @@ -248,7 +266,7 @@ export class DGPercentileRoll extends DGRoll { } }, }, - }, + ], }).render(true); }); } @@ -275,7 +293,7 @@ export class DGPercentileRoll extends DGRoll { this.options.rollMode = "blindroll"; } - let label = this.createLabel(); + const label = this.createLabel(); let resultString = ""; let styleOverride = ""; @@ -288,21 +306,20 @@ export class DGPercentileRoll extends DGRoll { } else { resultString = `${game.i18n.localize("DG.Roll.Success")}`; } + } else if (this.isCritical) { + resultString = `${game.i18n.localize("DG.Roll.CriticalFailure")}`; + resultString = `${resultString.toUpperCase()}`; + styleOverride = "color: red"; } else { - if (this.isCritical) { - resultString = `${game.i18n.localize("DG.Roll.CriticalFailure")}`; - resultString = `${resultString.toUpperCase()}`; - styleOverride = "color: red"; - } else { - resultString = `${game.i18n.localize("DG.Roll.Failure")}`; - } + resultString = `${game.i18n.localize("DG.Roll.Failure")}`; } - const failureMark = !this.isSuccess && this.skillPath - && !foundry.utils.getProperty(this.actor, `${this.skillPath}.failure`) - && game.settings.get(DG.ID, "skillFailure"); + const failureMark = + !this.isSuccess && + this.skillPath && + !foundry.utils.getProperty(this.actor, `${this.skillPath}.failure`) && + game.settings.get(DG.ID, "skillFailure"); - const { renderTemplate } = foundry.applications.handlebars; const html = await renderTemplate( "systems/deltagreen/templates/roll/percentile-roll.hbs", { @@ -310,26 +327,32 @@ export class DGPercentileRoll extends DGRoll { resultString, formula: this.formula, total: this.total, - failureMark - }); + failureMark, + }, + ); - //TODO: add setting for it? + // TODO: add setting for it? if (failureMark) { const keyForUpdate = `${this.skillPath}.failure`; - //TODO: auto-update actor or post icon with manual apply + // TODO: auto-update actor or post icon with manual apply await this.actor.update({ - [keyForUpdate]: true - }) + [keyForUpdate]: true, + }); - return this.toMessage({ flags: { deltagreen: { - rollbacks: { - [keyForUpdate]: false - } - } }, content: html, flavor: label }); - } else { - return this.toMessage({ content: html, flavor: label }); + return this.toMessage({ + flags: { + deltagreen: { + rollbacks: { + [keyForUpdate]: false, + }, + }, + }, + content: html, + flavor: label, + }); } + return this.toMessage({ content: html, flavor: label }); } /** @@ -383,16 +406,21 @@ export class DGPercentileRoll extends DGRoll { * @returns {string} */ createLabel() { - const startOfLabel = game.i18n.localize("DG.Roll.Rolling") - + ` ${this.localizedKey}` - const endOfLabel =`${game.i18n.localize("DG.Roll.Target")} ${this.effectiveTarget}` + const startOfLabel = `${game.i18n.localize("DG.Roll.Rolling")} ${ + this.localizedKey + }`; + const endOfLabel = `${game.i18n.localize("DG.Roll.Target")} ${ + this.effectiveTarget + }`; let label = this.isInhuman - // "Inhuman" stat being rolled. See function for details. - ? `${startOfLabel} [${game.i18n.localize("DG.Roll.Inhuman").toUpperCase()}] ${endOfLabel}` + ? // "Inhuman" stat being rolled. See function for details. + `${startOfLabel} [${game.i18n + .localize("DG.Roll.Inhuman") + .toUpperCase()}] ${endOfLabel}` : `${startOfLabel}
${endOfLabel}%`; - const {isExhausted, exhaustedCheckPenalty} = this.exhausted + const { isExhausted, exhaustedCheckPenalty } = this.exhausted; if (this.modifier || isExhausted) { label += ` (${this.target}%`; @@ -429,7 +457,7 @@ export class DGPercentileRoll extends DGRoll { exhaustedCheckPenalty = -20; } - return {isExhausted, exhaustedCheckPenalty}; + return { isExhausted, exhaustedCheckPenalty }; } /** @@ -510,7 +538,7 @@ export class DGPercentileRoll extends DGRoll { get effectiveTarget() { let target = 1; - let {isExhausted, exhaustedCheckPenalty} = this.exhausted + const { isExhausted, exhaustedCheckPenalty } = this.exhausted; if (!this.target || Number.isNaN(this.target)) { return null; @@ -715,22 +743,30 @@ export class DGDamageRoll extends DGRoll { const content = await renderTemplate(template, backingData); return new Promise((resolve, reject) => { - new Dialog({ + new foundry.applications.api.DialogV2({ content, - title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"), - default: "roll", - buttons: { - roll: { + window: { + title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"), + }, + buttons: [ + { + default: true, label: game.i18n.translations.DG.Roll.Roll, - - callback: (html) => { + action: "roll", + callback: (event, button, dialog) => { try { - const outerModifier = html.find("[name='outerModifier']").val(); // this is text as a heads up - let innerModifier = html.find("[name='innerModifier']").val(); // this is text as a heads up - const modifiedBaseRoll = html - .find("[name='originalFormula']") - .val(); // this is text as a heads up - const rollMode = html.find("[name='targetRollMode']").val(); + const outerModifier = dialog.element.querySelector( + "[name='outerModifier']", + )?.value; // this is text as a heads up + let innerModifier = dialog.element.querySelector( + "[name='innerModifier']", + )?.value; // this is text as a heads up + const modifiedBaseRoll = dialog.element.querySelector( + "[name='originalFormula']", + )?.value; // this is text as a heads up + const rollMode = dialog.element.querySelector( + "[name='targetRollMode']", + )?.value; if (innerModifier.replace(" ", "") === "+0") { innerModifier = ""; @@ -749,7 +785,7 @@ export class DGDamageRoll extends DGRoll { } }, }, - }, + ], }).render(true); }); } diff --git a/templates/dialog/modify-percentile-roll.html b/templates/dialog/modify-percentile-roll.html index c26f997..e4a7e00 100644 --- a/templates/dialog/modify-percentile-roll.html +++ b/templates/dialog/modify-percentile-roll.html @@ -16,8 +16,8 @@ {{localize 'DG.ModifySkillRollDialogue.TargetModifier'}} -
- From 47610808c564f7f7b7129d319e8be8359c09195d Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Fri, 1 Aug 2025 13:18:28 +0300 Subject: [PATCH 06/10] dialog stat parser --- module/other/stat-parser-macro.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/module/other/stat-parser-macro.js b/module/other/stat-parser-macro.js index 10acd86..f413db7 100644 --- a/module/other/stat-parser-macro.js +++ b/module/other/stat-parser-macro.js @@ -656,21 +656,24 @@ async function GetUserInput() {
`; - new Dialog({ - title: "Stat Block Parser", + new foundry.applications.api.DialogV2({ + window: { title: "Stat Block Parser" }, content, - buttons: { - roll: { + buttons: [ + { label: "PARSE", - callback: async (html) => { - const textInput = html.find("[name=parse-input]")[0].value; + action: "roll", + callback: (event, button, dialog) => { + const textInput = + dialog.element.querySelector("[name=parse-input]")?.value; - const actorType = html.find("[name=actor-type]")[0].value; + const actorType = + dialog.element.querySelector("[name=actor-type]")?.value; RegexParseNpcStatBlock(textInput, actorType); }, }, - }, + ], }).render(true); } From 514f2e0929af36ced3960ffdaee887bb54be6b0e Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Fri, 1 Aug 2025 13:28:09 +0300 Subject: [PATCH 07/10] actor dialogs --- module/sheets/base-actor-sheet.js | 109 +++++++++++++++++------------- 1 file changed, 62 insertions(+), 47 deletions(-) diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index cb21676..b100541 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -841,22 +841,25 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { htmlContent += ` `; htmlContent += ``; - new Dialog({ + new foundry.applications.api.DialogV2({ content: htmlContent, - title: - game.i18n.translations.DG?.Skills?.EditTypedOrCustomSkill ?? - "Edit Typed or Custom Skill", - default: "add", - buttons: { - add: { + window: { + title: + game.i18n.translations.DG?.Skills?.EditTypedOrCustomSkill ?? + "Edit Typed or Custom Skill", + }, + buttons: [ + { + default: true, + action: "add", label: game.i18n.translations.DG?.Skills?.EditSkill ?? "Edit Skill", - callback: (btn) => { - const newTypeSkillLabel = btn - .find("[name='new-type-skill-label']") - .val(); - const newTypeSkillGroup = btn - .find("[name='new-type-skill-group']") - .val(); + callback: (event, button, dialog) => { + const newTypeSkillLabel = dialog.element.querySelector( + "[name='new-type-skill-label']", + )?.value; + const newTypeSkillGroup = dialog.element.querySelector( + "[name='new-type-skill-group']", + )?.value; this._updateTypedSkill( targetSkill, newTypeSkillLabel, @@ -864,7 +867,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ); }, }, - }, + ], }).render(true); } @@ -909,26 +912,30 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { htmlContent += ` `; htmlContent += ``; - new Dialog({ + new foundry.applications.api.DialogV2({ content: htmlContent, - title: - game.i18n.translations.DG?.Skills?.AddTypedOrCustomSkill ?? - "Add Typed or Custom Skill", + window: { + title: + game.i18n.translations.DG?.Skills?.AddTypedOrCustomSkill ?? + "Add Typed or Custom Skill", + }, default: "add", - buttons: { - add: { + buttons: [ + { + default: true, + action: "add", label: game.i18n.translations.DG?.Skills?.AddSkill ?? "Add Skill", - callback: (btn) => { - const newTypeSkillLabel = btn - .find("[name='new-type-skill-label']") - .val(); - const newTypeSkillGroup = btn - .find("[name='new-type-skill-group']") - .val(); + callback: (event, button, dialog) => { + const newTypeSkillLabel = dialog.element.querySelector( + "[name='new-type-skill-label']", + )?.value; + const newTypeSkillGroup = dialog.element.querySelector( + "[name='new-type-skill-group']", + )?.value; this._addNewTypedSkill(newTypeSkillLabel, newTypeSkillGroup); }, }, - }, + ], }).render(true); } @@ -1072,20 +1079,24 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ); // Prepare and render dialog with above template. - new Dialog({ + new foundry.applications.api.DialogV2({ content, - title: game.i18n.localize("DG.SpecialTraining.Dialog.Title"), + window: { + title: game.i18n.localize("DG.SpecialTraining.Dialog.Title"), + }, default: "confirm", - buttons: { - confirm: { + buttons: [ + { + default: true, + action: "confirm", label: buttonLabel, - callback: (btn) => { - const specialTrainingLabel = btn - .find("[name='special-training-label']") - .val(); - const specialTrainingAttribute = btn - .find("[name='special-training-skill']") - .val(); + callback: (event, button, dialog) => { + const specialTrainingLabel = dialog.element.querySelector( + "[name='special-training-label']", + )?.value; + const specialTrainingAttribute = dialog.element.querySelector( + "[name='special-training-skill']", + )?.value; if (action === "create") this._createSpecialTraining( specialTrainingLabel, @@ -1099,7 +1110,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ); }, }, - }, + ], }).render(true); } @@ -1262,17 +1273,21 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { const { packType } = target.dataset; switch (packType) { case "weapon": { - new Dialog({ - title: "Select Compendium", - buttons: { - firearms: { + new foundry.applications.api.DialogV2({ + window: { title: "Select Compendium" }, + buttons: [ + { + action: "firearms", + label: "Firearms", icon: '', callback: () => game.packs .find((k) => k.collection === "deltagreen.firearms") .render(true), }, - melee: { + { + action: "melee", + label: "Melee", icon: '', callback: () => game.packs @@ -1281,7 +1296,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ) .render(true), }, - }, + ], }).render(true); break; } From 9579b00fb1e8890304146af83ee44fca2c73f077 Mon Sep 17 00:00:00 2001 From: reyzor1991 Date: Mon, 4 Aug 2025 23:31:45 +0300 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Jalen <72114365+jalensailin@users.noreply.github.com> --- templates/dialog/modify-percentile-roll.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/dialog/modify-percentile-roll.html b/templates/dialog/modify-percentile-roll.html index e4a7e00..8df5c75 100644 --- a/templates/dialog/modify-percentile-roll.html +++ b/templates/dialog/modify-percentile-roll.html @@ -17,7 +17,7 @@ {{localize 'DG.ModifySkillRollDialogue.TargetModifier'}}
- From 7388eb039512c5c5ed073b421ba7aa9f69dd865f Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Mon, 4 Aug 2025 23:42:50 +0300 Subject: [PATCH 09/10] change bts to generated by code --- module/roll/roll.js | 74 +++++++++++---------------------------------- 1 file changed, 18 insertions(+), 56 deletions(-) diff --git a/module/roll/roll.js b/module/roll/roll.js index 41121e2..d700525 100644 --- a/module/roll/roll.js +++ b/module/roll/roll.js @@ -160,6 +160,23 @@ export class DGPercentileRoll extends DGRoll { "systems/deltagreen/templates/dialog/modify-percentile-roll.html"; const content = await renderTemplate(template, backingData); return new Promise((resolve, reject) => { + const modButtons = [-40, -20, 20, 40].map((mod) => { + const sign = mod > 0 ? "Positive" : "Negative"; + return { + action: `roll${Math.abs(mod)}${sign}`, + label: String(mod), + callback: (event, button, dialog) => { + try { + const rollMode = + dialog.element.querySelector("[name='rollMode']")?.value; + resolve({ targetModifier: mod, rollMode }); + } catch (ex) { + reject(console.log(ex)); + } + }, + }; + }); + new foundry.applications.api.DialogV2({ content, window: { @@ -210,62 +227,7 @@ export class DGPercentileRoll extends DGRoll { } }, }, - { - action: "roll40Negative", - label: "-40", - callback: (event, button, dialog) => { - try { - const rollMode = - dialog.element.querySelector("[name='rollMode']")?.value; - const targetModifier = -40; - resolve({ targetModifier, rollMode }); - } catch (ex) { - reject(console.log(ex)); - } - }, - }, - { - action: "roll20Negative", - label: "-20", - callback: (event, button, dialog) => { - try { - const rollMode = - dialog.element.querySelector("[name='rollMode']")?.value; - const targetModifier = -20; - resolve({ targetModifier, rollMode }); - } catch (ex) { - reject(console.log(ex)); - } - }, - }, - { - action: "roll20Positive", - label: "+20", - callback: (event, button, dialog) => { - try { - const rollMode = - dialog.element.querySelector("[name='rollMode']")?.value; - const targetModifier = 20; - resolve({ targetModifier, rollMode }); - } catch (ex) { - reject(console.log(ex)); - } - }, - }, - { - action: "roll40Positive", - label: "+40", - callback: (event, button, dialog) => { - try { - const rollMode = - dialog.element.querySelector("[name='rollMode']")?.value; - const targetModifier = 40; - resolve({ targetModifier, rollMode }); - } catch (ex) { - reject(console.log(ex)); - } - }, - }, + ...modButtons, ], }).render(true); }); From ed6141e8789df653328105111ab5d3add19e0b9d Mon Sep 17 00:00:00 2001 From: Mykhailo Budiakov Date: Tue, 5 Aug 2025 20:56:27 +0300 Subject: [PATCH 10/10] add localization for weapon types add const for dialogv2 --- lang/en.json | 2 ++ module/roll/roll.js | 5 +++-- module/sheets/base-actor-sheet.js | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lang/en.json b/lang/en.json index fc65894..7594682 100644 --- a/lang/en.json +++ b/lang/en.json @@ -192,6 +192,8 @@ "DG.Mental.Motivations": "Motivation", "DG.Mental.Disorders": "Disorder", + "DG.Gear.WeaponTypes.Firearms": "Firearms", + "DG.Gear.WeaponTypes.Melee": "Melee", "DG.Gear.Weapons": "WEAPONS", "DG.Gear.Armor": "ARMOR", "DG.Gear.OtherGear": "OTHER GEAR", diff --git a/module/roll/roll.js b/module/roll/roll.js index d700525..af59a02 100644 --- a/module/roll/roll.js +++ b/module/roll/roll.js @@ -3,6 +3,7 @@ import DGUtils from "../other/utility-functions.js"; import DG from "../config.js"; const { renderTemplate } = foundry.applications.handlebars; +const { DialogV2 } = foundry.applications.api; export class DGRoll extends Roll { /** @@ -177,7 +178,7 @@ export class DGPercentileRoll extends DGRoll { }; }); - new foundry.applications.api.DialogV2({ + new DialogV2({ content, window: { title: DGUtils.localizeWithFallback( @@ -705,7 +706,7 @@ export class DGDamageRoll extends DGRoll { const content = await renderTemplate(template, backingData); return new Promise((resolve, reject) => { - new foundry.applications.api.DialogV2({ + new DialogV2({ content, window: { title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"), diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index b100541..0213bfa 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -8,6 +8,7 @@ import { import DGSheetMixin from "./base-sheet.js"; const { ActorSheetV2 } = foundry.applications.sheets; +const { DialogV2 } = foundry.applications.api; export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { /** @override */ @@ -841,7 +842,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { htmlContent += ` `; htmlContent += `
`; - new foundry.applications.api.DialogV2({ + new DialogV2({ content: htmlContent, window: { title: @@ -912,7 +913,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { htmlContent += ` `; htmlContent += ``; - new foundry.applications.api.DialogV2({ + new DialogV2({ content: htmlContent, window: { title: @@ -1079,7 +1080,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { ); // Prepare and render dialog with above template. - new foundry.applications.api.DialogV2({ + new DialogV2({ content, window: { title: game.i18n.localize("DG.SpecialTraining.Dialog.Title"), @@ -1273,12 +1274,12 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { const { packType } = target.dataset; switch (packType) { case "weapon": { - new foundry.applications.api.DialogV2({ + new DialogV2({ window: { title: "Select Compendium" }, buttons: [ { action: "firearms", - label: "Firearms", + label: game.i18n.localize("DG.Gear.WeaponTypes.Firearms"), icon: '', callback: () => game.packs @@ -1287,7 +1288,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { }, { action: "melee", - label: "Melee", + label: game.i18n.localize("DG.Gear.WeaponTypes.Melee"), icon: '', callback: () => game.packs