diff --git a/libs/actions.js b/libs/actions.js index 5405fa6e..3a9c5357 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1004,7 +1004,7 @@ actions.prototype._clickFly = function (x, y) { if ((x == 10 || x == 11) && y == 4) core.ui.drawFly(this._getNextFlyFloor(10)); if (x >= 5 && x <= 7 && y == 12) core.ui.closePanel(); if (x >= 0 && x <= 9 && y >= 3 && y <= 11) - core.control.flyTo(core.floorIds[core.status.event.data]); + core.flyTo(core.floorIds[core.status.event.data]); return; } diff --git a/libs/control.js b/libs/control.js index cb54ae61..7ae47130 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1242,6 +1242,7 @@ control.prototype._doReplayAction = function (action) { control.prototype._replay_finished = function () { core.status.replay.replaying = false; + core.status.event.selection = 0; core.ui.drawConfirmBox("录像播放完毕,你想退出播放吗?", function () { core.ui.closePanel(); core.stopReplay(true); @@ -1443,165 +1444,7 @@ control.prototype._replayAction_key = function (action) { return true; } -////// 判断当前能否进入某个事件 ////// -control.prototype.checkStatus = function (name, need, item) { - if (need && core.status.event.id == name) { - core.ui.closePanel(); - return false; - } - - if (need && core.status.lockControl) return false; - if (core.isset(item) && item && !core.hasItem(name)) { - core.drawTip("你没有" + core.material.items[name].name); - return false; - } - if (core.isMoving()) { - core.drawTip("请先停止勇士行动"); - return false; - } - - core.lockControl(); - core.status.event.id = name; - return true; -} - -////// 点击怪物手册时的打开操作 ////// -control.prototype.openBook = function (need) { - if (core.isReplaying()) return; - - if (core.status.event.id == 'book' && core.events.recoverEvents(core.status.event.interval)) { - return; - } - - // 当前是book,且从“浏览地图”打开 - if (core.status.event.id == 'book' && core.isset(core.status.event.ui)) { - core.status.boxAnimateObjs = []; - core.ui.drawMaps(core.status.event.ui); - return; - } - - // 从“浏览地图”页面打开 - if (core.status.event.id=='viewMaps') { - need=false; - core.status.event.ui = core.status.event.data; - } - - if (!core.checkStatus('book', need, true)) - return; - core.useItem('book', true); -} - -////// 点击楼层传送器时的打开操作 ////// -control.prototype.useFly = function (need) { - if (core.isReplaying()) return; - if (!core.checkStatus('fly', need, true)) - return; - if (core.flags.flyNearStair && !core.nearStair()) { - core.drawTip("只有在楼梯边才能使用传送器"); - core.unLockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - if (!core.canUseItem('fly')) { - core.drawTip("楼层传送器好像失效了"); - core.unLockControl(); - core.status.event.data = null; - core.status.event.id = null; - return; - } - core.useItem('fly', true); - return; -} - -control.prototype.flyTo = function (toId, callback) { - return this.controldata.flyTo(toId, callback); -} - -////// 点击装备栏时的打开操作 ////// -control.prototype.openEquipbox = function (need) { - if (core.isReplaying()) return; - if (!core.checkStatus('equipbox', need)) - return; - core.ui.drawEquipbox(); -} - -////// 点击工具栏时的打开操作 ////// -control.prototype.openToolbox = function (need) { - if (core.isReplaying()) return; - if (!core.checkStatus('toolbox', need)) - return; - core.ui.drawToolbox(); -} - -////// 点击快捷商店按钮时的打开操作 ////// -control.prototype.openQuickShop = function (need) { - if (core.isReplaying()) return; - if (!core.checkStatus('selectShop', need)) - return; - core.ui.drawQuickShop(); -} - -control.prototype.openKeyBoard = function (need) { - if (core.isReplaying()) return; - - if (!core.checkStatus('keyBoard', need)) - return; - core.ui.drawKeyBoard(); -} - -////// 点击保存按钮时的打开操作 ////// -control.prototype.save = function(need) { - if (core.isReplaying()) return; - - if (core.status.event.id == 'save' && core.events.recoverEvents(core.status.event.interval)) { - return; - } - - if (!core.checkStatus('save', need)) - return; - - var saveIndex = core.saves.saveIndex; - var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; - - core.ui.drawSLPanel(10*page+offset); -} - -////// 点击读取按钮时的打开操作 ////// -control.prototype.load = function (need) { - if (core.isReplaying()) return; - - var saveIndex = core.saves.saveIndex; - var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; - - // 游戏开始前读档 - if (!core.isPlaying()) { - core.dom.startPanel.style.display = 'none'; - core.clearStatus(); - core.clearMap('all'); - core.deleteAllCanvas(); - core.status.event = {'id': 'load', 'data': null}; - core.status.lockControl = true; - core.ui.drawSLPanel(10*page+offset); - return; - } - - if (core.status.event.id == 'load' && core.events.recoverEvents(core.status.event.interval)) { - return; - } - - if (!core.checkStatus('load', need)) - return; - core.ui.drawSLPanel(10*page+offset); -} - -////// 点击设置按钮时的操作 ////// -control.prototype.openSettings = function (need) { - if (core.isReplaying()) return; - if (!core.checkStatus('settings', need)) - return; - core.ui.drawSettings(); -} +// ------ 存读档相关 ------ // ////// 自动存档 ////// control.prototype.autosave = function (removeLast) { diff --git a/libs/events.js b/libs/events.js index de2f9cb3..215f0c97 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1516,7 +1516,142 @@ events.prototype._action_exit = function (data, x, y, prefix) { core.doAction(); } -// ------ 样板提供的的自定义事件 END ------ // +// ------ 点击状态栏图标所进行的一些操作 ------ // + +////// 判断当前能否进入某个事件 ////// +events.prototype._checkStatus = function (name, fromUserAction, checkItem) { + if (fromUserAction && core.status.event.id == name) { + core.ui.closePanel(); + return false; + } + if (fromUserAction && core.status.lockControl) return false; + if (checkItem && !core.hasItem(name)) { + core.drawTip("你没有" + core.material.items[name].name); + return false; + } + if (core.isMoving()) { + core.drawTip("请先停止勇士行动"); + return false; + } + core.lockControl(); + core.status.event.id = name; + return true; +} + +////// 点击怪物手册时的打开操作 ////// +events.prototype.openBook = function (fromUserAction) { + if (core.isReplaying()) return; + // 如果能恢复事件(从callBook事件触发) + if (core.status.event.id == 'book' && core.events.recoverEvents(core.status.event.interval)) + return; + // 当前是book,且从“浏览地图”打开 + if (core.status.event.id == 'book' && core.status.event.ui) { + core.status.boxAnimateObjs = []; + core.ui.drawMaps(core.status.event.ui); + return; + } + // 从“浏览地图”页面打开 + if (core.status.event.id == 'viewMaps') { + fromUserAction = false; + core.status.event.ui = core.status.event.data; + } + if (!this._checkStatus('book', fromUserAction, true)) return; + core.useItem('book', true); +} + +////// 点击楼层传送器时的打开操作 ////// +events.prototype.useFly = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('fly', fromUserAction, true)) return; + if (core.flags.flyNearStair && !core.nearStair()) { + core.drawTip("只有在楼梯边才能使用传送器"); + core.unLockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + if (!core.canUseItem('fly')) { + core.drawTip("楼层传送器好像失效了"); + core.unLockControl(); + core.status.event.data = null; + core.status.event.id = null; + return; + } + core.useItem('fly', true); + return; +} + +events.prototype.flyTo = function (toId, callback) { + return this.controldata.flyTo(toId, callback); +} + +////// 点击装备栏时的打开操作 ////// +events.prototype.openEquipbox = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('equipbox', fromUserAction)) return; + core.ui.drawEquipbox(); +} + +////// 点击工具栏时的打开操作 ////// +events.prototype.openToolbox = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('toolbox', fromUserAction)) return; + core.ui.drawToolbox(); +} + +////// 点击快捷商店按钮时的打开操作 ////// +events.prototype.openQuickShop = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('selectShop', fromUserAction)) return; + core.ui.drawQuickShop(); +} + +events.prototype.openKeyBoard = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('keyBoard', fromUserAction)) return; + core.ui.drawKeyBoard(); +} + +////// 点击保存按钮时的打开操作 ////// +events.prototype.save = function (fromUserAction) { + if (core.isReplaying()) return; + if (core.status.event.id == 'save' && core.events.recoverEvents(core.status.event.interval)) + return; + if (!this._checkStatus('save', fromUserAction)) return; + var saveIndex = core.saves.saveIndex; + var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; + core.ui.drawSLPanel(10*page+offset); +} + +////// 点击读取按钮时的打开操作 ////// +events.prototype.load = function (fromUserAction) { + if (core.isReplaying()) return; + var saveIndex = core.saves.saveIndex; + var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page; + // 游戏开始前读档 + if (!core.isPlaying()) { + core.dom.startPanel.style.display = 'none'; + core.clearStatus(); + core.clearMap('all'); + core.deleteAllCanvas(); + core.status.event = {'id': 'load', 'data': null}; + core.status.lockControl = true; + core.ui.drawSLPanel(10*page+offset); + return; + } + if (core.status.event.id == 'load' && core.events.recoverEvents(core.status.event.interval)) + return; + if (!this._checkStatus('load', fromUserAction)) return; + core.ui.drawSLPanel(10*page+offset); +} + +////// 点击设置按钮时的操作 ////// +events.prototype.openSettings = function (fromUserAction) { + if (core.isReplaying()) return; + if (!this._checkStatus('settings', fromUserAction)) + return; + core.ui.drawSettings(); +} // ------ 一些事件的具体执行过程 ------ //