Page 1 of 1

[Solved] Status Bar Woes

PostPosted: Sun Apr 04, 2021 2:50 pm
by NeoTerraNova
Greetings, all. I apologize, but I must return with another question from all you wonderful people. As usual, many thanks to those that stop by and offer constructive help.

I'll lead this off with a little background, and a simple question at the end..

-I have a mod with roughly 20-some-odd different weapons in it. I know, it sounds like a lot, but you can drop and swap weapons around. This leads to a very.. unique situation. I can't just have the standard DOOM SBAR weapon indicator with that many guns, and have the information it presents be meaningful. I need some way to inform the player of what weapons they're carrying in reserve. Now, at most, they might be able to lug around about five of them. I have an SBAR with enough room on it to have five small icons in an area I've set aside to indicate weapons..

The question is.. is it possible to have some kind of chunk of code, that would "fill" this area in, and not be dependent on positioning? Meaning that I don't have to designate 20+ sets of coordinates in combination with making room for 20+ weapon icons, but can have some kind of code chunk that "fills in" the area with the appropriate weapon icons, depending entirely on what the player is carrying?

If the question comes off convoluted, I apologize. Here's a simple image to help explain..

https://i.ibb.co/k8dcLR3/Weapon-Screen1.png

Basically, some way to have any combination of little icons in there, that don't necessarily depend on having any specific section or coordinates set aside for individual list items. I don't mind how this might work - ZSCRIPT or something else - I just want to get the effect working, so my players know what other weapons that they might have on them without having to scroll through them.

EDIT: Technically solved, since Jarewill kindly gave me some Code to use, but I'm now moving from SBARINFO to a ZSCRIPT Status Bar. Totally new topic.

Re: Status Bar Woes

PostPosted: Sun Apr 04, 2021 3:51 pm
by Jarewill
If I understood it right, you wanted to show 5 weapons the player is carrying, as that is the maximum number of weapons that they can carry?
After a bit of wrestling, I made this:
Spoiler:

This has some issues though:
1) It needs the weapons to have icons to work. Assign Inventory.Icon properties to them and it should work.
2) There's always a said order to how it displays the weapons, and it won't display past 5, but that shouldn't matter much.

Just put this in your status bar drawing function and it should work.

Re: Status Bar Woes

PostPosted: Sun Apr 04, 2021 4:20 pm
by NeoTerraNova
Oh, holy moley! I didn't expect a response THIS fast! THANK YOU!

One question, though: I'm already using the proper Weapon Icon (Inventory.Icon) for another function in the Status Bar. Can I scale down the image, somehow, when it's put into this function?

EDIT: Also, I should have specified, I'm using the standard SBARINFO lump. I'm guessing this is a ZSCRIPT function? I plugged it in and tried to boot it, and I got an error. If it is, I don't have a problem moving over to ZSCRIPT for my HUD, to give it this functionality.

Re: Status Bar Woes

PostPosted: Sun Apr 04, 2021 11:59 pm
by Jarewill
NeoTerraNova wrote:Can I scale down the image, somehow, when it's put into this function?

Yes you can, the scale parameter of DrawImage does just that.
This should draw it half as big:
Code: Select allExpand view
DrawImage(Icons[0], (15, 100), DI_ITEM_OFFSETS, scale:(0.5, 0.5)); 

Meanwhile scale:(2, 2) would draw it twice as big.

NeoTerraNova wrote:EDIT: Also, I should have specified, I'm using the standard SBARINFO lump. I'm guessing this is a ZSCRIPT function? I plugged it in and tried to boot it, and I got an error. If it is, I don't have a problem moving over to ZSCRIPT for my HUD, to give it this functionality.

Yes, this is a ZScript function, I should have specified.
I had no clue how to do this with SBARINFO, without involving a ton of checks for each individual sprite. This was simpler and more efficient.
If you need help converting your SBARINFO HUD to ZScript I can provide help.

Re: Status Bar Woes

PostPosted: Mon Apr 05, 2021 5:04 am
by NeoTerraNova
I appreciate it! Believe me! ^_^

I would like to try my hand at working this myself, first, but I'll definitely come back for help if I need it. For the moment, I'm going to call this Solved, since my actual question was answered. If I need more help, it'll be on a different topic.

Thank you, Jarewill.

Re: Status Bar Woes

PostPosted: Mon Apr 05, 2021 5:09 am
by Virathas
I just would like to add that instead of using scale you can also use "boxsize:(X,Y)" (X and Y are the size of the box) and it will scale the image to fit a particular box in the statusbar. (I personally use this, and it works wonders. Not sure how it interacts when using both boxsize and scale at the same time though)

I personally do recommend moving to ZSCRIPT with your HUD, as SBARINFO is extremely unwieldy and bloat-prone. Also it has extremely limited functions.