mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-17 05:34:37 +00:00
Update & refactor dark mode (#4114)
## Description: - The renderer no longer knows what "dark mode" is. `RenderSettings.dayNight.mode` (`"light" | "dark"`) is gone — passes read neutral values (`lighting.ambient: number`, `lighting.enabled: boolean`). - `render-settings.json` holds the light-mode baseline. Dark mode is just another override layer, applied the same way as graphics settings (`darkNames`, `classicIcons`, etc.). - New `src/client/render/gl/RenderOverrides.ts` exposes two in-place mutators with matching shapes: - `applyGraphicsOverrides(settings, overrides)` — replaces the old `generateRenderSettings` - `applyDarkModeOverride(settings, isDark)` - `ClientGameRunner` regenerates the live settings each time the user setting changes via `deepAssign(live, createRenderSettings())` + the override chain. No per-slice copy list, no intermediate object — adding a new override that touches a new section just works. - Renamed `dayNight` → `lighting`; collapsed `nightAmbient`/`dayAmbient` into single `ambient`; renamed `enableLightCompositing` → `enabled`. - Bumped dark-mode ambient from 0.15 → 0.35 so terrain stays readable. <img width="1250" height="846" alt="Screenshot 2026-06-02 at 11 47 28 AM" src="https://github.com/user-attachments/assets/b41e8ffb-6011-4ba0-9e1f-c2a21ff90794" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { GraphicsOverrides } from "./GraphicsOverrides";
|
||||
import defaults from "./render-settings.json";
|
||||
|
||||
export interface RenderSettings {
|
||||
@@ -47,10 +46,9 @@ export interface RenderSettings {
|
||||
particleStrength: number;
|
||||
particleFreshScale: number;
|
||||
};
|
||||
dayNight: {
|
||||
mode: "light" | "dark";
|
||||
nightAmbient: number;
|
||||
dayAmbient: number;
|
||||
lighting: {
|
||||
ambient: number;
|
||||
enabled: boolean;
|
||||
falloffPower: number;
|
||||
falloutLightR: number;
|
||||
falloutLightG: number;
|
||||
@@ -296,46 +294,6 @@ export function createRenderSettings(): RenderSettings {
|
||||
return JSON.parse(JSON.stringify(defaults)) as RenderSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a fresh RenderSettings by layering user overrides on top of the
|
||||
* render-settings.json defaults. Pure — does not mutate any input.
|
||||
*/
|
||||
export function generateRenderSettings(
|
||||
overrides: GraphicsOverrides,
|
||||
): RenderSettings {
|
||||
const settings = createRenderSettings();
|
||||
if (overrides.name?.nameScaleFactor !== undefined) {
|
||||
settings.name.nameScaleFactor = overrides.name.nameScaleFactor;
|
||||
}
|
||||
if (overrides.name?.cullThreshold !== undefined) {
|
||||
settings.name.cullThreshold = overrides.name.cullThreshold;
|
||||
}
|
||||
if (overrides.structure?.classicIcons === true) {
|
||||
// Classic look: lighter player-colored shape behind a dark icon glyph,
|
||||
// with a touch of translucency.
|
||||
settings.structure.borderDarken = 0.7;
|
||||
settings.structure.fillDarken = 1.0;
|
||||
settings.structure.iconR = 0;
|
||||
settings.structure.iconG = 0;
|
||||
settings.structure.iconB = 0;
|
||||
settings.structure.iconAlpha = 0.75;
|
||||
}
|
||||
if (overrides.name?.darkNames !== undefined) {
|
||||
const dark = overrides.name.darkNames;
|
||||
// Dark: black fill + player-colored outline. Force outline RGB to black
|
||||
// so the shader's defaultFill ramp (mix(uOutlineColor, black, fillT))
|
||||
// collapses to pure black regardless of ambient.
|
||||
// Colored: player-colored fill + white outline (defaults from JSON).
|
||||
settings.name.fillUsePlayerColor = !dark;
|
||||
settings.name.outlineUsePlayerColor = dark;
|
||||
const channel = dark ? 0 : 1;
|
||||
settings.name.outlineR = channel;
|
||||
settings.name.outlineG = channel;
|
||||
settings.name.outlineB = channel;
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
/** Dump current settings to a downloadable JSON file. */
|
||||
export function dumpSettings(settings: RenderSettings): void {
|
||||
const json = JSON.stringify(settings, null, 2);
|
||||
|
||||
Reference in New Issue
Block a user