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

[RMMZ] 【汉化】视觉小说风格的选项

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-5-28 08:58:38 | 显示全部楼层 |阅读模式
本帖最后由 烁灵 于 2024-5-28 10:37 编辑


大意了,Galv的脚本不能二次发布以后不翻译了


原地址:Galv's Visual Novel Choices MZ | RPG Maker Forums (rpgmakerweb.com)

效果:
QQ截图20240528085310.png

范例:https://www.123pan.com/s/uBKyVv-ptF3A.html 提取码:7MnO

插件代码:

  1. //-----------------------------------------------------------------------------
  2. //  Galv's Visual Novel Choices MZ
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV/MZ
  5. //  GALV_VisualNovelChoicesMZ.js
  6. //-----------------------------------------------------------------------------
  7. //  2020-11-17 - Version 1.0 - release
  8. //-----------------------------------------------------------------------------
  9. // Terms can be found at:
  10. // galvs-scripts.com
  11. // 汉化 by 烁灵
  12. // 更多汉化脚本请访问:http://www.hknmtt.com
  13. //-----------------------------------------------------------------------------

  14. var Imported = Imported || {};
  15. Imported.Galv_VisualNovelChoices = true;

  16. var Galv = Galv || {};            // Galv's main object
  17. Galv.VNC = Galv.VNC || {};        // Plugin object
  18. Galv.VNC.pluginName = "GALV_VisualNovelChoicesMZ";

  19. //-----------------------------------------------------------------------------
  20. /*:
  21. * @plugindesc (v.1.0) Changes how the "Choice" message boxes display to appear more like visual novels.
  22. * @url http://galvs-scripts.com
  23. * @target MZ
  24. * @author Galv
  25. * @orderAfter GALV_MessageStylesMZ
  26. *
  27. * @param Command Width
  28. * @desc VNButtons.png 图片的宽度.
  29. * @default 700
  30. *
  31. * @param Command Height
  32. * @desc 每个选项的高度
  33. * @default 48
  34. *
  35. * @param Always Middle
  36. * @desc 保持居中,忽略选项的“窗口位置”设置. 填 true 或 false
  37. * @default true
  38. *
  39. * @param Message Gap
  40. * @desc 选项与对话框的距离
  41. * @default 0
  42. *
  43. * @param Disabled Button
  44. * @desc 用于显示无效选项的图片编号(如果使用了无效选项插件的话)
  45. * @default 3
  46. *
  47. * @requiredAssets img/system/VNButtons
  48. *
  49. * @help
  50. *   Galv's Visual Novel Choices
  51. * ----------------------------------------------------------------------------
  52. * 以视觉小说的风格显示选项. 选项按钮图片需要放在 /img/system/ 文件夹下,图片名为:
  53. * "VNButtons.png". 这是一张单图片,包含了所有选项背景,从上到下排列。
  54. * Command Width 和 Command Height 设置图片的宽度和每个按钮图片的高度,确保将
  55. * "Command Width" 设定为图片的宽度。
  56. *
  57. * VNButtons 文件里第一张图片的按钮编号是 0。这张图是选项的光标图。默认应用的选项按钮图是
  58. * 1 号按钮(在光标图下边第一张)
  59. *
  60. * 在选项的文本中使用 \b[x] 可以指定不同的选项图片,x 是行数(从1开始)
  61. *
  62. * "Disabled Button" 选项是为了当你使用无效选项插件做准备的,比如:
  63. * Hime 的 "Disabled Choice Conditions" 插件.
  64. *
  65. * ----------------------------------------------------------------------------
  66. *  脚本调用:
  67. * ----------------------------------------------------------------------------
  68. *
  69. *        $gameSystem.vnChoices = status;      // status 可以为 true 或 false
  70. */

  71. //-----------------------------------------------------------------------------
  72. //  CODE STUFFS
  73. //-----------------------------------------------------------------------------

  74. Galv.VNC.width = Number(PluginManager.parameters(Galv.VNC.pluginName)["Command Width"]);
  75. Galv.VNC.height = Number(PluginManager.parameters(Galv.VNC.pluginName)["Command Height"]);
  76. Galv.VNC.alwaysMid = PluginManager.parameters(Galv.VNC.pluginName)["Always Middle"].toLowerCase() == 'true';
  77. Galv.VNC.msgGap = Number(PluginManager.parameters(Galv.VNC.pluginName)["Message Gap"]);
  78. Galv.VNC.disableBtn = Number(PluginManager.parameters(Galv.VNC.pluginName)["Disabled Button"]);

  79. // Cache
  80. Galv.VNC.Scene_Boot_loadSystemImages = Scene_Boot.prototype.loadSystemImages;
  81. Scene_Boot.prototype.loadSystemImages = function() {
  82.     ImageManager.loadSystem('VNButtons');
  83.         Galv.VNC.Scene_Boot_loadSystemImages.call(this);
  84. };

  85. // Choice stuff
  86. Galv.VNC.Game_System_initialize = Game_System.prototype.initialize;
  87. Game_System.prototype.initialize = function() {
  88.         Galv.VNC.Game_System_initialize.call(this);
  89.         this.vnChoices = true;
  90. };

  91. // Overwrite
  92. Window_ChoiceList.prototype.textHeight = Window_ChoiceList.prototype.lineHeight;
  93. Galv.VNC.Window_ChoiceList_lineHeight = Window_ChoiceList.prototype.lineHeight;
  94. Window_ChoiceList.prototype.lineHeight = function() {return $gameSystem.vnChoices ? Galv.VNC.height : Galv.VNC.Window_ChoiceList_lineHeight.call(this);};
  95. Galv.VNC.Window_ChoiceList_itemHeight = Window_ChoiceList.prototype.itemHeight;
  96. Window_ChoiceList.prototype.itemHeight = function() {return $gameSystem.vnChoices ? Galv.VNC.height : Galv.VNC.Window_ChoiceList_itemHeight.call(this);};

  97. Galv.VNC.Window_ChoiceList_drawItem = Window_ChoiceList.prototype.drawItem;
  98. Window_ChoiceList.prototype.drawItem = function(index) {
  99.         if ($gameSystem.vnChoices) {
  100.                 const rect = this.itemRectForText(index);
  101.                 this.drawButton(index,rect.y);
  102.                 if (index === this._index) this.drawButton(index,rect.y,true);
  103.                 const offset = 0;//(this.lineHeight() - this.textHeight()) * 0.5;
  104.                 this.drawTextEx(this.commandName(index), rect.x, rect.y + offset);
  105.         } else {
  106.                 Galv.VNC.Window_ChoiceList_drawItem.call(this,index);
  107.         };
  108. };

  109. Galv.VNC.Window_ChoiceList_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
  110. Window_ChoiceList.prototype.updatePlacement = function() {
  111.         Galv.VNC.Window_ChoiceList_updatePlacement.call(this);
  112.         if ($gameSystem.vnChoices && Galv.VNC.alwaysMid) {
  113.                 this.x = (Graphics.boxWidth - this.width) / 2;
  114.         };
  115.         if (this._messageWindow.y >= Graphics.boxHeight / 2) {
  116.                 this.y -= Galv.VNC.msgGap;
  117.     } else {
  118.         this.y += Galv.VNC.msgGap;
  119.     };
  120. };

  121. Galv.VNC.Window_ChoiceList__refreshCursor = Window_ChoiceList.prototype._refreshCursor;
  122. Window_ChoiceList.prototype._refreshCursor = function() {
  123.         if ($gameSystem.vnChoices) {
  124.                 this._cursorSprite.opacity = 0;
  125.         } else {
  126.                 Galv.VNC.Window_ChoiceList__refreshCursor.call(this);
  127.         };
  128. };

  129. Galv.VNC.Window_ChoiceList_drawItemBackground = Window_ChoiceList.prototype.drawItemBackground;
  130. Window_ChoiceList.prototype.drawItemBackground = function(index) {
  131.         if ($gameSystem.vnChoices) return;
  132.         Galv.VNC.Window_ChoiceList_drawItemBackground.call(this,index);
  133. };

  134. Window_ChoiceList.prototype.drawButton = function(index,y,cursor) {
  135.     const bitmap = ImageManager.loadSystem('VNButtons');
  136.     const pw = Galv.VNC.width;
  137.     const ph = Galv.VNC.height;
  138.         let bgId = 0;

  139.     const sx = 0;
  140.         if (cursor) {
  141.                 bgId = 0;
  142.         } else {
  143.                 if (this._list[index].enabled === false || !this.choice_background) {
  144.                         bgId = Galv.VNC.disableBtn;
  145.                 } else {
  146.                         bgId = this.choice_background[index] ? this.choice_background[index] : 1;
  147.                 };
  148.         };
  149.     const sy = bgId * ph;
  150.     this.contents.blt(bitmap, sx, sy, pw, ph, 0, y);
  151. };

  152. Galv.VNC.Window_ChoiceList_start = Window_ChoiceList.prototype.start;
  153. Window_ChoiceList.prototype.start = function() {
  154.         this.setupVNChoices();
  155.         Galv.VNC.Window_ChoiceList_start.call(this);
  156. };

  157. Window_ChoiceList.prototype.setupVNChoices = function() {
  158.         this.ChoiceSprites = [];
  159.         this.choice_background = [];
  160.         this._vnIndex = this._index;
  161.     if ($gameSystem.vnChoices) {
  162.       this.opacity = 0;
  163.         } else {
  164.       this.opacity = 255;
  165.         };
  166. };

  167. Galv.VNC.Window_ChoiceList_update = Window_ChoiceList.prototype.update;
  168. Window_ChoiceList.prototype.update = function() {
  169.         Galv.VNC.Window_ChoiceList_update.call(this);
  170.         if (this._vnIndex != this._index) {
  171.                 this.refresh();
  172.                 this._vnIndex = this._index;
  173.         }
  174. };

  175. Galv.VNC.Window_ChoiceList_updateBackground = Window_ChoiceList.prototype.updateBackground;
  176. Window_ChoiceList.prototype.updateBackground = function() {
  177.         if ($gameSystem.vnChoices) {
  178.                 this._background = 2;
  179.                     this.setBackgroundType(this._background);
  180.         } else {
  181.                 Galv.VNC.Window_ChoiceList_updateBackground.call(this);
  182.         };
  183.    
  184. };

  185. Galv.VNC.Window_ChoiceList_convertEscapeCharacters = Window_ChoiceList.prototype.convertEscapeCharacters;
  186. Window_ChoiceList.prototype.convertEscapeCharacters = function(text,index) {
  187.         text = text.replace(/\\/g, '\x1b');
  188.         text = text.replace(/\x1b\x1b/g, '\\');
  189.         text = text.replace(/\x1bB\[(\d+)\]/gi, function() {
  190.                 this.choice_background[index] = parseInt(arguments[1]);
  191.         return "";
  192.     }.bind(this));
  193.         
  194.         return Galv.VNC.Window_ChoiceList_convertEscapeCharacters.call(this,text);
  195. };

  196. Window_ChoiceList.prototype.itemRectForText = function(index) {
  197.     let rect = this.itemRect(index);
  198.         if ($gameSystem.vnChoices) {

  199.                 let txt = $gameMessage._choices[index];
  200.                
  201.                 // count icon code
  202.                 let icons = txt.match(/\\i\[/g) || txt.match(/\\I\[/g);
  203.                 icons = icons ? icons.length * 36 : 0;
  204.                
  205.                 txt = this.convertEscapeCharacters(txt,index);
  206.                 txt = txt.replace(/i\[\d*\]/g,"");
  207.                 txt = txt.replace(/I\[\d*\]/g,"");
  208.                
  209.                 txt = txt.replace(/c\[\d*\]/g,"");
  210.                 txt = txt.replace(/C\[\d*\]/g,"");
  211.                 const txtSize = this.textWidth(txt) + icons;

  212.                 rect.x = (Galv.VNC.width - txtSize) / 2;
  213.         } else {
  214.                 rect.x += $gameSystem.windowPadding();
  215.         };
  216.         rect.width -= $gameSystem.windowPadding() * 2;
  217.         return rect;
  218. };

  219. Window_ChoiceList.prototype.windowWidth = function() {
  220.     const width = this.maxChoiceWidth() + this.padding * 2;
  221.     return Math.min(width, Graphics.boxWidth);
  222. };

  223. Galv.VNC.Window_ChoiceList_maxChoiceWidth = Window_ChoiceList.prototype.maxChoiceWidth;
  224. Window_ChoiceList.prototype.maxChoiceWidth = function() {
  225.         if ($gameSystem.vnChoices) {
  226.                 return Galv.VNC.width;
  227.         } else {
  228.                 return Galv.VNC.Window_ChoiceList_maxChoiceWidth.call(this);
  229.         };
  230. };

  231. Galv.VNC.Window_Message_updateFloatChoiceWindow = Window_Message.prototype.updateFloatChoiceWindow;
  232. Window_Message.prototype.updateFloatChoiceWindow = function() {
  233.         if ($gameSystem.vnChoices) {
  234.                 let targetY = Graphics.height - this._choiceListWindow.height;
  235.                 if (this.y + this.height > targetY) targetY = 0;
  236.                         this._choiceListWindow.y = targetY;
  237.                 return;
  238.         };
  239.         Galv.VNC.Window_Message_updateFloatChoiceWindow.call(this);
  240. };
复制代码


回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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