Upvote Upvoted 10 Downvote Downvoted
Quick(er) Hud Reload
posted in Customization
1
#1
0 Frags +

EDIT: Turns out I am not very good at finding issues, as it was brought to my attention that testhudanim requires sv_cheats 1. Oops!

I've been messing around with hud editing recently and came across a quicker hud reload method that I don't think is documented anywhere. Its not a ton quicker but i'm sure that most players would prefer that their game is frozen for a bit less time.
I'm going to say in advance; This is not very helpful to hud developers! Due to the way it works, it doesn't apply edits made to the hud files!

Anyway, here's how to add it, it utilizes hud animations so if you don't have a custom hud you'll need to at the very least get the default hud's "hudanimations_tf.txt" file.

Simply add

event QuickReloadHud
{
	FireCommand 0.0 "reloadscheme"
}

to your "hudanimations_tf.txt" file, do note that some huds separate their animations into a different file, and it probably would be better if you added it to that instead.

In order to run it ingame, simply run the command

testhudanim QuickReloadHud

or bind that to whatever key you want

bind KEY "testhudanim QuickReloadHud"

the name of the animation can be anything, not just "QuickReloadHud", just make sure that the animation name is the same as the one in the command.

There are 2 potential issues I found,
1. This seems to skip some code events that "hud_reloadscheme" doesn't.
Most noticeably, on TF2's default hud (and probably many custom huds) the freezecam data will appear on screen
example:

https://cdn.discordapp.com/attachments/321072514748907520/981801940184870917/unknown.png

You can either wait for this to disappear by dying, or fix it yourself by opening up "freezepanel_basic.res" and adding the line

"visible" "0"

to "FreezePanel".
This does not disable the freezecam data when you die, just when you reload the hud.
2. This way doesn't clear the KeyValues cache (see below for details). I haven't done a ton of testing or digging but this might potentially cause a memory leak (probably only after hours and hours of playtime and constant hud reloading though. If this turns out to be a real worry or if you are extremely worried that your game might crash (low ram, general worry, etc.) I'd recommend doing a full hud reload either manually occasionally, on class change (via adding "hud_reloadscheme" to your class config files), or you might even be able to change something like the team select button to also reload the hud (Haven't looked into it, idk if its possible)

How does it work?
It's a bit complicated, but essentially there's 2 forms of hud reloading.
hud_reloadscheme calls the function ReloadScheme with flushLowLevel=true, reloadscheme calls the same function, but with flushLowLevel=false instead, but unfortunately is not a console command, and it seems can only be called via either a hud animation or a hud button.
flushLowLevel=true makes the game clear the KeyValues cache, which seems to be what causes the most time when reloading the hud. When flushLowLevel=false, it doesn't do this, resulting in our faster hud reload at the cost of the potential bugs listed above.

Please let me know if there's any other issues with this! If this is causing any issues with people's games, then that deserves to be looked into!

EDIT: Turns out I am not very good at finding issues, as it was brought to my attention that testhudanim requires sv_cheats 1. Oops!

I've been messing around with hud editing recently and came across a quicker hud reload method that I don't think is documented anywhere. Its not a ton quicker but i'm sure that most players would prefer that their game is frozen for a bit less time.
I'm going to say in advance; [b]This is not very helpful to hud developers![/b] Due to the way it works, it doesn't apply edits made to the hud files!

Anyway, here's how to add it, it utilizes hud animations so if you don't have a custom hud you'll need to at the very least get the default hud's "hudanimations_tf.txt" file.

Simply add
[code]event QuickReloadHud
{
FireCommand 0.0 "reloadscheme"
}[/code]
to your "hudanimations_tf.txt" file, do note that some huds separate their animations into a different file, and it probably would be better if you added it to that instead.

In order to run it ingame, simply run the command [code]testhudanim QuickReloadHud[/code]or bind that to whatever key you want [code]bind KEY "testhudanim QuickReloadHud"[/code]
the name of the animation can be anything, not just "QuickReloadHud", just make sure that the animation name is the same as the one in the command.

There are 2 potential issues I found,
1. This seems to skip some code events that "hud_reloadscheme" doesn't.
Most noticeably, on TF2's default hud (and probably many custom huds) the freezecam data will appear on screen
example:
[img]https://cdn.discordapp.com/attachments/321072514748907520/981801940184870917/unknown.png[/img]
You can either wait for this to disappear by dying, or fix it yourself by opening up "freezepanel_basic.res" and adding the line [code]"visible" "0"[/code] to "FreezePanel".
This does not disable the freezecam data when you die, just when you reload the hud.
2. This way doesn't clear the KeyValues cache (see below for details). I haven't done a ton of testing or digging but this might potentially cause a memory leak (probably only after hours and hours of playtime and constant hud reloading though. If this turns out to be a real worry or if you are extremely worried that your game might crash (low ram, general worry, etc.) I'd recommend doing a full hud reload either manually occasionally, on class change (via adding "hud_reloadscheme" to your class config files), or you might even be able to change something like the team select button to also reload the hud (Haven't looked into it, idk if its possible)

How does it work?
It's a bit complicated, but essentially there's 2 forms of hud reloading.
hud_reloadscheme calls the function ReloadScheme with flushLowLevel=true, reloadscheme calls the same function, but with flushLowLevel=false instead, but unfortunately is not a console command, and it seems can only be called via either a hud animation or a hud button.
flushLowLevel=true makes the game clear the KeyValues cache, which seems to be what causes the most time when reloading the hud. When flushLowLevel=false, it doesn't do this, resulting in our faster hud reload at the cost of the potential bugs listed above.

Please let me know if there's any other issues with this! If this is causing [i]any[/i] issues with people's games, then that deserves to be looked into!
Please sign in through STEAM to post a comment.