Game Development Community

Skinnable GUI Controls in TGE

by Justin DuJardin · 06/06/2002 (1:08 pm) · 35 comments

Download Code File

Let me preface this resource with some ScreenShots!

hosted.tribes-universe.com/gameportal/legends.jpg
hosted.tribes-universe.com/gameportal/legendsXP.jpg
Let me begin by saying that this code is provided as is, with no assurance of proper functionality with your TGE setup, it has been tested on a clean HEAD build from the CVS and I used that as the basis for writing this resource.

I only post this code in hopes that you (the community) will help me to improve upon something i've put a bit of time and heart into creating. You're free to use this (duh?!) but I would ask that if you make any updates/changes to the code that you submit them to myself as well so I may update this resource.

On to the implementation!

First off, in the accompanying zip file there are modified GUI class .cc's and .h's, you simply overwrite your orginials (if they're un-modified by yourself) with these and compile. Simple enough?

There is ONE OPTIONAL EXCEPTION, I modified guiControl.cc and .h to support an extra border type. If you set the border = 5 then the control references the bitmap of that profile and uses it to draw the border. example below.

new GuiControlProfile(GuiDefaultBorderProfile : GuiDefaultProfile)
{
   hasBitmapArray = true;
   border = 5;
   bitmap = "fps/data/skins/WindowsXP/XPGuiBorder";

};

If you don't wish to add that functionality to your program, then simply don't use the guiControl.cc and .h from the zip.

Pretty simple thus far, ehh? Well the next piece is the only queer part. Now we must modify your defaultProfiles.cs, Most people have these already modified so i'll show you what to change if you've already got your default profiles like you like them. If you don't really care, i've also included a defaultProfiles.cs in the zip that you can use which is just a clean HEAD build defaultProfiles.cs with the changes that i'll list below.

starting from the top of the defaultProfiles.cs we'll go down the list.

first off, in any text editor with a replace/replace all option, i've changed the naming convention of the bitmaps to match. I did this because i failed to see the logic behind having darkWindow and then torqueRadio, torqueCheck, etc.. So open it up, go to replace, and replace all 'darkWindow' with 'torqueWindow', then all 'darkScroll' with 'torqueScroll'.

Next we have to add some stuff to the default profiles. First we find GuiButtonProfile, we need to add a hasBitmapArray = true and a bitmap member to them.

if(!isObject(GuiButtonProfile)) new GuiControlProfile (GuiButtonProfile)
{
   opaque = true;
   border = true;
   fontColor = "0 0 0";
   fontColorHL = "32 100 100";
   fixedExtent = true;
   justify = "center";
	canKeyFocus = false;
   [b]hasBitmapArray = true;
   bitmap = "./torqueButton";[/b]

};


Next we find GuiTextEditProfile.

if(!isObject(GuiTextEditProfile)) new GuiControlProfile (GuiTextEditProfile)
{
   opaque = true;
   fillColor = "255 255 255";
   fillColorHL = "128 128 128";
   border = 3;
   borderThickness = 2;
   borderColor = "0 0 0";
   fontColor = "0 0 0";
   fontColorHL = "255 255 255";
   fontColorNA = "128 128 128";
   textOffset = "0 2";
   autoSizeWidth = false;
   autoSizeHeight = true;
   tab = true;
   canKeyFocus = true;
   [b]bitmap = "./torqueTextEdit";
   hasBitmapArray = true;[/b]

};

Next we find GuiControlListPopupProfile. Here instead of adding bitmap we modify it as follows

if(!isObject(GuiControlListPopupProfile)) new GuiControlProfile (GuiControlListPopupProfile)
{
   opaque = true;
   fillColor = "255 255 255";
   fillColorHL = "128 128 128";
   border = true;
   borderColor = "0 0 0";
   fontColor = "0 0 0";
   fontColorHL = "255 255 255";
   fontColorNA = "128 128 128";
   textOffset = "0 2";
   autoSizeWidth = false;
   autoSizeHeight = true;
   tab = true;
   canKeyFocus = true;
   [b]bitmap = "./torquePopupMenu";[/b]
   hasBitmapArray = true;
};


Next is GuiPopupMenuProfile. We change this one like we did the one above.

if(!isObject(GuiPopUpMenuProfile)) new GuiControlProfile (GuiPopUpMenuProfile)
{
   opaque = true;
   mouseOverSelected = true;

   border = 4;
   borderThickness = 2;
   borderColor = "0 0 0";
   fontSize = 14;
   fontColor = "0 0 0";
   fontColorHL = "32 100 100";
   fontColorSEL = "32 100 100";
   fixedExtent = true;
   justify = "center";
   [b]bitmap = "./torquePopupMenu";[/b]
   hasBitmapArray = true;
};


and finally we have GuiEditorClassProfile

if(!isObject(GuiEditorClassProfile)) new GuiControlProfile (GuiEditorClassProfile)
{
   opaque = true;
   fillColor = "232 232 232";
   border = true;
   borderColor   = "0 0 0";
   borderColorHL = "127 127 127";
   fontColor = "0 0 0";
   fontColorHL = "32 100 100";
   fixedExtent = true;
   justify = "center";
   bitmap = "./torquePopupMenu";
   hasBitmapArray = true;
};


Oops, this is out of place but i forgot about it! so find your GuiSliderProfile and add to it these values

if(!isObject(GuiSliderProfile)) new GuiControlProfile (GuiSliderProfile)
{
   [b]hasBitmapArray = true;
   bitmap = "./torqueSlider";[/b]
};

That should get you setup to use your own skinnable controls!

Skinnable they are, but changeable is a different story, I devised a way to make skins for our project, but it took a bit of scripting restructuring and I really just don't have the energy to include it in this resoruce, perhaps at a later date. However the changing bitmaps on the fly code is still implemented in the controls, so changing a control's skin is as simple as overwriting it's GuiControlProfile in-game, if you do that it will automatically update itself.

Good luck, and I hope I didn't forget anything!

Oh yes, I included a windowsxp style skin in the resource so add those bitmaps in your common/ui directory :)

