I think that is possible! I'll give you some general guidelines. I've not tested it myself so a little tweaking may be required...
First of all you'll have to open the
Titlesbank\default\title.lua file (or any other, but I'll be editing this one).
Scroll down to the main section of the script. You'll see the following:
if g_MouseX > 50-(GetImageWidth(g_imgButton[1])/2) and g_MouseX <= 50+(GetImageWidth(g_imgButton[1])/2) then
for i = 1, TITLE_QUIT, 1
do
if g_MouseY > g_posButton[i] and g_MouseY <= g_posButton[i]+GetImageHeight(g_imgButton[i]) then
iHighlightButton = i
end
end
end
and:
for i = 1, TITLE_QUIT, 1
do
if iHighlightButton == i then
SetSpriteImage ( g_sprButton[i], g_imgButtonH[i] )
else
SetSpriteImage ( g_sprButton[i], g_imgButton[i] )
end
end
if g_MouseClick == 1 then
if iHighlightButton==TITLE_NEW then
SwitchPage("")
end
if iHighlightButton==TITLE_LOADGAME then
SwitchPage("loadgame")
end
if iHighlightButton==TITLE_ABOUT then
SwitchPage("about")
end
if iHighlightButton==TITLE_QUIT then
QuitGame()
end
end
The first snippet handles the hovering over a button, the second for the actual click. So we will paste the code for playing a sound here.
Second we need to actually load and play the sound, so here's how to do that (thanks to the new commands):
1) In the
init part of the script we will load the sound:
LoadGlobalSound("audiobank\\hover_sound_example.wav",0)
LoadGlobalSound("audiobank\\click_sound_example.wav",1)
2) Play the sound
PlayGlobalSound(sound_index)
With sound index being 0 for the hover sound and 1 for the click sound.
3) Place the PlaySound command in the title.lua file like so:
-- control menus
SetSpritePosition ( g_sprCursor, g_MouseX, g_MouseY )
iHighlightButton = 0
if g_MouseX > 50-(GetImageWidth(g_imgButton[1])/2) and g_MouseX <= 50+(GetImageWidth(g_imgButton[1])/2) then
for i = 1, TITLE_QUIT, 1
do
if g_MouseY > g_posButton[i] and g_MouseY <= g_posButton[i]+GetImageHeight(g_imgButton[i]) then
iHighlightButton = i
PlayGlobalSound(0)
end
end
end
for i = 1, TITLE_QUIT, 1
do
if iHighlightButton == i then
SetSpriteImage ( g_sprButton[i], g_imgButtonH[i] )
else
SetSpriteImage ( g_sprButton[i], g_imgButton[i] )
end
end
if g_MouseClick == 1 then
PlayGlobalSound(1)
if iHighlightButton==TITLE_NEW then
SwitchPage("")
end
if iHighlightButton==TITLE_LOADGAME then
SwitchPage("loadgame")
end
if iHighlightButton==TITLE_ABOUT then
SwitchPage("about")
end
if iHighlightButton==TITLE_QUIT then
QuitGame()
end
end
And that should do it... Make sure to back up your files, because they are replaced with every update. You can always make your own style by creating a new folder in the Titlesbank and replace the content of the file
style.txt with the name of your new folder.
Hope this helps