Change Menu Open and Close sound

Yes, in the system tab you can select what sound to play when handling 'OK' and 'Cancel'. I know this is a way to change the sounds.


But I would like to have independent sounds, so that opening the menu has its very own sound. And closing the menu too.


For example: I want the menu to have a 'backpack' theme. When you open the menu, you hear a zipper. When you close the menu, you hear another zipper sound, as if you open and close a backpack. But I don't want to have the zipper sound played everytime you confirm something in the game!


I tried to figure this out myself, I changed the opening sound simply by changing the call menu script soundmanager playOk to playShop and then change the Shop sound to anything I wanted to hear when opening the menu.


However, I couldn't do the same for the closing sound, because I can't find the script call!


Still, it would be better to have a plugin that changes these sounds, without having to solve it as I did.


Anyone who can help me out?   ~Thankyou!
I'm just tinkering around right now to find an answer.


I see a lot of system sounds have their own global SoundManager function in rpg_managers.js, so find those called functions you can replace them when they are called inside the replicated menu functions for your plugin.


Change the sound in perhaps search for the occurrence of


SoundManager.playOk();



and replace that with


AudioManager.playStaticSe({"name":"Applause1","pan":0,"pitch":100,"volume":90});


just an example where Applause1 is the ogg/m4a couple in your sounds. Pan, pitch, and volume are self explanatory because it's like the sounds window.


You may need a boolean if the menu function is calling a certain menu name. I didn't dig that deep yet. I will if you need me to. I'm just not sure if this is a plugin request.
I'm just tinkering around right now to find an answer.


I see a lot of system sounds have their own global SoundManager function in rpg_managers.js, so find those called functions you can replace them when they are called inside the replicated menu functions for your plugin.


Change the sound in perhaps search for the occurrence of



SoundManager.playOk();



and replace that with



AudioManager.playStaticSe({"name":"Applause1","pan":0,"pitch":100,"volume":90});


just an example where Applause1 is the ogg/m4a couple in your sounds. Pan, pitch, and volume are self explanatory because it's like the sounds window.


You may need a boolean if the menu function is calling a certain menu name. I didn't dig that deep yet. I will if you need me to. I'm just not sure if this is a plugin request.

Alright! That would solve the opening sound! Thankyou. 


Yet, I can't find the Soundmanager.playCancel(); .  Well, there is one, but this one changes ALL the cancel sounds..


So I still need a certain line where it changes the 'cancel' sound only for quitting the menu..


Thank you for your help!
I'm stumped.


I've learned that in


Window_Selectable.prototype.processCancel //rpg_windows.js


In the chance it's canceling from an item category this._category will make an identifiable string like "keyitem".


But I can't find anything to identify parent categories unless this needs to be added in whatever initiates that to return such a string.


I'm guessing this is the function with the playCancel you are talking about.
Alright! I solved it!


In an unexpected way....


First, I added a plugin with only the lines:


Scene_Map.prototype.callMenu = function() {
AudioManager.playStaticSe({"name":"OpenMenu","pan":0,"pitch":100,"volume":90});
SceneManager.push(Scene_Menu);
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._mapNameWindow.hide();
this._waitCount = 2;
};


For the opening sound, thanks to Mogwai.


Then, I added the plugin Yanfly's MainMenuManager.


In that plugin I removed the line:


this._commandWindow.setHandler('cancel', this.popScene.bind(this));


Now you can't exit the menu by pressing the cancel button.


Then I added a menu option called 'Quit Menu' with Yanfly's MainMenuManager.


It quits the menu and calls a common event.


In that common event it says: Play SE 'Zipper'


So the menu can only be closed by handling the 'Quit Menu' option, causing it to run a common event, quits the menu while it plays my desired SE.


Problem Solved!


Thank you so much for your time, Mogwai!
@TheLegendOfWolf


I'm not sure what I did or if I understand. You will want a cancel button; that's just basic UI. The Yanfly plugin corrects the cancel button?
I deleted the line to quit the menu by pressing 'X'.


With Yanlfy's plugin, I added a menuoption called 'QuitMenu'.


This quits the menu and runs a common event, which I have set to play my 'CloseBackpack SE'.


So there is only one way to quit the menu. And that way will play the SE I wanted!
How about if you check a boolean in the cancel menu function? like this.


Scene_Map.prototype.callMenu = function() {
AudioManager.playStaticSe({
"name": "OpenMenu",
"pan": 0,
"pitch": 100,
"volume": 90
});
$gameMap._inZipperMenu = true; // zipper menu activated
$gameMap._zipperSubmenu = 0;
SceneManager.push(Scene_Menu);
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._mapNameWindow.hide();
this._waitCount = 2;
};
Window_Selectable.prototype.processCancel = function() {
if ($gameMap._inZipperMenu !== undefined && $gameMap._inZipperMenu &&
$gameMap._zipperSubmenu === 0) {
$gameMap._inZipperMenu = false; // deactivate zipper menu
AudioManager.playStaticSe({
"name": "(CloseMenu?)",
"pan": 0,
"pitch": 100,
"volume": 90
});
} else
SoundManager.playCancel();
if (!isNaN($gameMap._zipperSubmenu))
$gameMap._zipperSubmenu--;
this.updateInputData();
this.deactivate();
this.callCancelHandler();
};
// edit: forgot so it doesn't play the sound cancelling a submenu
Window_Selectable.prototype.processOk = function() {
$gameMap._zipperSubmenu = isNaN($gameMap._zipperSubmenu) ?
0 : $gameMap._zipperSubmenu + 1; // in a submenu
if (this.isCurrentItemEnabled()) {
this.playOkSound();
this.updateInputData();
this.deactivate();
this.callOkHandler();
} else {
this.playBuzzerSound();
}
};


Now, are you sure this is the menu you want the particular sound in and not a submenu?
I'm just tinkering around right now to find an answer.


I see a lot of system sounds have their own global SoundManager function in rpg_managers.js, so find those called functions you can replace them when they are called inside the replicated menu functions for your plugin.


Change the sound in perhaps search for the occurrence of


SoundManager.playOk();



and replace that with


AudioManager.playStaticSe({"name":"Applause1","pan":0,"pitch":100,"volume":90});


just an example where Applause1 is the ogg/m4a couple in your sounds. Pan, pitch, and volume are self explanatory because it's like the sounds window.


You may need a boolean if the menu function is calling a certain menu name. I didn't dig that deep yet. I will if you need me to. I'm just not sure if this is a plugin request.

I tried this but I get a black screen. I don't get it...

bws81691, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


I think you're better off making a new thread with your problem.

Original thread: https://forums.rpgmakerweb.com/threads/change-menu-open-and-close-sound.74219/