查看: 962|回复: 0

[交流讨论] mog插件小功能提取——窗口透明

[复制链接]
梦石
0
星屑
79
在线时间
11 小时
注册时间
2025-5-28
回帖
2
发表于 2025-8-30 16:43:29 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
mog插件MenuBackGround功能提取



源插件的功能是在窗口处添加背景图片,此时为了显示背景图加入了窗口透明度控制功能
遵循作者要求在改动后仍然保留了原作者mog的信息。

具体功能不变

[pre lang="JavaScript" file="TransparentMenuWindows.js"]//=============================================================================
// 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;
    };

})();[/pre]
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部