*NOTE* I just took the Zip, and a new clean HEAD (not the one i used to compile this resource) extracted the files, rebuilt the libs and .exe and started. The bitmaps weren't visible! Not to fear, it's the damned .dso's for some reason it wasn't re-compiling the defaultProfiles.cs in common/ui. So if you experience this problem, just delete the .dso's in common/ui

One thing you may notice is that in some of the editors the textedit's use weird bitmaps, this is not my fault and i won't go into step by step fixing all the profiles *glares at GG guys*. Had they simply derived them all from the default profiles there wouldn't be this problem :(
Page «Previous 1 2
#1
06/06/2002 (1:54 pm)
Hey, sounds pretty cool!! But do you have a larger screenshot with some example skins? Would really like to see it before I change my code... ;-) Thanks a lot!
#2
06/06/2002 (2:23 pm)
Sure thing, posted it in the resource
#3
06/06/2002 (2:31 pm)
Justin Dujardin - Skinnable Controls
Justin Mette - Skinnable Controls

COINCIDENCE? I THINK NOT!
#4
06/06/2002 (2:35 pm)
Now that's a deal! Looks great, I for sure will put this one into our code!! :-) Thanks for posting it!! :-))
#5
06/06/2002 (3:25 pm)
This looks great, should save a lot of messing around.
#6
06/06/2002 (4:30 pm)
Please let me know of any troubles you have (i'm sure one or two ppl will have problems.) I'll fix them as expediently as possible.
#7
06/06/2002 (5:42 pm)
Excellent Work Justin.

Would be great if the community could start getting a gallery of skins together.

Now sumone has to code a skin previwer and auto applyer :)

So anyone can change skins on the fly (Like deus ex where u can change skins and colours for menus)
#8
06/06/2002 (6:43 pm)
Great tutorial :)
So what is happening with legends? I've heard a lot about it.
#9
06/07/2002 (2:06 am)
I have made some small C++ changes and got realtime theme switching working with it...just need to finish the script portion of it and I'll share it.

Update: I got theme switching in realtime working from the optionsDlg. You basically create a dir titled what your theme is called, then you put all of your themes images in this dir and add a [themeName]Theme.th file that specifies all of your images. Right now its basic in that it only changes the bitmaps. I'm gonna add text color, etc to the theme files soon. I was gonna go ahead and post the current one now but I think I'll wait and post the full thing. Should be done sometime tomorrow evening as long as things go well. I'll post my theme manager in another resource since it will be rather large...as long as Avon doesnt object to me using his tutorial as a basis.

--------------------------------

Note: For the Gui editor to display correctly you need to add:

bitmap = "./torqueTextEdit";
hasBitmapArray = true;

to the GuiInspectorTextEditProfile profile.
#10
06/07/2002 (5:36 am)
THis maybe a dumb question but how can I get those fancy buttons like yours? maybe I'm tired...
#11
06/07/2002 (6:05 am)
There's a link at the top of the resource :)
#12
06/07/2002 (6:43 am)
Sexay Justin. This is really neat!
#13
06/07/2002 (10:27 am)
Nice job [av0n] ;)
#14
06/07/2002 (7:57 pm)
mmm I don't get different buttons. But the same gray ones with the gray background?
#15
06/08/2002 (4:33 am)
Edward,

Did you re-build your binary? If so, also make sure you followed the instructions provided here for modifying the default profiles.
#16
06/08/2002 (5:02 am)
yeah thanks it works now :-D.
#17
06/08/2002 (7:07 pm)
Where can I change the bit behind the buttons?(The gray bit)
#18
06/09/2002 (1:48 pm)
I am wondering, does the GUI editor suppossed to work when you get done installing this or is that possible. When I hit f10 I get an exception breakpoint error, or somthing like that, then the engine kicks out.

Looking at the tutorial again I mite not have done the "naming convention" thing right. Could you elaborate on that a little more. I am not a very accomplished programmer.
#19
06/13/2002 (1:32 am)
How can I change the gray to a white or something?
#20
06/21/2002 (4:12 pm)
Awesome stuff
Page «Previous 1 2