查看: 5432|回复: 5

[搬运汉化] 選択肢拡張 正式移殖 MZ版

[复制链接]
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2020-12-19 22:34:55 | 显示全部楼层 |阅读模式

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

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

×
好用的MV Plugin正式開始移殖
http://woodpenguin.web.fc2.com/MV_Plugin/index.html#top


選択肢拡張 4.0 MV/MZ两用版

  1. //=============================================================================
  2. // MPP_ChoiceEX.js
  3. //=============================================================================
  4. // Copyright (c) 2015 Mokusei Penguin
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================

  8. /*:
  9. * @target MV MZ
  10. * @plugindesc Extend the functionality of your choices.
  11. * @author Mokusei Penguin
  12. * @url
  13. *
  14. * @help [version 4.0]
  15. * This plugin is for RPG Maker MV and MZ.
  16. *
  17. * ▼ Plugin command
  18. *  - In MV, the variable N is referred to by writing v [N] in the item for
  19. *    inputting a numerical value.
  20. *  - In MZ, in the item to enter a numerical value, select the text and
  21. *    write v [N] to refer to the variable N.
  22. *  - It is basically preferable to execute the plugin command before
  23. *    [Show Choices].
  24. *  - If you want to use the plug-in command while the message window is
  25. *    displayed, execute it before [Display text].
  26. *  
  27. *  〇 MV / MZ
  28. *  
  29. *  〇 ChoicePos x y row  / choicePos
  30. *       x   : X coordinate of choice window
  31. *       y   : Y coordinate of choice window
  32. *       row : The number of lines in the choice window. Show all if not set
  33. *   - Specify the position (x, y) and the number of rows of the next choice
  34. *     to display.
  35. *
  36. *  〇 ChoiceVariableId varId  / choiceVariableId
  37. *       varId : Variable number
  38. *   - Set the default position of the next choice to display to the value of
  39. *     the variable.
  40. *   - In addition, put the current cursor position in a variable.
  41. *   - The cursor position is 0 to 5 for the first option from the top,
  42. *     10 to 15 for the next option, and +10 for each option.
  43. *
  44. *  〇 ChoiceRect x y width height  / choiceRect
  45. *       x      : X coordinate
  46. *       y      : Y coordinate
  47. *       width  : width
  48. *       height : height
  49. *   - Specify the coordinates and size of the next choice to display.
  50. *   - For items that have not been set or for which -1 is specified,
  51. *     normal values will be applied.
  52. *   
  53. *  〇 ChoiceInMessage  / ChoiceInMessage
  54. *   - The next choice to display is displayed in the message window.
  55. *   - This function will not work unless it is used in combination with
  56. *     [Display Text].
  57. *   - Please execute before [Display text].
  58. *   
  59. * ▼ More choices
  60. *  - If you place the event command [Display Choices] in succession,
  61. *    they will be combined into one choice.
  62. *  - If you don't want to put them together, you can separate them as usual by
  63. *    inserting annotations in between.
  64. *  - For the "default" process, the one set other than none is applied.
  65. *  - For the "Cancel" process, the ones other than prohibited are applied.
  66. *  - In both cases, the setting of the option that follows takes precedence.
  67. *  - For "Background" and "Window position", the settings of the options that
  68. *    follow are applied.
  69. *
  70. * ▼ Setting conditions for displaying items
  71. *  - If you enter
  72. *      if(condition)
  73. *    in the text of the choice and the condition becomes false,
  74. *    the item will not be displayed.
  75. *  - The operation when the "Default" item is not displayed can be set in the
  76. *    [Disabled Index] of the plug-in parameter.
  77. *  - If the "Cancel" item is not displayed, the same processing as prohibition
  78. *    is performed.
  79. *  - Within the condition, you can refer to the switch with "s" and
  80. *    the variable with "v".
  81. *     Example: When set to if(s[1])
  82. *                => Switch No. 1 is ON for display and OFF for non-display.
  83. *              When set to if(!s[2])
  84. *                => Switch 2 is displayed when it is OFF,
  85. *                   and is hidden when it is ON.
  86. *              When set to if(v[5]>0)
  87. *                => Display if variable 5 is greater than 0,
  88. *                   hide if variable 5 is less than 0.
  89. *     
  90. *     Inequalities that can be used in variables
  91. *       === : equal
  92. *       !== : Not equal
  93. *       <   : Smaller
  94. *       <=  : Less than or equal to
  95. *       >   : Greater
  96. *       >=  : Greater than or equal to
  97. *
  98. * ▼ Setting conditions for displaying items semi-transparently
  99. *  - Enter
  100. *      en(condition)
  101. *    in the text of the choice, and if the condition is false,
  102. *    the item will be displayed semi-transparently.
  103. *  - Items that are semi-transparent cannot be selected.
  104. *  - The conditions are the same as "Setting the conditions for displaying
  105. *    items" above.
  106. *  - If the "Cancel" item is semi-transparent, you cannot cancel it.
  107. *
  108. * ▼ Display help message
  109. *  - You can put
  110. *      ChoiceHelp
  111. *    in the [Annotation] below each choice item to indicate the following text
  112. *    as a help message when you hover over it.
  113. *  - Help messages use the same functionality as View Text, so you can use
  114. *    control characters. (\! And \ ^ cannot be used)
  115. *
  116. * ================================
  117. * Mail : wood_penguin@yahoo.co.jp (@ is half-width)
  118. * Blog : [url]http://woodpenguin.blog.fc2.com/[/url]
  119. * License : MIT license
  120. *
  121. * @command choicePos
  122. * @desc Specify the position and number of lines for the next choice to display.
  123. *
  124. * @arg x
  125. * @desc
  126. * @type number
  127. * @min 0
  128. * @default 0
  129. *
  130. * @arg y
  131. * @desc
  132. * @type number
  133. * @min 0
  134. * @default 0
  135. *
  136. * @arg row
  137. * @desc 0 : Show all
  138. * @type number
  139. * @default 0
  140. *
  141. *
  142. * @command choiceVariableId
  143. * @desc Set the default position of the next choice to display to the value of the variable. In addition, put the current cursor position in a variable.
  144. *
  145. * @arg varId
  146. * @desc
  147. * @type variable
  148. * @default 0
  149. *
  150. *
  151. * @command choiceRect
  152. * @desc Specify the coordinates and size of the next choice to display.
  153. * Normal values are applied to unset items.
  154. *
  155. * @arg x
  156. * @desc
  157. * @type number
  158. * @min 0
  159. * @default
  160. *
  161. * @arg y
  162. * @desc
  163. * @type number
  164. * @min 0
  165. * @default
  166. *
  167. * @arg width
  168. * @desc
  169. * @type number
  170. * @min 1
  171. * @default
  172. *
  173. * @arg height
  174. * @desc
  175. * @type number
  176. * @min 1
  177. * @default
  178. *
  179. *
  180. * @command ChoiceInMessage
  181. * @desc The next choice to display is displayed in the message window.
  182. * It will not work unless it is used in combination with [Display text].
  183. *
  184. *
  185. * @param Max Page Row
  186. * @desc Maximum number of lines displayed on one page
  187. * @type number
  188. * @min 1
  189. * @default 6
  190. *
  191. * @param Disabled Position
  192. * @desc Cursor position when the default choice is not displayed
  193. * @type select
  194. * @option none
  195. * @option top
  196. * @default none
  197. *
  198. *
  199. */

  200. /*:ja
  201. * @target MV MZ
  202. * @plugindesc 選択肢の機能を拡張します。
  203. * @author 木星ペンギン
  204. * @url
  205. *
  206. * @help [version 4.0]
  207. * このプラグインはRPGツクールMVおよびMZ用です。
  208. *
  209. * ▼ プラグインコマンド
  210. *  - MVでは数値を入力する項目で v[N] と記述することで変数N番を参照します。
  211. *  - MZでは数値を入力する項目で、テキストを選択して v[N] と記述することで
  212. *    変数N番を参照します。
  213. *  - プラグインコマンドは基本的に[選択肢の表示]の前に実行するのが好ましいです。
  214. *  - メッセージウィンドウを表示したままプラグインコマンドを使いたい場合、
  215. *    [文章の表示]の前に実行してください。
  216. *  
  217. *  〇 MV / MZ
  218. *  
  219. *  〇 ChoicePos x y row  / 選択肢位置設定
  220. *       x   : 選択肢ウィンドウのX座標
  221. *       y   : 選択肢ウィンドウのY座標
  222. *       row : 選択肢ウィンドウの行数。未設定の場合はすべて表示
  223. *   - 次に表示する選択肢の位置(x,y)と行数(row)指定します。
  224. *
  225. *  〇 ChoiceVariableId varId  / カーソル位置設定
  226. *       varId : 変数番号
  227. *   - 次に表示する選択肢のデフォルト位置を変数の値にします。
  228. *   - さらに現在のカーソル位置を変数に入れます。
  229. *   - カーソル位置は最初の選択肢が上から0~5、次の選択肢は10~15と、
  230. *     選択肢毎に+10されます。
  231. *
  232. *  〇 ChoiceRect x y width height  / 選択肢サイズ設定
  233. *       x      : X座標
  234. *       y      : Y座標
  235. *       width  : 幅
  236. *       height : 高さ
  237. *   - 次に表示する選択肢の座標とサイズを指定します。
  238. *   - 未設定もしくは-1を指定した項目は、通常の値が適用されます。
  239. *   
  240. *  〇 ChoiceInMessage  / メッセージ内表示
  241. *   - 次に表示する選択肢をメッセージウィンドウ内に表示させます。
  242. *   - この機能は[文章の表示]と併用しなければ機能しません。
  243. *   - [文章の表示]の前に実行してください。
  244. *   
  245. * ▼ 選択肢を増やす
  246. *  - イベントコマンド『選択肢の表示』を続けて配置すると
  247. *    一つの選択肢にまとめられます。
  248. *  - まとめたくない場合は、間に注釈などを入れることで
  249. *    通常通り分けることができます。
  250. *  - 『デフォルト』の処理は、なし以外を設定したものが適用されます。
  251. *  - 『キャンセル』の処理は、禁止以外を設定したものが適用されます。
  252. *  - どちらも後にある選択肢の設定が優先されます。
  253. *  - 『背景』と『ウィンドウ位置』は後にある選択肢の設定が適用されます。
  254. *
  255. * ▼ 項目が表示される条件の設定
  256. *  - 選択肢の文章中に
  257. *      if(条件)
  258. *    と入れ、その条件が偽になると項目が表示されなくなります。
  259. *  - 『デフォルト』の項目が表示されない場合の動作は、
  260. *    プラグインパラメータの[Disabled Index]にて設定できます。
  261. *  - 『キャンセル』の項目が表示されない場合、禁止と同じ処理をします。
  262. *  - 条件内では s でスイッチ、v で変数を参照できます。
  263. *     例:if(s[1]) とした場合
  264. *          => スイッチ1番がONで表示、OFFで非表示。
  265. *        if(!s[2]) とした場合
  266. *          => スイッチ2番がOFFで表示、ONで非表示。
  267. *        if(v[5]>0) とした場合
  268. *          => 変数5番が0より大きければ表示、0以下で非表示。
  269. *     
  270. *     変数で使える不等号
  271. *       === : 等しい
  272. *       !== : 等しくない
  273. *       <   : より小さい
  274. *       <=  : より小さいまたは等しい
  275. *       >   : より大きい
  276. *       >=  : より大きいまたは等しい
  277. *
  278. * ▼ 項目を半透明で表示する条件の設定
  279. *  - 選択肢の文章中に
  280. *      en(条件)
  281. *    と入れ、その条件が偽になると項目が半透明で表示されます。
  282. *  - 半透明となった項目は選択できなくなります。
  283. *  - 条件は上の『項目が表示される条件の設定』と同じです。
  284. *  - 『キャンセル』の項目が半透明の場合、キャンセルできなくなります。
  285. *
  286. * ▼ ヘルプメッセージの表示
  287. *  - 各選択肢項目の下に注釈で
  288. *      選択肢ヘルプ
  289. *    と入れると、続きの文章をヘルプメッセージとしてカーソルを合わせたときに
  290. *    標示させることができます。
  291. *  - ヘルプメッセージは[文章の表示]と同じ機能を使っているため、
  292. *    制御文字が使用できます。(\!と\^は使用できません)
  293. *
  294. * ================================
  295. * Mail : wood_penguin@yahoo.co.jp (@は半角)
  296. * Blog : [url]http://woodpenguin.blog.fc2.com/[/url]
  297. * License : MIT license
  298. *
  299. * @command choicePos
  300. * @text 選択肢位置設定
  301. * @desc 次に表示する選択肢の位置と行数を指定します。
  302. *
  303. * @arg x
  304. * @desc
  305. * @type number
  306. * @min 0
  307. * @default 0
  308. *
  309. * @arg y
  310. * @desc
  311. * @type number
  312. * @min 0
  313. * @default 0
  314. *
  315. * @arg row
  316. * @text 行数
  317. * @desc 0 : 全て表示
  318. * @type number
  319. * @default 0
  320. *
  321. *
  322. * @command choiceVariableId
  323. * @text カーソル位置設定
  324. * @desc 次に表示する選択肢のデフォルト位置を変数の値にします。
  325. * さらに現在のカーソル位置を変数に入れます。
  326. *
  327. * @arg varId
  328. * @text 変数
  329. * @desc
  330. * @type variable
  331. * @default 0
  332. *
  333. *
  334. * @command choiceRect
  335. * @text 選択肢サイズ設定
  336. * @desc 次に表示する選択肢の座標とサイズを指定します。
  337. * 未設定の項目は通常の値が適用されます。
  338. *
  339. * @arg x
  340. * @desc
  341. * @type number
  342. * @min 0
  343. * @default
  344. *
  345. * @arg y
  346. * @desc
  347. * @type number
  348. * @min 0
  349. * @default
  350. *
  351. * @arg width
  352. * @text 幅
  353. * @desc
  354. * @type number
  355. * @min 1
  356. * @default
  357. *
  358. * @arg height
  359. * @text 高さ
  360. * @desc
  361. * @type number
  362. * @min 1
  363. * @default
  364. *
  365. *
  366. * @command ChoiceInMessage
  367. * @text メッセージ内表示
  368. * @desc 次に表示する選択肢をメッセージウィンドウ内に表示させます。
  369. * [文章の表示]と併用しなければ機能しません。
  370. *
  371. *
  372. * @param Max Page Row
  373. * @text 最大表示行数
  374. * @desc 1ページに表示される最大行数
  375. * @type number
  376. * @min 1
  377. * @default 6
  378. *
  379. * @param Disabled Position
  380. * @text 無効時のカーソル位置
  381. * @desc [デフォルト]となる選択肢が表示されない場合のカーソル位置
  382. * @type select
  383. * @option なし
  384. * @value none
  385. * @option 先頭
  386. * @value top
  387. * @default none
  388. *
  389. *
  390. */

  391. (() => {
  392.     'use strict';
  393.    
  394.     const pluginName = "MPP_ChoiceEX";
  395.    
  396.     //Plugin Parameters
  397.     const parameters = PluginManager.parameters(pluginName);
  398.    
  399.     const param_MaxPageRow = Number(parameters["Max Page Row"]);
  400.     const param_DisabledPosition = parameters["Disabled Position"];
  401.    
  402.     //Dealing with other plugins
  403.     const __base = (obj, prop) => {
  404.         if (obj.hasOwnProperty(prop)) {
  405.             return obj[prop];
  406.         } else {
  407.             const proto = Object.getPrototypeOf(obj);
  408.             return function () { return proto[prop].apply(this, arguments); };
  409.         }
  410.     };
  411.    
  412.     //-------------------------------------------------------------------------
  413.     // PluginManager
  414.    
  415.     PluginManager._commands = PluginManager._commands || {};
  416.    
  417.     if (!PluginManager.registerCommand) {
  418.         PluginManager.registerCommand = function(pluginName, commandName, func) {
  419.             const key = pluginName + ":" + commandName;
  420.             this._commands[key] = func;
  421.         };
  422.     }

  423.     if (!PluginManager.callCommand) {
  424.         PluginManager.callCommand = function(self, pluginName, commandName, args) {
  425.             const key = pluginName + ":" + commandName;
  426.             const func = this._commands[key];
  427.             if (typeof func === "function") {
  428.                 func.bind(self)(args);
  429.             }
  430.         };
  431.     }

  432.     PluginManager.registerCommand(pluginName, "choicePos", args => {
  433.         const x = PluginManager.mppValue(args.x);
  434.         const y = PluginManager.mppValue(args.y);
  435.         const row = PluginManager.mppValue(args.row) || 99;
  436.         $gameMessage.setChoicePos(x, y, row);
  437.     });

  438.     PluginManager.registerCommand(pluginName, "choiceVariableId", args => {
  439.         const variableId = PluginManager.mppValue(args.varId);
  440.         $gameMessage.setChoiceVariableId(variableId);
  441.     });

  442.     PluginManager.registerCommand(pluginName, "choiceRect", args => {
  443.         const x = (args.x ? PluginManager.mppValue(args.x) : -1);
  444.         const y = (args.y ? PluginManager.mppValue(args.y) : -1);
  445.         const width = (args.width ? PluginManager.mppValue(args.width) : -1);
  446.         const height = (args.height ? PluginManager.mppValue(args.height) : -1);
  447.         $gameMessage.setChoiceRect(x, y, width, height);
  448.     });

  449.     PluginManager.registerCommand(pluginName, "ChoiceInMessage", args => {
  450.         $gameMessage.requestChoiceInMessage();
  451.     });

  452.     PluginManager.mppValue = function(value) {
  453.         const match = /^V\[(\d+)\]$/i.exec(value);
  454.         return match ? $gameVariables.value(+match[1]) : +value;
  455.     };
  456.    
  457.     //-------------------------------------------------------------------------
  458.     // Game_Message

  459.     Object.defineProperties(Game_Message.prototype, {
  460.         choiceX: {
  461.             get: function() {
  462.                 return this._choiceX;
  463.             },
  464.             configurable: true
  465.         },
  466.         choiceY: {
  467.             get: function() {
  468.                 return this._choiceY;
  469.             },
  470.             configurable: true
  471.         },
  472.         choiceWidth: {
  473.             get: function() {
  474.                 return this._choiceWidth;
  475.             },
  476.             configurable: true
  477.         },
  478.         choiceHeight: {
  479.             get: function() {
  480.                 return this._choiceHeight;
  481.             },
  482.             configurable: true
  483.         }
  484.     });

  485.     const _Game_Message_clear = Game_Message.prototype.clear;
  486.     Game_Message.prototype.clear = function() {
  487.         _Game_Message_clear.apply(this, arguments);
  488.         this._choiceEnables = [];
  489.         this._choiceResults = [];
  490.         this._helpTexts = [];
  491.         this._choiceX = -1;
  492.         this._choiceY = -1;
  493.         this._choiceWidth = -1;
  494.         this._choiceHeight = -1;
  495.         this._choiceMaxRow = param_MaxPageRow;
  496.         this._choiceVariableId = 0;
  497.         this._choiceInMessage = false;
  498.     };

  499.     Game_Message.prototype.choiceMaxRow = function() {
  500.         return this._choiceMaxRow;
  501.     };

  502.     Game_Message.prototype.setTexts = function(texts) {
  503.         this._texts = texts;
  504.     };

  505.     Game_Message.prototype.setChoiceEnables = function(enables) {
  506.         this._choiceEnables = enables;
  507.     };

  508.     Game_Message.prototype.choiceEnables = function() {
  509.         return this._choiceEnables;
  510.     };

  511.     Game_Message.prototype.setChoiceResults = function(results) {
  512.         this._choiceResults = results;
  513.     };

  514.     Game_Message.prototype.choiceResults = function() {
  515.         return this._choiceResults;
  516.     };

  517.     Game_Message.prototype.setChoiceHelpTexts = function(texts) {
  518.         this._helpTexts = texts;
  519.     };

  520.     Game_Message.prototype.isHelp = function() {
  521.         return !this._choiceInMessage && this._helpTexts.length > 0;
  522.     };

  523.     Game_Message.prototype.helpTexts = function() {
  524.         return this._helpTexts;
  525.     };

  526.     Game_Message.prototype.setChoicePos = function(x, y, row) {
  527.         this._choiceX = x;
  528.         this._choiceY = y;
  529.         this._choiceWidth = -1;
  530.         this._choiceHeight = -1;
  531.         this._choiceMaxRow = row;
  532.     };

  533.     Game_Message.prototype.setChoiceRect = function(x, y, width, height) {
  534.         this._choiceX = x;
  535.         this._choiceY = y;
  536.         this._choiceWidth = width;
  537.         this._choiceHeight = height;
  538.     };

  539.     Game_Message.prototype.setChoiceVariableId = function(id) {
  540.         this._choiceVariableId = id;
  541.     };

  542.     Game_Message.prototype.lowerChoiceHeight = function(height) {
  543.         this._choiceY += height;
  544.         this._choiceHeight -= height;
  545.     };

  546.     Game_Message.prototype.requestChoiceInMessage = function() {
  547.         this._choiceInMessage = true;
  548.     };

  549.     Game_Message.prototype.choiceVariableId = function() {
  550.         return this._choiceVariableId;
  551.     };

  552.     Game_Message.prototype.isChoiceInMessage = function() {
  553.         return this._choiceInMessage;
  554.     };


  555.     //-----------------------------------------------------------------------------
  556.     // Game_Interpreter

  557.     Game_Interpreter.prototype.setupChoices = function(params) {
  558.         const data = {
  559.             choices: [],
  560.             enables: [],
  561.             results: [],
  562.             helpTexts: [],
  563.             cancelType: -1,
  564.             defaultType: -1,
  565.             positionType: 0,
  566.             background: 0
  567.         };
  568.         this.addChoices(params, this._index, data, 0);
  569.         if (data.choices.length > 0) {
  570.             const helpTexts = this.choiceHelpTexts(data);
  571.             const cancelType = this.choiceCancelType(data);
  572.             const defaultType = this.choiceDefaultType(data);
  573.             $gameMessage.setChoices(data.choices, defaultType, cancelType);
  574.             $gameMessage.setChoiceEnables(data.enables);
  575.             $gameMessage.setChoiceResults(data.results);
  576.             $gameMessage.setChoiceHelpTexts(helpTexts);
  577.             $gameMessage.setChoiceBackground(data.background);
  578.             $gameMessage.setChoicePositionType(data.positionType);
  579.             $gameMessage.setChoiceCallback(
  580.                 n => this._branch[this._indent] = data.results[n]
  581.             );
  582.         } else {
  583.             this._branch[this._indent] = -1;
  584.         }
  585.     };

  586.     Game_Interpreter.prototype.addChoices = function(params, index, data, d) {
  587.         this.checkChoiceConditions(params[0], data, d);
  588.         if (params[1] !== -1) {
  589.             data.cancelType = params[1] + d;
  590.         }
  591.         const defaultType = params.length > 2 ? params[2] : 0;
  592.         if (defaultType >= 0) {
  593.             data.defaultType = defaultType + d;
  594.         }
  595.         data.positionType = params.length > 3 ? params[3] : 2;
  596.         data.background = params.length > 4 ? params[4] : 0;
  597.         index = this.setupHelpText(index, data, d);
  598.         const command = this._list[index + 1];
  599.         if (command && command.code === 102) {
  600.             this.addChoices(command.parameters, index + 1, data, d + 10);
  601.         }
  602.     };

  603.     Game_Interpreter.prototype.checkChoiceConditions = function(texts, data, d) {
  604.         const regIf = /\s?if\((.+?)\)/;
  605.         const regEn = /\s?en\((.+?)\)/;
  606.         texts.forEach((text, n) => {
  607.             if (!this.meetsChoiceConditions(text, regIf)) return;
  608.             const realText = text.replace(regIf, "").replace(regEn, "");
  609.             data.choices.push(realText);
  610.             data.enables.push(this.meetsChoiceConditions(text, regEn));
  611.             data.results.push(n + d);
  612.         });
  613.     };

  614.     Game_Interpreter.prototype.meetsChoiceConditions = function(text, reg) {
  615.         const match = reg.exec(text);
  616.         return !match || this.evalChoice(match[1]);
  617.     };

  618.     Game_Interpreter.prototype.evalChoice = function(condition) {
  619.         try {
  620.             const s = $gameSwitches._data;
  621.             condition = condition.replace(/v\[(\d+)\]/gi,
  622.                 (match, n) => $gameVariables.value(+n) );
  623.             return !!eval(condition);
  624.         } catch (e) {
  625.             console.log("条件エラー \n " + condition);
  626.             return true;
  627.         }
  628.     };

  629.     Game_Interpreter.prototype.setupHelpText = function(index, data, d) {
  630.         for (;;) {
  631.             index++;
  632.             const command = this._list[index];
  633.             if (!command) break;
  634.             if (command.indent === this._indent) {
  635.                 if (command.code === 402) {
  636.                     const type = command.parameters[0] + d;
  637.                     const helpTexts = this.getHelpTexts(index + 1);
  638.                     if (helpTexts) data.helpTexts[type] = helpTexts;
  639.                 } else if (command.code === 404) {
  640.                     break;
  641.                 }
  642.             }
  643.         }
  644.         return index;
  645.     };

  646.     Game_Interpreter.prototype.getHelpTexts = function(index) {
  647.         const commandNames = ["ChoiceHelp", "選択肢ヘルプ"];
  648.         if (this._list[index].code === 108 &&
  649.                 commandNames.includes(this._list[index].parameters[0])) {
  650.             const texts = [];
  651.             while (this._list[index + 1].code === 408) {
  652.                 index++;
  653.                 texts.push(this._list[index].parameters[0]);
  654.             }
  655.             return texts;
  656.         } else {
  657.             return null;
  658.         }
  659.     };

  660.     Game_Interpreter.prototype.choiceHelpTexts = function(data) {
  661.         const helpTexts = data.helpTexts;
  662.         return helpTexts.length > 0 ? data.results.map(i => helpTexts[i]) : [];
  663.     };

  664.     Game_Interpreter.prototype.choiceCancelType = function(data) {
  665.         const cancelType = data.cancelType;
  666.         if (cancelType.mod(10) === 8 || data.results.contains(cancelType)) {
  667.             data.results.push(cancelType);
  668.             return data.choices.length;
  669.         } else {
  670.             return -1;
  671.         }
  672.     };

  673.     Game_Interpreter.prototype.choiceDefaultType = function(data) {
  674.         const vId = $gameMessage.choiceVariableId();
  675.         const index = vId > 0 ? $gameVariables.value(vId) : data.defaultType;
  676.         const defaultType = data.results.indexOf(index);
  677.         if (index >= 0 && defaultType < 0 && param_DisabledPosition === "top") {
  678.             return 0;
  679.         } else {
  680.             return defaultType;
  681.         }
  682.     };

  683.     //overwrite
  684.     Game_Interpreter.prototype.command403 = function() {
  685.         if (this._branch[this._indent] !== -2) {
  686.             this.skipBranch();
  687.         }
  688.         return true;
  689.     };

  690.     Game_Interpreter.prototype.command404 = function() {
  691.         if (this.nextEventCode() === 102) {
  692.             this._branch[this._indent] -= 10;
  693.             this._index++;
  694.         }
  695.         return true;
  696.     };

  697.     const _Game_Interpreter_pluginCommand =
  698.             Game_Interpreter.prototype.pluginCommand;
  699.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  700.         _Game_Interpreter_pluginCommand.apply(this, arguments);
  701.         let commandName, args2;
  702.         switch (command) {
  703.             case "ChoicePos":
  704.             case "選択肢位置設定":
  705.                 commandName = "choicePos";
  706.                 args2 = { x: args[0], y: args[1], row: args[2] };
  707.                 break;
  708.             case "ChoiceVariableId":
  709.             case "カーソル位置設定":
  710.                 commandName = "choiceVariableId";
  711.                 args2 = { varId: args[0] };
  712.                 break;
  713.             case "ChoiceRect":
  714.             case "選択肢サイズ設定":
  715.                 commandName = "choiceRect";
  716.                 args2 = { x:args[0], y:args[1], width:args[2], height:args[3] };
  717.                 break;
  718.             case "ChoiceInMessage":
  719.             case "メッセージ内表示":
  720.                 commandName = "ChoiceInMessage";
  721.                 break;
  722.         }
  723.         if (commandName) {
  724.             PluginManager.callCommand(
  725.                     this, pluginName, commandName, args2 || {});
  726.         }
  727.         return true;
  728.     };

  729.     //-----------------------------------------------------------------------------
  730.     // Window_ChoiceList

  731.     const _Window_ChoiceList_close =
  732.             __base(Window_ChoiceList.prototype, "close");
  733.     Window_ChoiceList.prototype.close = function() {
  734.         if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
  735.         _Window_ChoiceList_close.apply(this, arguments);
  736.     };

  737.     const _Window_ChoiceList_select =
  738.             __base(Window_ChoiceList.prototype, "select");
  739.     Window_ChoiceList.prototype.select = function(index) {
  740.         const variableId = $gameMessage.choiceVariableId();
  741.         if (index !== this.index() && variableId > 0) {
  742.             const results = $gameMessage.choiceResults();
  743.             $gameVariables.setValue(variableId, results[index]);
  744.         }
  745.         _Window_ChoiceList_select.apply(this, arguments);
  746.     };

  747.     const _Window_ChoiceList_updatePlacement =
  748.             Window_ChoiceList.prototype.updatePlacement;
  749.     Window_ChoiceList.prototype.updatePlacement = function() {
  750.         _Window_ChoiceList_updatePlacement.apply(this, arguments);
  751.         const {
  752.             choiceX: x,
  753.             choiceY: y,
  754.             choiceWidth: width,
  755.             choiceHeight: height
  756.         } = $gameMessage;
  757.         if (width >= 0)  this.width = width.clamp(1, Graphics.boxWidth);
  758.         if (height >= 0) this.height = height.clamp(1, Graphics.boxHeight);
  759.         if (x >= 0)      this.x = Math.min(x, Graphics.boxWidth - this.width);
  760.         if (y >= 0)      this.y = Math.min(y, Graphics.boxHeight - this.height);
  761.         this._isWindow = !$gameMessage.isChoiceInMessage();
  762.     };

  763.     //overwrite
  764.     Window_ChoiceList.prototype.numVisibleRows = function() {
  765.         const choices = $gameMessage.choices();
  766.         const maxLines = $gameMessage.choiceMaxRow();
  767.         return Math.min(choices.length, maxLines);
  768.     };

  769.     //overwrite
  770.     Window_ChoiceList.prototype.makeCommandList = function() {
  771.         const enables = $gameMessage.choiceEnables();
  772.         $gameMessage.choices().forEach((choice, i) => {
  773.             this.addCommand(choice, "choice", enables[i]);
  774.         });
  775.     };

  776.     const _Window_ChoiceList_drawItem = Window_ChoiceList.prototype.drawItem;
  777.     Window_ChoiceList.prototype.drawItem = function(index) {
  778.         this.changePaintOpacity(this.isCommandEnabled(index));
  779.         _Window_ChoiceList_drawItem.apply(this, arguments);
  780.     };

  781.     const _Window_ChoiceList_callOkHandler =
  782.             Window_ChoiceList.prototype.callOkHandler;
  783.     Window_ChoiceList.prototype.callOkHandler = function() {
  784.         _Window_ChoiceList_callOkHandler.apply(this, arguments);
  785.         this._messageWindow.forceClear();
  786.     };

  787.     const _Window_ChoiceList_callCancelHandler =
  788.             Window_ChoiceList.prototype.callCancelHandler;
  789.     Window_ChoiceList.prototype.callCancelHandler = function() {
  790.         _Window_ChoiceList_callCancelHandler.apply(this, arguments);
  791.         this._messageWindow.forceClear();
  792.     };

  793.     const _Window_ChoiceList_processCancel =
  794.             __base(Window_ChoiceList.prototype, "processCancel");
  795.     Window_ChoiceList.prototype.processCancel = function() {
  796.         const type = $gameMessage.choiceCancelType();
  797.         const results = $gameMessage.choiceResults();
  798.         const index = results.indexOf(results[type]);
  799.         if (this.isCancelEnabled() && index !== type &&
  800.                 !this.isCommandEnabled(index)) {
  801.             this.playBuzzerSound();
  802.         } else {
  803.             _Window_ChoiceList_processCancel.apply(this, arguments);
  804.         }
  805.     };

  806.     Window_ChoiceList.prototype.callUpdateHelp = function() {
  807.         if (this.active && this._messageWindow && $gameMessage.isHelp() &&
  808.                 this._helpIndex !== this.index()) {
  809.             this._helpIndex = this.index();
  810.             this.updateHelp();
  811.         }
  812.     };

  813.     Window_ChoiceList.prototype.updateHelp = function() {
  814.         const texts = $gameMessage.helpTexts()[this.index()];
  815.         this._messageWindow.forceClear();
  816.         $gameMessage.setTexts(texts ? texts.clone() : [""]);
  817.         this._messageWindow.startMessage();
  818.     };

  819.     //-----------------------------------------------------------------------------
  820.     // Window_Message

  821.     const _Window_Message_updatePlacement =
  822.             Window_Message.prototype.updatePlacement;
  823.     Window_Message.prototype.updatePlacement = function() {
  824.         _Window_Message_updatePlacement.apply(this, arguments);
  825.         this.clearInChoice();
  826.     };

  827.     Window_Message.prototype.clearInChoice = function() {
  828.         if ($gameMessage.isChoiceInMessage()) {
  829.             const x = this.x + this.choiceStartX();
  830.             const y = this.y + 4;
  831.             const height = this.height;
  832.             $gameMessage.setChoiceRect(x, y, -1, height);
  833.         }
  834.     };

  835.     Window_Message.prototype.choiceStartX = function() {
  836.         if (Utils.RPGMAKER_NAME === "MV") {
  837.             return this.standardPadding() + this._textState.left;
  838.         } else {
  839.             return $gameSystem.windowPadding() + this._textState.startX;
  840.         }
  841.     };

  842.     const _Window_Message_processNewLine =
  843.             __base(Window_Message.prototype, "processNewLine");
  844.     Window_Message.prototype.processNewLine = function(textState) {
  845.         if ($gameMessage.isChoiceInMessage()) {
  846.             $gameMessage.lowerChoiceHeight(textState.height);
  847.         }
  848.         _Window_Message_processNewLine.apply(this, arguments);
  849.     };

  850.     const _Window_Message_updateInput = Window_Message.prototype.updateInput;
  851.     Window_Message.prototype.updateInput = function() {
  852.         if ($gameMessage.isHelp() && this._textState) return false;
  853.         return _Window_Message_updateInput.apply(this, arguments);
  854.     };

  855.     const _Window_Message_onEndOfText = Window_Message.prototype.onEndOfText;
  856.     Window_Message.prototype.onEndOfText = function() {
  857.         const choiceWindow = this._choiceWindow || this._choiceListWindow;
  858.         if (!choiceWindow.active && $gameMessage.isHelp()) {
  859.             this.startInput();
  860.         } else {
  861.             _Window_Message_onEndOfText.apply(this, arguments);
  862.         }
  863.     };

  864.     const _Window_Message_startInput = Window_Message.prototype.startInput;
  865.     Window_Message.prototype.startInput = function() {
  866.         const choiceWindow = this._choiceWindow || this._choiceListWindow;
  867.         if (choiceWindow.active) return true;
  868.         if (this.isLowerChoice()) {
  869.             $gameMessage.lowerChoiceHeight(this._textState.height);
  870.         }
  871.         return _Window_Message_startInput.apply(this, arguments);
  872.     };

  873.     Window_Message.prototype.isLowerChoice = function() {
  874.         const startX = Utils.RPGMAKER_NAME === "MV" ? "left" : "startX";
  875.         return $gameMessage.isChoice() && $gameMessage.isChoiceInMessage() &&
  876.                 this._textState.x !== this._textState[startX];
  877.     };

  878.     Window_Message.prototype.forceClear = function() {
  879.         this._textState = null;
  880.         this.close();
  881.         this._goldWindow.close();
  882.     };

  883.     Window_Message.prototype.onShowFast = function() {
  884.         this._showFast = true;
  885.     };

  886.     const _Window_Message_newPage = Window_Message.prototype.newPage;
  887.     Window_Message.prototype.newPage = function(textState) {
  888.         _Window_Message_newPage.apply(this, arguments);
  889.         this.clearInChoice();
  890.     };

  891. })();

