//=============================================================================
// TransparentMenuWindows.js
//=============================================================================
/*:
* @target MZ
* @plugindesc (v1.0) 插件允许更改菜单的背景图像。//提取了一一些功能
* @author Moghunter
* @url https://mogplugins.wordpress.com
*
* @param Window Opacity
* @desc Set the opacity of menu windows (0 = fully transparent, 255 = fully opaque).
* @type number
* @default 0
* @min 0
* @max 255
*
* @param Disable Scenes
* @desc 放在这里白名单不会受到影响(e.g., Scene_Title, Scene_Message).
* @default Scene_Title,Scene_Message
*
* @help
* =============================================================================
* ♦♦♦ MOG - 菜单背景 ♦♦♦
* Author - Moghunter
* Version - 1.0
* Updated - 2020/10/18
* https://mogplugins.wordpress.com
* =============================================================================
* 改编自mog插件menubackground设置不同的窗口透明
*/
(() => {
// Plugin Parameters
const parameters = PluginManager.parameters('TransparentMenuWindows');
const windowOpacity = Number(parameters['Window Opacity'] || 0);
const disableScenes = String(parameters['Disable Scenes'] || 'Scene_Title,Scene_Message').split(',');
// SceneManager Flag for Menu Scenes
SceneManager._transparentWindows = false;
//=============================================================================
// ■■■ Window Base ■■■
//=============================================================================
// ALIAS: Initialize
const _windowBase_initialize = Window_Base.prototype.initialize;
Window_Base.prototype.initialize = function(rect) {
_windowBase_initialize.call(this, rect);
if (this.needUpdateOpacity()) {
this.updateOpacity();
}
};
// ALIAS: Update
const _windowBase_update = Window_Base.prototype.update;
Window_Base.prototype.update = function() {
_windowBase_update.call(this);
if (this.needUpdateOpacity()) {
this.updateOpacity();
}
};
// Check if Opacity Update is Needed
Window_Base.prototype.needUpdateOpacity = function() {
return SceneManager._transparentWindows;
};
// Update Window Opacity
Window_Base.prototype.updateOpacity = function() {
this.opacity = windowOpacity;
};
//=============================================================================
// ■■■ Scene MenuBase ■■■
//=============================================================================
// Check if Scene Should Skip Transparency
Scene_MenuBase.prototype.isTransparencyDisabled = function() {
if (!SceneManager._scene) return false;
return disableScenes.includes(SceneManager._scene.constructor.name);
};
// ALIAS: Create Background
const _sceneMenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function() {
SceneManager._transparentWindows = !this.isTransparencyDisabled();
_sceneMenuBase_createBackground.call(this);
};
// ALIAS: Terminate
const _sceneMenuBase_terminate = Scene_MenuBase.prototype.terminate;
Scene_MenuBase.prototype.terminate = function() {
_sceneMenuBase_terminate.call(this);
SceneManager._transparentWindows = false;
};
//=============================================================================
// ■■■ Scene Map ■■■
//=============================================================================
// ALIAS: Call Menu
const _sceneMap_callMenu = Scene_Map.prototype.callMenu;
Scene_Map.prototype.callMenu = function() {
_sceneMap_callMenu.call(this);
SceneManager._transparentWindows = false;
};
})();