Page 1 of 1

Add an element to the HUD without doing a complete Replace

Posted: Fri Nov 13, 2015 4:09 pm
by mh82
Hey everyone!

I'm back with another question!
I want to add a custom dial which displays the reaminig time until entering witchspace as soon as the player starts the countdown.
So far so good - no problem until here... Set up a small script, edited a copy of HUD.plist, the bar fills nicely and smooth via a addFrameCallback...
So, that's it... 8) ... not! :evil:

I realized that what I was doing was a replacement for the standard HUD. But that is not what I want to do.
Instead I just want to add this little drawCustomBar dial to the current HUD. So no matter what HUD is currently being used, the dial shows up.

Any chance to achieve this?

Re: Add an element to the HUD without doing a complete Repla

Posted: Fri Nov 13, 2015 6:46 pm
by phkb
I think you might be stuck with this one. HUD's are fairly static, so you can't really inject anything into them. And it would be difficult to anyway, as it would be hard to know what part of the screen was free for your additional element - each HUD puts things in different spots, so what might be OK for one might be on top of something in another.

But you still have some options. Using a Multi-function display may work for you. Or you can individually set the crosshairs for the player ship independently of the HUD, by using player.ship.crosshairs = "my_crosshairs.plist";. I hope that helps a bit.

Re: Add an element to the HUD without doing a complete Repla

Posted: Fri Nov 13, 2015 7:05 pm
by mh82
Unfortunately it doesn't :cry: :cry: :cry:

But first off: thank you for your reply. Actually it just confirms what I suspected when I was browsing through the wiki.
Designing a complete HUD is on my list but more like "at the end of it..." I just wanted to check if this is possible. It would have made some design steps easier... :wink:

But I thought about the same problems when it comes to element placement on screen...

Thanks again, phkb (...and of course everyone else for reading :wink: )

Re: Add an element to the HUD without doing a complete Repla

Posted: Sat Nov 14, 2015 6:16 am
by Wildeblood
phkb wrote:
Or you can individually set the crosshairs for the player ship independently of the HUD, by using player.ship.crosshairs = "my_crosshairs.plist";. I hope that helps a bit.
That one. Trivial problem if you can be bothered with the tedious task of creating the cross-hair files.

Re: Add an element to the HUD without doing a complete Repla

Posted: Sat Nov 14, 2015 3:25 pm
by mh82
I'm thinking about that one for quite a while now...
But it raises some gameplay / compatibility questions:
When that animation is played it will completely replace the players crosshair.
When using a OXP-HUD, there's a good chance that the size / shape of the animated crosshair doesn't fit the layout
Plus the controlling script needs to check if the crosshair was changed (HUD selector) and override that setting as long as the animation plays. Afterwards switch back to the old one...

I think I'll create a custom HUD for my project. But I'll definitely use that one for something.

Thanks, phkb & Wildeblood 8)

Re: Add an element to the HUD without doing a complete Repla

Posted: Sat Nov 14, 2015 7:47 pm
by phkb
Thinking about it a bit more, another option is to do something like what Snoopers does when there is a news item to view when you're on your way to the station. It slides down a little graphic in the top right corner of the screen. You might be able to leverage some of that code to achieve what you want. I can't give you any more pointers that that, though. I haven't looked into Snoopers to see how it works.

Re: Add an element to the HUD without doing a complete Repla

Posted: Sat Nov 14, 2015 11:19 pm
by Norby
phkb wrote:
do something like what Snoopers does
Snoopers depends on [wiki]CCL[/wiki] and use [wiki]Cabal Common Library Doc Overlay[/wiki] for this featue.

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 8:18 am
by mh82
CCL is using a shader/effect to show the overlays, right? Had a brief look at the package last night...

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 11:07 am
by Svengali
mh82 wrote:
CCL is using a shader/effect to show the overlays, right? Had a brief look at the package last night...
Yes, Cabal_Common_Overlay uses shaders for the overlays. It was (and still is) the only approach to reach what I had in mind when I wrote it back in 2012. And as long as HUD elements can't be created, injected and animated on the fly it doesn't make sense to change it. Since Oolite v1.80 it would be possible to do the basic overlays for non-shadered machines as well, because view_position is exposed to JS now, but the more advanced options (e.g. in Vector.oxp) still wouldn't work at all, or would be much more inefficient.

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 12:52 pm
by Amah
Just wondering... Don't know if it's a good idea to implement something with shaders without a simple fallback...

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 1:16 pm
by spara
Amah wrote:
Just wondering... Don't know if it's a good idea to implement something with shaders without a simple fallback...
Please, don't give up developing if the idea is not working on non-shader setups. Players using non-shader setups just don't use it, thats all. And at least it's a proof of concept. If the idea proves to be solid enough, then the devs just might start thinking about including a more more generic support for it to the core game.

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 1:45 pm
by Amah
ah, misunderstanding... I just wanted to add the point to the discussion, that there should be something like a simple fallback, not giving up building something with bling, bling ;-)

Re: Add an element to the HUD without doing a complete Repla

Posted: Sun Nov 15, 2015 2:59 pm
by Svengali
Sure, a fallback would be nice, but I think it depends. Creating mechanisms which work for both cases usually means to limit the possibilities and/or makes it a lot harder to develop and maintain. And doing advanced (read CPU/Mem intensive) stuff on non-shadered machines is something to be considered carefully, because these machines are more likely lower-end machines. In the end it all boils down to what you have in mind .-)