Forums » Community Projects

Lua: Hiding the HUD

Jul 09, 2007 Demonen link
Processing the "hudtoggle" command is very primitive, so I've been looking at the HUD table.

Just a small thing:

HUD.HideHUD(HUD) -- Hides the whole HUD
HUD.ShowHUD(HUD) -- Shows it again

Just sharing :)

Only thing to figure out now, is:
How do I keep the background(or whatnot) from stealing focus making my little window loose focus (and possibilities of regaining it)...?
Jul 09, 2007 mr_spuck link
damn .. I didn't know the addon environment was different to the one in the shell. that's cool

I just always create a transparent fullscreen dialog.
Jul 10, 2007 raybondo link
Or you can do:
HUD:ShowHUD()
HUD:HideHUD()

The object:function() is lua sytactic sugar for object.function(object). Kinda vaguely similar to the this pointer in C++. The object then can be referenced as 'self' in the function.

object = {}
function object:whee()
self.blah = 5
end

Is the same as:
object = {}
function object.whee(self)
self.blah = 5
end

(and this:
object = {
whee=function(self)
self.blah = 5
end
}

and then:
object:whee()
print(object.blah)

Probably not the best example of coding standards but I'm just showing syntax.
Jul 10, 2007 raybondo link
Do you mean when the HUD is open, clicking on it puts it on top above your dialog? Heh, the same thing happens with the console. The HUD is defined as topmost so that's why that happens.
Jul 10, 2007 Demonen link
My little window is defined as TOPMOST=YES, too, so I guess they get in a little fight over who is TOPMOSTest... ;)

Thanks for the syntax pointers, that looks slicker :)
Jul 20, 2007 firsm link
Demonen,

try the MODAL=YES setting with iup.dialog.

If that doesn't work, you could do something like this

function DrawMyDialogThing()
if not PlayerInStation()
-- open the PDA
end
mydialog.draw()
end

a dialog won't lose focus if you are docked to a station or have the PDA open. This way you can even chat while doing your thing.

- firsm
Jul 20, 2007 Scuba Steve 9.0 link
This works to hide the HUD without your window losing focus:
HUD.dlg.active = "NO"
HUD:HideHUD()

And to restore the HUD:
HUD.dlg.active = "YES"
HUD:ShowHUD()

Make sure to set HUD.dlg.active = "YES" when reshowing the HUD if you want to do anything with it later.

Edit: For future reference, it's a bad idea to do iup.Destroy(HUD.dlg)
Jul 20, 2007 mr_spuck link
is there no way the dialog could lose focus that way? that'd be cool.
mine have a problem that they lose focus when opened during launch or warp animations.
Jul 20, 2007 Scuba Steve 9.0 link
You'd have to play with it a bit. I figured out how to do it 30 seconds before I posted how to do it. It looks like the way to go though.

Edit: Let me clarify. It *shouldn't* unless something modifies the active attribute when you warp. I think it just calls show() and hide() on certain interface elements when you jump in/out.
Jul 23, 2007 firsm link
mmh, you could then bind something like

iup.SetAttributes(vgui.dialog, 'VISIBLE=NO')
iup.SetAttributes(vgui.dialog, 'VISIBLE=YES')
and maybe
iup.SetAttributes(vgui.dialog, 'TOPMOST=YES')
or
iup.SetAttributes(vgui.dialog, 'BRINGFRONT=YES')

to the LAUNCH and/or JUMP event thing.