Ajustement de luminosité automatique
Activable par le MJ avec le bouton lumière du calendrier
This commit is contained in:
34
module/time/auto-adjust-darkness.js
Normal file
34
module/time/auto-adjust-darkness.js
Normal file
@ -0,0 +1,34 @@
|
||||
import { SYSTEM_RDD } from "../constants.js";
|
||||
|
||||
export const AUTO_ADJUST_DARKNESS = "auto-adjust-darkness";
|
||||
|
||||
export class AutoAdjustDarkness {
|
||||
|
||||
static init() {
|
||||
game.settings.register(SYSTEM_RDD, AUTO_ADJUST_DARKNESS, {
|
||||
name: AUTO_ADJUST_DARKNESS,
|
||||
scope: "world",
|
||||
config: false,
|
||||
default: true,
|
||||
type: Boolean
|
||||
});
|
||||
}
|
||||
|
||||
static async adjust(darkness) {
|
||||
if (AutoAdjustDarkness.isAuto()) {
|
||||
const scene = game.scenes.viewed;
|
||||
if (scene.globalLight && scene.tokenVision) {
|
||||
await scene.update({ darkness });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static isAuto() {
|
||||
return game.settings.get(SYSTEM_RDD, AUTO_ADJUST_DARKNESS);
|
||||
}
|
||||
|
||||
static async toggle() {
|
||||
const previous = AutoAdjustDarkness.isAuto();
|
||||
await game.settings.set(SYSTEM_RDD, AUTO_ADJUST_DARKNESS, !previous)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user