SBARINFO

Moderator: GZDoom Developers

Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

A memory/cpu usage problem was brought to my attention over at the skulltag forums. I made a quick fix for this issue.

Code: Select all

- Fixed a massive memory leak in SBARINFO.  The leak also lead to progressive 
  CPU usage.
Attached is the diff as always.
User avatar
Nash
 
 
Posts: 17513
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: SBARINFO

Post by Nash »

Blzut, I think a force scaling option is a good idea to ensure the HUDs will always look "correct".
User avatar
AFADoomer
Posts: 1346
Joined: Tue Jul 15, 2003 4:18 pm

Re: SBARINFO

Post by AFADoomer »

Personally, I would prefer an option that would not require forced scaling... Some way to position items from the top and right edges of the screen, as gets done with the fullscreen hud currently, would be nice. Maybe building in some sort of height/width references, or use some variation of the sethudsize hudmessage coordinate format to format positioning?
Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

My last update seems to have pretty much been ignored so here is an updated version of update #4.

Code: Select all

- Fixed a massive memory leak in SBARINFO.  The leak also lead to progressive 
  CPU usage.
- Fixed: Playerclass didn't work in SBARINFO.
- Fixed: Artiflash was improperly initialized causing it not to display the 
  first time.
- Changed the variable SBarInfoScript to be a pointer to prevent more memory 
  leaks.
Attached is the diff.

Also Torr Samaho is telling me to move the loading location from g_level.cpp so that it not re-parsed every level. Would this be a good idea? (I particularly don't want to do it since the ideal location would be d_main.cpp. Which I've already modified with personal changes.)
User avatar
randi
Site Admin
Posts: 7750
Joined: Wed Jul 09, 2003 10:30 pm

Re: SBARINFO

Post by randi »

Added, but just so you know, I saw these lines in Update #4 and got really worried:

Code: Select all

delete &SBarInfoScript;
delete &huds[i];
delete &commands;
They're not in Update #4.1, thank goodness. I hope that's because you realized that was a very, very, very bad thing to do. You never use delete to free memory that was not allocated with new.
User avatar
Enjay
 
 
Posts: 27648
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: SBARINFO

Post by Enjay »

