Calendrier/timestamp, suite

Correction autour des éditeurs/affichages
Migration de la date du monde dans les settings
This commit is contained in:
Vincent Vandemeulebrouck 2023-01-07 20:06:04 +01:00
parent 19b3adc222
commit 739fcbdf09
13 changed files with 136 additions and 182 deletions

View File

@ -1,5 +1,6 @@
import { SYSTEM_RDD } from "./constants.js"; import { SYSTEM_RDD } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { RdDTimestamp } from "./rdd-timestamp.js";
const LATEST_USED_JOURNAL_ID = "chronologie-dernier-journal"; const LATEST_USED_JOURNAL_ID = "chronologie-dernier-journal";
@ -16,16 +17,13 @@ export class DialogChronologie extends Dialog {
}); });
} }
static async create() { static async create() {
const dateRdD = game.system.rdd.calendrier.getCalendrier();
const dialogData = { const dialogData = {
auteur: game.user.name, auteur: game.user.name,
isGM: game.user.isGM, isGM: game.user.isGM,
information: "", information: "",
journalId: game.settings.get(SYSTEM_RDD, LATEST_USED_JOURNAL_ID), journalId: game.settings.get(SYSTEM_RDD, LATEST_USED_JOURNAL_ID),
journaux: game.journal.filter(it => it.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)), journaux: game.journal.filter(it => it.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)),
dateRdD: dateRdD, timestamp: game.system.rdd.calendrier.timestamp,
jourRdD: dateRdD.jour +1,
heureRdD: game.system.rdd.calendrier.heureCourante().key,
dateReel: DialogChronologie.getCurrentDateTime() dateReel: DialogChronologie.getCurrentDateTime()
}; };
const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-chronologie.html", dialogData); const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-chronologie.html", dialogData);
@ -93,11 +91,12 @@ export class DialogChronologie extends Dialog {
auteur: this.html.find("form.rdddialogchrono :input[name='auteur']").val(), auteur: this.html.find("form.rdddialogchrono :input[name='auteur']").val(),
information: this.html.find("form.rdddialogchrono :input[name='information']").val(), information: this.html.find("form.rdddialogchrono :input[name='information']").val(),
dateRdD: { dateRdD: {
jour: this.html.find("form.rdddialogchrono :input[name='jourRdD']").val(), jour: this.html.find("form.rdddialogchrono :input[name='chronologie.jourDuMois']").val(),
moisRdD: this.html.find("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(), mois: RdDTimestamp.definition(this.html.find("form.rdddialogchrono :input[name='chronologie.mois']").val()),
annee: this.html.find("form.rdddialogchrono :input[name='dateRdD.annee']").val() annee: this.html.find("form.rdddialogchrono :input[name='chronologie.annee']").val(),
heure: RdDTimestamp.definition(this.html.find("form.rdddialogchrono :input[name='chronologie.heure']").val()),
minute: this.html.find("form.rdddialogchrono :input[name='chronologie.minute']").val(),
}, },
heureRdD: this.html.find("form.rdddialogchrono :input[name='heureRdD']").val(),
dateReel: this.html.find("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ') dateReel: this.html.find("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ')
} }
} }

View File

