Skip to content

System menu: Apply restarts the renderer only when a changed setting needs it - #42

Open
wizzan1 wants to merge 1 commit into
ReactionQuake3:masterfrom
wizzan1:pr/apply-restart
Open

wizzan1 wants to merge 1 commit into
ReactionQuake3:masterfrom
wizzan1:pr/apply-restart

Conversation

@wizzan1

@wizzan1 wizzan1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What was wrong

The System menu's Apply button ran vid_restart whatever was changed, also when nothing was. In a game that loads the
whole map again. Many of the menu's settings need no restart: the ui sets them at once and they show at once. A player
who changes one of those, sees it work, and then clicks Apply waits for the game to come back for nothing.

What changed

code/ui (ui_main.c, ui_local.h) and uifiles/system.menu, 97 lines added.

  • Apply restarts only for a change that needs it: the video mode, as before, or one of the settings the renderer reads
    only as it starts. A ui module can't ask the engine for a cvar's flags, and its own sets go past the latch, so
    ui_main.c keeps those names in one list (uiRestartCvars: the menu's CVAR_LATCH cvars) and compares their values
    with the ones at the last restart it knows of: the game's start and each Apply that restarted.
  • That baseline is a cvar (ui_RQ3_restartBase, read-only, not archived). The ui's own memory is new at every start of
    the ui, and a map load starts the ui too while the renderer keeps its extension settings (texture compression,
    anisotropic filtering) from its last full start.
  • After an Apply that needed no restart the menu says so under the button: "Applied. No restart was needed". Without it
    the click would seem to do nothing. The note goes when the pointer leaves the button or the menu is opened again.
  • The in-game Setup opens the same menu, so it holds there too.

The list also names fs_modernPacks, the cvar of #37 (the Look switch). Without #37 the engine has no such cvar and
the name reads the same value every time, so the two pull requests can go in either order.

Limits

  • A vid_restart typed at the console is not seen, so the next Apply may restart once more than it had to.
  • A setting typed at the console and still pending ("will be changed upon restarting") is no longer applied by Apply,
    since its value has not changed yet. vid_restart applies it, as the console says.
  • A new menu row for a latched cvar has to be added to uiRestartCvars, or Apply will not restart for it.

Cost

Twenty cvar reads on an Apply click, and one string set when the ui starts.

Proof

A real client running the QVMs, at the main menu and in a game on urban. One setting at a time is changed through the
ui module, as a click changes it, and the Apply button's own script is run; the log shows whether the renderer started
again, and the engine's cvarlist says which cvars are latched.

Before After
Apply with nothing changed, main menu and in a game restarts no restart, the note shows
A change taken back before Apply restarts no restart
Each of the 10 cvars of the Graphics tab that are not latched restarts no restart
Each of the 19 latched ones, and set back again restarts restarts
A latched one changed in a game restarts restarts

r_textureMode holds a word, which the check cannot step, so it was not tried. Built as QVM and DLL, with GCC and
Visual Studio 2022.

Not tested

A mouse click on the button itself: the checks run its script. The resolution and fullscreen road of Apply, which is
unchanged.

🤖 Generated with Claude Code

The System menu's Apply button ran vid_restart whatever was changed, also
when nothing was. In a game that loads the whole map again. Most of the
menu's settings need no restart, and a player who changes one of them sees
it take effect at once, then clicks Apply and waits for the game to come
back.

Apply now restarts only for a change that needs it: the video mode, as
before, or one of the settings the renderer reads only as it starts
(CVAR_LATCH in the engine) and the look's packs (fs_modernPacks, read as
each image loads). A ui module can't ask the engine for a cvar's flags, and
its sets go past the latch, so ui_main.c keeps those twenty names
(uiRestartCvars) and compares their values with the ones at the last
restart it knows of: the game's start and each Apply that restarted. That
baseline is a cvar (ui_RQ3_restartBase, read-only, not archived), because a
map load starts the ui again while the renderer keeps its extension
settings (texture compression, anisotropic filtering) from its last full
start.

After an Apply that needed no restart the menu says so under the button:
"Applied. No restart was needed" (ui_RQ3_applyNote), until the pointer
leaves the button or the menu is opened again. Without it the click would
seem to do nothing.

The in-game Setup opens the same menu, so it holds there too.

Limits: a vid_restart typed at the console is not seen, so the next Apply
may restart once more than it had to. A setting typed at the console and
still pending ("will be changed upon restarting") is no longer applied by
Apply, since its value has not changed yet; vid_restart applies it, as the
console says.

Checked in a real client (the QVM, main menu and in a game on urban), by
running the button's own script after changing one setting at a time
through the ui module: of the 30 cvars of the Graphics tab that were tried
(r_textureMode holds a word and was not), the 19 the engine's cvarlist
marks latched and fs_modernPacks restart, also when set back; the 10
others, no change at all, and a change taken back do not, and the note
cvar says which it was. Before: every one of those Applies restarted.

Cost: twenty cvar reads on an Apply click, one string at the ui's start.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant