feat: improve the advance ticks dialog
This commit is contained in:
parent
9a9bff08c0
commit
f88a2a853a
3 changed files with 23 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"TICKWERK.AdvanceTicks": "Auf der Tickleiste Vorrücken",
|
||||
"TICKWERK.NumberOfTicks": "Anzahl an Ticks",
|
||||
"TICKWERK.StopWaiting": "Abwarten Beenden",
|
||||
"TICKWERK.Tick": "Tick",
|
||||
"TICKWERK.Wait": "Abwarten",
|
||||
|
@ -7,5 +8,6 @@
|
|||
"TICKWERK.WarningCannotAdvanceWhileWaiting": "Während des Abwartens ist es nicht möglich, auf der Tickleiste vorzurücken.",
|
||||
"TICKWERK.WarningCannotAdvanceWithoutStartedCombat": "Solange der Kampf nicht gestartet ist es nicht möglich, auf der Tickleiste vorzurücken.",
|
||||
"TICKWERK.WarningCannotAdvanceWithoutTickValue": "Ohne Tickwert ist es nicht möglich, auf der Tickleiste vorzurücken.",
|
||||
"TICKWERK.WarningCannotStartCombat": "Der Kampf kann nur begonnen werden, wenn mindestens ein Kampfteilnehmer einen Tickwert hat."
|
||||
"TICKWERK.WarningCannotStartCombat": "Der Kampf kann nur begonnen werden, wenn mindestens ein Kampfteilnehmer einen Tickwert hat.",
|
||||
"TICKWERK.WarningInvalidNumberOfTicks": "Bitte gib eine valide Anzahl an Ticks ein."
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"TICKWERK.AdvanceTicks": "Advance on the Tickbar",
|
||||
"TICKWERK.NumberOfTicks": "Number of Ticks",
|
||||
"TICKWERK.StopWaiting": "Stop Waiting",
|
||||
"TICKWERK.Tick": "Tick",
|
||||
"TICKWERK.Wait": "Wait",
|
||||
|
@ -7,5 +8,6 @@
|
|||
"TICKWERK.WarningCannotAdvanceWhileWaiting": "Cannot advance while waiting.",
|
||||
"TICKWERK.WarningCannotAdvanceWithoutStartedCombat": "Cannot advance without the combat being started.",
|
||||
"TICKWERK.WarningCannotAdvanceWithoutTickValue": "Cannot advance without having a tick value.",
|
||||
"TICKWERK.WarningCannotStartCombat": "In order to start the combat, there needs to be at least one combatant with a tick value."
|
||||
"TICKWERK.WarningCannotStartCombat": "In order to start the combat, there needs to be at least one combatant with a tick value.",
|
||||
"TICKWERK.WarningInvalidNumberOfTicks": "Please enter a valid number of ticks."
|
||||
}
|
||||
|
|
|
@ -65,19 +65,30 @@ const CombatantMixin = (BaseCombatant: typeof Combatant) => {
|
|||
|
||||
async advanceTicksDialog(): Promise<void> {
|
||||
const game = getGame();
|
||||
const id = foundry.utils.randomID();
|
||||
|
||||
const ticks = await Dialog.prompt({
|
||||
const form = `<form><div class="form-group">
|
||||
<label for="ticks-${id}">${game.i18n.localize('TICKWERK.NumberOfTicks')}</label>
|
||||
<input id="ticks-${id}" name="ticks" type="number" value="5" min="0" required />
|
||||
</div></form>`;
|
||||
|
||||
const ticks = await Dialog.confirm({
|
||||
title: game.i18n.localize('TICKWERK.AdvanceTicks'),
|
||||
content: '<input name="ticks" type="number" value="5" min="0" />',
|
||||
label: game.i18n.localize('TICKWERK.AdvanceTicks'),
|
||||
callback: (html) => {
|
||||
content: form,
|
||||
yes: (html) => {
|
||||
const ticks = html[0]?.querySelector<HTMLInputElement>('input[name="ticks"]')?.value;
|
||||
return ticks !== undefined ? parseInt(ticks) : undefined;
|
||||
const parsedTicks = ticks !== undefined ? parseInt(ticks) : undefined;
|
||||
return Number.isSafeInteger(parsedTicks) ? parsedTicks : undefined;
|
||||
},
|
||||
rejectClose: false,
|
||||
});
|
||||
|
||||
if (ticks !== undefined && ticks !== null) {
|
||||
if (ticks === undefined) {
|
||||
ui.notifications?.warn('TICKWERK.WarningInvalidNumberOfTicks', { localize: true });
|
||||
return;
|
||||
}
|
||||
|
||||
if (ticks !== null && ticks !== false) {
|
||||
await this.advanceTicks(ticks);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue