Implement localization (en only).
This commit is contained in:
parent
2d809c955b
commit
d6ddad67cc
5 changed files with 47 additions and 16 deletions
|
@ -115,5 +115,18 @@
|
|||
"DS4.ProfileSpecialCharacteristics": "Special Characteristics",
|
||||
"DS4.WarningManageActiveEffectOnOwnedItem": "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update.",
|
||||
"DS4.ErrorDiceCritOverlap": "There's an overlap between Fumbles and Coups",
|
||||
"DS4.ErrorExplodingRecursionLimitExceeded": "Maximum recursion depth for exploding dice roll exceeded"
|
||||
"DS4.ErrorExplodingRecursionLimitExceeded": "Maximum recursion depth for exploding dice roll exceeded",
|
||||
"DS4.RollDialogDefaultTitle": "Roll Options",
|
||||
"DS4.RollDialogOkButton": "Ok",
|
||||
"DS4.RollDialogCancelButton": "Cancel",
|
||||
"DS4.HtmlTypeError": "Type Error: Expected {exType}, got {realType}",
|
||||
"DS4.RollDialogTargetLabel": "Check Target Number",
|
||||
"DS4.RollDialogModifierLabel": "Game Master Modifier",
|
||||
"DS4.RollDialogCoupLabel": "Coup to",
|
||||
"DS4.RollDialogFumbleLabel": "Fumble from",
|
||||
"DS4.RollDialogVisibilityLabel": "Visibility",
|
||||
"DS4.ChatVisibilityRoll": "All",
|
||||
"DS4.ChatVisibilityGmRoll": "Self & GM",
|
||||
"DS4.ChatVisibilityBlindRoll": "GM only",
|
||||
"DS4.ChatVisibilitySelfRoll": "Self only"
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ export const DS4 = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Define the profile info types for hanndlebars of a character
|
||||
* Define the profile info types for handlebars of a character
|
||||
*/
|
||||
profileDTypes: {
|
||||
gender: "String",
|
||||
|
@ -188,4 +188,14 @@ export const DS4 = {
|
|||
eyeColor: "String",
|
||||
specialCharacteristics: "String",
|
||||
},
|
||||
|
||||
/**
|
||||
* Define localization strings for Chat Visibility
|
||||
*/
|
||||
chatVisibilities: {
|
||||
roll: "DS4.ChatVisibilityRoll",
|
||||
gmroll: "DS4.ChatVisibilityGmRoll",
|
||||
blindroll: "DS4.ChatVisibilityBlindRoll",
|
||||
selfroll: "DS4.ChatVisibilitySelfRoll",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -85,6 +85,7 @@ Hooks.once("setup", function () {
|
|||
"progression",
|
||||
"language",
|
||||
"profile",
|
||||
"chatVisibilities",
|
||||
];
|
||||
|
||||
// Exclude some from sorting where the default order matters
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<form class="{{cssClass}} grid">
|
||||
<label for="ctv">Check Target Value</label>
|
||||
<label for="ctv">{{localize "DS4.RollDialogTargetLabel"}}</label>
|
||||
<input id="ctv" data-type="Number" type="number" name="ctv" value="{{checkTargetValue}}" />
|
||||
<label for="gmmod">Game Master Modifier</label>
|
||||
<label for="gmmod">{{localize "DS4.RollDialogModifierLabel"}}</label>
|
||||
<input id="gmmod" data-type="Number" type="number" name="gmmod" value="0" />
|
||||
<label for="maxcoup">Coup to</label>
|
||||
<label for="maxcoup">{{localize "DS4.RollDialogCoupLabel"}}</label>
|
||||
<input id="maxcoup" data-type="Number" type="number" name="maxcoup" value="{{maxCritSuccess}}" />
|
||||
<label for="minfumble">Fumble from</label>
|
||||
<label for="minfumble">{{localize "DS4.RollDialogFumbleLabel"}}</label>
|
||||
<input id="minfumble" data-type="Number" type="number" name="minfumble" value="{{minCritFailure}}" />
|
||||
<label for="visibility">Visibility</label>
|
||||
<label for="visibility">{{localize "DS4.RollDialogVisibilityLabel"}}</label>
|
||||
<select id="visibility" data-type="String">
|
||||
{{#each rollModes as |rollMode|}}
|
||||
<option value="{{rollMode}}">{{rollMode}}</option>
|
||||
<option value="{{rollMode}}">{{lookup ../config.chatVisibilities rollMode}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue