GUI Control Graphics: Easily modified?
by Paul Sprague · in Torque Game Engine · 08/31/2001 (8:06 pm) · 7 replies
Are the controls skinnable? I would assume they are which is why the T2 gui components are different then the components in the gui editor example I saw. But I have seen zero information about this. Can this be done? Is there a tutorial or information about this somewhere?
Thanks
Thanks
About the author
#2
--Rick GG
09/01/2001 (7:53 am)
The GUI controls that ship withthe V12 are not skinnable. We thought about it but the truth is everbody needs something just a little different so we decided not to. The good news is GUI Controls are a complete breeze to make. Like Matthew said there are lots of poeple already customizing the GUI for their game right now. I am sure you will start to see more tutorials and documenetaion.--Rick GG
#3
11/27/2002 (9:41 am)
Ok so is there a tutorial or information on how to make your own gui? I have skinned the controls that come with the test, but I don't like there setup or design. Some help on this would be wonderful. If someone could tell me how to do this or provide a tutorial and possibly email or send me the link. <- btw complete newbie here. The most I have done is create a mod for tribes 2.
#4
Anyway, I haven't looked for tutorials, but I assume what you want to do is make new controls, or move around the ones that are there.
Press f10 in the game to edit the gui, play around with those options. Have a look at the .ui files in the ./client/ui folder and see how they're scripted if you want to make new ones.
I haven't got into that part yet, still working on vehicles etc., but it looks reasonably straightforward.
Good luck
Nick
11/27/2002 (6:18 pm)
I'm only just starting to look into it. I bought Torque a few months ago but I've been really busy (still am, but I'm squeezing in valuable time with Torque :) ).Anyway, I haven't looked for tutorials, but I assume what you want to do is make new controls, or move around the ones that are there.
Press f10 in the game to edit the gui, play around with those options. Have a look at the .ui files in the ./client/ui folder and see how they're scripted if you want to make new ones.
I haven't got into that part yet, still working on vehicles etc., but it looks reasonably straightforward.
Good luck
Nick
#5
Theme Manager v1.0 avaliable here, which lets you create themes for your buttons, windows, checkboxes ...
Plus Tim Newell has another resource that I found more than helpful when designing GUIs: its the GuiBitmapButtonCtrl Tutorial which allows you to use images as buttons, use highlights and sounds onmouseover. Available here.
Hope they help ...
11/28/2002 (2:18 am)
There is a great tutorial/resource by Tim Newell called Theme Manager v1.0 avaliable here, which lets you create themes for your buttons, windows, checkboxes ...
Plus Tim Newell has another resource that I found more than helpful when designing GUIs: its the GuiBitmapButtonCtrl Tutorial which allows you to use images as buttons, use highlights and sounds onmouseover. Available here.
Hope they help ...
#6
First you need to decide if your new control needs to have notification for mouse events like the mouse ntering or leaving the client are. If you need that functionality you'd make your new control a subclass of GuiMouseMouseEventControl. Otherwise you'll make it a subclass of GuiControl. For this excercise we'll assume you're a sublass of GuiControl.
Since GuiControl based classes are derrived from ConsoleObject you'll need a couple macros that expose it to the console. In your header file you need a typedef for your parent, and a DECLARE_CONOBJECTmacro. In your source file you'll neeed an IMPLEMENT_CONOBJECT macro.
There are a handful of member functions you need to implement:
OnWake - This function gets called when the control needs to wake up. At this point all of it's persistant data fields have been initialized.
OnSleep - Called to put the control to sleep. This deactivates a control.
consoleInit - This is called by the framework and is where you expose your console functions for manipulating your control. Console functions are exposed via calls to Con::addCommand.
initPersistFields - This function is called by the framework and is where you tell the engine about your various data members. Anything exposed here will be saved as part of the .gui file.
onRender - This function is called by the control when your control needs to redraw itself. This funtion is passed a Point2I indicating the offset to start drawing at and a RectI indicating the area that needs redrawn. Note: This is not always the full client area of the control. If you want to always redraw your client area you can call getPosition to get your top left corner as a Point2I and use the member variable mBounds.extent to get the size of your client area.
One other important element is a GuiControlProfile. This class allows designers to create a set of common attributes for all controls. It contains data members such as mFont (the font to use) and mBorder (should the control draw a border).
Hope this rather long post helped. If you have any questions don't hesitate to ask.
11/28/2002 (4:30 am)
If you're interested in what is required for setting a new control class I think I can help.First you need to decide if your new control needs to have notification for mouse events like the mouse ntering or leaving the client are. If you need that functionality you'd make your new control a subclass of GuiMouseMouseEventControl. Otherwise you'll make it a subclass of GuiControl. For this excercise we'll assume you're a sublass of GuiControl.
Since GuiControl based classes are derrived from ConsoleObject you'll need a couple macros that expose it to the console. In your header file you need a typedef for your parent, and a DECLARE_CONOBJECTmacro. In your source file you'll neeed an IMPLEMENT_CONOBJECT macro.
There are a handful of member functions you need to implement:
OnWake - This function gets called when the control needs to wake up. At this point all of it's persistant data fields have been initialized.
OnSleep - Called to put the control to sleep. This deactivates a control.
consoleInit - This is called by the framework and is where you expose your console functions for manipulating your control. Console functions are exposed via calls to Con::addCommand.
initPersistFields - This function is called by the framework and is where you tell the engine about your various data members. Anything exposed here will be saved as part of the .gui file.
onRender - This function is called by the control when your control needs to redraw itself. This funtion is passed a Point2I indicating the offset to start drawing at and a RectI indicating the area that needs redrawn. Note: This is not always the full client area of the control. If you want to always redraw your client area you can call getPosition to get your top left corner as a Point2I and use the member variable mBounds.extent to get the size of your client area.
One other important element is a GuiControlProfile. This class allows designers to create a set of common attributes for all controls. It contains data members such as mFont (the font to use) and mBorder (should the control draw a border).
Hope this rather long post helped. If you have any questions don't hesitate to ask.
#7
P.S.
Thanks J. Donavan Stanley that is a great tutorial finally had a chance to sit down and work through it. I do get a little confused when it comes to coding complete noob here like I said.
11/28/2002 (1:17 pm)
Thanks alex that is exactly what I was looking for; not only because it is a great rescource, but also because it tells you how he did it. Thanks everyone for you help.P.S.
Thanks J. Donavan Stanley that is a great tutorial finally had a chance to sit down and work through it. I do get a little confused when it comes to coding complete noob here like I said.
Associate Matt Fairfax
Night Heron Games