mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-10 14:14:37 +00:00
Add ocean color override to graphics settings (#4269)
## What Adds a **Terrain** section to the graphics settings modal with a color picker and a hex-code text field (paste a `#rrggbb` code) for the **ocean** (deep water) color. ## Details - The picked color sets the *shallow-water base*; the existing per-depth brightness gradient is preserved (deeper water still darkens). - Only deep water is affected — shoreline water and land are untouched. - Follows the same override pattern as every other graphics setting: the default lives in `render-settings.json` (`terrain.oceanColor`), the override is a field in `GraphicsOverrides`, and `applyGraphicsOverrides` copies it into the live `RenderSettings`. - Rebased on #4271 (settings resolved before renderer construction): the terrain texture **bakes the resolved ocean color at construction**, so a saved override shows on load with no special-casing. Terrain is baked into a GPU texture rather than read per-frame, so a *live* change still triggers an explicit `view.rebuildTerrain()`. - Resetting graphics overrides clears it back to the default ocean color. ## Testing Verified live in a headless singleplayer game: - A **saved** ocean override renders green deep-water on load, baked at construction with no settings-change event fired. - A mid-game color change recolors the deep ocean instantly, gradient preserved, shoreline/land untouched. `tsc` and ESLint clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -521,14 +521,18 @@ async function createClientGame(
|
||||
// graphics-override change (covers a theme switch such as colorblind mode).
|
||||
const onGraphicsChanged = (): void => {
|
||||
regenerateRenderSettings();
|
||||
// Terrain is baked into a GPU texture rather than read per-frame, so a
|
||||
// terrain-color override (e.g. ocean) needs an explicit texture rebuild.
|
||||
view.rebuildTerrain();
|
||||
// A graphics override can switch the active theme (e.g. colorblind mode),
|
||||
// so re-theme existing players and re-upload the palette to recolor their
|
||||
// territory fills/borders live.
|
||||
gameView.refreshPlayerColors();
|
||||
webglBuilder.refreshPalette(gameView);
|
||||
};
|
||||
// No initial regenerate needed — the renderer was constructed with the
|
||||
// resolved settings above.
|
||||
// No initial regenerate or terrain rebuild needed — the renderer was
|
||||
// constructed with the resolved settings above, so the terrain texture
|
||||
// already bakes any saved ocean-color override.
|
||||
globalThis.addEventListener(
|
||||
`${USER_SETTINGS_CHANGED_EVENT}:${GRAPHICS_KEY}`,
|
||||
onGraphicsChanged,
|
||||
|
||||
Reference in New Issue
Block a user