设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2965|回复: 1
打印 上一主题 下一主题

[已经解决] 请教公共事件选择器BUG修正问题

[复制链接]

Lv2.观梦者

梦石
0
星屑
723
在线时间
530 小时
注册时间
2010-6-9
帖子
840
跳转到指定楼层
1
发表于 2015-12-31 12:22:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如下插件:每次选择完公共事件后,并也执行了,但一直没有关闭窗口的操作及命令,最后的Onok里this.close()似乎无效,导致无限弹窗,除非按取消。求执行完公共事件后关闭窗口。
JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // EventSelector.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc 显示一个窗口来选择公共事件
  7.  * @author Yoji Ojima
  8.  *
  9.  * @help 插件指令:
  10.  *   EventSelector open       # 打开事件选择器
  11.  *   EventSelector add 3      # 添加3号公共事件到选择器中
  12.  *   EventSelector remove 4   # 从选择器中移除4号公共事件
  13.  *   EventSelector clear      # 清除时间选择器
  14.  */
  15.  
  16. (function() {
  17.  
  18.     var eventSelectorStatus = '';
  19.     var selectedCommonEvent = null;
  20.  
  21.     var _Game_Interpreter_pluginCommand =
  22.             Game_Interpreter.prototype.pluginCommand;
  23.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  24.         _Game_Interpreter_pluginCommand.call(this, command, args);
  25.         if (command === 'EventSelector') {
  26.             switch (args[0]) {
  27.             case 'open':
  28.                 eventSelectorStatus = 'open';
  29.                 this.setWaitMode('EventSelector');
  30.                 break;
  31.             case 'add':
  32.                 $gameSystem.addToEventSelector(Number(args[1]));
  33.                 break;
  34.             case 'remove':
  35.                 $gameSystem.removeFromEventSelector(Number(args[1]));
  36.                 break;
  37.             case 'clear':
  38.                 $gameSystem.clearEventSelector();
  39.                 break;
  40.             }
  41.         }
  42.     };
  43.  
  44.     var _Game_Interpreter_updateWaitMode =
  45.             Game_Interpreter.prototype.updateWaitMode;
  46.     Game_Interpreter.prototype.updateWaitMode = function() {
  47.         if (this._waitMode === 'EventSelector') {
  48.             if (eventSelectorStatus === 'close') {
  49.                 this._waitMode = '';
  50.                 if (selectedCommonEvent) {
  51.                     this.setupChild(selectedCommonEvent.list);
  52.                     this._callingSelectedEvent = true;
  53.                 }
  54.                 eventSelectorStatus = '';
  55.             }
  56.             return true;
  57.         } else {
  58.             return _Game_Interpreter_updateWaitMode.call(this);
  59.         }
  60.     };
  61.  
  62.     var _Game_Interpreter_updateChild = Game_Interpreter.prototype.updateChild;
  63.     Game_Interpreter.prototype.updateChild = function() {
  64.         var result = _Game_Interpreter_updateChild.call(this);
  65.         if (this._callingSelectedEvent && !result) {
  66.             this._callingSelectedEvent = false;
  67.             eventSelectorStatus = 'open';
  68.             this.setWaitMode('EventSelector');
  69.             return true;
  70.         }
  71.         return result;
  72.     };
  73.  
  74.     Game_System.prototype.addToEventSelector = function(commonEventId) {
  75.         if (!this._eventSelectorData) {
  76.             this.clearEventSelector();
  77.         }
  78.         if (!this._eventSelectorData.contains(commonEventId)) {
  79.             this._eventSelectorData.push(commonEventId);
  80.         }
  81.     };
  82.  
  83.     Game_System.prototype.removeFromEventSelector = function(commonEventId) {
  84.         if (this._eventSelectorData) {
  85.             var index = this._eventSelectorData.indexOf(commonEventId);
  86.             if (index >= 0) {
  87.                 this._eventSelectorData.splice(index, 1);
  88.             }
  89.         }
  90.     };
  91.  
  92.     Game_System.prototype.clearEventSelector = function() {
  93.         this._eventSelectorData = [];
  94.     };
  95.  
  96.     Game_System.prototype.eventSelectorData = function() {
  97.         if (this._eventSelectorData) {
  98.             return this._eventSelectorData.clone();
  99.         } else {
  100.             return [];
  101.         }
  102.     };
  103.  
  104.     var _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
  105.     Scene_Map.prototype.createAllWindows = function() {
  106.         _Scene_Map_createAllWindows.call(this);
  107.         this._eventSelectorWindow = new Window_EventSelector(0, 0);
  108.         this.addChild(this._eventSelectorWindow);
  109.     };
  110.  
  111.     function Window_EventSelector() {
  112.         this.initialize.apply(this, arguments);
  113.     }
  114.  
  115.     Window_EventSelector.prototype = Object.create(Window_Selectable.prototype);
  116.     Window_EventSelector.prototype.constructor = Window_EventSelector;
  117.  
  118.     Window_EventSelector.lastTopRow = 0;
  119.     Window_EventSelector.lastIndex  = 0;
  120.  
  121.     Window_EventSelector.prototype.initialize = function(x, y) {
  122.         var width = Graphics.boxWidth/4;
  123.         var height = this.fittingHeight(10);
  124.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  125.         this.openness = 0;
  126.         this.deactivate();
  127.         this.setHandler('ok',     this.onOk.bind(this));
  128.         this.setHandler('cancel', this.onCancel.bind(this));
  129.     };
  130.  
  131.     Window_EventSelector.prototype.maxCols = function() {
  132.         return 1;
  133.     };
  134.  
  135.     Window_EventSelector.prototype.maxItems = function() {
  136.         return this._list ? this._list.length : 0;
  137.     };
  138.  
  139.     Window_EventSelector.prototype.update = function() {
  140.         Window_Selectable.prototype.update.call(this);
  141.         switch (eventSelectorStatus) {
  142.         case 'open':
  143.             this.refresh();
  144.             this.setTopRow(Window_EventSelector.lastTopRow);
  145.             this.select(Window_EventSelector.lastIndex);
  146.             this.open();
  147.             this.activate();
  148.             eventSelectorStatus = 'select';
  149.             break;
  150.         case 'select':
  151.             if (this.isClosed()) {
  152.                 eventSelectorStatus = 'close';
  153.             }
  154.             break;
  155.         }
  156.     };
  157.  
  158.     Window_EventSelector.prototype.refresh = function() {
  159.         var data = $gameSystem.eventSelectorData();
  160.         this._list = [];
  161.         for (var i = 0; i < data.length; i++) {
  162.             var commonEvent = $dataCommonEvents[data[i]];
  163.             if (commonEvent) {
  164.                 this._list.push(commonEvent);
  165.             }
  166.         }
  167.         this.createContents();
  168.         this.drawAllItems();
  169.     };
  170.  
  171.     Window_EventSelector.prototype.drawItem = function(index) {
  172.         var commonEvent = this._list[index];
  173.         var rect = this.itemRectForText(index);
  174.         this.drawText(commonEvent.name, rect.x, rect.y, rect.width);
  175.     };
  176.  
  177.     Window_EventSelector.prototype.isCurrentItemEnabled = function() {
  178.         var commonEvent = this._list[this.index()];
  179.         return !!commonEvent;
  180.     };
  181.  
  182.     Window_EventSelector.prototype.isOkTriggered = function() {
  183.         return Input.isTriggered('ok');
  184.     };
  185.  
  186.     Window_EventSelector.prototype.onOk = function() {
  187.         selectedCommonEvent = this._list[this.index()];
  188.         Window_EventSelector.lastTopRow = this.topRow();
  189.         Window_EventSelector.lastIndex = this.index();
  190.         this.close();
  191.     };
  192.  
  193.     Window_EventSelector.prototype.onCancel = function() {
  194.         selectedCommonEvent = null;
  195.         Window_EventSelector.lastTopRow = this.topRow();
  196.         Window_EventSelector.lastIndex = this.index();
  197.         this.close();
  198.     };
  199.  
  200. })();

Lv1.梦旅人

梦石
0
星屑
60
在线时间
306 小时
注册时间
2014-8-5
帖子
416
2
发表于 2015-12-31 20:26:58 | 只看该作者
本帖最后由 夏末渐离 于 2015-12-31 20:29 编辑

1.请将目光投在你贴出来的脚本的52行。

2.将52行改为this._callingSelectedEvent = false;

3.进入游戏测试。

点评

于是应该被版主改好了……  发表于 2016-1-1 19:30
当时好奇,能不能再点一次~~  发表于 2016-1-1 13:43
应该把本帖标记为已经解决而不是已经过期,方便其他人搜索  发表于 2015-12-31 21:21
感谢,认可该楼。  发表于 2015-12-31 20:53

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
余烬之中 + 1 0x0
负零 + 10 认可答案

查看全部评分

  点我进入    
       ↓      
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-15 14:04

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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