feat: calendrier impérial et conversions calendaires
- calendrier impérial : fenêtre compacte (260px), affichage date - commande /cal, auto-ouverture paramétrable dans les settings - socket calendarSync : mise à jour temps réel pour les joueurs - config MJ : année, jour (label live), heure:minute, planète - boutons +1 jour et +1 heure (report 24h→jour, 365→1) - conversions : Solomani, Vilani, Zhodani (Olympiade), Aslan, K'Kree, Hiver - formules wiki.travellerrpg.com/Date_Conversion, section repliable - fix: renderChatInput /cal trop large → exact match - fix: fenêtre refermable (onClose nullifie la référence) - fix: socket joueur lit data direct au lieu de readCalendar()
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { formatImperialDate } from './calendarDate.js';
|
||||
|
||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const MODULE_ID = 'mgt2-compendium-amiral-denisov';
|
||||
|
||||
export class CalendarApp extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
static DEFAULT_OPTIONS = {
|
||||
id: 'mgt2-calendar',
|
||||
classes: ['mgt2-calendar'],
|
||||
position: { width: 260, height: 'auto' },
|
||||
window: {
|
||||
icon: 'fas fa-calendar-alt',
|
||||
title: 'Calendrier Impérial',
|
||||
resizable: false,
|
||||
},
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: `modules/${MODULE_ID}/templates/calendar-app.hbs`,
|
||||
root: true,
|
||||
},
|
||||
};
|
||||
|
||||
constructor({ onConfig, onClose } = {}) {
|
||||
super();
|
||||
this._onConfig = onConfig;
|
||||
this._onClose = onClose;
|
||||
this._data = { year: 1116, day: 1, hour: 12, minute: 0, planet: '' };
|
||||
}
|
||||
|
||||
get title() {
|
||||
return 'Calendrier Impérial';
|
||||
}
|
||||
|
||||
async _prepareContext() {
|
||||
return {
|
||||
dateLabel: formatImperialDate(this._data),
|
||||
isGM: game.user?.isGM ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
const html = $(this.element);
|
||||
html.find('.mgt2-cal-config-btn').on('click', () => {
|
||||
this._onConfig?.();
|
||||
});
|
||||
}
|
||||
|
||||
updateDisplay(data) {
|
||||
this._data = { ...this._data, ...data };
|
||||
this.render();
|
||||
}
|
||||
|
||||
close() {
|
||||
this._onConfig = null;
|
||||
this._onClose?.();
|
||||
this._onClose = null;
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user