Game Development Community

Does AudioButtonDown work?

by Ritchey "Hawk" Mulhollem · in Torque Game Engine · 08/25/2004 (2:51 pm) · 19 replies

Does anyone know if the AudioButtonDown function work? I added the definition to my audioProfile.cs:
new AudioProfile(AudioButtonDown)
{
   filename = "~/data/sound/buttonDown.ogg";
   description = "AudioGui";
	preload = true;
};
...for both Over and Down. Over works just fine, but Down has no effect on the menu buttons. I know its not the path to the sound file because I swapped the two and it works with the Down sound.

It's listed in guiTypes in the game engine:
// sound members
   AudioProfile *mSoundButtonDown;                 ///< Sound played when the object is "down" ie a button is pushed
   AudioProfile *mSoundButtonOver;                 ///< Sound played when the mouse is over the object
...so I know the engine was designed to use it. Any ideas??

#1
08/25/2004 (3:08 pm)
The engine was designed to use it, most probably. But as far as I know it doesn't work.

I go around the problem by creating a function that is called upon pressing the button, that plays the sound and does the command.
#2
08/25/2004 (3:52 pm)
It works and it works fine !

Edit.
check the client/ui/defaultGameProfiles.cs
On the top add a new line for the AudioButtonDown
like this
GuiButtonProfile.soundButtonDown = "AudioButtonDown";

Dont forget to add a new Audioprofile in client/audioProfiles.cs
#3
08/25/2004 (5:44 pm)
Stefan: Cool! Glad to know it was not just me! I might just have to do the same thing then.
Billy: Doesn't work. I cut-n-pasted the line directly into the module. Besides, that would not explain why ButtonOver works now without that line added. I am working off the latest build from the CVS, are you?
#4
08/25/2004 (5:57 pm)
Sorry !
I wrote wrong filename !
Check in this file client/ui/defaultGameProfiles.cs
there you should have the ButtonOver already !
I edited above hope it works now.
#5
08/25/2004 (7:54 pm)
You are a genious! It works great now! Well I am glad my question has helped others. Thanks Billy!

For anyone else following this thread the solution was to add the following line to "client/ui/defaultGameProfiles.cs":

GuiButtonProfile.soundButtonDown = "AudioButtonDown";
#6
09/18/2004 (12:20 pm)
@Billy I added this GuiButtonProfile.soundButtonDown = "AudioButtonDown"; to my files and I still dont get button over or button down sounds. I have other sounds in the same directory and they work fine but no buttons. Any Ideas?
#7
09/18/2004 (1:33 pm)
@Howard
have you checked the client/audioprofiles.cs ?
#8
09/18/2004 (3:14 pm)
For what Billy? If you mean does the button sound exist then yes. This is in my client/audioprofiles.cs

new AudioProfile(AudioButtonOver)
{
filename = "~/data/sound/gui/button.wav";
description = "AudioGui";
preload = true;
};

There are 2 audioprofiles.cs the one in the server dont have this defined.
#9
09/18/2004 (3:39 pm)
Ok i understand .
There is 2 kind of buttons but they use differnt profiles .
You can do 2 ways here

1. Use the GuiButtonProfile on the Bitmapbutton or
2. make some new lines called GuiBitMapButtonProfile.soundButtonOver and Down
#10
09/25/2004 (8:58 am)
Still screwed up...either it can't find it, doesn't use it or just plain crashes. I guess I wont be using button sounds
#11
09/25/2004 (9:56 am)
I bind all my buttons to a function that calls a sound. That's a workaround and not a solution but it works just as good.
#12
09/25/2004 (10:12 am)
Thanks Stefan, I'll give that a shot.
#13
09/25/2004 (11:21 am)
No, it DOES work! I have it working in my game now! The problem is with how the Torque example is written. It loads profiles and then immediately deletes them and loads new ones. That is what happens to the buttons. It loads the sound profiles, deletes them, then never puts them back. So even though you tell it what to use, it just deletes it.

I'm slowly writing a stripped version of the starter.fps example that removes much of the BS without changing how it functions. It's not ready for the public, but I can send you what I have: rthawkcom@yahoo.com

Anyway, to re-enable the sounds verify these items:

1. Profiles are defined in /client/scripts/audioprofiles.cs
new AudioProfile(AudioButtonOver){
   filename = "~/data/sound/buttonOver.wav";
   description = "AudioGui";
   preload = true;
};


