Skip to content

fix(ui): save resolution based font in setting#2171

Merged
alandtse merged 4 commits into
community-shaders:devfrom
SkrubbySkrubInAShrub:font-checkbox
Apr 21, 2026
Merged

fix(ui): save resolution based font in setting#2171
alandtse merged 4 commits into
community-shaders:devfrom
SkrubbySkrubInAShrub:font-checkbox

Conversation

@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub commented Apr 21, 2026

Closes #2166

this PR changes the saving logic for the resolution based font setting. Now it will save in the usersettings, and when it is toggled on, it will apply the fontsize = 0.0f setting on theme load. This way the toggle persists logically, while themes don't get affected by it when saved.

Summary by CodeRabbit

  • New Features

    • Added a settings option (enabled by default) to toggle resolution-based font sizing in preferences.
  • Improvements

    • UI updates immediately when switching between automatic (resolution-based) and fixed font sizes; slider enable/disable behavior follows the setting.
    • Dynamic scaling now derives size from display/VR overlay height with safer fallbacks and clamping for consistent results.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13ae4a5b-5648-46ed-bb3e-1e01f31b7bd2

📥 Commits

Reviewing files that changed from the base of the PR and between 97d580f and 9c087dc.

📒 Files selected for processing (1)
  • src/Menu.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Menu.h

📝 Walkthrough

Walkthrough

Added a persistent UseResolutionFont setting to Menu, bound the settings UI checkbox to that field, and updated ThemeManager to choose between fixed theme font size or dynamic resolution/VR-based sizing based on the new flag.

Changes

Cohort / File(s) Summary
Menu settings & serialization
src/Menu.h, src/Menu.cpp
Added Menu::Settings::UseResolutionFont (default true); included in JSON (de)serialization; added const Settings& GetSettings() const accessor.
UI: Settings tab
src/Menu/SettingsTabRenderer.cpp
Checkbox now reads/writes menu.GetSettings().UseResolutionFont; seeding and disabled-state logic for the fixed-size slider adjusted to follow the new flag.
Theme resolution logic
src/Menu/ThemeManager.cpp
ResolveFontSize reads menu.GetSettings().UseResolutionFont; when false uses settings.Theme.FontSize (validated/clamped), otherwise computes dynamic size from VR overlay or screen height with fallback and clamping.

Sequence Diagram(s)

sequenceDiagram
    participant UI as "SettingsTabRenderer (UI)"
    participant Menu as "Menu (Settings)"
    participant Theme as "ThemeManager"
    participant Display as "Display / VR Config"

    UI->>Menu: Toggle UseResolutionFont
    Menu-->>UI: Persisted UseResolutionFont
    UI->>Theme: Request ResolveFontSize(menu)
    Theme->>Menu: Read settings (UseResolutionFont, Theme.FontSize)
    alt UseResolutionFont == false
        Theme->>Theme: Use settings.Theme.FontSize (round/validate/ clamp)
    else UseResolutionFont == true
        Theme->>Display: Query overlay/screen height
        Display-->>Theme: height
        Theme->>Theme: Compute dynamic font size (ratio, fallback, clamp)
    end
    Theme-->>UI: Effective font size
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • davo0411
  • doodlum

Poem

🐰 I nudged a switch and fonts learned to sway,
Fixed or flowing with each screen or display.
Settings now rest where toggles belong,
I hop in the code and hum a small song. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: persisting the resolution-based font setting in user settings instead of losing it between sessions.
Linked Issues check ✅ Passed The PR successfully addresses #2166 by storing the checkbox state in usersettings, ensuring persistence across restarts without modifying theme files.
Out of Scope Changes check ✅ Passed All changes directly support the stated objective: adding UseResolutionFont field to Settings, updating font resolution logic, and ensuring the setting persists across sessions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Menu/SettingsTabRenderer.cpp (1)

855-870: ⚠️ Potential issue | 🟡 Minor

Clarify that this checkbox is saved globally.

UseResolutionFont is now a user setting, but the Fonts tab still opens with theme-save guidance. A user could save the theme and expect this checkbox to persist, even though only the global settings save writes it.