@ -3,23 +3,28 @@
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog} * @extends {Dialog}
*/ */
export class RdDAstrologieEditeur extends Dialog { export class RdDAstrologieEditeur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, calendrier, calendrierData) { constructor(html, calendrier, calendrierData) {
let myButtons = { let myButtons = {
resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() }, resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() },
saveButton: { label: "Fermer", callback: html => this.fillData() } saveButton: { label: "Fermer", callback: html => this.fillData() }
}; };
// Common conf // Common conf
let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" }; let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" };
let dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 'fit-content', 'z-index': 99999 } let dialogOptions = {
classes: ["rdd-roll-dialog"], width: 600,
height: 'fit-content',
'max-height': 800,
'z-index': 99999
}
super(dialogConf, dialogOptions) super(dialogConf, dialogOptions)
this.calendrier = calendrier; this.calendrier = calendrier;
this.updateData( calendrierData ); this.updateData(calendrierData);
} }
activateListeners(html) { activateListeners(html) {
@ -37,11 +42,11 @@
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
fillData( ) { fillData() {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
updateData( calendrierData ) { updateData(calendrierData) {
this.calendrierData = duplicate(calendrierData); this.calendrierData = duplicate(calendrierData);
} }

View File

@ -26,40 +26,35 @@ export class RdDCalendrierEditeur extends Dialog {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
this.html.find("input[name='annee']").val(this.calendrierData.annee);
this.html.find("select[name='nomMois']").val(this.calendrierData.moisKey);
this.html.find("input[name='jourMois']").val(this.calendrierData.jourMois);
this.html.find("select[name='nomHeure']").val(this.calendrierData.heureKey);
this.html.find("input[name='minutesRelative']").val(this.calendrierData.minutesRelative);
this.html.find("input[name='jourMois']").change(event => { this.html.find("input[name='calendar.annee']").val(this.calendrierData.annee);
const jour = Number.parseInt(this.html.find("input[name='jourMois']").val()); this.html.find("select[name='calendar.mois']").val(this.calendrierData.mois.key);
if (jour < 1) { this.html.find("select[name='calendar.heure']").val(this.calendrierData.heure.key);
this.html.find("input[name='jourMois']").val(1); RdDCalendrierEditeur.setLimited(this.html.find("input[name='calendar.jourDuMois']"), this.calendrierData.jourDuMois, 1, 28);
RdDCalendrierEditeur.setLimited(this.html.find("input[name='calendar.minute']"), this.calendrierData.minute, 0, 119);
}
static setLimited(input, init, min, max) {
input.val(init);
input.change(event => {
const val = Number.parseInt(input.val());
if (val < min) {
input.val(min);
} }
if (jour > 28) { if (val > max) {
this.html.find("input[name='jourMois']").val(28); input.val(max);
} }
}); });
this.html.find("input[name='minutesRelative']").change(event => {
const minute = Number.parseInt(this.html.find("input[name='minutesRelative']").val());
if (minute < 0) {
this.html.find("input[name='minutesRelative']").val(0);
}
if (minute > 119) {
this.html.find("input[name='minutesRelative']").val(119);
}
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
saveCalendrier() { saveCalendrier() {
const annee = Number.parseInt(this.html.find("input[name='annee']").val()); const annee = Number.parseInt(this.html.find("input[name='calendar.annee']").val());
const mois = this.html.find("select[name='nomMois']").val(); const mois = this.html.find("select[name='calendar.mois']").val();
const jour = Number.parseInt(this.html.find("input[name='jourMois']").val()); const jour = Number.parseInt(this.html.find("input[name='calendar.jourDuMois']").val());
const heure = this.html.find("select[name='nomHeure']").val(); const heure = this.html.find("select[name='calendar.heure']").val();
const minute = Number.parseInt(this.html.find("input[name='minutesRelative']").val()); const minute = Number.parseInt(this.html.find("input[name='calendar.minute']").val());
this.calendrier.setNewTimestamp(RdDTimestamp.timestamp(annee, mois, jour, heure, minute)) this.calendrier.setNewTimestamp(RdDTimestamp.timestamp(annee, mois, jour, heure, minute))
} }

View File

@ -6,15 +6,7 @@ import { RdDDice } from "./rdd-dice.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { DialogChronologie } from "./dialog-chronologie.js"; import { DialogChronologie } from "./dialog-chronologie.js";
import { RdDTimestamp } from "./rdd-timestamp.js"; import { RdDTimestamp, WORLD_TIMESTAMP_SETTING } from "./rdd-timestamp.js";
/* -------------------------------------------- */
const saisonsDef = {
"printemps": { label: "Printemps" },
"ete": { label: "Eté" },
"automne": { label: "Automne" },
"hiver": { label: "Hiver" }
};
const RDD_JOUR_PAR_MOIS = 28; const RDD_JOUR_PAR_MOIS = 28;
const RDD_HEURES_PAR_JOUR = 12; const RDD_HEURES_PAR_JOUR = 12;
@ -45,7 +37,7 @@ export class RdDCalendrier extends Application {
game.settings.set(SYSTEM_RDD, "calendrier-pos", this.calendrierPos); game.settings.set(SYSTEM_RDD, "calendrier-pos", this.calendrierPos);
} }
// Calendrier // Calendrier
this.timestamp = new RdDTimestamp({}); this.timestamp = RdDTimestamp.getWorldTime();
if (Misc.isUniqueConnectedGM()) { // Uniquement si GM if (Misc.isUniqueConnectedGM()) { // Uniquement si GM
RdDTimestamp.setWorldTime(this.timestamp); RdDTimestamp.setWorldTime(this.timestamp);
@ -53,10 +45,14 @@ export class RdDCalendrier extends Application {
this.rebuildListeNombreAstral(HIDE_DICE); // Ensure always up-to-date this.rebuildListeNombreAstral(HIDE_DICE); // Ensure always up-to-date
} }
console.log('RdDCalendrier.constructor()', this.timestamp, this.timestamp.toOldCalendrier(), this.calendrierPos, this.listeNombreAstral); console.log('RdDCalendrier.constructor()', this.timestamp, this.timestamp.toOldCalendrier(), this.calendrierPos, this.listeNombreAstral);
Hooks.on('updateSetting', async (setting, update, options, id) => this.onUpdateSetting(setting, update, options, id));
} }
getCalendrier() { async onUpdateSetting(setting, update, options, id) {
return this.timestamp.toOldCalendrier(); if (setting.key == SYSTEM_RDD + '.' + WORLD_TIMESTAMP_SETTING) {
this.timestamp = RdDTimestamp.getWorldTime();
this.updateDisplay();
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -162,6 +158,7 @@ export class RdDCalendrier extends Application {
} }
isAfterIndexDate(indexDate) { isAfterIndexDate(indexDate) {
// TODO: standardize
return indexDate < this.timestamp.indexDate; return indexDate < this.timestamp.indexDate;
} }
@ -339,12 +336,6 @@ export class RdDCalendrier extends Application {
await this.setNewTimestamp(this.timestamp.nouveauJour()); await this.setNewTimestamp(this.timestamp.nouveauJour());
} }
/* -------------------------------------------- */
syncPlayerTime(timestamp) {
this.timestamp = new RdDTimestamp(timestamp);
this.updateDisplay();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async positionnerHeure(indexHeure) { async positionnerHeure(indexHeure) {
await this.setNewTimestamp(new RdDTimestamp({ indexDate: this.timestamp.indexDate + (this.timestamp.heure < indexHeure ? 0 : 1) }).addHeures(indexHeure)) await this.setNewTimestamp(new RdDTimestamp({ indexDate: this.timestamp.indexDate + (this.timestamp.heure < indexHeure ? 0 : 1) }).addHeures(indexHeure))
@ -355,21 +346,23 @@ export class RdDCalendrier extends Application {
const mois = RdDTimestamp.definition(this.timestamp.mois); const mois = RdDTimestamp.definition(this.timestamp.mois);
const heure = RdDTimestamp.definition(this.timestamp.heure); const heure = RdDTimestamp.definition(this.timestamp.heure);
formData.timestamp = this.timestamp;
formData.annee = this.timestamp.annee; formData.annee = this.timestamp.annee;
formData.mois = mois;
formData.jourDuMois = this.timestamp.jour + 1;
formData.jour = this.timestamp.jour;
formData.heure = heure;
formData.minute = this.timestamp.minute;
formData.moisKey = mois.key; // formData.nomMois = mois.label; // heures et mois nommés identiques
formData.nomMois = mois.label; // heures et mois nommés identiques // formData.iconMois = mois.icon;
formData.iconMois = mois.icon;
formData.nomSaison = saisonsDef[mois.saison].label;
formData.jourMois = this.timestamp.jour + 1; // formData.heureKey = heure.key;
// formData.heureRdD = formData.heure.heure;
// formData.nomHeure = heure.label;
// formData.iconHeure = heure.icon;
formData.heureKey = heure.key; // formData.minutes = this.timestamp.minute;
formData.heureRdD = this.timestamp.heure;
formData.nomHeure = heure.label;
formData.iconHeure = heure.icon;
formData.minutesRelative = this.timestamp.minute;
formData.isGM = game.user.isGM; formData.isGM = game.user.isGM;
@ -509,21 +502,21 @@ export class RdDCalendrier extends Application {
updateDisplay() { updateDisplay() {
let calendrier = this.fillCalendrierData(); let calendrier = this.fillCalendrierData();
// Rebuild text du calendrier // Rebuild text du calendrier
let dateHTML = `${calendrier.jourMois} ${calendrier.nomMois} ${calendrier.annee} (${calendrier.nomSaison})` let dateHTML = `${calendrier.jourDuMois} ${calendrier.mois.label} ${calendrier.annee} (${calendrier.mois.saison})`
if (game.user.isGM) { if (game.user.isGM) {
dateHTML = dateHTML + " - NA: " + (this.getCurrentNombreAstral() ?? "indéterminé"); dateHTML = dateHTML + " - NA: " + (this.getCurrentNombreAstral() ?? "?");
} }
for (let handle of document.getElementsByClassName("calendar-date-rdd")) { for (let handle of document.getElementsByClassName("calendar-date-rdd")) {
handle.innerHTML = dateHTML; handle.innerHTML = dateHTML;
} }
for (let heure of document.getElementsByClassName("calendar-heure-texte")) { for (let heure of document.getElementsByClassName("calendar-heure-texte")) {
heure.innerHTML = calendrier.nomHeure; heure.innerHTML = calendrier.heure.label;
} }
for (const minute of document.getElementsByClassName("calendar-time-disp")) { for (const minute of document.getElementsByClassName("calendar-time-disp")) {
minute.innerHTML = `${calendrier.minutesRelative} minutes`; minute.innerHTML = `${calendrier.minute} minutes`;
} }
for (const heureImg of document.getElementsByClassName("calendar-heure-img")) { for (const heureImg of document.getElementsByClassName("calendar-heure-img")) {
heureImg.src = calendrier.iconHeure; heureImg.src = calendrier.heure.icon;
} }
} }
@ -531,10 +524,10 @@ export class RdDCalendrier extends Application {
async saveEditeur(calendrierData) { async saveEditeur(calendrierData) {
const newTimestamp = RdDTimestamp.timestamp( const newTimestamp = RdDTimestamp.timestamp(
Number.parseInt(calendrierData.annee), Number.parseInt(calendrierData.annee),
RdDTimestamp.definition(calendrierData.moisKey).heure, calendrierData.mois.heure,
Number.parseInt(calendrierData.jourMois), Number.parseInt(calendrierData.jourMois),
RdDTimestamp.definition(calendrierData.heureKey).heure, calendrierData.heure.heure,
Number.parseInt(calendrierData.minutesRelative) Number.parseInt(calendrierData.minutes)
); );
await this.setNewTimestamp(newTimestamp); await this.setNewTimestamp(newTimestamp);
} }

View File

@ -3,6 +3,8 @@ import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
export const WORLD_TIMESTAMP_SETTING = "calendrier";
const RDD_MOIS_PAR_AN = 12; const RDD_MOIS_PAR_AN = 12;
const RDD_JOURS_PAR_MOIS = 28; const RDD_JOURS_PAR_MOIS = 28;
const RDD_JOURS_PAR_AN = 336; //RDD_JOURS_PAR_MOIS * RDD_MOIS_PAR_AN; const RDD_JOURS_PAR_AN = 336; //RDD_JOURS_PAR_MOIS * RDD_MOIS_PAR_AN;
@ -10,21 +12,20 @@ const RDD_HEURES_PAR_JOUR = 12;
const RDD_MINUTES_PAR_HEURES = 120; const RDD_MINUTES_PAR_HEURES = 120;
const RDD_MINUTES_PAR_JOUR = 1440; //RDD_HEURES_PAR_JOUR * RDD_MINUTES_PAR_HEURES; const RDD_MINUTES_PAR_JOUR = 1440; //RDD_HEURES_PAR_JOUR * RDD_MINUTES_PAR_HEURES;
const ROUNDS_PAR_MINUTE = 10; const ROUNDS_PAR_MINUTE = 10;
const CALENDRIER = "calendrier";
const DEFINITION_HEURES = [ const DEFINITION_HEURES = [
{ key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "printemps" }, { key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "Printemps" },
{ key: "sirene", label: "Sirène", lettreFont: 'i', saison: "printemps" }, { key: "sirene", label: "Sirène", lettreFont: 'i', saison: "Printemps" },
{ key: "faucon", label: "Faucon", lettreFont: 'f', saison: "printemps" }, { key: "faucon", label: "Faucon", lettreFont: 'f', saison: "Printemps" },
{ key: "couronne", label: "Couronne", lettreFont: '', saison: "ete" }, { key: "couronne", label: "Couronne", lettreFont: '', saison: "Eté" },
{ key: "dragon", label: "Dragon", lettreFont: 'd', saison: "ete" }, { key: "dragon", label: "Dragon", lettreFont: 'd', saison: "Eté" },
{ key: "epees", label: "Epées", lettreFont: 'e', saison: "ete" }, { key: "epees", label: "Epées", lettreFont: 'e', saison: "Eté" },
{ key: "lyre", label: "Lyre", lettreFont: 'l', saison: "automne" }, { key: "lyre", label: "Lyre", lettreFont: 'l', saison: "Automne" },
{ key: "serpent", label: "Serpent", lettreFont: 's', saison: "automne" }, { key: "serpent", label: "Serpent", lettreFont: 's', saison: "Automne" },
{ key: "poissonacrobate", label: "Poisson Acrobate", lettreFont: 'p', saison: "automne" }, { key: "poissonacrobate", label: "Poisson Acrobate", lettreFont: 'p', saison: "Automne" },
{ key: "araignee", label: "Araignée", lettreFont: 'a', saison: "hiver" }, { key: "araignee", label: "Araignée", lettreFont: 'a', saison: "Hiver" },
{ key: "roseau", label: "Roseau", lettreFont: 'r', saison: "hiver" }, { key: "roseau", label: "Roseau", lettreFont: 'r', saison: "Hiver" },
{ key: "chateaudormant", label: "Château Dormant", lettreFont: 'c', saison: "hiver" }, { key: "chateaudormant", label: "Château Dormant", lettreFont: 'c', saison: "Hiver" },
] ]
const FORMULES_DUREE = [ const FORMULES_DUREE = [
@ -46,11 +47,11 @@ export class RdDTimestamp {
} }
static init() { static init() {
game.settings.register(SYSTEM_RDD, CALENDRIER, { game.settings.register(SYSTEM_RDD, WORLD_TIMESTAMP_SETTING, {
name: CALENDRIER, name: WORLD_TIMESTAMP_SETTING,
scope: "world", scope: "world",
config: false, config: false,
default: { indexJour: 0, heureRdD: 0, minutesRelative: 0 }, default: { indexDate: 0, indexMinute: 0 },
type: Object type: Object
}); });
@ -59,7 +60,6 @@ export class RdDTimestamp {
DEFINITION_HEURES[i].icon = RdDTimestamp.iconeHeure(i); DEFINITION_HEURES[i].icon = RdDTimestamp.iconeHeure(i);
DEFINITION_HEURES[i].webp = DEFINITION_HEURES[i].icon.replace(".svg", ".webp"); DEFINITION_HEURES[i].webp = DEFINITION_HEURES[i].icon.replace(".svg", ".webp");
} }
// TODO: positionner les calculs de FORMULES_DUREE
} }
/** /**
@ -124,6 +124,7 @@ export class RdDTimestamp {
static formatIndexDate(indexDate) { static formatIndexDate(indexDate) {
return new RdDTimestamp({ indexDate }).formatDate() return new RdDTimestamp({ indexDate }).formatDate()
} }
static splitIndexDate(indexDate) { static splitIndexDate(indexDate) {
const timestamp = new RdDTimestamp({ indexDate }); const timestamp = new RdDTimestamp({ indexDate });
return { return {
@ -133,16 +134,21 @@ export class RdDTimestamp {
} }
static getWorldTime() { static getWorldTime() {
return game.settings.get(SYSTEM_RDD, CALENDRIER); let worldTime = game.settings.get(SYSTEM_RDD, WORLD_TIMESTAMP_SETTING);
if (worldTime.indexJour && worldTime.heureRdD) {
// Migration
worldTime = {
indexDate: worldTime.indexJour,
indexMinute: worldTime.heureRdD * 120 + worldTime.minutesRelative
};
RdDTimestamp.setWorldTime(new RdDTimestamp(worldTime))
}
return new RdDTimestamp(worldTime);
} }
static setWorldTime(timestamp) { static setWorldTime(timestamp) {
game.settings.set(SYSTEM_RDD, CALENDRIER, timestamp.toOldCalendrier()); game.settings.set(SYSTEM_RDD, WORLD_TIMESTAMP_SETTING, duplicate(timestamp));
game.socket.emit(SYSTEM_SOCKET_ID, {
msg: "msg_sync_time",
data: duplicate(timestamp)
});
} }
/** construit un RdDTimestamp à partir de l'année/mois/jour/heure?/minute? */ /** construit un RdDTimestamp à partir de l'année/mois/jour/heure?/minute? */
@ -164,16 +170,9 @@ export class RdDTimestamp {
* @param indexMinute: la minute de la journée à utiliser pour ce timestamp * @param indexMinute: la minute de la journée à utiliser pour ce timestamp
* *
*/ */
constructor({ indexDate = undefined, indexMinute = undefined }) { constructor({ indexDate, indexMinute = undefined }) {
function fromSettings() { this.indexDate = indexDate
const fromSettings = RdDTimestamp.getWorldTime(); this.indexMinute = indexMinute ?? 0
return { indexDate: fromSettings.indexJour, indexMinute: fromSettings.heureRdD * RDD_MINUTES_PAR_HEURES + fromSettings.minutesRelative };
}
const val = Number.isInteger(indexDate) ? { indexDate, indexMinute: indexMinute ?? 0 } : fromSettings();
this.indexDate = val.indexDate
this.indexMinute = val.indexMinute
} }
toCalendrier() { toCalendrier() {
@ -182,6 +181,7 @@ export class RdDTimestamp {
annee: this.annee, annee: this.annee,
mois: RdDTimestamp.definition(this.mois), mois: RdDTimestamp.definition(this.mois),
jour: this.jour, jour: this.jour,
jourDuMois: this.jour + 1,
heure: RdDTimestamp.definition(this.heure), heure: RdDTimestamp.definition(this.heure),
minute: this.minute minute: this.minute
}; };
@ -191,7 +191,7 @@ export class RdDTimestamp {
* Convertit un timestamp en donnée utile à l'affichage d'un calendrier * Convertit un timestamp en donnée utile à l'affichage d'un calendrier
*/ */
toOldCalendrier() { toOldCalendrier() {
const calendrier = { return {
indexJour: this.indexDate, indexJour: this.indexDate,
annee: this.annee, annee: this.annee,
moisRdD: this.mois, moisRdD: this.mois,
@ -201,7 +201,6 @@ export class RdDTimestamp {
heureLabel: RdDTimestamp.definition(this.heure).label, heureLabel: RdDTimestamp.definition(this.heure).label,
minutesRelative: this.minute, minutesRelative: this.minute,
}; };
return calendrier
} }
get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) } get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) }
get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) } get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) }

View File

@ -648,8 +648,6 @@ export class RdDUtility {
switch (sockmsg.msg) { switch (sockmsg.msg) {
case "msg_gm_chat_message": case "msg_gm_chat_message":
return ChatUtility.handleGMChatMessage(sockmsg.data); return ChatUtility.handleGMChatMessage(sockmsg.data);
case "msg_sync_time":
return game.system.rdd.calendrier.syncPlayerTime(sockmsg.data);
case "msg_request_nombre_astral": case "msg_request_nombre_astral":
return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data); return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data);
case "msg_response_nombre_astral": case "msg_response_nombre_astral":

View File

@ -478,8 +478,8 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
} }
.img-signe-heure { .img-signe-heure {
vertical-align: bottom; vertical-align: bottom;
max-width: 1.5rem; max-width: 1.5em;
max-height: 1.5rem; max-height: 1.5em;
border-width: 0; border-width: 0;
} }
.button-effect-img { .button-effect-img {

View File

@ -37,6 +37,7 @@
<span class="flex-grow-2"> <span class="flex-grow-2">
|{{#each heuresDef as |ajustement|}} |{{#each heuresDef as |ajustement|}}
<span> <span>
<strong>{{ajustement.ajustement}}</strong>
{{#each ajustement.heures as |heure|}} {{#each ajustement.heures as |heure|}}
{{timestamp-imgSigneHeure heure}} {{timestamp-imgSigneHeure heure}}
{{/each}} {{/each}}

View File

@ -8,37 +8,12 @@
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<div class="flexcol flex-shrink"> {{>"systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs"
<label for="jourMois">Jour</label> (timestamp-extract timestamp)
<input type="number" class="number-x4" name="jourMois" value="{{jourMois}}" data-dtype="Number" min="1" max="28"/> path='calendar'
</div> label='Date courante'
<div class="flexcol"> disabled=''
<label for="nomMois">Mois</label> }}
<select name="nomMois" data-dtype="String">
{{#select nomMois}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}}
</select>
</div>
<div class="flexcol flex-shrink">
<label for="annee">Année</label>
<input type="number" class="number-x4" name="annee" value="{{annee}}" data-dtype="Number" min="0"/>
</div>
</div>
<div class="form-group">
<div class="flexcol">
<label for="nomHeure">Heure</label>
<select name="nomHeure" data-dtype="String">
{{#select nomHeure}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}}
</select>
</div>
<div class="flexcol flex-shrink">
<label for="minutesRelative">Minutes</label>
<input type="number" class="number-x4" name="minutesRelative" value="{{minutesRelative}}" data-dtype="Number" min="0" max="119"/>
</div>
</div> </div>
</section> </section>
</form> </form>

View File

@ -5,7 +5,7 @@
<i class="astrologie-btn-edit fas fa-cog" title="Astrologie"></i> <i class="astrologie-btn-edit fas fa-cog" title="Astrologie"></i>
{{/if}} {{/if}}
<div class="calendar-hdr"> <div class="calendar-hdr">
<p id="calendar-move-handle" class="calendar-date-rdd" title="Deplacer">Jour {{jourMois}} de {{nomMois}} ({{nomSaison}})</p> <p id="calendar-move-handle" class="calendar-date-rdd" title="Deplacer">{{jourDuMois}} {{mois.label}} ({{mois.saison}})</p>
</div> </div>
<div class="calendar-container"> <div class="calendar-container">
{{#if isGM}} {{#if isGM}}
@ -20,15 +20,12 @@
</div> </div>
{{/if}} {{/if}}
<div class="calendar-weekday-time"> <div class="calendar-weekday-time">
{{#if isGM}}
<a class="ajout-chronologie calendar-weekday"> <a class="ajout-chronologie calendar-weekday">
<img class="calendar-heure-img" src="{{iconHeure}}" alt="{{nomHeure}}"/>&nbsp;<span class="calendar-heure-texte">{{nomHeure}}</span> <img class="calendar-heure-img" src="{{heure.icon}}" alt="{{nomHeure}}"/>&nbsp;
</a> <span class="calendar-heure-texte">{{heure.label}}</span>
<p class="calendar-time-disp calendar-time isGM">{{minutesRelative}} minutes</p>
{{else}}
<a class="ajout-chronologie">
<img class="calendar-heure-img" src="{{iconHeure}}" alt="{{nomHeure}}"/>&nbsp;<span class="calendar-heure-texte">{{nomHeure}}</span>
</a> </a>
{{#if isGM}}
<p class="calendar-time-disp calendar-time isGM">{{minute}} minutes</p>
{{/if}} {{/if}}
</div> </div>
{{#if isGM}} {{#if isGM}}

View File

@ -1,4 +1,4 @@
<h2>{{dateRdD.jour}} {{signeHeure 'label' dateRdD.moisRdD}}, an {{dateRdD.annee}} à l'heure de {{signeHeure 'label' heureRdD}}</h2> <h2>{{dateRdD.jour}} {{dateRdD.mois.label}} {{dateRdD.annee}}, à l'heure de {{dateRdD.heure.label}}</h2>
<p>{{information}}</p> <p>{{information}}</p>
<p class="poesie-reference">Par {{auteur}} ({{dateReel}})</p> <p class="poesie-reference">Par {{auteur}} ({{dateReel}})</p>
<hr> <hr>

View File

@ -1,23 +1,27 @@
<div class="flexcol"> <div class="flexcol">
<div class="flexrow"> <div class="flexrow">
<label>{{label}}</label> <label>{{label}}</label>
<input {{#if disabled}}{{disabled}}{{/if}} type="number" class="flex-shrink number-x2" name="{{path}}.jour" value="{{jour}}" data-dtype="Number" min="1" max="28"/> <input {{#if disabled}}{{disabled}}{{/if}}
{{timestamp-imgSigne mois}} class="flex-shrink number-x2"
type="number" data-dtype="Number" min="1" max="28"
name="{{path}}.jourDuMois" value="{{jourDuMois}}" />
<select {{#if disabled}}{{disabled}}{{/if}} name="{{path}}.mois" class="flex-shrink" data-dtype="String"> <select {{#if disabled}}{{disabled}}{{/if}} name="{{path}}.mois" class="flex-shrink" data-dtype="String">
{{#select mois.key}} {{#select mois.key}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}} {{/select}}
</select> </select>
{{timestamp-imgSigne mois}}
<input {{#if disabled}}{{disabled}}{{/if}} type="number" class="number-x2" name="{{path}}.annee" value="{{annee}}" data-dtype="Number"/> <input {{#if disabled}}{{disabled}}{{/if}} type="number" class="number-x2" name="{{path}}.annee" value="{{annee}}" data-dtype="Number"/>
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label>à l'heure de</label> <label>à l'heure de</label>
{{timestamp-imgSigne heure}}
<select {{#if disabled}}{{disabled}}{{/if}} name="{{path}}.heure" class="flex-shrink" data-dtype="String"> <select {{#if disabled}}{{disabled}}{{/if}} name="{{path}}.heure" class="flex-shrink" data-dtype="String">
{{#select heure.key}} {{#select heure.key}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}} {{/select}}
</select> </select>
{{timestamp-imgSigne heure}}
<input {{#if disabled}}{{disabled}}{{/if}} type="number" class="number-x2" name="{{path}}.minute" value="{{minute}}" data-dtype="Number"/> <input {{#if disabled}}{{disabled}}{{/if}} type="number" class="number-x2" name="{{path}}.minute" value="{{minute}}" data-dtype="Number"/>
<label>minutes</label>
</div> </div>
</div> </div>

View File

@ -9,24 +9,12 @@
<textarea autocomplete="off" title="Information" name="information">{{information}}</textarea> <textarea autocomplete="off" title="Information" name="information">{{information}}</textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="heureRdD">Heure</label> {{>"systems/foundryvtt-reve-de-dragon/templates/common/timestamp.hbs"
<select type="text" name="heureRdD" value="{{heureRdD}}" data-dtype="String" /> (timestamp-extract timestamp)
{{#select heureRdD}} path='chronologie'
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}} label='Date en jeu'
{{/select}} disabled=''
</select> }}
</div>
<div class="form-group">
<label for="jourRdD">Date en jeu</label>
<span class="flexrow">
<input type="text" name="jourRdD" value="{{jourRdD}}" data-dtype="Number" min="1" max="28"/>
<select type="text" name="dateRdD.moisRdD.key" value="{{dateRdD.moisRdD.key}}" data-dtype="String" >
{{#select dateRdD.moisRdD.key}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}}
</select>
<input type="text" name="dateRdD.annee" value="{{dateRdD.annee}}" data-dtype="Number" />
</span>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="dateReel">Date réelle</label> <label for="dateReel">Date réelle</label>