Game Development Community

dev|Pro Game Development Curriculum

GuiSkinnedProgressBar - Implementing a multi-use skinned progress bar

by Rob Parton · 09/05/2006 (11:23 pm) · 7 comments

Download Code File

I've been working on this off and on for a month, and since I'm absurdly busy with work, I'm going to post this as a complete-yet-incomplete resource. Feel free to do with it as you will, and any changes or improvements are more than appreciated. Just drop them into your engine\gui\controls folder, add them to your project and compile, and everything should be good to go. The included archive has both the header and the source file as well as an example skin for it.

The following features are implemented:
- horizontal progress bar
- boolean toggle in the editor allows you to turn it into a health bar

The following are NOT implemented in this version:
- vertical progress bars
- the bar does not stretch vertically. It will automatically resize vertically to match the height of the skin's pixel height. Some may not like this approach but I prefer the consistancy.

To use this control in your project, just add the following block to your customProfiles.cs file in the /client/ui folder of your project:

new GuiControlProfile (GuiSkinnedProgressProfile)
{
   bitmap = "./progress_green";
   hasBitmapArray = true;
};

And set the profile to GuiSkinnedProgressProfile.

Remember that in its current incarnation, no matter what your resolution is, the bar's height is restricted by the height of your actual bar skin.

#1
09/07/2006 (11:17 am)
I had to change it a bit to work with TGB, but otherwise it works flawlessly. If anyone is curious all I did was remove the parts tied to the "health". I also made console function to set the value from script. Thanks for this!
#2
09/11/2006 (2:07 pm)
Yup, ported to TSE quite well too. Very nice.
#3
04/07/2007 (6:57 pm)
beutiful, exept that the progress bar is always black-and-white.
#4
04/07/2007 (9:32 pm)
Eli: black and white? not sure what would be causing that... what skin/ version of Torque are you using?
#5
08/17/2007 (1:55 am)
This does not work with TGEA due to using the DGL stuff, im suprised it worked with previous versions of TGEA as commented above? I edited and converted the DGL stuff to GFX, but there is still the issue of 'mTextureHandle', im only a novice programmer but im not sure on how to convert mTextureHandle. Any advice?

Chris
#6
11/17/2007 (3:52 pm)
@Erik: how U have it working in TSE? Can you share?

Tnx,Bye :)
#7
10/14/2008 (2:53 am)
Thanks for the resource Rob.

@Others: Porting to TGEA shouldn't be to hard. You just have to change the GL code to the D3D wrapper code.