Skip to content

HUD component visibility state handling#5028

Closed
HeresHavi wants to merge 4 commits into
multitheftauto:masterfrom
HeresHavi:hud-component-visibility-state
Closed

HUD component visibility state handling#5028
HeresHavi wants to merge 4 commits into
multitheftauto:masterfrom
HeresHavi:hud-component-visibility-state

Conversation

@HeresHavi

@HeresHavi HeresHavi commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Updated isPlayerHudComponentVisible to report whether a HUD component can actually be drawn, including the global showhud state and fullscreen map suppression.

Radar child components now follow the parent radar state without losing their own visibility settings.

Motivation

Previously, isPlayerHudComponentVisible only checked the state of the requested component. This meant the radar could be hidden by showhud while the function still returned true.

The fullscreen player map also used the same global HUD state. Closing the map could re-enable a HUD that the player had already hidden with showhud.

For example, a resource might display a custom minimap only while the GTA radar is hidden. If the API incorrectly reports that the radar is still visible, the resource cannot reliably decide when to show its replacement.

Fixes #5026.

Test plan

Runtime

  • Before Fix: Running showhud hid the radar, but isPlayerHudComponentVisible("radar") still returned true.
  • After Fix: The function returned false while the HUD was hidden and returned true after restoring it.
  • Valid Case: Hiding the radar directly, toggling showhud, and restoring the HUD kept the radar hidden until it was explicitly restored.
  • Player Map: Opening the fullscreen map temporarily hid the HUD without replacing the state requested through showhud.
  • Radar Children: radar_map, radar_blips, and radar_altimeter followed the parent radar state while keeping their own visibility settings.
  • Reset: Reconnecting restored the global HUD and component visibility defaults.

Builds and Tests

  • Debug | Win32: Client build passed.
  • Release | Win32: Client build passed.
  • Client tests: 304 tests passed.
  • Ran clang-format.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Implemented owner-aware HUD visibility:

- `showhud` and the full-screen map no longer overwrite each other’s state.
- `isPlayerHudComponentVisible` now respects global HUD visibility.
- Radar child components respect the main radar’s state.
- Reset behavior clears stale map/HUD state.
- No migration, network, or component-ID changes.
- Formatting, project generation, and source-level checks passed.
- Nothing was staged, committed, or pushed; runtime testing remains.
@FileEX FileEX added the bugfix Solution to a bug of any kind label Jul 22, 2026
Comment thread Client/game_sa/CHudSA.cpp Outdated
Comment thread Client/game_sa/CHudSA.cpp Outdated
Comment thread Client/game_sa/CHudSA.h Outdated
Comment thread Client/game_sa/CHudSA.h Outdated
Comment thread Client/sdk/game/CHud.h Outdated
Comment thread Client/sdk/game/CHud.h Outdated
@FileEX

FileEX commented Jul 22, 2026

Copy link
Copy Markdown
Member

What makes this PR better than #5027 ?

@HeresHavi

Copy link
Copy Markdown
Contributor Author

@FileEX Apologies, this PR was meant to stay as a draft because I wasn’t done finalizing it yet. I’ve prioritized it and pushed the remaining changes so it doesn’t become stale

I've incorporated your suggestions and made some further improvements to how HUD visibility is handled. Compared with the other PR, I think this approach is more complete because it fixes the underlying issue while preserving the existing behavior for scripts. It also keeps the requested HUD state separate from temporary suppression and effective visibility, which avoids changing the meaning of the existing API

@FileEX

FileEX commented Jul 22, 2026

Copy link
Copy Markdown
Member

At the moment, your PR replicates the behavior of #5027, including adding a new argument to the function 👀

@HeresHavi

Copy link
Copy Markdown
Contributor Author

At the moment, your PR replicates the behavior of #5027, including adding a new argument to the function 👀

I compared it with mine just now, and at this point they provide essentially the same API and behavior. Though mine is somewhat smaller and avoids the suppression enum, bitset, and additional state methods, but that is an implementation trade off rather than a clear advantage over #5027. I don't think the remaining differences are enough to justify using my PR.

There are still a couple of smaller implementation details from this PR that may be useful there such as:

Basically your PR suggestions.

You can close this one in favor of #5027, I don't mind it!

@FileEX FileEX added the enhancement New feature or request label Jul 23, 2026
@FileEX

FileEX commented Jul 23, 2026

Copy link
Copy Markdown
Member

Closing in favor of #5027

@FileEX FileEX closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isPlayerHudComponentVisible("radar") does not reflect showhud state

2 participants