查看: 3224|回复: 3

[已经过期] 如何设置选项框位置

[复制链接]
梦石
0
星屑
719
在线时间
145 小时
注册时间
2011-11-18
回帖
37
发表于 2017-1-4 13:04:06 | 显示全部楼层 |阅读模式

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

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

×
如何设置选项框位置{:2_248:}
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2017-1-4 19:26:49 | 显示全部楼层
選択肢機能拡張
ChoicePos x y row      # 選択肢位置(x,y);行数(row)指定
選択肢機能拡張
  1. //=============================================================================
  2. // MPP_ChoiceEX.js
  3. //=============================================================================
  4. // Copyright (c) 2016 Mokusei Penguin
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================

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

  100. (function() {

  101. var parameters = PluginManager.parameters('MPP_ChoiceEX');

  102. var maxPageRow = Number(parameters['maxPageRow']);

  103. var Alias = {};

  104. //-----------------------------------------------------------------------------
  105. // Game_Message

  106. //332
  107. Alias.GaMe_clear = Game_Message.prototype.clear;
  108. Game_Message.prototype.clear = function() {
  109.     Alias.GaMe_clear.call(this);
  110.     this._choiceEnables = [];
  111.     this._choiceResults = [];
  112.     this._helpTexts = [];
  113.     this._choiceX = -1;
  114.     this._choiceY = -1;
  115.     this._choiceMaxRow = maxPageRow;
  116.     this._choiceVariableId = 0;
  117. };

  118. Game_Message.prototype.setChoiceEnables = function(enables) {
  119.     this._choiceEnables = enables;
  120. };

  121. Game_Message.prototype.choiceEnables = function() {
  122.     return this._choiceEnables;
  123. };

  124. Game_Message.prototype.setChoiceResults = function(results) {
  125.     this._choiceResults = results;
  126. };

  127. Game_Message.prototype.setChoiceHelpTexts = function(texts) {
  128.     this._helpTexts = texts;
  129. };

  130. Game_Message.prototype.isHelp = function() {
  131.     return this._helpTexts.length > 0;
  132. };

  133. Game_Message.prototype.setChoicePos = function(x, y, row) {
  134.     this._choiceX = x;
  135.     this._choiceY = y;
  136.     this._choiceMaxRow = row;
  137. };

  138. Game_Message.prototype.setChoiceVariableId = function(id) {
  139.     this._choiceVariableId = id;
  140. };

  141. //-----------------------------------------------------------------------------
  142. // Game_Interpreter

  143. //9062
  144. Game_Interpreter.prototype.setupChoices = function(params) {
  145.     var data = {
  146.         choices: [],
  147.         enables: [],
  148.         results: [],
  149.         helpTexts: [],
  150.         cancelType: -1,
  151.         defaultType: -1,
  152.         positionType: 0,
  153.         background: 0
  154.     };
  155.     data = this.addChoices(params, this._index, data, 0);
  156.     if (data.choices.length > 0) {
  157.         var helpTexts = [];
  158.         if (data.helpTexts.length > 0) {
  159.             helpTexts = data.results.map(function(i) {
  160.                 return data.helpTexts[i];
  161.             });
  162.         }
  163.         var cancelType = -1;
  164.         if (data.cancelType.mod(10) === 8 || data.results.contains(data.cancelType)) {
  165.             data.results.push(data.cancelType);
  166.             cancelType = data.choices.length;
  167.         }
  168.         var defaultType = -1;
  169.         if ($gameMessage._choiceVariableId > 0) {
  170.             var index = $gameVariables.value($gameMessage._choiceVariableId);
  171.             defaultType = data.results.indexOf(index);
  172.         } else {
  173.             defaultType = data.results.indexOf(data.defaultType);
  174.         }
  175.         $gameMessage.setChoices(data.choices, defaultType, cancelType);
  176.         $gameMessage.setChoiceEnables(data.enables);
  177.         $gameMessage.setChoiceResults(data.results);
  178.         $gameMessage.setChoiceHelpTexts(helpTexts);
  179.         $gameMessage.setChoiceBackground(data.background);
  180.         $gameMessage.setChoicePositionType(data.positionType);
  181.         $gameMessage.setChoiceCallback(function(n) {
  182.             this._branch[this._indent] = data.results[n];
  183.         }.bind(this));
  184.     } else {
  185.         this._branch[this._indent] = -1;
  186.     }
  187. };

  188. Game_Interpreter.prototype.addChoices = function(params, i, data, d) {
  189.     var regIf = /\s*if\(([^\)]+)\)/;
  190.     var regEn = /\s*en\(([^\)]+)\)/;
  191.     for (var n = 0; n < params[0].length; n++) {
  192.         var str = params[0][n];
  193.         if (regIf.test(str)) {
  194.             str = str.replace(regIf, '');
  195.             if (RegExp.$1 && !this.evalChoice(RegExp.$1)) continue;
  196.         }
  197.         var enable = true;
  198.         if (regEn.test(str)) {
  199.             str = str.replace(regEn, '');
  200.             enable = this.evalChoice(RegExp.$1);
  201.         }
  202.         data.choices.push(str);
  203.         data.enables.push(enable);
  204.         data.results.push(n + d);
  205.     }
  206.     var cancelType = params[1];
  207.     if (cancelType !== -1) {
  208.         data.cancelType = cancelType + d;
  209.     }
  210.     var defaultType = params.length > 2 ? params[2] : 0;
  211.     if (defaultType >= 0) {
  212.         data.defaultType = defaultType + d;
  213.     }
  214.     data.positionType = params.length > 3 ? params[3] : 2;
  215.     data.background = params.length > 4 ? params[4] : 0;
  216.     for (;;) {
  217.         i++;
  218.         if (this._list[i].indent === this._indent) {
  219.             if (this._list[i].code === 402) {
  220.                 this.getHelpText(this._list[i].parameters[0] + d, i + 1, data);
  221.             } else if (this._list[i].code === 404) {
  222.                 break;
  223.             }
  224.         }
  225.     }
  226.     if (this._list[i + 1].code === 102) {
  227.         this.addChoices(this._list[i + 1].parameters, i + 1, data, d + 10);
  228.     }
  229.     return data;
  230. };

  231. Game_Interpreter.prototype.getHelpText = function(c, i, data) {
  232.     if (this._list[i].code === 108 && this._list[i].parameters[0] === '選択肢ヘルプ') {
  233.         var texts = [];
  234.         while (this._list[i + 1].code === 408) {
  235.             i++;
  236.             texts.push(this._list[i].parameters[0]);
  237.         }
  238.         data.helpTexts[c] = texts;
  239.     }
  240. };

  241. Game_Interpreter.prototype.evalChoice = function(formula) {
  242.     try {
  243.         var s = $gameSwitches._data;
  244.         var v = $gameVariables._data;
  245.         return !!eval(formula);
  246.     } catch (e) {
  247.         alert("条件エラー \n\n " + formula);
  248.         return true;
  249.     }
  250. };

  251. //9088
  252. Game_Interpreter.prototype.command403 = function() {
  253.     if (this._branch[this._indent] !== -2) {
  254.         this.skipBranch();
  255.     }
  256.     return true;
  257. };

  258. Game_Interpreter.prototype.command404 = function() {
  259.     if (this.nextEventCode() === 102) {
  260.         this._branch[this._indent] -= 10;
  261.         this._index++;
  262.     }
  263.     return true;
  264. };

  265. //10449
  266. Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  267. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  268.     Alias.GaIn_pluginCommand.call(this, command, args);
  269.     switch (command) {
  270.     case 'ChoicePos':
  271.         var x = Number(args[0]);
  272.         var y = Number(args[1]);
  273.         var row = Number(args[2] || 99);
  274.         $gameMessage.setChoicePos(x, y, row);
  275.         break;
  276.     case 'ChoiceVariableId':
  277.         $gameMessage.setChoiceVariableId(Number(args[0]));
  278.         break;
  279.     }
  280.     return true;
  281. };

  282. //-----------------------------------------------------------------------------
  283. // Window_ChoiceList

  284. Alias.WiChLi_close = Window_ChoiceList.prototype.close;
  285. Window_ChoiceList.prototype.close = function() {
  286.     if ($gameMessage.isHelp()) this._messageWindow.onShowFast();
  287.     Alias.WiChLi_close.call(this);
  288. };

  289. Alias.WiChLi_update = Window_ChoiceList.prototype.update;
  290. Window_ChoiceList.prototype.update = function() {
  291.     var lastIndex = this.index();
  292.     Alias.WiChLi_update.call(this);
  293.     var variableId = $gameMessage._choiceVariableId;
  294.     if (lastIndex !== this.index() && variableId > 0) {
  295.         var results = $gameMessage._choiceResults;
  296.         $gameVariables.setValue(variableId, results[this.index()]);
  297.     }
  298. };

  299. //34
  300. Alias.WiChLi_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
  301. Window_ChoiceList.prototype.updatePlacement = function() {
  302.     Alias.WiChLi_updatePlacement.call(this);
  303.     if ($gameMessage._choiceX >= 0 && $gameMessage._choiceY >= 0) {
  304.         this.x = Math.min($gameMessage._choiceX, Graphics.boxWidth - this.width);
  305.         this.y = Math.min($gameMessage._choiceY, Graphics.boxHeight - this.height);
  306.     }
  307. };

  308. //67
  309. Window_ChoiceList.prototype.numVisibleRows = function() {
  310.     return Math.min($gameMessage.choices().length, $gameMessage._choiceMaxRow);
  311. };

  312. //103
  313. Window_ChoiceList.prototype.makeCommandList = function() {
  314.     var choices = $gameMessage.choices();
  315.     var enables = $gameMessage._choiceEnables;
  316.     for (var i = 0; i < choices.length; i++) {
  317.         this.addCommand(choices[i], 'choice', enables[i]);
  318.     }
  319. };

  320. //110
  321. Alias.WiChLi_drawItem = Window_ChoiceList.prototype.drawItem;
  322. Window_ChoiceList.prototype.drawItem = function(index) {
  323.     this.changePaintOpacity(this.isCommandEnabled(index));
  324.     Alias.WiChLi_drawItem.call(this, index);
  325. };

  326. //123
  327. Alias.WiChLi_callOkHandler = Window_ChoiceList.prototype.callOkHandler;
  328. Window_ChoiceList.prototype.callOkHandler = function() {
  329.     Alias.WiChLi_callOkHandler.call(this);
  330.     this._messageWindow.forceClear();
  331. };

  332. //129
  333. Alias.WiChLi_callCancelHandler = Window_ChoiceList.prototype.callCancelHandler;
  334. Window_ChoiceList.prototype.callCancelHandler = function() {
  335.     Alias.WiChLi_callCancelHandler.call(this);
  336.     this._messageWindow.forceClear();
  337. };

  338. Alias.WiChLi_processCancel = Window_ChoiceList.prototype.processCancel;
  339. Window_ChoiceList.prototype.processCancel = function() {
  340.     var type = $gameMessage.choiceCancelType();
  341.     var results = $gameMessage._choiceResults;
  342.     var index = results.indexOf(results[type]);
  343.     if (this.isCancelEnabled() && index !== type && !this.isCommandEnabled(index)) {
  344.         this.playBuzzerSound();
  345.     } else {
  346.         Alias.WiChLi_processCancel.call(this);
  347.     }
  348. };

  349. Window_ChoiceList.prototype.callUpdateHelp = function() {
  350.     if (this.active && this._messageWindow && $gameMessage.isHelp()) {
  351.         this.updateHelp();
  352.     }
  353. };

  354. Window_ChoiceList.prototype.updateHelp = function() {
  355.     this._messageWindow.forceClear();
  356.     var texts = $gameMessage._helpTexts[this.index()];
  357.     $gameMessage._texts = texts ? texts.clone() : [''];
  358.     this._messageWindow.startMessage();
  359. };


  360. //-----------------------------------------------------------------------------
  361. // Window_Message

  362. //65
  363. //Window_Message.prototype.update = function() {
  364. //    this.checkToNotClose();
  365. //    Window_Base.prototype.update.call(this);
  366. //    while (!this.isOpening() && !this.isClosing()) {
  367. //        if (this.updateWait()) {
  368. //            return;
  369. //        } else if (this.updateLoading()) {
  370. //            return;
  371. //        } else if (!this.pause && this.updateMessage()) {
  372. //            return;
  373. //        } else if (this.updateInput()) {
  374. //            return;
  375. //        } else if (this.canStart()) {
  376. //            this.startMessage();
  377. //        } else {
  378. //            this.startInput();
  379. //            return;
  380. //        }
  381. //    }
  382. //};

  383. //148
  384. Alias.WiMe_updateInput = Window_Message.prototype.updateInput;
  385. Window_Message.prototype.updateInput = function() {
  386.     if ($gameMessage.isHelp() && this._textState) {
  387.         return false;
  388.     }
  389.     return Alias.WiMe_updateInput.call(this);
  390. };

  391. //206
  392. Alias.WiMe_startInput = Window_Message.prototype.startInput;
  393. Window_Message.prototype.startInput = function() {
  394.     if (this._choiceWindow.active) {
  395.         return true;
  396.     }
  397.     return Alias.WiMe_startInput.call(this);
  398. };

  399. Window_Message.prototype.forceClear = function() {
  400.     this._textState = null;
  401.     this.close();
  402.     this._goldWindow.close();
  403. };

  404. Window_Message.prototype.onShowFast = function() {
  405.     this._showFast = true;
  406. };


  407. })();
复制代码

回复 1 0

使用道具 举报

梦石
0
星屑
719
在线时间
145 小时
注册时间
2011-11-18
回帖
37
 楼主| 发表于 2017-1-4 23:47:32 | 显示全部楼层
thank you so much, i am in the school now, dont have the pinyin input, but thank you
回复

使用道具 举报

梦石
0
星屑
719
在线时间
145 小时
注册时间
2011-11-18
回帖
37
 楼主| 发表于 2017-1-4 23:47:53 | 显示全部楼层
thank you so much, i am in the school now, dont have the pinyin input, but thank you
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部