From e938e5936b9959dff6edcd57af41dd09ae12ab44 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 28 May 2026 13:54:05 -0700 Subject: [PATCH] Add Graphics Settings name color toggle and unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a single "Name color" toggle (Colored / Black) to the Graphics Settings modal, backed by a `darkNames` boolean in the override schema that derives the five underlying name-rendering fields (fill/outline player-color flags + static outline RGB). Forcing the outline RGB to 0 in dark mode is what makes the shader's defaultFill ramp actually render black — flipping the boolean uniforms alone wasn't enough because the fill is derived from uOutlineColor when fillUsePlayerColor is false. Flips the render-settings.json defaults so black names are the renderer baseline; the modal's no-override state follows the JSON source of truth. Adds tests covering schema parse behavior and the generateRenderSettings derivation for each override field. --- resources/lang/en.json | 4 + .../hud/layers/GraphicsSettingsModal.ts | 31 +++++ src/client/render/gl/GraphicsOverrides.ts | 1 + src/client/render/gl/RenderSettings.ts | 13 ++ src/client/render/gl/render-settings.json | 10 +- tests/GraphicsOverrides.test.ts | 120 ++++++++++++++++++ 6 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 tests/GraphicsOverrides.test.ts diff --git a/resources/lang/en.json b/resources/lang/en.json index da3ae5706..afc4e8bf0 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -923,6 +923,10 @@ "name_scale_label": "Name Scale", "name_cull_label": "Minimum name size", "name_cull_desc": "Hide names smaller than this size", + "colored_names_label": "Name color", + "colored_names_desc": "Show player names in their player color or in black", + "colored": "Colored", + "black": "Black", "reset_label": "Reset to defaults", "reset_desc": "Clear all graphics overrides" }, diff --git a/src/client/hud/layers/GraphicsSettingsModal.ts b/src/client/hud/layers/GraphicsSettingsModal.ts index 969691edb..7219e0dde 100644 --- a/src/client/hud/layers/GraphicsSettingsModal.ts +++ b/src/client/hud/layers/GraphicsSettingsModal.ts @@ -137,6 +137,17 @@ export class GraphicsSettingsModal extends LitElement implements Controller { this.patchName({ cullThreshold: value }); } + private currentDarkNames(): boolean { + return ( + this.userSettings.graphicsOverrides().name?.darkNames ?? + !renderDefaults.name.fillUsePlayerColor + ); + } + + private onToggleNamesColored() { + this.patchName({ darkNames: !this.currentDarkNames() }); + } + private onResetClick() { this.userSettings.setGraphicsOverrides({}); this.requestUpdate(); @@ -147,6 +158,7 @@ export class GraphicsSettingsModal extends LitElement implements Controller { const nameScale = this.currentNameScale(); const nameCull = this.currentNameCull(); + const namesColored = !this.currentDarkNames(); return html`
+ +