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!


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.
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.
Next we find GuiTextEditProfile.
Next we find GuiControlListPopupProfile. Here instead of adding bitmap we modify it as follows
Next is GuiPopupMenuProfile. We change this one like we did the one above.
and finally we have GuiEditorClassProfile
Oops, this is out of place but i forgot about it! so find your GuiSliderProfile and add to it these values
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 :(
Let me preface this resource with some ScreenShots!


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 :(
#23
EDIT: Um, it kinda fixed itself - and yes, I did compile my eh ... to make my .exe =/
07/02/2002 (4:35 pm)
eh, i'm new to compiling and stuff - I didn't see ANY change on my buttons ... I read the post above about rebuilding the binary? Where do I do that? lol!EDIT: Um, it kinda fixed itself - and yes, I did compile my eh ... to make my .exe =/
#24
question: how does one fix this ?????
07/03/2002 (11:24 pm)
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 :( question: how does one fix this ?????
#25
07/31/2002 (1:45 am)
It doesn't work with 1.1.2 well I find anyway?
#26
I commented it out since I didn't see it being used anywhere and that fixed it.
02/09/2003 (10:06 am)
I just tried this on HEAD on I got a compile error.guiConsoleEditCtrl.cpp C:\pophome\csrc\client\popclientTorque\engine\gui\guiConsoleEditCtrl.cpp(18) : error C2065: 'mSinkAllKeyEvents' : undeclared identifier
I commented it out since I didn't see it being used anywhere and that fixed it.
#27
hope that helps...
03/02/2003 (9:41 pm)
You can add the following bold line (which seems to have been omitted) to guiTextEditCtrl.h to fix the problem. (about line 75)bool mHistoryDirty; S32 mHistoryLast; S32 mHistoryIndex; S32 mHistorySize; bool mPasswordText; [b]bool mSinkAllKeyEvents; // any non-ESC key is handled here or not at all[/b] char **mHistoryBuf; void updateHistory(const char *txt, bool moveIndex);
hope that helps...
#28
I'm probably missing something obvious but any help would be appreciated. :)
Edit: Managed to compile without a hitch by modifying Line 34 of objectTypes.h (found in engine/game). With the latest HEAD, Line 34 should read "UNUSED_AVAILABLE = bit(7)," by changing this to "GuiControlObjectType = bit(7)," compilation works. Not sure what the consequences of changing Line 34 are but so far no problems.
08/24/2003 (4:11 pm)
I can't seem to get this to work on the latest HEAD. During compilation I get an error about console/objectTypes.h not existing. After some digging I discovered this was deleted a while back (redundant file?). There is a objectTypes.h file in game/ but including that into guicontrol.cc results in the following error: c:\torque\engine\gui\guicontrol.cc(50) : error C2065: 'GuiControlObjectType' : undeclared identifierI'm probably missing something obvious but any help would be appreciated. :)
Edit: Managed to compile without a hitch by modifying Line 34 of objectTypes.h (found in engine/game). With the latest HEAD, Line 34 should read "UNUSED_AVAILABLE = bit(7)," by changing this to "GuiControlObjectType = bit(7)," compilation works. Not sure what the consequences of changing Line 34 are but so far no problems.
#30
Incidentally, I was adding this resource in attempt to add the theme editor.
Seems they both need some updating in order to work properly with the latest revs.
05/24/2005 (7:28 pm)
I get some pretty serious compile errors under 1.3:opengl2d3d warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification glu2d3d warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification c:\Torque\SDK\engine\gui\guiEditCtrl.cc(829): error C2039: 'getChildPos' : is not a member of 'GuiScrollCtrl' c:\Torque\SDK\engine\gui\guiControl.cc(17): fatal error C1083: Cannot open include file: 'console/objectTypes.h': No such file or directory c:\Torque\SDK\engine\gui\guiConsoleEditCtrl.cc(16): error C2065: 'mSinkAllKeyEvents' : undeclared identifier
Incidentally, I was adding this resource in attempt to add the theme editor.
Seems they both need some updating in order to work properly with the latest revs.
#31
ConsoleMethod( GuiSliderCtrl, getValue, F32, 2, 2, "Get the position of the slider.")
{
return object->getValue();
}
Other than that everything work great. THANKS!
08/31/2005 (9:23 am)
Great resource! Just one minor issue. The following lines of code must be added to guiSliderCtrl.cc in order for the getValue function to work propperly.ConsoleMethod( GuiSliderCtrl, getValue, F32, 2, 2, "Get the position of the slider.")
{
return object->getValue();
}
Other than that everything work great. THANKS!
#32
12/01/2005 (5:27 am)
Has anyone gotten this to work with 1.4? If so, would you consider posting an update to the files?
#33
05/31/2006 (3:11 pm)
I got it to compile in 1.4 CVS but none of the images show up.
#34
10/03/2006 (11:04 am)
it's merged into HEAD 1.4.2. Nice one! :)
#35
But when I used the included guiControl.cc and .h, crashed on start up.
Any help ?
:-)
10/15/2006 (10:36 am)
Really great resource. I got it compiled in 1.3 without any problem.But when I used the included guiControl.cc and .h, crashed on start up.
Any help ?
:-)
Torque Owner BLACKHOUND