Add custom VGUI2 HUD - #280
Conversation
Custom HUD for health, battery and ammo.
Conflicts: src/game/client/vgui/CMakeLists.txt
|
Merged master and fixed conflicts: rtxa#1 |
Merge master branch
|
Thanks, but I'm not sure if the history is gonna be clean, hope you can manage this or perhaps I can open a new PR and cherry-pick the commit with latest master changes and conflict resolved. |
tmp64
left a comment
There was a problem hiding this comment.
This looks really cool! Great work!
-
I don't think this works with WeaponMod, which can can add custom sprites. You can use the code from
CHudDeathNoticePanel::PaintBackgroundto draw sprites in VGUI. -
I don't like the wrapper methods in
CClientViewport(likeShowHealthPanel,HideHealthPanel, etc). I think it would be better to add getters for the panels and call methods directly on them. -
I don't like that old sprite HUD updates the visibility of new VGUI HUD. I think it's better to move all visibility updates to
CHud::Redraw. Do something like this:if (g_pViewport) { g_pViewport->GetHudAmmo()->ShowPanel( hud_draw.GetFloat() > 0 && m_iWeaponBits & (1 << (WEAPON_SUIT)) && !(m_iHideHUDDisplay & HIDEHUD_ALL | HIDEHUD_WEAPONS)) // ... other panels ... }
Ideally, HUD code needs to be reworked to better support VGUI panels, but that's beyond the scope of this PR.
| int m_HUD_selection; | ||
| int m_iMaxSlot; // There are 5 (0-4) slots by default and they can extend to 6. This will be used to draw additional weapon bucket(s) on a hud. | ||
| int m_iLastFOV = 0; | ||
| ConVarRef m_pHudCustom{"hud_custom"}; |
There was a problem hiding this comment.
Add extern ConVar hud_custom to hud.h and use it directly
| if (g_pViewport) { | ||
| g_pViewport->HideBatteryPanel(); | ||
| } |
|
Weird that the font looks like this, we need to check if other Linux users have the same issue. I'm not sure if manipulating About WeaponMod, I didn't know you can draw sprites in the VGUI2 panel. Anyway, when using custom ammo icons, it would fallback to a default ammo texture with a dot. PD: By the way, why do we need to check g_pViewport all the time? Is there a way to ensure in class constructor that has been initialized, so we can remove the checks? |
|
Seems like in Linux, glyphs that are outside their bounding box are clipped/not rendered. On Windows, they do render. |
That's a remnant from VGUI1 code. In BHL, the viewport is created once during VGUI init. Most checks can be safely removed. |
|
Please, review my changes. I don't see a much better way to show/hide ammo panels, so I left it as it. If everything looks good, I'll merge this |
|
Thanks! |













Custom VGUI2 HUD for health, battery and ammo. You can enable it with
hud_custom 1.Extra commands have been added to improve coloring of the HUD when health/ammo is very low or to use one main color for the HUD without changing all
hud_color1/2/3values.Commands:
hud_custom 1- Enables/disables the custom VGUI2 HUD. Disabled by default.hud_dim 1- Enables/disables dimming of the hud. Enabled by default.hud_color4 "255 0 0"- HUD color when health/ammo is very low (0%; 25%).hud_color_override 1- Disables HUD coloring of health/ammo according to amount. Disabled by default.hud_reloadscheme- This reload the .res files of the HUD. This will refresh the HUD and display your modifications.I recommend using these colors for the new HUD when hud coloring by amount is enabled due to the defaults ones being too dark.
Resources being used:
Screenshots
Thanks and I hope you like the new HUD and gets into the official client, people's feedback has been good so far.