new AudioProfile(AudioButtonDown){
   filename = "~/data/sound/buttonDown.wav";
   description = "AudioGui";
   preload = true;
};

2.Profiles are attached to profile GuiButtonProfile in starter/client/ui/defaultGameProfiles.cs

GuiButtonProfile.soundButtonOver = "AudioButtonOver";
GuiButtonProfile.soundButtonDown = "AudioButtonDown";

3. You actually HAVE sound files in data/sound

4. Do not add anything to common/ui/defaultProfiles.cs (like is shown in the example) because it will just get deleted.
#14
09/25/2004 (11:29 am)
This is getting way too confusing. I get errors like it can't find the audio profiles because at the time the button is defined the audio profiles have not been exec'ed so I tried to add the audioprofiles.cs before calling the defaults and it crashes. So I moved things to the game/server directory and it complains that things aren't defined.

I have a custom button I derive from the standard gui button (different colors fonts etc) so If I put it in the customprofiles.cs file it crashes or wont show the button so I moved it over to the defaults to get it to work.

It would be just great to have all the gui deffs in one file to cut the confusion.
#15
09/25/2004 (12:03 pm)
I agree with Howard. On top of this, if you mix capital and non-capital letters in your descriptions and names, sometimes they won't get called at all. I haven't fiddled around with that part for a while but I might be able to reproduce this next week again and give some details.
#16
09/25/2004 (12:07 pm)
You can't just go re-arranging how things are called in the example. It's a deck of cards in there. Yes, I know what you mean about the crashing. That's due to missing profiles. Instead of alerting you that it can't find something, Torque just up and crashes instead.

I know exactly what you mean, hence why I re-wrote their example. The inside of that example is a complete mess. I know why they did it. For "MOD'ing". However, people like us don't give a rats ass about modding we just want to write a functional game!

They need to write a beginners example level that has fixed keyboard mapping, fixed profiles and to stop scattering their code all over the damn place. I usually add my functions inside the gui that is calling it so as not to have an extra file.

Always, always, always, delete those .DSO files! I have a batch file that goes though and does clean up. Sometimes Torque recompiles the DSO files, sometimes it does not, depends on what kind of mood it is in. That alone can allow the program to run even when your code has an error which is VERY bad! It's bitten me many, many times.

Give me your email address and I will send you what I have with some of my trouble shooting notes. It will save you hours of trouble shooting time. And I DO mean hours!!
#17
09/28/2004 (10:25 pm)
>I know why they did it. For "MOD'ing". However, people like us don't give a rats ass about modding >we just want to write a functional game!

Damn skippy.
#18
06/21/2005 (7:30 pm)
Im gona bump this up again to see if anyone has a solution.
@Stefan when you say you bind the button to a function do you mean in C++ ? Got an example of where to add it?

Here is what I have.
In client/scripts/AudioProfiles.cs

new AudioProfile(AudioButtonOver)
{
filename = "~/data/sound/gui/buttonover.ogg";
description = "AudioGui";
preload = true;
};

new AudioProfile(AudioButtonDown)
{
filename = "~/data/sound/gui/buttondown.ogg";
description = "AudioGui";
preload = true;
};

Both button sounds are in that directory and are valid sounds.

In client/ui/defaultGameProfiles.cs at the top

GuiDefaultProfile.soundButtonOver = "AudioButtonOver";
GuiDefaultProfile.soundButtonDown = "AudioButtonDown";

I get no sound when mouse over the buttons. I built a debug version of the game and set breakpoints at guiTypes.cc

if (def)
{
mTabable = def->mTabable;
mCanKeyFocus = def->mCanKeyFocus;

mOpaque = def->mOpaque;
mFillColor = def->mFillColor;
mFillColorHL = def->mFillColorHL;
mFillColorNA = def->mFillColorNA;

** OTHER CODE REMOVED

<< BREAKPOINT
// default sound
mSoundButtonDown = def->mSoundButtonDown;
mSoundButtonOver = def->mSoundButtonOver;

Both of these items are null no matter what I do.

I opened the console at the main menu and do a dump on GuiDefaultProfile and the audio descriptions are there and do a dump on the audio descriptions and they point to the files..

NO CLUE....why this dont work. Seems to be declared fine in the script but not being passed to the engine.
#19
06/22/2005 (5:41 am)
Bump Again Howard :)
I hope you use the defaultprofile on your button.
Othervise this should work , check your audiofiles , AudioGui description and the $AudioType.
No C++ is involved here .
You are doing the right thing !
To be sure of the audiofile use a wav file.