From 14e30d7b4114697aa4dec0f23189118edb8d0c92 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Thu, 23 Apr 2026 18:23:51 -0400 Subject: [PATCH] Localize and finish dialog --- lang/en.json | 15 ++++-- .../applications/dialogs/groupRollDialog.mjs | 47 ++++++++++--------- module/data/groupRollData.mjs | 2 +- .../less/dialog/group-roll-dialog/main.less | 23 +++++++-- .../groupRollDialog/initialization.hbs | 17 ++++--- templates/dialogs/groupRollDialog/main.hbs | 8 ++-- .../dialogs/groupRollDialog/parts/member.hbs | 39 +++++++++++---- .../dialogs/groupRollDialog/parts/result.hbs | 10 ++-- 8 files changed, 107 insertions(+), 54 deletions(-) diff --git a/lang/en.json b/lang/en.json index 2efd6d7b..a4f136a7 100755 --- a/lang/en.json +++ b/lang/en.json @@ -759,15 +759,20 @@ } }, "GroupRollSelect": { - "title": "Group Roll", - "aidingCharacters": "Aiding Characters", + "cancelConfirmText": "Are you sure you want to cancel the Group Roll? This will close it for all other players too.", + "cancelConfirmTitle": "Cancel Group Roll", + "initializationTitle": "Character Selection", + "finishGroupRoll": "Finish Group Roll", "leader": "Leader", "leaderRoll": "Leader Roll", + "members": "Members", "openDialogForAll": "Open Dialog For All", + "removeRoll": "Remove Roll", + "resultsHint": "Results will appear when characters roll", + "selectLeaderHint": "Select one Character to be the leader", + "selectParticipantsHint": "Select one Character to be the leader", "startGroupRoll": "Start Group Roll", - "finishGroupRoll": "Finish Group Roll", - "cancelConfirmTitle": "Cancel Group Roll", - "cancelConfirmText": "Are you sure you want to cancel the Group Roll? This will close it for all other players too." + "title": "Group Roll" }, "TokenConfig": { "actorSizeUsed": "Actor size is set, determining the dimensions" diff --git a/module/applications/dialogs/groupRollDialog.mjs b/module/applications/dialogs/groupRollDialog.mjs index 6325795a..df03a061 100644 --- a/module/applications/dialogs/groupRollDialog.mjs +++ b/module/applications/dialogs/groupRollDialog.mjs @@ -146,12 +146,10 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat const leader = this.party.system.groupRoll.leader; partContext.hasRolled = leader?.rollData || - Object.values(this.party.system.groupRoll?.aidingCharacters ?? {}).some( - x => x.successfull !== null - ); + Object.values(this.party.system.groupRoll?.aidingCharacters ?? {}).some(x => x.successful !== null); const { modifierTotal, modifiers } = Object.values(this.party.system.groupRoll.aidingCharacters).reduce( (acc, curr) => { - const modifier = curr.successfull === true ? 1 : curr.successfull === false ? -1 : null; + const modifier = curr.successful === true ? 1 : curr.successful === false ? -1 : null; if (modifier) { acc.modifierTotal += modifier; acc.modifiers.push(modifier); @@ -177,7 +175,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat case 'footer': partContext.canFinishRoll = Boolean(this.party.system.groupRoll.leader?.rollData) && - Object.values(this.party.system.groupRoll.aidingCharacters).every(x => x.successfull !== null); + Object.values(this.party.system.groupRoll.aidingCharacters).every(x => x.successful !== null); break; } @@ -195,6 +193,10 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat const actor = game.actors.get(data.id); const isLeader = data === this.party.system.groupRoll.leader; + const roll = data.roll; + const withTypeSuffix = !roll ? null : roll.isCritical ? 'criticalShort' : roll.withHope ? 'hope' : 'fear'; + const thing = withTypeSuffix ? _loc(`DAGGERHEART.GENERAL.${withTypeSuffix}`) : null; + return { ...data, type: isLeader ? 'leader' : 'aid', @@ -205,7 +207,8 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat key: partId, readyToRoll: Boolean(data.rollChoice), hasRolled: Boolean(data.rollData), - modifier: data.successfull ? 1 : data.successfull === false ? -1 : 0 + modifier: data.successful ? 1 : data.successful === false ? -1 : 0, + withLabelShort: thing ? _loc('DAGGERHEART.GENERAL.withThing', { thing }) : null }; } @@ -298,6 +301,9 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat static #toggleSelectMember(_, button) { const member = this.partyMembers.find(x => x.id === button.dataset.id); member.selected = !member.selected; + if (this.leader?.memberId === member.id) { + this.leader = null; + } this.render(); } @@ -337,11 +343,14 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat } //#endregion - async makeRoll(button, characterData, path) { - const actor = game.actors.find(x => x.id === characterData.id); + /** @this GroupRollDialog */ + static async #makeRoll(_event, button) { + const member = button.closest('[data-member-key]').dataset.memberKey; + const { data, basePath } = this.#getCharacterDataById(member); + const actor = game.actors.find(x => x.id === data.id); if (!actor) return; - const result = await actor.rollTrait(characterData.rollChoice, { + const result = await actor.rollTrait(data.rollChoice, { skips: { createMessage: true, resources: true, @@ -350,34 +359,30 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat }); if (!result) return; + // todo: move logic to actor.rollTrait() or actor.diceRoll() if (!game.modules.get('dice-so-nice')?.active) foundry.audio.AudioHelper.play({ src: CONFIG.sounds.dice }); const rollData = result.messageRoll.toJSON(); delete rollData.options.messageRoll; this.updatePartyData( { - [path]: rollData + [basePath]: { rollData, successful: null } }, this.getUpdatingParts(button) ); } - /** @this GroupRollDialog */ - static async #makeRoll(_event, button) { - const { data, basePath } = this.#getCharacterDataById(button.dataset.member); - this.makeRoll(button, data, `${basePath}.rollData`); - } - /** @this GroupRollDialog */ static async #removeRoll(_event, button) { - const { basePath } = this.#getCharacterDataById(button.dataset.member); + const member = button.closest('[data-member-key]').dataset.memberKey; + const { basePath } = this.#getCharacterDataById(member); this.updatePartyData( { [basePath]: { rollData: null, rollChoice: null, selected: false, - successfull: null + successful: null } }, this.getUpdatingParts(button) @@ -409,11 +414,11 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat static #markSuccessful(_event, button) { const memberKey = button.closest('[data-member-key]').dataset.memberKey; - const previousValue = this.party.system.groupRoll.aidingCharacters[memberKey].successfull; + const previousValue = this.party.system.groupRoll.aidingCharacters[memberKey].successful; const newValue = Boolean(button.dataset.success === 'true'); this.updatePartyData( { - [`system.groupRoll.aidingCharacters.${memberKey}.successfull`]: + [`system.groupRoll.aidingCharacters.${memberKey}.successful`]: previousValue === newValue ? null : newValue }, this.getUpdatingParts(button) @@ -457,7 +462,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat static async #finishRoll() { const totalRoll = this.party.system.groupRoll.leader.roll; for (const character of Object.values(this.party.system.groupRoll.aidingCharacters)) { - totalRoll.terms.push(new foundry.dice.terms.OperatorTerm({ operator: character.successfull ? '+' : '-' })); + totalRoll.terms.push(new foundry.dice.terms.OperatorTerm({ operator: character.successful ? '+' : '-' })); totalRoll.terms.push(new foundry.dice.terms.NumericTerm({ number: 1 })); } diff --git a/module/data/groupRollData.mjs b/module/data/groupRollData.mjs index 78a06b13..10123152 100644 --- a/module/data/groupRollData.mjs +++ b/module/data/groupRollData.mjs @@ -30,7 +30,7 @@ export class CharacterData extends foundry.abstract.DataModel { }), rollData: new fields.JSONField({ nullable: true, initial: null }), selected: new fields.BooleanField({ initial: false }), - successfull: new fields.BooleanField({ nullable: true, initial: null }) + successful: new fields.BooleanField({ nullable: true, initial: null }) }; } diff --git a/styles/less/dialog/group-roll-dialog/main.less b/styles/less/dialog/group-roll-dialog/main.less index d89c61bf..e0742f0c 100644 --- a/styles/less/dialog/group-roll-dialog/main.less +++ b/styles/less/dialog/group-roll-dialog/main.less @@ -78,10 +78,9 @@ align-items: center; justify-content: space-between; gap: 8px; - height: 3.375rem; + min-height: 3.375rem; &.inactive { - opacity: 0.3; pointer-events: none; } @@ -109,10 +108,16 @@ .buttons { display: flex; - flex-direction: column; + flex-direction: row; button { + --button-text-color: var(--color-text-primary); --button-size: 1.5em; padding: 0 var(--spacer-4); + img { + width: 100%; + height: 100%; + object-fit: contain; + } } } @@ -185,7 +190,7 @@ } .buttons { - gap: 2px; + flex-direction: column; button { color: var(--medium-red); &[data-success=true] { @@ -209,6 +214,16 @@ padding: 6px 12px; margin-top: 8px; + &.empty { + color: light-dark(@dark-blue-80, @beige-80); + border-radius: 3px; + justify-content: center; + border: 1px dashed light-dark(@dark-blue-80, @beige-80); + text-align: center; + height: 3.25rem; + font-family: @font-body; + } + .row { display: flex; align-items: center; diff --git a/templates/dialogs/groupRollDialog/initialization.hbs b/templates/dialogs/groupRollDialog/initialization.hbs index fcbbcf95..a01a00bb 100644 --- a/templates/dialogs/groupRollDialog/initialization.hbs +++ b/templates/dialogs/groupRollDialog/initialization.hbs @@ -1,15 +1,15 @@
-

Character Selection

-
Leader
+

{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.initializationTitle"}}

+
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}
-
Select one Character to be the leader
+
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.selectLeaderHint"}}
-
Party Members
-
Select all Characters who will participate in the roll
+
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.members"}}
+
{{"DAGGERHEART.APPLICATIONS.GroupRollSelect.selectParticipantsHint"}}
{{#each memberSelection as |member|}} {{/each}} diff --git a/templates/dialogs/groupRollDialog/main.hbs b/templates/dialogs/groupRollDialog/main.hbs index b1e855fc..6807a7e4 100644 --- a/templates/dialogs/groupRollDialog/main.hbs +++ b/templates/dialogs/groupRollDialog/main.hbs @@ -1,15 +1,15 @@
-

Group Roll

-
Members
+

{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.title"}}

+
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.members"}}
{{#each aidKeys as |key|}}
{{/each}}
-
Leader
+
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}
-
Result
+
{{localize "DAGGERHEART.GENERAL.result.single"}}
\ No newline at end of file diff --git a/templates/dialogs/groupRollDialog/parts/member.hbs b/templates/dialogs/groupRollDialog/parts/member.hbs index 535f9992..9fa4e49c 100644 --- a/templates/dialogs/groupRollDialog/parts/member.hbs +++ b/templates/dialogs/groupRollDialog/parts/member.hbs @@ -1,6 +1,5 @@ {{#with (ifThen (eq partId "leader") leader (lookup members partId))}}
- {{log this}}
{{name}} @@ -12,10 +11,23 @@ {{numberFormat modifier sign=true}} {{/if}} + {{#if isEditable}} +
+ + +
+ {{/if}}
{{else if readyToRoll}}
- Trait + {{localize "DAGGERHEART.CONFIG.RollTypes.trait.name" }} @@ -27,7 +39,7 @@
{{roll.total}} - {{localize "DAGGERHEART.GENERAL.withThing" thing=roll.totalLabel}} + {{withLabelShort}}
- {{#if (and isEditable (ne ../partId "leader"))}} + {{#if (and @root.isGM (ne ../partId "leader"))}}
- - + +
{{/if}}
- {{else if readyToRoll}} - + {{else if (and readyToRoll isEditable)}} + 2d12 {{/if}} diff --git a/templates/dialogs/groupRollDialog/parts/result.hbs b/templates/dialogs/groupRollDialog/parts/result.hbs index 993fbb02..800e9288 100644 --- a/templates/dialogs/groupRollDialog/parts/result.hbs +++ b/templates/dialogs/groupRollDialog/parts/result.hbs @@ -1,15 +1,15 @@ -{{#if hasRolled}} +{{#if (and hasRolled leader.roll)}}
- Leader Roll + {{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leaderRoll"}} {{leader.roll.total}} {{localize "DAGGERHEART.GENERAL.withThing" thing=leader.roll.totalLabel}}
- Modifiers + {{localize "DAGGERHEART.GENERAL.Modifier.plural"}}
{{#each groupRoll.modifiers as |modifier|}} @@ -20,12 +20,12 @@
- Total + {{localize "DAGGERHEART.GENERAL.total"}} {{groupRoll.total}} {{groupRoll.totalLabel}}
{{else}}
- Results will appear when characters roll + {{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.resultsHint"}}
{{/if}} \ No newline at end of file