找回密码
 注册用户
查看: 230|回复: 0

[RMMZ] 【含MV】完美像素缩放模式

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-6-3 10:21:20 | 显示全部楼层 |阅读模式
本帖最后由 烁灵 于 2024-6-20 17:50 编辑

凑数翻译了个寂寞,根本不用翻
避免窗体缩放时像素模糊。

原地址:https://galenmereth.itch.io/pixel-perfect-for-rpg-maker/

效果:
xFIWkK.png




脚本:TDDP_PixelPerfect.js


  1. //=============================================================================
  2. // RPG Maker MZ - Pixel Perfect scaling
  3. //=============================================================================

  4. /*:
  5. * @plugindesc 1.1.1 启用完美像素缩放模式
  6. * @author Galenmereth / TDD
  7. * @help 可选的游戏内菜单选项,控制是否开启完美像素模式
  8. * 汉化 by 烁灵 更多脚本请访问 www.hknmtt.com
  9. * @url https://github.com/TorD/mz-plugins
  10. *
  11. * @param enableIngameOptions
  12. * @text 开启游戏内选项
  13. * @desc 是否在菜单内显示开启完美像素模式
  14. * @type boolean
  15. * @default false
  16. *
  17. * @param labels
  18. * @text 菜单标签
  19. *
  20. * @param en
  21. * @parent labels
  22. * @text EN - English
  23. * @type text
  24. * @default Pixel Perfect Mode
  25. *
  26. * @param ja
  27. * @parent labels
  28. * @text JA - Japanese
  29. * @type text
  30. * @default ピクセルパーフェクトモード
  31. *
  32. * @param zh
  33. * @parent labels
  34. * @text ZH - Chinese
  35. * @type text
  36. * @default 完美像素模式
  37. *
  38. * @param ko
  39. * @parent labels
  40. * @text KO - Korean
  41. * @type text
  42. * @default 픽셀 퍼펙트 모드
  43. *
  44. * @param ru
  45. * @parent labels
  46. * @text RU - Russian
  47. * @type text
  48. * @default Режим Pixel Perfect
  49. */

  50. /*:ja
  51. * @target MZ
  52. * @plugindesc ゲームのピクセルパーフェクトスケーリングモードを有効にする
  53. * @author Galenmereth / TDD
  54. * @help プレーヤーがピクセルパーフェクトモードをオフまたはオンにするためのゲーム内メニューオプションを最適に追加します
  55. * @url https://github.com/TorD/mz-plugins
  56. *
  57. * @param enableIngameOptions
  58. * @text ゲーム内オプションを有効にする
  59. * @desc プレーヤーがゲーム内でPixelPerfectモードをオン/オフするためのゲーム内オプションを表示する場合は切り替えます
  60. * @type boolean
  61. * @default false
  62. *
  63. * @param labels
  64. * @text ゲーム内オプションラベル
  65. *
  66. * @param en
  67. * @parent labels
  68. * @text EN - 英語
  69. * @type text
  70. * @default Pixel Perfect Mode
  71. *
  72. * @param ja
  73. * @parent labels
  74. * @text JP - 日本
  75. * @type text
  76. * @default ピクセルパーフェクトモード
  77. *
  78. * @param zh
  79. * @parent labels
  80. * @text ZH - 中国語
  81. * @type text
  82. * @default 完美像素模式
  83. *
  84. * @param ko
  85. * @parent labels
  86. * @text KO - 韓国語
  87. * @type text
  88. * @default 픽셀 퍼펙트 모드
  89. *
  90. * @param ru
  91. * @parent labels
  92. * @text RU - ロシア
  93. * @type text
  94. * @default Режим Pixel Perfect
  95. */

  96. /*
  97. MIT License

  98. Copyright (c) 2021 Tor Damian Design

  99. Permission is hereby granted, free of charge, to any person obtaining a copy
  100. of this software and associated documentation files (the "Software"), to deal
  101. in the Software without restriction, including without limitation the rights
  102. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  103. copies of the Software, and to permit persons to whom the Software is
  104. furnished to do so, subject to the following conditions:

  105. The above copyright notice and this permission notice shall be included in all
  106. copies or substantial portions of the Software.

  107. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  108. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  109. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  110. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  111. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  112. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  113. SOFTWARE.
  114. */

  115. (() => {
  116.         'use strict';

  117.         ////////////////////////////////////////////////////////////////////////
  118.         // Fetch parameters
  119.         ////////////////////////////////////////////////////////////////////////
  120.         const script = document.currentScript;
  121.         let name = script.src.split('/');
  122.         name = name[name.length-1].replace('.js','');

  123.     const params = PluginManager.parameters(name);

  124.         function usePixelPerfectMode() {
  125.                 return params.enableIngameOptions == "false" || ConfigManager.TDDP_pixelPerfectMode == true;
  126.         }

  127.         ////////////////////////////////////////////////////////////////////////
  128.         // Bitmap extensions
  129.         ///////////////////////////////////////////////////////////////////////
  130.         const _Bitmap_prototype_initialize = Bitmap.prototype.initialize;
  131.         Bitmap.prototype.initialize = function(width, height) {
  132.                 _Bitmap_prototype_initialize.call(this, width, height);
  133.                 this._smooth = !usePixelPerfectMode();
  134.         }

  135.         ////////////////////////////////////////////////////////////////////////
  136.         // Graphics extensions
  137.         ///////////////////////////////////////////////////////////////////////
  138.         const _Graphics__createCanvas = Graphics._createCanvas;
  139.         Graphics._createCanvas = function() {
  140.                 _Graphics__createCanvas.call(this);
  141.                 this.TDDP_updateCanvasImageRenderingMode();
  142.         }

  143.         const _Graphics__updateCanvas = Graphics._updateCanvas;
  144.         Graphics._updateCanvas = function() {
  145.                 _Graphics__updateCanvas.call(this);
  146.                 this.TDDP_updateCanvasImageRenderingMode();
  147.         };

  148.         // NEW
  149.         Graphics.TDDP_updateCanvasImageRenderingMode = function() {
  150.                 this._canvas.style.imageRendering = usePixelPerfectMode() ? 'pixelated' : '';
  151.         }

  152.         if (params.enableIngameOptions == "true") {
  153.                 ////////////////////////////////////////////////////////////////////////
  154.                 // Window_Options extensions - only if ingame options enabled in plugin params
  155.                 ///////////////////////////////////////////////////////////////////////
  156.                 const _Window_Options_prototype_addGeneralOptions = Window_Options.prototype.addGeneralOptions;
  157.                 Window_Options.prototype.addGeneralOptions = function() {
  158.                         _Window_Options_prototype_addGeneralOptions.call(this);

  159.                         let label = params.en; // default is english
  160.                         if ($gameSystem.isJapanese()) {
  161.                                 label = params.ja;
  162.                         }
  163.                         else if ($gameSystem.isChinese()) {
  164.                                 label = params.zh;
  165.                         }
  166.                         else if ($gameSystem.isKorean()) {
  167.                                 label = params.ko;
  168.                         }
  169.                         else if ($gameSystem.isRussian()) {
  170.                                 label = params.ru;
  171.                         }

  172.                         this.addCommand(label, "TDDP_pixelPerfectMode");
  173.                 };

  174.                 const _Window_Options_prototype_setConfigValue = Window_Options.prototype.setConfigValue;
  175.                 Window_Options.prototype.setConfigValue = function(symbol, volume) {
  176.                         _Window_Options_prototype_setConfigValue.call(this, symbol, volume);
  177.                         
  178.                         if (symbol == 'TDDP_pixelPerfectMode') Graphics.TDDP_updateCanvasImageRenderingMode();
  179.                 };

  180.                 ////////////////////////////////////////////////////////////////////////
  181.                 // ConfigManager extensions - only if ingame options enabled in plugin params
  182.                 ///////////////////////////////////////////////////////////////////////
  183.                 const _ConfigManager_makeData = ConfigManager.makeData;
  184.                 ConfigManager.makeData = function() {
  185.                         const config = _ConfigManager_makeData.call(this);
  186.                         config.TDDP_pixelPerfectMode = this.TDDP_pixelPerfectMode;
  187.                         return config
  188.                 }
  189.                
  190.                 const _ConfigManager_applyData = ConfigManager.applyData;
  191.                 ConfigManager.applyData = function(config) {
  192.                         _ConfigManager_applyData.call(this, config);
  193.                         this.TDDP_pixelPerfectMode = this.readFlag(config, "TDDP_pixelPerfectMode", true);
  194.                 }
  195.         }
  196. })();
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2024-10-23 13:35 , Processed in 0.083589 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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