3 State GuiBitmapButtonCtrl Tutorial
by Mark Harmon · 02/13/2003 (5:01 pm) · 7 comments
Download Code File
This update to the GuiBitmapButtonCtrl adds a [i]button pressed[/] state and also makes the button behave exactly like any other button. The original code for this control did not behave like a normal button.
If you haven't already done the original tutorial then go do that first. I'll wait here.
Original Tutorial
Ok now download the zip file and extract the .cc and .h file to your engine/gui/ directory.
Recompile your code.
This control requires three bitmaps per button. Each bitmap corresponds to a button state. The states are unselected/unpressed, selected/unpressed and selected/pressed.
This update to the GuiBitmapButtonCtrl adds a [i]button pressed[/] state and also makes the button behave exactly like any other button. The original code for this control did not behave like a normal button.
If you haven't already done the original tutorial then go do that first. I'll wait here.
Original Tutorial
Ok now download the zip file and extract the .cc and .h file to your engine/gui/ directory.
Recompile your code.
This control requires three bitmaps per button. Each bitmap corresponds to a button state. The states are unselected/unpressed, selected/unpressed and selected/pressed.
About the author
#2
You need to open fps/client/ui/defaultGameProfiles.cs and add the following code to the end of it:
You have to use "GuiBitmapButtonProfile" and you need to create the profile before you start placing buttons or they will use the the "GuiDefaultProfile" and the sounds wont work. "BitmapButtonProfile" wont work either, its not the correct classname.
Viola... sound should work... if you are on windows you may need to place OpenAL32.dll in the working directory of your game exe along with the other dlls
09/10/2003 (8:03 am)
To get the sound to work I had to fiddle with the profile. It was not finding the profile information for "BitmapButtonProfile" or "GuiBitmapButtonProfile" ... You need to open fps/client/ui/defaultGameProfiles.cs and add the following code to the end of it:
new GuiControlProfile ("GuiBitmapButtonProfile")
{
opaque = false;
border = false;
soundButtonOver = "AudioButtonOver";
};You have to use "GuiBitmapButtonProfile" and you need to create the profile before you start placing buttons or they will use the the "GuiDefaultProfile" and the sounds wont work. "BitmapButtonProfile" wont work either, its not the correct classname.
Viola... sound should work... if you are on windows you may need to place OpenAL32.dll in the working directory of your game exe along with the other dlls
#3
Am I missing something?
Kevin
11/03/2004 (10:02 am)
Isn't this control already in the 1.3 and HEAD versions? There is already a guiBitmapButtonCtrl which seems to work exactly like this one... Am I missing something?
Kevin
#4
02/08/2005 (11:11 pm)
I've love to use this feature but I can't get it to work. I created a new GuiBitmapButtonCtrl, and set the "bitmap" field to be the name of my bitmap. I verified that the bitmap file is not read-only. I then load the engine and nothing, just the boring stock brown button. I've tried absolute paths, relative paths, I set it to common/ui/mybutton.bmp, I've put the button bitmap in 4 or 5 different directories and I cannot figure out where that file needs to go or how this works. If I just create a plain ol' bitmap control and add it to my GUI, it loads just fine but the button face just refuses to change to my bitmap! I'm pulling my hair out here.
#5
_ where is:
n = Normal
d = Depressed
h = Highlight
i = Inactive
[Supposedly] Only the Normal state bitmap is required.
Also, you should not include the extension or the state suffix in the bitmap field of the datablock. For example, given the bitmap files "button_n.png", "button_d.png", etc.:
bitmap = "./images/button";
02/11/2005 (12:13 am)
The name of the bitmap is n = Normal
d = Depressed
h = Highlight
i = Inactive
[Supposedly] Only the Normal state bitmap is required.
Also, you should not include the extension or the state suffix in the bitmap field of the datablock. For example, given the bitmap files "button_n.png", "button_d.png", etc.:
bitmap = "./images/button";
#6
Kevin Rogers menions, in the post above this one, that i = Inactive. Ok so when is this state acually used? My buttons work fine without an inactive bimap but the console comes up with errors saying it can't find the Inactive texture. It says something like "Could not locate texture: starter.fps/client/ui/start_button_i".
To get rid of these errors i just made a dummy texture and named it appropriately.
So my question is when is this 'Inactive' state used or called upon? What does it do if anything? Like i said it makes absolutely no difference to my buttons with or without it.
Can anyone explain this to me so i can stop scratching my head???
04/16/2005 (4:58 am)
I'm not having any problems with this but i do have a question. Kevin Rogers menions, in the post above this one, that i = Inactive. Ok so when is this state acually used? My buttons work fine without an inactive bimap but the console comes up with errors saying it can't find the Inactive texture. It says something like "Could not locate texture: starter.fps/client/ui/start_button_i".
To get rid of these errors i just made a dummy texture and named it appropriately.
So my question is when is this 'Inactive' state used or called upon? What does it do if anything? Like i said it makes absolutely no difference to my buttons with or without it.
Can anyone explain this to me so i can stop scratching my head???
#7
05/06/2005 (7:15 am)
Without looking at the code I would guess that the "Inactive" state is used for a button that is present, but deactivated. That is: you can see it, but you cant press it. 
Torque Owner Jared Schnelle
You have to specify a bitmap(only one).
If there is no HoverBitmap specified, it stores the BitmapHandle in the HoverHandle.
If there is no DownBitmap specified, it stores the HoverHandle into the DownHandle.
I like to keep my GUI somewhat simple, and I sometimes want to use just a single texture for a button, this just simplifies it some. Anyhow, good work, I'll probably do something similar for my GUI :)