I feel [i]really[/i] stupid asking this, but is there a way to control depth of something drawn with SWEP:DrawHud?
I'm making a sniper scope and I'd like to have the regular hud show over it for the ammo and killfeeds and such.
Draw background before foreground.
[QUOTE=Disseminate;33904999]Draw background before foreground.[/QUOTE]
Specifically, what would this look like? Do you just need to put --Background or --Foreground before the image specifications?
Things are pretty simple... It draws when you tell it to. If you draw a box first and then a text, you will have the text over the box. If you draw the text first and then the box, you'll have a box (and the text behind it).
Drawing isn't like VGUI, where the controls are layered. When you call a draw function, it draws over the existing buffer.
[QUOTE=vercas;33919509]Things are pretty simple... It draws when you tell it to. If you draw a box first and then a text, you will have the text over the box. If you draw the text first and then the box, you'll have a box (and the text behind it).
Drawing isn't like VGUI, where the controls are layered. When you call a draw function, it draws over the existing buffer.[/QUOTE]
Sooooooo that means that it's impossible to draw over the default hud?
You can hide the default HUD and make your own with this hook.
[b][url=wiki.garrysmod.com/?title=Gamemode.HUDShouldDraw]Gamemode.HUDShouldDraw [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Did you try using this hook instead?
[b][url=wiki.garrysmod.com/?title=Gamemode.HUDPaintBackground]Gamemode.HUDPaintBackground [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[editline]28th December 2011[/editline]
Well since the hook I showed you is a gamemode hook, you'll obviously need to check the current weapon held by the local player before drawing your scope. You can always do something like this to keep things practical:
[lua]hook.Add("HUDPaintBackground", "some_unique_name_here", function()
local w = LocalPlayer():GetActiveWeapon()
if ValidEntity(w) and w:GetClass() == "my_sniper_rifle" then
w:DrawHudBackground()
end
end)[/lua]
Then all you'd need to do is add a DrawHudBackground function in your weapon and do all your HUD drawing in there. Don't forget to change hook and class names so they fit the name of your weapon.
[QUOTE=Supah_Sonic;33923322]Sooooooo that means that it's impossible to draw over the default hud?[/QUOTE]
It means that when you tell it to draw, it draws over whatever is already on the screen.
Just like real painting... You can't draw a line behind another.
Sorry, you need to Log In to post a reply to this thread.