Skip to content

Commit

Permalink
fix: move initiative roll to DialogV2
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin9257 committed Oct 19, 2024
1 parent f1b3550 commit 6731fa8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/module/sheets/AbstractTwodsixActorSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,36 +478,38 @@ export abstract class AbstractTwodsixActorSheet extends ActorSheet {

protected async initiativeDialog(dialogData):Promise<any> {
const template = 'systems/twodsix/templates/chat/initiative-dialog.html';

const buttons = {
ok: {
label: game.i18n.localize("TWODSIX.Rolls.Roll"),
icon: '<i class="fa-solid fa-dice"></i>',
callback: (buttonHtml) => {
const buttons = [
{
action: "ok",
label: "TWODSIX.Rolls.Roll",
icon: "fa-solid fa-dice",
callback: (event, button, dialog) => {
const buttonHtml = $(dialog);
dialogData.shouldRoll = true;
dialogData.rollType = buttonHtml.find('[name="rollType"]').val();
dialogData.diceModifier = buttonHtml.find('[name="diceModifier"]').val();
dialogData.rollMode = buttonHtml.find('[name="rollMode"]').val();
dialogData.rollFormula = buttonHtml.find('[name="rollFormula"]').val();
}
},
cancel: {
icon: '<i class="fa-solid fa-xmark"></i>',
label: game.i18n.localize("Cancel"),
{
action: "cancel",
icon: "fa-solid fa-xmark",
label: "Cancel",
callback: () => {
dialogData.shouldRoll = false;
}
},
};
];

const html = await renderTemplate(template, dialogData);
return new Promise<void>((resolve) => {
new Dialog({
title: game.i18n.localize("TWODSIX.Rolls.RollInitiative"),
new foundry.applications.api.DialogV2({
window: {title: "TWODSIX.Rolls.RollInitiative"},
content: html,
buttons: buttons,
default: 'ok',
close: () => {
submit: () => {
resolve();
},
}).render(true);
Expand Down

0 comments on commit 6731fa8

Please sign in to comment.