设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 49|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
37
在线时间
6 小时
注册时间
2025-5-28
帖子
3
跳转到指定楼层
1
发表于 前天 16:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
mog插件MenuBackGround功能提取



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

具体功能不变

JAVASCRIPT 代码复制下载
  1. //=============================================================================
  2. // TransparentMenuWindows.js
  3. //=============================================================================
  4. /*:
  5.  * @target MZ
  6.  * @plugindesc (v1.0) 插件允许更改菜单的背景图像。//提取了一一些功能
  7.  * @author Moghunter
  8.  * @url https://mogplugins.wordpress.com
  9.  *
  10.  * @param Window Opacity
  11.  * @desc Set the opacity of menu windows (0 = fully transparent, 255 = fully opaque).
  12.  * @type number
  13.  * @default 0
  14.  * @min 0
  15.  * @max 255
  16.  *
  17.  * @param Disable Scenes
  18.  * @desc 放在这里白名单不会受到影响(e.g., Scene_Title, Scene_Message).
  19.  * @default Scene_Title,Scene_Message
  20.  *
  21.  * @help
  22.  * =============================================================================
  23.  * ♦♦♦ MOG - 菜单背景 ♦♦♦
  24.  * Author   -   Moghunter
  25.  * Version  -   1.0
  26.  * Updated  -   2020/10/18
  27.  * https://mogplugins.wordpress.com
  28.  * =============================================================================
  29.  * 改编自mog插件menubackground设置不同的窗口透明
  30.  */
  31.  
  32. (() => {
  33.     // Plugin Parameters
  34.     const parameters = PluginManager.parameters('TransparentMenuWindows');
  35.     const windowOpacity = Number(parameters['Window Opacity'] || 0);
  36.     const disableScenes = String(parameters['Disable Scenes'] || 'Scene_Title,Scene_Message').split(',');
  37.  
  38.     // SceneManager Flag for Menu Scenes
  39.     SceneManager._transparentWindows = false;
  40.  
  41.     //=============================================================================
  42.     // ■■■ Window Base ■■■
  43.     //=============================================================================
  44.  
  45.     // ALIAS: Initialize
  46.     const _windowBase_initialize = Window_Base.prototype.initialize;
  47.     Window_Base.prototype.initialize = function(rect) {
  48.         _windowBase_initialize.call(this, rect);
  49.         if (this.needUpdateOpacity()) {
  50.             this.updateOpacity();
  51.         }
  52.     };
  53.  
  54.     // ALIAS: Update
  55.     const _windowBase_update = Window_Base.prototype.update;
  56.     Window_Base.prototype.update = function() {
  57.         _windowBase_update.call(this);
  58.         if (this.needUpdateOpacity()) {
  59.             this.updateOpacity();
  60.         }
  61.     };
  62.  
  63.     // Check if Opacity Update is Needed
  64.     Window_Base.prototype.needUpdateOpacity = function() {
  65.         return SceneManager._transparentWindows;
  66.     };
  67.  
  68.     // Update Window Opacity
  69.     Window_Base.prototype.updateOpacity = function() {
  70.         this.opacity = windowOpacity;
  71.     };
  72.  
  73.     //=============================================================================
  74.     // ■■■ Scene MenuBase ■■■
  75.     //=============================================================================
  76.  
  77.     // Check if Scene Should Skip Transparency
  78.     Scene_MenuBase.prototype.isTransparencyDisabled = function() {
  79.         if (!SceneManager._scene) return false;
  80.         return disableScenes.includes(SceneManager._scene.constructor.name);
  81.     };
  82.  
  83.     // ALIAS: Create Background
  84.     const _sceneMenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
  85.     Scene_MenuBase.prototype.createBackground = function() {
  86.         SceneManager._transparentWindows = !this.isTransparencyDisabled();
  87.         _sceneMenuBase_createBackground.call(this);
  88.     };
  89.  
  90.     // ALIAS: Terminate
  91.     const _sceneMenuBase_terminate = Scene_MenuBase.prototype.terminate;
  92.     Scene_MenuBase.prototype.terminate = function() {
  93.         _sceneMenuBase_terminate.call(this);
  94.         SceneManager._transparentWindows = false;
  95.     };
  96.  
  97.     //=============================================================================
  98.     // ■■■ Scene Map ■■■
  99.     //=============================================================================
  100.  
  101.     // ALIAS: Call Menu
  102.     const _sceneMap_callMenu = Scene_Map.prototype.callMenu;
  103.     Scene_Map.prototype.callMenu = function() {
  104.         _sceneMap_callMenu.call(this);
  105.         SceneManager._transparentWindows = false;
  106.     };
  107.  
  108. })();
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-9-1 10:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表