Skip to content

[gui] The K1 combat HUD text scale is absolute, not compounded - #339

Merged
modawan merged 1 commit into
modawan:masterfrom
MichaelMoroz:fix/k1-combat-hud-text-scale
Aug 28, 2026
Merged

[gui] The K1 combat HUD text scale is absolute, not compounded#339
modawan merged 1 commit into
modawan:masterfrom
MichaelMoroz:fix/k1-combat-hud-text-scale

Conversation

@MichaelMoroz

Copy link
Copy Markdown

The defect

The K1 combat sequence HUD's text grows with every level load, doubling each
time, until it wraps and clips.

Cause

HUD::onGUILoaded scales by reading the control's own scale back:

control->setScale(control->scale() * kK1CombatTextScale);

That is a read-modify-write on state the wrapper does not own. The HUD wrapper
is reconstructed on loadgame, reset and new-session, but the control tree it
binds lives in the GUI cache and survives — so each reconstruction multiplies
the previous result again.

An ordinary warp preserves the wrapper and shows nothing, which is why this
presents as a level-load bug rather than a HUD one, and why it is easy to miss
when testing by warping.

Fix

Derive the value from the live layout and text inputs, so applying it to an
already-scaled tree is idempotent. The wrapper and the control tree have
different lifetimes; the operation should not care which one it is looking at.

Measurement

Three loadgame cycles, glyph region of the combat text:

load before after
1 1203 px, 314x14 1203 px, 314x14
2 5207 px, 629x28 1203 px, 314x14
3 22770 px, clipped 1203 px, 314x14

After the fix the first and third regions are pixel-identical.

Note on verification

The measurements above were taken on a downstream branch that carries this file
unchanged from master — the block is byte-identical here, and the patch
applies to master as-is. I have not built master itself, so a CI run is
worth having before merge.

The combat sequence HUD's text grows with every level load, doubling each
time, until it wraps and clips.

onGUILoaded scales by reading the control's own scale back:

    control->setScale(control->scale() * kK1CombatTextScale);

That is a read-modify-write on state this wrapper does not own. The HUD
wrapper is reconstructed on loadgame, reset and new-session, but the control
tree it binds lives in the GUI cache and survives, so each reconstruction
multiplies the previous result again. An ordinary warp preserves the wrapper
and shows nothing, which is why it presents as a level-load bug rather than a
HUD one.

Derive it from the live layout and text inputs instead, so applying it to an
already-scaled tree is idempotent. The wrapper and the tree have different
lifetimes; the operation should not care which one it is looking at.

Measured over three loadgame cycles, glyph region: 1203 px at 314x14, then
22770 px and clipped by the third. After: 1203 px at 314x14 on loads one, two
and three, with the first and third regions pixel-identical.

@modawan modawan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good catch. Thank you!

@modawan
modawan merged commit 1a73ba0 into modawan:master Aug 28, 2026
2 checks passed
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.

2 participants