Finally got to messing with SBARINFO yesterday. A powerful little tool. At last I have got all 10 of my ammo types on a Doom-like status bar. All I have to do now is figure out how much of a departure I want it to look from the original (it's pretty standard ATM).

Anyway, I was wondering about these functions:

drawselectedinventory
drawinventorybar

Both are involved in putting information about inventory items on the screen and both have an option to specify which font will be used for the numbers of the item held. However, unlike most of the font related stuff, I can't see anyway of specifying which colour the font should be and it seems to force a yellow translation onto the font. Is there a colour option for these functions?

And whilst I'm on about colour... Is there any way to specify colour ranges for the numbers that change? ie, could I specify different colours, or even different fonts/graphics for particular bands of health, armour, ammo etc? You know, red for 0-245 health, orange for 25-49 etc?
Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

About font translations, look harder. It is part of the optional arguments at the end.
DrawInventoryBar <style> [, flags, ... ], <size>, <font>, <x>, <y> [, <counterx>, <countery> [, <translation> [, <fontspacing>]]];

Although range coloring will need to be done for Hexen's status bar I do not see a feature to add that to the inventorybar commands anytime soon.
User avatar
Enjay
 
 
Posts: 27648
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: SBARINFO

Post by Enjay »

Aha! thank you. I simply hadn't spotted those options. Obviously, to get the translations, I need to put in counterx and countery values too. Can you explain what these are for? They seem to simply be used to position the numbers (the Wiki says "Counterx and countery is where the numbers should start drawing"), but I'd already done that with the x and y values. What additional stuff do the counter arguments do?

Here's one of my entries that I have used.

drawinventorybar Doom, 7, ENJAYBARFONT, 50, 170, 78, 193, brick;

Initially the numbers were in pretty much the right place with the X and Y values of 50 and 170. To get them where I wanted whilst having the "brick" translation, I needed to add conterx and y values. I initially tried 0, thinking that's what they might have defaulted to before when they weren't explicitly used. By trial and error, I got the numbers back where I wanted by using 78 and 193.
Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

By default the counterx and countery locations are (x+26, y+22) for drawinventorybar. Drawselectedinventory uses (x+30, y+24). Anyone feel like adding that information to the wiki?

I've prepared another SBarInfo update which adds some new flags and fixes some bugs.

Code: Select all

- Fixed: Playerclass still didn't work due to comparing of improper numbers.
- Fixed: The arrows on drawinventorybar had a hard coded location instead of 
  relative to the specified coordinates.
- Added noarrows flag to drawinventorybar to remove the blue arrows drawn when 
  there are more items to the left or right of the viewable bar.
- Added forcescaled flag to the statusbar command.  This is ignored on the 
  inventory and inventoryfullscreen types.
I'm not sure if I went about fixing the first bug the correct way, but it does work.
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: SBARINFO

Post by Graf Zahl »

Patch applied.
User avatar
Enjay
 
 
Posts: 27648
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: SBARINFO

Post by Enjay »

Blzut3 wrote:By default the counterx and countery locations are (x+26, y+22) for drawinventorybar.
So, basically the X and Y values are for putting the numbers onto the screen at similar values to the inventory boxes, but in the background they are getting shifted by 26 and 22 to their actual position if no counter values are specified. If I want to position them exactly myself, I use counterx and countery which overrides the x and x parameters. Would that be correct? If so, I must be missing something because I still don't get what the advantage is. Why are the original X and Y values done that way? Would it not be better to simply have the X and Y arguments work like the counter arguments and do away with the extra arguments? Or am I missing something obvious again (quite likely).

Looks like where my graphics ended up was slightly further across and lower than where I first had them. I thought I'd done that but they look better there. :)
Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

The counterx and countery values are mainly so you could put the numbers in the (for example) top right corner if you wanted. If they are not supplied I just assume you want the same position that the hard coded status bars use (I think I based it directly off of Heretic). In your case the following would be just like not specifying them and having the translation being brick.

Code: Select all

drawinventorybar Doom, 7, ENJAYBARFONT, 50, 170, 76, 192, brick;
Of course if you had a really tall font for the numbers you would also want to adjust the counterx and countery values so that the font doesn't go below the box.
User avatar
Enjay
 
 
Posts: 27648
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: SBARINFO

Post by Enjay »

OK, thanks for the clarification. Just to be absolutely clear, am I right in saying that:

drawinventorybar Doom, 7, ENJAYBARFONT, 50, 170, 76, 192, brick;

and

drawinventorybar Doom, 7, ENJAYBARFONT, 0, 0, 76, 192, brick;

would have the same effect, or do the X and Y values still have some influence even when counter values are used?
Blzut3
 
 
Posts: 3219
Joined: Wed Nov 24, 2004 12:59 pm
Operating System Version (Optional): Kubuntu
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: SBARINFO

Post by Blzut3 »

Well the second one would cause the boxes to be drawn at the top left hand corner of the screen while the numbers are drawn near the bottom of the screen.
User avatar
Enjay
 
 
Posts: 27648
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: SBARINFO

Post by Enjay »

Ah right! finally I see (but only after I checked with actual examples - I think I'm just being a bit thick today).

My mistake was assuming that the x and y values and the counterx and countery values were both to do with the positioning of the font. I think I assumed that because I copied a lot of my code from the example in the Wiki without altering it, so things ended up in much the right place automatically and I assumed that the word "counter" meant something "technical" like "counter-clockwise" rather than the position of the numbers that count how many of each item you have.

And with me assuming all that, I didn't explain what I was meaning properly and you must have thought I just came into town on the 'tard bus. Doh!

Right, finally I get it. The X and Y numbers position the item's icon. By default, the counter ( :roll: ) for that icon will be positioned 26 units across from that position and 22 units down. However, the exact position of the counter can be positioned explicitly by using the counterx and countery values. It's so obvious now. Boy do I feel dumb. :oops:


Oh, I meant to ask, is there any way of getting the inventory to display a #1. The inventory bar that I have made has a small box on it for the number to go in and it just looks a bit odd sitting there with no number on it when I only have a single item of a particular kind.

Return to “Closed Feature Suggestions [GZDoom]”