feat: Graphics presets and shareable settings JSON#4481
Conversation
Add a Presets dropdown at the top of the graphics settings modal (Default, Performance, Atmospheric, High Contrast; shows Custom when the current overrides match no preset), and a Share section with a copy-to-clipboard button and a paste field that validates imported JSON with GraphicsOverridesSchema before applying. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
WalkthroughGraphicsSettingsModal.ts gains a preset system (default, performance, atmospheric, high_contrast, custom) with deep-equal matching, plus copy-to-clipboard and JSON import of graphics overrides validated by GraphicsOverridesSchema. New UI sections render preset selection and share controls. Corresponding English translation strings are added. ChangesGraphics presets and share/import
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/client/hud/layers/GraphicsSettingsModal.ts (1)
137-162: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a typed union for preset ids instead of plain
string.
id: stringonGRAPHICS_PRESETSletsp.idandPRESET_CUSTOMdrift apart silently (typo in an id wouldn't be caught at compile time, and it's also used to build the translation keygraphics_setting.preset_${id}). A string-literal union tightens this contract.♻️ Suggested typed-union tightening
-const GRAPHICS_PRESETS: { id: string; overrides: GraphicsOverrides }[] = [ +const GRAPHICS_PRESET_IDS = [ + "default", + "performance", + "atmospheric", + "high_contrast", +] as const; +type GraphicsPresetId = (typeof GRAPHICS_PRESET_IDS)[number]; + +const GRAPHICS_PRESETS: { id: GraphicsPresetId; overrides: GraphicsOverrides }[] = [ { id: "default", overrides: {} }, ... ]; -const PRESET_CUSTOM = "custom"; +const PRESET_CUSTOM = "custom" as const;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/client/hud/layers/GraphicsSettingsModal.ts` around lines 137 - 162, The preset identifiers in GRAPHICS_PRESETS are currently typed as plain string, which allows PRESET_CUSTOM and the preset ids used for graphics_setting.preset_${id} to drift or typo silently. Tighten this by introducing a string-literal union for the preset id values and using it in GRAPHICS_PRESETS, PRESET_CUSTOM, and any helpers that compare or derive from preset ids, so only the known preset ids can be assigned or referenced.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/client/hud/layers/GraphicsSettingsModal.ts`:
- Around line 137-162: The preset identifiers in GRAPHICS_PRESETS are currently
typed as plain string, which allows PRESET_CUSTOM and the preset ids used for
graphics_setting.preset_${id} to drift or typo silently. Tighten this by
introducing a string-literal union for the preset id values and using it in
GRAPHICS_PRESETS, PRESET_CUSTOM, and any helpers that compare or derive from
preset ids, so only the known preset ids can be assigned or referenced.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8017f84c-65d8-430c-bcf1-69b9eb30aebb
📒 Files selected for processing (2)
resources/lang/en.jsonsrc/client/hud/layers/GraphicsSettingsModal.ts
Closes #4444
What
Adds two things to the in-game graphics settings modal:
Presets — a dropdown at the top of the modal for casual users:
render-settings.jsonA preset replaces the whole overrides object, so the resulting look is predictable and the dropdown can show which preset is active (deep-compare against stored overrides). Tweaking any individual setting flips the dropdown to Custom.
Share — a section above Reset:
GraphicsOverridesSchemabefore being applied, and invalid text shows an inline errorPresets and imports apply live through the existing
USER_SETTINGS_CHANGED_EVENT:settings.graphicslistener — no new renderer wiring.Testing
npx tsc --noEmit, ESLint, Prettier cleanEnJsonSortedandTranslationSystemtests pass🤖 Generated with Claude Code