Consider adding a short note near this checkbox, or splitting the save guidance so global/user settings are distinguished from theme settings.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Menu/SettingsTabRenderer.cpp` around lines 855 - 870, The
"UseResolutionFont" checkbox is a global user setting but the Fonts tab still
shows theme-save guidance, which is misleading; update the UI near the checkbox
(in SettingsTabRenderer::Render... where UseResolutionFont is used) to add a
short inline note or tooltip clarifying that UseResolutionFont is saved to the
global user settings and not to the current theme, and/or adjust the existing
theme save guidance (e.g., RenderSaveInfoText or the Fonts subheading) to
distinguish theme-scoped saves from global/user-scoped settings so users know
this checkbox will persist globally rather than with a saved theme.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Menu.cpp`:
- Around line 431-435: The ApplyResolutionFontOverride() mutates
settings.Theme.FontSize based on settings.UseResolutionFont which pollutes theme
state and causes incorrect resolution and theme persistence; instead stop
writing to settings.Theme.FontSize and implement the override in the
font-resolution path: update ThemeManager::ResolveFontSize(...) to accept the
user toggle/optional fixed size (e.g., pass settings.UseResolutionFont and an
optional settings.UserFontSize) and, when the toggle is enabled, return the
computed resolution-based size without modifying settings.Theme, or if you
prefer a stored user value add a separate settings field (e.g., UserFontSize)
and ensure SaveTheme() only persists theme fields, not the user toggle/value.

---

Outside diff comments:
In `@src/Menu/SettingsTabRenderer.cpp`:
- Around line 855-870: The "UseResolutionFont" checkbox is a global user setting
but the Fonts tab still shows theme-save guidance, which is misleading; update
the UI near the checkbox (in SettingsTabRenderer::Render... where
UseResolutionFont is used) to add a short inline note or tooltip clarifying that
UseResolutionFont is saved to the global user settings and not to the current
theme, and/or adjust the existing theme save guidance (e.g., RenderSaveInfoText
or the Fonts subheading) to distinguish theme-scoped saves from
global/user-scoped settings so users know this checkbox will persist globally
rather than with a saved theme.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c2fc9b67-fdf9-4802-946e-94a5887ded74

📥 Commits

Reviewing files that changed from the base of the PR and between 359e9bf and 2ffd56f.

📒 Files selected for processing (3)
  • src/Menu.cpp
  • src/Menu.h
  • src/Menu/SettingsTabRenderer.cpp

Comment thread src/Menu.cpp Outdated
SkrubbySkrubInAShrub and others added 2 commits April 21, 2026 15:14
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/Menu.h (1)

414-414: Comment wording is slightly stale.

The trailing (FontSize=0) hint implies runtime still keys off FontSize==0, but ThemeManager::ResolveFontSize now dispatches on UseResolutionFont directly. Consider updating the comment to describe what this flag truly controls (runtime dispatch + theme-file zeroing for persistence), so future readers don't look for a FontSize==0 check that's no longer there.

📝 Suggested wording
-		bool UseResolutionFont = true;                                                      // When true, font size scales with screen resolution (FontSize=0)
+		bool UseResolutionFont = true;                                                      // When true, ThemeManager::ResolveFontSize derives font size from the current screen resolution; the theme's FontSize is ignored.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Menu.h` at line 414, Update the comment for the boolean UseResolutionFont
to accurately describe its behavior: explain that when true
ThemeManager::ResolveFontSize will choose a resolution-scaled font size at
runtime and when persisted to theme files the font size is written as zero for
backward-compatible representation; remove the outdated "(FontSize=0)"
implication that code checks FontSize==0 and instead state that
UseResolutionFont directly controls runtime dispatch and causes theme-file
zeroing for persistence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Menu.h`:
- Line 414: Update the comment for the boolean UseResolutionFont to accurately
describe its behavior: explain that when true ThemeManager::ResolveFontSize will
choose a resolution-scaled font size at runtime and when persisted to theme
files the font size is written as zero for backward-compatible representation;
remove the outdated "(FontSize=0)" implication that code checks FontSize==0 and
instead state that UseResolutionFont directly controls runtime dispatch and
causes theme-file zeroing for persistence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9610787-54ba-4af1-ba53-d46ccac7e5e1

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffd56f and 97d580f.

📒 Files selected for processing (4)
  • src/Menu.cpp
  • src/Menu.h
  • src/Menu/SettingsTabRenderer.cpp
  • src/Menu/ThemeManager.cpp
✅ Files skipped from review due to trivial changes (1)
  • src/Menu.cpp

Comment thread src/Menu.h
@alandtse alandtse changed the title fix: save resolution based font in usersettings. fix(ui): save resolution based font in setting Apr 21, 2026
@alandtse alandtse merged commit 4e1ea45 into community-shaders:dev Apr 21, 2026
6 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants