Is there a way to draw an image dynamically on a HUD?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Is there a way to draw an image dynamically on a HUD?

Post by Alexagon »

And what I mean by that is, draw an image on screen that can be moved around when some condition is met.

For example, I want to put a bar in my HUD that has the map name, but since map names vary so much in length, I wanted to know if there is a way to just draw the "end" of the bar right after the level name, so the bar never exceeds more than a few pixels after the level name. Essentially, the end of the bar moveswith the end of the level name dynamically.

I hope that makes sense. If anyone could help that'd be great.
User avatar
Dan_The_Noob
Posts: 880
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Is there a way to draw an image dynamically on a HUD?

Post by Dan_The_Noob »

well how do you plan to measure level length?
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Is there a way to draw an image dynamically on a HUD?

Post by kodi »

Once you got the level name accessible as a string, you should be able to do this:
YourCurrentFont.StringWidth(LevelNameStringHere) to get the width of the string, then clip the bar drawing to that.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Is there a way to draw an image dynamically on a HUD?

Post by Alexagon »

kodi wrote:Once you got the level name accessible as a string, you should be able to do this:
YourCurrentFont.StringWidth(LevelNameStringHere) to get the width of the string, then clip the bar drawing to that.
I'm not following entirely. How would I format it with this code I'm using?:

Code: Select all

drawstring CONFONT, white, levellump, 9, 6, 0, alignment (left);
drawstring CONFONT, white, levelname, 60, 6, 0, alignment (left);
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Is there a way to draw an image dynamically on a HUD?

Post by Alexagon »

anyone else able to help me with this?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Is there a way to draw an image dynamically on a HUD?

Post by Graf Zahl »

No, not with SBARINFO. That is totally static.
If you want more dynamic effects you'll have to code your HUD in ZScript.
Alexagon
Posts: 74
Joined: Mon Apr 22, 2019 2:58 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Is there a way to draw an image dynamically on a HUD?

Post by Alexagon »

Graf Zahl wrote:No, not with SBARINFO. That is totally static.
If you want more dynamic effects you'll have to code your HUD in ZScript.
Ok. Thank you.
Post Reply

Return to “Scripting”