Skip to content

Commit

Permalink
implement tint-ignore on non-controlled scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
unsoluble committed Nov 2, 2023
1 parent 94030da commit b2b7a12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scripts/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ST_Config.PhaseValues = {
};

// Saving the default core Darkness color for reference.
ST_Config.coreDarknessColor = '2368584';
ST_Config.coreDarknessColor = 2368584;

// Default offset from the Player List window when pinned,
// an Epoch offset for game systems that don't start at midnight,
Expand Down
33 changes: 19 additions & 14 deletions scripts/smalltime-app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,25 @@ Hooks.on('init', () => {
});
});

Hooks.on('canvasInit', () => {
// Start by resetting the Darkness color to the core value.
CONFIG.Canvas.darknessColor = ST_Config.coreDarknessColor;

if (game.modules.get('foundryvtt-simple-calendar')?.active) {
if (game.scenes.viewed.getFlag('smalltime', 'darkness-link')) {
// Set the global Darkness color to the color of the first moon in Simple Calendar, if configured.
// The pSBC function drops the brightness to an appropriate level.
// Ignore if the moon is set to its default color of white.
if (SimpleCalendar.api.getAllMoons()[0].color != '#ffffff') {
const darknessColorFromMoon = Helpers.pSBC(-0.9, SimpleCalendar.api.getAllMoons()[0].color);
CONFIG.Canvas.darknessColor = darknessColorFromMoon;
}
}
}
// Re-draw the canvas with the new Darkness color.
canvas.colorManager.initialize()
});

// Set the initial state for newly rendered scenes.
Hooks.on('canvasReady', () => {
// Account for the extra border art in certain game systems.
Expand Down Expand Up @@ -376,20 +395,6 @@ Hooks.on('canvasReady', () => {
thisScene.setFlag('smalltime', 'player-vis', visDefault);
}

CONFIG.Canvas.darknessColor = ST_Config.coreDarknessColor;

if (game.modules.get('foundryvtt-simple-calendar')?.active) {
if (thisScene.getFlag('smalltime', 'darkness-link')) {
// Set the global Darkness color to the color of the first moon in Simple Calendar, if configured.
// The pSBC function drops the brightness to an appropriate level.
// Ignore if the moon is set to its default color of white.
if (SimpleCalendar.api.getAllMoons()[0].color != '#ffffff') {
const darknessColorFromMoon = Helpers.pSBC(-0.9, SimpleCalendar.api.getAllMoons()[0].color);
CONFIG.Canvas.darknessColor = darknessColorFromMoon;
}
}
}

// Refresh the current scene's Darkness level if it should be linked.
if (thisScene.getFlag('smalltime', 'darkness-link')) {
SmallTimeApp.timeTransition(Helpers.getWorldTimeAsDayTime());
Expand Down

0 comments on commit b2b7a12

Please sign in to comment.