Implement localization (en only).
This commit is contained in:
parent
2d809c955b
commit
d6ddad67cc
5 changed files with 47 additions and 16 deletions
|
@ -1,5 +1,7 @@
|
|||
// TODO: Rename to something sane.
|
||||
|
||||
import { DS4 } from "../config";
|
||||
|
||||
/**
|
||||
* Provides default values for all arguments the `CheckFactory` expects.
|
||||
*/
|
||||
|
@ -112,13 +114,15 @@ async function askGmModifier(
|
|||
): Promise<GmModifierData> {
|
||||
// Render model interface and return value
|
||||
const usedTemplate = template ?? "systems/ds4/templates/roll/roll-options.hbs";
|
||||
const usedTitle = title ?? game.i18n.localize("DS4.RollDialogDefaultTitle");
|
||||
const templateData = {
|
||||
cssClass: "roll-option",
|
||||
title: title ?? "Roll Options",
|
||||
title: usedTitle,
|
||||
checkTargetValue: targetValue,
|
||||
maxCritSuccess: options.maxCritSuccess ?? defaultCheckOptions.maxCritSuccess,
|
||||
minCritFailure: options.minCritFailure ?? defaultCheckOptions.minCritFailure,
|
||||
rollModes: rollModes,
|
||||
config: DS4,
|
||||
};
|
||||
const renderedHtml = await renderTemplate(usedTemplate, templateData);
|
||||
|
||||
|
@ -126,17 +130,22 @@ async function askGmModifier(
|
|||
const dialogPromise = new Promise<HTMLFormElement>((resolve) => {
|
||||
new Dialog(
|
||||
{
|
||||
title: title ?? "Roll Options",
|
||||
title: usedTitle,
|
||||
close: () => {
|
||||
// Don't do anything
|
||||
},
|
||||
content: renderedHtml,
|
||||
buttons: {
|
||||
ok: {
|
||||
label: "OK",
|
||||
label: game.i18n.localize("DS4.RollDialogOkButton"),
|
||||
callback: (html: HTMLElement | JQuery) => {
|
||||
if (!("jquery" in html)) {
|
||||
throw new Error("Internal Type Error");
|
||||
throw new Error(
|
||||
game.i18n.format("DS4.HtmlTypeError", {
|
||||
exType: "JQuery",
|
||||
realType: "HTMLElement",
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
const innerForm = html[0].querySelector("form");
|
||||
resolve(innerForm);
|
||||
|
@ -144,7 +153,7 @@ async function askGmModifier(
|
|||
},
|
||||
},
|
||||
cancel: {
|
||||
label: "Cancel",
|
||||
label: game.i18n.localize("DS4.RollDialogCancelButton"),
|
||||
callback: () => {
|
||||
// Don't do anything
|
||||
},
|
||||
|
@ -160,7 +169,7 @@ async function askGmModifier(
|
|||
}
|
||||
|
||||
function parseDialogFormData(formData: HTMLFormElement, targetValue: number): GmModifierData {
|
||||
const parsedData = {
|
||||
return {
|
||||
checkTargetValue: parseInt(formData["ctv"]?.value) ?? targetValue,
|
||||
gmModifier: parseInt(formData["gmmod"]?.value) ?? 0,
|
||||
maxCritSuccess: parseInt(formData["maxcoup"]?.value) ?? defaultCheckOptions.maxCritSuccess,
|
||||
|
@ -168,8 +177,6 @@ function parseDialogFormData(formData: HTMLFormElement, targetValue: number): Gm
|
|||
useSlayingDice: false,
|
||||
rollMode: formData["visibility"]?.value ?? defaultCheckOptions.rollMode,
|
||||
};
|
||||
console.log("Data", parsedData);
|
||||
return parsedData;
|
||||
}
|
||||
|
||||
// TODO: Remove unnecessary data step by step
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue