查看: 4435|回复: 5

[有事请教] 有没有选择框拓展方面的插件?

[复制链接]
梦石
0
星屑
8201
在线时间
1331 小时
注册时间
2006-7-18
回帖
460
发表于 2018-6-15 19:52:19 | 显示全部楼层 |阅读模式

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

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

×
比如:光标指向一个选择时,下方会显示这个选择项的说明!
再比如:用变量或开关控制一个选项的显示和隐藏!
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2018-6-16 10:30:21 | 显示全部楼层
本帖最后由 tseyik 于 2018-6-16 21:45 编辑

http://woodpenguin.web.fc2.com/MV_Plugin/MPP_ChoiceEX.html

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

  8. /*:
  9. * @plugindesc 【ver.3.7】選択肢の機能拡張
  10. * @author 木星ペンギン
  11. *
  12. * @help
  13. * プラグインコマンド:
  14. *   ChoicePos x y row      # 選択肢の位置(x,y)と行数(row)指定
  15. *                            rowが未設定の場合、すべての選択肢を表示する
  16. *   ChoiceVariableId n     # 選択肢のデフォルト位置を変数n番にする
  17. *                            選択中の位置を変数n番にいれる
  18. *   ChoiceRect x y width height
  19. *                          # 選択肢の座標とサイズ(x,y,width,height)指定
  20. *                            各項目 -1 でデフォルト値
  21. *
  22. * 注釈:
  23. *   選択肢ヘルプ             # 各項目の下に設定することでヘルプを表示させる
  24. *
  25. * 選択肢テキスト:
  26. *   if(条件)                # 条件が偽になると項目が表示されなくなる
  27. *   en(条件)                # 条件が偽になると項目が選択不可
  28. *
  29. * ================================
  30. * ●選択肢を増やす
  31. *  イベントコマンド『選択肢の表示』を続けて配置すると
  32. *  一つの選択肢にまとめられます。
  33. *  まとめたくない場合は、間に注釈などを入れることで通常通り分けることができます。
  34. *
  35. *  『デフォルト』の処理は、なし以外を設定したものが適用されます。
  36. *  『デフォルト』の処理が複数ある場合、
  37. *  後に設定された選択肢のものが適用されます。
  38. *
  39. *  『キャンセル』の処理は、禁止以外を設定したものが適用されます。
  40. *  『キャンセル』の処理が複数ある場合、
  41. *  後に設定された選択肢のものが適用されます。
  42. *
  43. * 『背景』と『ウィンドウ位置』は後の選択肢のものが適用されます。
  44. *
  45. *
  46. * ●項目が表示される条件の設定
  47. *  選択肢の文章中に
  48. *    if(条件)
  49. *  と入れ、その条件が偽になると項目が表示されなくなります。
  50. *
  51. *  条件内では s でスイッチ、v で変数を参照できます。
  52. *  (例:if(s[1]) とした場合、スイッチ1番がONで表示、OFFで非表示となります)
  53. *
  54. *  『デフォルト』や『キャンセル』の項目が表示されない場合、
  55. *  なしや禁止と同じ処理をします。
  56. *
  57. *
  58. * ●項目を半透明で表示する条件の設定
  59. *  選択肢の文章中に
  60. *    en(条件)
  61. *  と入れ、その条件が偽になると項目が半透明で表示されます。
  62. *  半透明となった項目は選択できなくなります。
  63. *
  64. *  条件は上の『項目が表示される条件の設定』と同じです。
  65. *
  66. *  『キャンセル』の項目が半透明の場合、ブザーが鳴ります。
  67. *
  68. *
  69. * ●選択肢のカーソル位置指定と保存
  70. *  イベントコマンドの【プラグインコマンド】にて以下のように入力すると
  71. *  次に表示する選択肢のデフォルト位置を変数の値にして、
  72. *  決定またはキャンセル時にカーソル位置をその変数に入れます。
  73. *
  74. *   ChoiceVariableId n
  75. *     n : 変数番号
  76. *
  77. * カーソル位置は最初の選択肢が上から0~5、次の選択肢は10~15と、
  78. * 選択肢毎に+10されます。
  79. *
  80. * 変数に入った値の項目がない場合、なしと同じ処理をします。
  81. *
  82. *
  83. * ●プラグインコマンドの実行タイミング
  84. *  上記のプラグインコマンドを使用する場合、【選択肢の表示】の前に実行するのが
  85. *  好ましいです。
  86. *  ただし、メッセージウィンドウを表示したまま選択肢の処理を実行したい場合、
  87. *  【文章の表示】より前にプラグインコマンドを実行してください。
  88. *
  89. * ●ヘルプメッセージの表示
  90. *  各選択肢項目の下に注釈で以下の文字列を入れると、
  91. *  続きの文章をヘルプメッセージとしてカーソルを合わせたときに
  92. *  標示させることができます。
  93. *  
  94. *    選択肢ヘルプ
  95. *
  96. *  ※注意点
  97. *   ヘルプメッセージは[文章の表示]と同じ機能を使っているため、制御文字が使用できます。
  98. *   ただし、\!と\^は使用できません。
  99. *  
  100. * ================================
  101. * ▼コマンドの名前変更について
  102. *  プラグインコマンドや注釈で使用するコマンドは、
  103. *  プラグインパラメータから変更できます。
  104. *  
  105. *  コマンドを短くしたり日本語にしたりなどして、自分が使いやすいようにしてください。
  106. *  
  107. *  プラグインコマンドのみ、変更後もデフォルトのコマンドでも動作します。
  108. *
  109. * ================================
  110. * 制作 : 木星ペンギン
  111. * URL : [url]http://woodpenguin.blog.fc2.com/[/url]
  112. *
  113. * @param maxPageRow
  114. * @desc 1ページに表示される行数
  115. * @default 6
  116. *
  117. * @param === Command ===
  118. *
  119. * @param Plugin Commands
  120. * @type struct<Plugin>
  121. * @desc プラグインコマンド名
  122. * @default {"ChoicePos":"ChoicePos","ChoiceVariableId":"ChoiceVariableId","ChoiceRect":"ChoiceRect"}
  123. * @parent === Command ===
  124. *
  125. * @param Event Comment
  126. * @type struct<EventComment>
  127. * @desc イベントメモ欄のデータ名
  128. * @default {"ChoiceHelp":"選択肢ヘルプ"}
  129. * @parent === Command ===
  130. *
  131. */

  132. /*~struct~Plugin:
  133. * @param ChoicePos
  134. * @desc 選択肢の位置(x,y)と行数(row)指定
  135. * @default ChoicePos
  136. *
  137. * @param ChoiceVariableId
  138. * @desc 選択肢のデフォルト位置を変数n番にする
  139. * @default ChoiceVariableId
  140. *
  141. * @param ChoiceRect
  142. * @desc 選択肢の座標とサイズ(x,y,width,height)指定
  143. * @default ChoiceRect
  144. *
  145. */

  146. /*~struct~EventComment:
  147. * @param ChoiceHelp
  148. * @desc 各項目の下に設定することでヘルプを表示させる
  149. * @default 選択肢ヘルプ
  150. */

  151. (function() {

  152. var MPPlugin = {};

  153. (function() {
  154.    
  155.     var parameters = PluginManager.parameters('MPP_ChoiceEX');
  156.    
  157.     MPPlugin.maxPageRow = Number(parameters['maxPageRow']);
  158.    
  159.     MPPlugin.PluginCommands = JSON.parse(parameters['Plugin Commands']);
  160.     MPPlugin.EventComment = JSON.parse(parameters['Event Comment']);

  161. })();

  162. var Alias = {};

  163. //-----------------------------------------------------------------------------
  164. // Game_Message

  165. //15
  166. Alias.GaMe_clear = Game_Message.prototype.clear;
  167. Game_Message.prototype.clear = function() {
  168.     Alias.GaMe_clear.call(this);
  169.     this._choiceEnables = [];
  170.     this._choiceResults = [];
  171.     this._helpTexts = [];
  172.     this._choiceX = -1;
  173.     this._choiceY = -1;
  174.     this._choiceWidth = -1;
  175.     this._choiceHeight = -1;
  176.     this._choiceMaxRow = MPPlugin.maxPageRow;
  177.     this._choiceVariableId = 0;
  178. };

  179. Game_Message.prototype.setChoiceEnables = function(enables) {
  180.     this._choiceEnables = enables;
  181. };

  182. Game_Message.prototype.choiceEnables = function() {
  183.     return this._choiceEnables;
  184. };

  185. Game_Message.prototype.setChoiceResults = function(results) {
  186.     this._choiceResults = results;
  187. };

  188. Game_Message.prototype.setChoiceHelpTexts = function(texts) {
  189.     this._helpTexts = texts;
  190. };

  191. Game_Message.prototype.isHelp = function() {
  192.     return this._helpTexts.length > 0;
  193. };

  194. Game_Message.prototype.setChoicePos = function(x, y, row) {
  195.     this._choiceX = x;
  196.     this._choiceY = y;
  197.     this._choiceWidth = -1;
  198.     this._choiceHeight = -1;
  199.     this._choiceMaxRow = row;
  200. };

  201. Game_Message.prototype.setChoiceRect = function(x, y, width, height) {
  202.     this._choiceX = x;
  203.     this._choiceY = y;
  204.     this._choiceWidth = width;
  205.     this._choiceHeight = height;
  206. };

  207. Game_Message.prototype.setChoiceVariableId = function(id) {
  208.     this._choiceVariableId = id;
  209. };

  210. //-----------------------------------------------------------------------------
  211. // Game_Interpreter

  212. //336
  213. Game_Interpreter.prototype.setupChoices = function(params) {
  214.     var data = {
  215.         choices: [],
  216.         enables: [],
  217.         results: [],
  218.         helpTexts: [],
  219.         cancelType: -1,
  220.         defaultType: -1,
  221.         positionType: 0,
  222.         background: 0
  223.     };
  224.     data = this.addChoices(params, this._index, data, 0);
  225.     if (data.choices.length > 0) {
  226.         var helpTexts = [];
  227.         if (data.helpTexts.length > 0) {
  228.             helpTexts = data.results.map(function(i) {
  229.                 return data.helpTexts[i];
  230.             });
  231.         }
  232.         var cancelType = -1;
  233.         if (data.cancelType.mod(10) === 8 || data.results.contains(data.cancelType)) {
  234.             data.results.push(data.cancelType);
  235.             cancelType = data.choices.length;
  236.         }
  237.         var defaultType = -1;
  238.         if ($gameMessage._choiceVariableId > 0) {
  239.             var index = $gameVariables.value($gameMessage._choiceVariableId);
  240.             defaultType = data.results.indexOf(index);
  241.         } else {
  242.             defaultType = data.results.indexOf(data.defaultType);
  243.         }
  244.         $gameMessage.setChoices(data.choices, defaultType, cancelType);
  245.         $gameMessage.setChoiceEnables(data.enables);
  246.         $gameMessage.setChoiceResults(data.results);
  247.         $gameMessage.setChoiceHelpTexts(helpTexts);
  248.         $gameMessage.setChoiceBackground(data.background);
  249.         $gameMessage.setChoicePositionType(data.positionType);
  250.         $gameMessage.setChoiceCallback(function(n) {
  251.             this._branch[this._indent] = data.results[n];
  252.         }.bind(this));
  253.     } else {
  254.         this._branch[this._indent] = -1;
  255.     }
  256. };

  257. Game_Interpreter.prototype.addChoices = function(params, i, data, d) {
  258.     var regIf = /\s*if\(([^\)]+)\)/;
  259.     var regEn = /\s*en\(([^\)]+)\)/;
  260.     for (var n = 0; n < params[0].length; n++) {
  261.         var str = params[0][n];
  262.         if (regIf.test(str)) {
  263.             str = str.replace(regIf, '');
  264.             if (RegExp.$1 && !this.evalChoice(RegExp.$1)) continue;
  265.         }
  266.         var enable = true;
  267.         if (regEn.test(str)) {
  268.             str = str.replace(regEn, '');
  269.             enable = this.evalChoice(RegExp.$1);
  270.         }
  271.         data.choices.push(str);
  272.         data.enables.push(enable);
  273.         data.results.push(n + d);
  274.     }
  275.     var cancelType = params[1];
  276.     if (cancelType !== -1) {
  277.         data.cancelType = cancelType + d;
  278.     }
  279.     var defaultType = params.length > 2 ? params[2] : 0;
  280.     if (defaultType >= 0) {
  281.         data.defaultType = defaultType + d;
  282.     }
  283.     data.positionType = params.length > 3 ? params[3] : 2;
  284.     data.background = params.length > 4 ? params[4] : 0;
  285.     var command;
  286.     for (;;) {
  287.         i++;
  288.         command = this._list[i];
  289.         if (!command) break;
  290.         if (command.indent === this._indent) {
  291.             if (command.code === 402) {
  292.                 this.getHelpText(command.parameters[0] + d, i + 1, data);
  293.             } else if (command.code === 404) {
  294.                 break;
  295.             }
  296.         }
  297.     }
  298.     command = this._list[i + 1];
  299.     if (command && command.code === 102) {
  300.         this.addChoices(command.parameters, i + 1, data, d + 10);
  301.     }
  302.     return data;
  303. };

  304. Game_Interpreter.prototype.getHelpText = function(c, i, data) {
  305.     var command = MPPlugin.EventComment.ChoiceHelp || '選択肢ヘルプ';
  306.     if (this._list[i].code === 108 && this._list[i].parameters[0] === command) {
  307.         var texts = [];
  308.         while (this._list[i + 1].code === 408) {
  309.             i++;
  310.             texts.push(this._list[i].parameters[0]);
  311.         }
  312.         data.helpTexts[c] = texts;
  313.     }
  314. };

  315. Game_Interpreter.prototype.evalChoice = function(formula) {
  316.     try {
  317.         var s = $gameSwitches._data;
  318.         var v = $gameVariables._data;
  319.         return !!eval(formula);
  320.     } catch (e) {
  321.         alert("条件エラー \n\n " + formula);
  322.         return true;
  323.     }
  324. };

  325. //362
  326. Game_Interpreter.prototype.command403 = function() {
  327.     if (this._branch[this._indent] !== -2) {
  328.         this.skipBranch();
  329.     }
  330.     return true;
  331. };

  332. Game_Interpreter.prototype.command404 = function() {
  333.     if (this.nextEventCode() === 102) {
  334.         this._branch[this._indent] -= 10;
  335.         this._index++;
  336.     }
  337.     return true;
  338. };

  339. //1739
  340. Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  341. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  342.     Alias.GaIn_pluginCommand.call(this, command, args);
  343.     switch (command) {
  344.     case MPPlugin.PluginCommands.ChoicePos: case 'ChoicePos':
  345.         var x = Number(args[0]);
  346.         var y = Number(args[1]);
  347.         var row = Number(args[2] || 99);
  348.         $gameMessage.setChoicePos(x, y, row);
  349.         break;
  350.     case MPPlugin.PluginCommands.ChoiceVariableId: case 'ChoiceVariableId':
  351.         $gameMessage.setChoiceVariableId(Number(args[0]));
  352.         break;
  353.     case MPPlugin.PluginCommands.ChoiceRect: case 'ChoiceRect':
  354.         var x = Number(args[0] || -1);
  355.         var y = Number(args[1] || -1);
  356.         var width = Number(args[2] || -1);
  357.         var height = Number(args[3] || -1);
  358.         $gameMessage.setChoiceRect(x, y, width, height);
  359.         break;
  360.     }
  361.     return true;
  362. };

  363. //-----------------------------------------------------------------------------
  364. // Window_ChoiceList

  365. if (Window_ChoiceList.prototype.hasOwnProperty('close')) {
  366.     Alias.WiChLi_close = Window_ChoiceList.prototype.close
  367. }
  368. Window_ChoiceList.prototype.close = function() {
  369.     if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
  370.     if (Alias.WiChLi_close) {
  371.         Alias.WiChLi_close.call(this);
  372.     } else {
  373.         Window_Command.prototype.close.call(this);
  374.     }
  375. };

  376. if (Window_ChoiceList.prototype.hasOwnProperty('update')) {
  377.     Alias.WiChLi_update = Window_ChoiceList.prototype.update
  378. }
  379. Window_ChoiceList.prototype.update = function() {
  380.     var lastIndex = this.index();
  381.     if (Alias.WiChLi_update) {
  382.         Alias.WiChLi_update.call(this);
  383.     } else {
  384.         Window_Command.prototype.update.call(this);
  385.     }
  386.     var variableId = $gameMessage._choiceVariableId;
  387.     if (lastIndex !== this.index() && variableId > 0) {
  388.         var results = $gameMessage._choiceResults;
  389.         $gameVariables.setValue(variableId, results[this.index()]);
  390.     }
  391. };

  392. //34
  393. Alias.WiChLi_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
  394. Window_ChoiceList.prototype.updatePlacement = function() {
  395.     Alias.WiChLi_updatePlacement.call(this);
  396.     if ($gameMessage._choiceWidth >= 0) {
  397.         this.width = Math.min($gameMessage._choiceWidth, Graphics.boxWidth);
  398.     }
  399.     if ($gameMessage._choiceHeight >= 0) {
  400.         this.height = Math.min($gameMessage._choiceHeight, Graphics.boxHeight);
  401.     }
  402.     if ($gameMessage._choiceX >= 0) {
  403.         this.x = Math.min($gameMessage._choiceX, Graphics.boxWidth - this.width);
  404.     }
  405.     if ($gameMessage._choiceY >= 0) {
  406.         this.y = Math.min($gameMessage._choiceY, Graphics.boxHeight - this.height);
  407.     }
  408. };

  409. //67
  410. Window_ChoiceList.prototype.numVisibleRows = function() {
  411.     return Math.min($gameMessage.choices().length, $gameMessage._choiceMaxRow);
  412. };

  413. //103
  414. Window_ChoiceList.prototype.makeCommandList = function() {
  415.     var choices = $gameMessage.choices();
  416.     var enables = $gameMessage._choiceEnables;
  417.     for (var i = 0; i < choices.length; i++) {
  418.         this.addCommand(choices[i], 'choice', enables[i]);
  419.     }
  420. };

  421. //110
  422. Alias.WiChLi_drawItem = Window_ChoiceList.prototype.drawItem;
  423. Window_ChoiceList.prototype.drawItem = function(index) {
  424.     this.changePaintOpacity(this.isCommandEnabled(index));
  425.     Alias.WiChLi_drawItem.call(this, index);
  426. };

  427. //123
  428. Alias.WiChLi_callOkHandler = Window_ChoiceList.prototype.callOkHandler;
  429. Window_ChoiceList.prototype.callOkHandler = function() {
  430.     Alias.WiChLi_callOkHandler.call(this);
  431.     this._messageWindow.forceClear();
  432. };

  433. //129
  434. Alias.WiChLi_callCancelHandler = Window_ChoiceList.prototype.callCancelHandler;
  435. Window_ChoiceList.prototype.callCancelHandler = function() {
  436.     Alias.WiChLi_callCancelHandler.call(this);
  437.     this._messageWindow.forceClear();
  438. };

  439. if (Window_ChoiceList.prototype.hasOwnProperty('processCancel')) {
  440.     Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel
  441. }
  442. Window_ChoiceList.prototype.processCancel = function() {
  443.     var type = $gameMessage.choiceCancelType();
  444.     var results = $gameMessage._choiceResults;
  445.     var index = results.indexOf(results[type]);
  446.     if (this.isCancelEnabled() && index !== type && !this.isCommandEnabled(index)) {
  447.         this.playBuzzerSound();
  448.     } else {
  449.         if (Alias.WiChLi_processCancel) {
  450.             Alias.WiChLi_processCancel.call(this);
  451.         } else {
  452.             Window_Command.prototype.processCancel.call(this);
  453.         }
  454.     }
  455. };

  456. Window_ChoiceList.prototype.callUpdateHelp = function() {
  457.     if (this.active && this._messageWindow && $gameMessage.isHelp()) {
  458.         this.updateHelp();
  459.     }
  460. };

  461. Window_ChoiceList.prototype.updateHelp = function() {
  462.     this._messageWindow.forceClear();
  463.     var texts = $gameMessage._helpTexts[this.index()];
  464.     $gameMessage._texts = texts ? texts.clone() : [''];
  465.     this._messageWindow.startMessage();
  466. };


  467. //-----------------------------------------------------------------------------
  468. // Window_Message

  469. //149
  470. Alias.WiMe_updateInput = Window_Message.prototype.updateInput;
  471. Window_Message.prototype.updateInput = function() {
  472.     if ($gameMessage.isHelp() && this._textState) {
  473.         return false;
  474.     }
  475.     return Alias.WiMe_updateInput.call(this);
  476. };

  477. //207
  478. Alias.WiMe_startInput = Window_Message.prototype.startInput;
  479. Window_Message.prototype.startInput = function() {
  480.     if (this._choiceWindow.active) {
  481.         return true;
  482.     }
  483.     return Alias.WiMe_startInput.call(this);
  484. };

  485. Window_Message.prototype.forceClear = function() {
  486.     this._textState = null;
  487.     this.close();
  488.     this._goldWindow.close();
  489. };

  490. Window_Message.prototype.onShowFast = function() {
  491.     this._showFast = true;
  492. };

  493. //196
  494. Alias.WiMe_onEndOfText = Window_Message.prototype.onEndOfText;
  495. Window_Message.prototype.onEndOfText = function() {
  496.     if ($gameMessage.isHelp() && !this._choiceWindow.active) {
  497.         this.startInput();
  498.     } else {
  499.         Alias.WiMe_onEndOfText.call(this);
  500.     }
  501. };






  502. })();
复制代码

点评

FC2自2010年4月3日起被中國大陸防火長城封鎖,部分伺服器無法開啟。2013年2月起開始解除封鎖,4月底再次被封鎖,關鍵詞為fc2.com。但fc2cn.com可以存取。  发表于 2018-6-16 21:43
fc2的國内都要翻墙(不知是日方鎖IP,還是國内鎖fc2,這作者的MV_Plugin都很好用  发表于 2018-6-16 21:39
打不开!出错,找不到页面!看样子又要翻墙啊?  发表于 2018-6-16 19:53
回复

使用道具 举报

梦石
0
星屑
613
在线时间
161 小时
注册时间
2020-10-11
回帖
30
发表于 2021-11-27 09:41:57 | 显示全部楼层
tseyik 发表于 2018-6-16 10:30
http://woodpenguin.web.fc2.com/MV_Plugin/MPP_ChoiceEX.html

[fold=MPP_ChoiceEX.js]//================ ...

能求 MZ版本的 插件文件么。 我没梯子过不去。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部