Added countdowns UI element

This commit is contained in:
WBHarry 2025-09-14 19:52:28 +02:00
parent 2c51f06f86
commit 3c8116c4dc
11 changed files with 206 additions and 461 deletions

View file

@ -1,4 +1,5 @@
import { DhCountdown } from '../../data/countdowns.mjs';
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -62,7 +63,10 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
async updateSetting(update) {
await this.data.updateSource(update);
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, this.data);
await emitAsGM(GMUpdateEvent.UpdateCountdowns, this.gmSetSetting.bind(this.data), this.data, null, {
refreshType: RefreshType.Countdown
});
this.render();
}
@ -70,6 +74,15 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
this.updateSetting(foundry.utils.expandObject(formData.object));
}
async gmSetSetting(data) {
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, data),
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.Refresh,
data: { refreshType: RefreshType.Countdown }
});
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
}
static #addCountdown() {
this.updateSetting({
[`countdowns.${foundry.utils.randomID()}`]: DhCountdown.defaultCountdown()