Game Development Community

Main Menu Sound

by Jace · in Torque 3D Professional · 01/08/2010 (8:40 am) · 11 replies

Issue solved.

#1
01/08/2010 (10:54 am)
Good for you.

Now explain what it was and how you solved it so others will know if they get caught out by it, por favor.
#2
01/08/2010 (4:21 pm)
I noticed that since beta 2 of T3D, or so, that the on_over and on_pressed (or whatever the exact terms are) sounds no longer were there when moving the mouse over and/or pressing the main menu buttons.

Is it like that for everybody? Is that what this post is about?

I assumed it was just something that got turned off at some point and didn't get turned back on again... I didn't play around to see if it might be a bug or not.

So, Jace or whoever, how does one turn that back on again? I was meaning to ask but kinda forgot about it until I read this post.
#3
01/08/2010 (6:21 pm)
I will haft to grab filenames later at work right now.. However the code needed was there it was just commented out. Think it was in the mainscreen GUI cs file. But again I am at work =/ save me!
#4
01/09/2010 (8:01 am)

Checked this with current HEAD and soundButtonDown/Over both work as expected. If there was a bug at some point, it probably got fixed along the way.
#5
01/09/2010 (7:20 pm)
In the meantime for those that want to turn those sounds back on(the way it was in Beta 2 and earlier) before waiting for the next release, one can do this (I don't know why this got disabled so I am not sure if there is something wrong with doing this):

Using the Examples\FPSExample\ as an example...
First off open up game\art\gui\defaultGameProfiles.cs
and uncomment these lines (remove the two forward slashes for those unfamiliar with scripting):
//GuiMenuButtonProfile.soundButtonOver = "AudioButtonOver";
//GuiMenuButtonProfile.soundButtonDown = "AudioButtonDown";

Now you need to make sure those profiles exist so create a file called audioProfiles.cs in game\scripts\client\ with this content:
new SFXProfile(AudioButtonOver)
{
    filename = "art/sound/gui/buttonOver";
    description = "AudioGui";
    preload = false;
};

new SFXProfile(AudioButtonDown)
{
    filename = "art/sound/gui/buttonDown";
    description = "AudioGui";
    preload = false;
};

( The "AudioGui" SFXDescription should already exist in game\core\scripts\client\audio.cs )

Next you need to make sure that file you just created gets exec'ed in game\scripts\client\init.cs
// Use our prefs to configure our Canvas/Window
   configureCanvas();
      
   exec("./audioProfiles.cs");  // ADD THIS LINE

   // Load up the Game GUIs
   exec("art/gui/defaultGameProfiles.cs");



I think that should do it...

/edited for consistency and readability
/edited again to put the \'s back in that got stripped out on the last edit... :\
#6
01/12/2010 (3:15 am)
I did the same thing in my project successfully. Problem is, the game crashes when you hit "Yes" or "No" in the exit message box.

It seems that the soundButtonDown SFXProfile definition for the Main Menu is not retained in the game context for message boxes. But I cannot seem to be able to find where to define this for the exit message box.
#7
01/12/2010 (12:57 pm)
I am not sure what you mean. You mean when in-game you hit the escape key and the "Exit from this Mission?" dialog box pops up? That works the way it should for me. It doesn't have any sounds like the main menu because it is a separate gui.

Maybe the files in \game\core\scripts\gui\messageBoxes\ would be the place to look.

I am not exactly sure what the best way would be to get what you want working. I just restored what was setup in beta 2 to get that main menu making button sounds again.
#8
01/12/2010 (12:58 pm)
Are you defining the SFXProfile as a networked datablock? These get purged when the server is shut down.

To clarify:

datablock SFXProfile() { /* ... */ }; // Valid only during missions; don't keep references around.
singleton SFXProfile() { /* ... */ }; // Client-side datablock; persists between missions.

The Datablock Editor creates networked datablocks (i.e. the first type above).

It shouldn't crash, though. I'll fix this and make sure GuiProfile uses SimObjectPtrs to not cause dangling pointers.
#9
01/12/2010 (1:21 pm)
Changing it to a singleton fixed it, thanks.
#10
01/12/2010 (1:27 pm)
So all the instances of "new" in the example above should be changed to "singleton"?

Yup, that works...

And in the file \game\core\scripts\gui\messageBoxes\messageBox.ed.cs I uncommented this section below and changed the instances of "new" to singleton:

// --------------------------------------------------------------------
// Message Sound
// --------------------------------------------------------------------
singleton SFXDescription(MessageBoxAudioDescription)
{
   volume      = 1.0;
   isLooping   = false;
   is3D        = false;
   channel     = $GuiAudioType;
};

singleton SFXProfile(messageBoxBeep)
{
   filename    = "./messageBoxSound";
   description = MessageBoxAudioDescription;
   preload     = true;
};

and also uncommented:
sfxPlayOnce( messageBoxBeep );

to get a beep when the messagebox pops up. So Rich can probably use these examples to get soundButtonDown/Over sounds for the buttons on that messagebox too if he wants.

#11
01/12/2010 (1:36 pm)
Whether you use 'new' or 'singleton' does not matter in terms of whether you get networked or client-side datablocks.

Only a datablock defined like so

datablock <DatablockClass>() /* ... */;

will be a networked datablock. The difference between 'new' and 'singleton' is simply that 'new' always creates a new object whereas 'singleton', when re-executed, only updates the existing object.

Usually, with datablocks, you'd want to use 'singleton' since datablocks usually follow the singleton pattern.
//Edit: of course only where client-side datablocks make sense... which pretty much is SFX only

For most datablock types, the editor will not even allow you to put references to client-side datablocks into networked objects. SFX datablocks (since 1.1) form an exception and in most cases can be used either way.