Ajustement de luminosité automatique
Activable par le MJ avec le bouton lumière du calendrier
This commit is contained in:
@ -5,10 +5,11 @@ import { RdDUtility } from "../rdd-utility.js";
|
||||
import { RdDDice } from "../rdd-dice.js";
|
||||
import { Misc } from "../misc.js";
|
||||
import { DialogChronologie } from "../dialog-chronologie.js";
|
||||
import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "../constants.js";
|
||||
import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "../constants.js";
|
||||
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
|
||||
import { DialogChateauDormant } from "../sommeil/dialog-chateau-dormant.js";
|
||||
import { APP_ASTROLOGIE_REFRESH, AppAstrologie } from "../sommeil/app-astrologie.js";
|
||||
import { AutoAdjustDarkness } from "./auto-adjust-darkness.js";
|
||||
|
||||
const TEMPLATE_CALENDRIER = "systems/foundryvtt-reve-de-dragon/templates/time/calendar.hbs";
|
||||
|
||||
@ -51,7 +52,7 @@ export class RdDCalendrier extends Application {
|
||||
if (Misc.isUniqueConnectedGM()) { // Uniquement si GM
|
||||
RdDTimestamp.setWorldTime(this.timestamp);
|
||||
this.nombresAstraux = this.getNombresAstraux();
|
||||
this.rebuildNombresAstraux(HIDE_DICE); // Ensure always up-to-date
|
||||
this.rebuildNombresAstraux(); // Ensure always up-to-date
|
||||
}
|
||||
Hooks.on('updateSetting', async (setting, update, options, id) => this.onUpdateSetting(setting, update, options, id));
|
||||
}
|
||||
@ -84,26 +85,20 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
display() {
|
||||
AutoAdjustDarkness.adjust(RdDTimestamp.getWorldTime().darkness);
|
||||
const pos = this.getSavePosition()
|
||||
this.render(true, { left: pos.left, top: pos.top });
|
||||
return this;
|
||||
}
|
||||
|
||||
_getHeaderButtons() {
|
||||
const buttons = [];
|
||||
if (game.user.isGM) {
|
||||
buttons.unshift({
|
||||
class: "calendar-astrologie",
|
||||
icon: "fa-solid fa-moon-over-sun",
|
||||
onclick: ev => this.showAstrologieEditor()
|
||||
},
|
||||
{
|
||||
class: "calendar-set-datetime",
|
||||
icon: "fa-solid fa-calendar-pen",
|
||||
onclick: ev => this.showCalendarEditor()
|
||||
});
|
||||
return [
|
||||
{ class: "calendar-astrologie", icon: "fa-solid fa-moon-over-sun", onclick: ev => this.showAstrologieEditor() },
|
||||
{ class: "calendar-set-datetime", icon: "fa-solid fa-calendar-pen", onclick: ev => this.showCalendarEditor() },
|
||||
]
|
||||
}
|
||||
return buttons
|
||||
return []
|
||||
}
|
||||
|
||||
async close() { }
|
||||
@ -129,6 +124,7 @@ export class RdDCalendrier extends Application {
|
||||
formData.isGM = game.user.isGM;
|
||||
formData.heures = RdDTimestamp.definitions()
|
||||
formData.horlogeAnalogique = this.horlogeAnalogique;
|
||||
formData.autoDarkness = AutoAdjustDarkness.isAuto()
|
||||
return formData;
|
||||
}
|
||||
|
||||
@ -139,6 +135,7 @@ export class RdDCalendrier extends Application {
|
||||
this.html = html;
|
||||
this.html.find('.ajout-chronologie').click(ev => DialogChronologie.create());
|
||||
this.html.find('.toggle-horloge-analogique').click(ev => this.onToggleHorlogeAnalogique())
|
||||
this.html.find('.toggle-auto-darkness').click(ev => this.onToggleAutoDarkness())
|
||||
this.html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
|
||||
this.html.find('.horloge-roue .horloge-heure').click(event => {
|
||||
const h = this.html.find(event.currentTarget)?.data('heure');
|
||||
@ -224,15 +221,8 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ajouterNombreAstral(indexDate, showDice = SHOW_DICE) {
|
||||
const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: showDice, rollMode: "selfroll" });
|
||||
const dateFuture = RdDTimestamp.formatIndexDate(indexDate);
|
||||
if (showDice != HIDE_DICE) {
|
||||
ChatMessage.create({
|
||||
whisper: ChatMessage.getWhisperRecipients("GM"),
|
||||
content: `Le chiffre astrologique du ${dateFuture} sera le ${nombreAstral}`
|
||||
});
|
||||
}
|
||||
async ajouterNombreAstral(indexDate) {
|
||||
const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: HIDE_DICE, rollMode: "selfroll" });
|
||||
return {
|
||||
nombreAstral: nombreAstral,
|
||||
valeursFausses: [],
|
||||
@ -267,9 +257,8 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rebuildNombresAstraux(showDice = HIDE_DICE) {
|
||||
async rebuildNombresAstraux() {
|
||||
if (Misc.isUniqueConnectedGM()) {
|
||||
console.log("Astral rebuild")
|
||||
let newList = [];
|
||||
for (let i = 0; i < MAX_NOMBRE_ASTRAL; i++) {
|
||||
let dayIndex = this.timestamp.indexDate + i;
|
||||
@ -277,7 +266,7 @@ export class RdDCalendrier extends Application {
|
||||
if (na) {
|
||||
newList[i] = na;
|
||||
} else {
|
||||
newList[i] = await this.ajouterNombreAstral(dayIndex, showDice);
|
||||
newList[i] = await this.ajouterNombreAstral(dayIndex);
|
||||
}
|
||||
}
|
||||
this.nombresAstraux = newList;
|
||||
@ -447,4 +436,9 @@ export class RdDCalendrier extends Application {
|
||||
async showAstrologieEditor() {
|
||||
await AppAstrologie.create();
|
||||
}
|
||||
|
||||
async onToggleAutoDarkness() {
|
||||
await AutoAdjustDarkness.toggle()
|
||||
this.display()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user