复制代码



评分

参与人数 1赞 +1 收起 理由
火锅深处 + 1 感谢提醒

查看全部评分

梦石
20
星屑
13972
在线时间
1744 小时
注册时间
2017-1-12
回帖
1666

MZ评测员开拓者

发表于 2020-12-20 08:50:22 | 显示全部楼层
谢谢楼主,一直就等这个插件出MZ版本呢。
回复

使用道具 举报

梦石
0
星屑
121
在线时间
10 小时
注册时间
2021-11-29
回帖
19
发表于 2021-12-1 21:59:30 | 显示全部楼层
这个代码要自己保存下来改成JS文件嘛?

点评

在原網頁有js文件下載,並己更新4.2  发表于 2021-12-1 22:04
回复

使用道具 举报

梦石
0
星屑
963
在线时间
319 小时
注册时间
2011-8-31
回帖
86

RM创作大赛01参赛者

发表于 2022-3-4 16:04:31 | 显示全部楼层
为啥你们都能访问我们访问不了的网站…… 这不是指了条死路吗……
回复

使用道具 举报

梦石
0
星屑
49
在线时间
5 小时
注册时间
2022-2-28
回帖
8
发表于 2022-3-6 02:21:32 | 显示全部楼层
这个是啥插件,有啥用啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部