diff --git a/_server/CodeMirror/defs.js b/_server/CodeMirror/defs.js index 0d0d247d..b618fe4e 100644 --- a/_server/CodeMirror/defs.js +++ b/_server/CodeMirror/defs.js @@ -1852,8 +1852,12 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ "!doc": "当前是否显示状态栏" }, "toolbarBtn": { - "!type": "bool", - "!doc": "当前工具栏是否是1-8的按钮" + "!type": "string", + "!doc": "当前工具栏的按钮种类" + }, + "toolsCount": { + "!type": "number", + "!doc": "当前工具栏的按钮数量" }, }, "bigmap": { diff --git a/index.html b/index.html index a233f02a..03527373 100644 --- a/index.html +++ b/index.html @@ -154,7 +154,7 @@ - + @@ -165,8 +165,15 @@ + + + + + + + - +

diff --git a/libs/control.js b/libs/control.js index a1b91055..97bc0fa6 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1471,6 +1471,7 @@ control.prototype.startReplay = function (list) { core.updateStatusBar(false, true); core.drawTip("开始播放"); this.replay(); + core.setToolbarButton("replay"); } ////// 更改播放状态 ////// @@ -1514,32 +1515,6 @@ control.prototype.stepReplay = function () { core.replay(true); } -////// 拦截录像,在运行到指定步数时暂停 ////// -control.prototype.interceptReplay = function () { - if (!core.isPlaying() || !core.isReplaying()) return; - if (!core.status.replay.pausing) { - core.playSound('操作失败'); - return core.drawTip("请先暂停录像"); - } - if (core.isMoving() || core.status.replay.animate || core.status.event.id) { - core.playSound('操作失败'); - return core.drawTip("请等待当前事件的处理结束"); - } - core.myprompt("请输入一个自然数,这将设置一个临时拦截点,录像将在运行到该步数时自动暂停。设为0将取消该拦截。", null, function (value) { - value = parseInt(value); - if (Number.isNaN(value) || value < 0) { - core.drawFailTip('错误:不合法的输入!'); - return; - } - else if (value === 0) { - core.setFlag('replayValve', null); - } - else { - core.setFlag('replayValve', value); - } - }, () => { }); -} - ////// 加速播放 ////// control.prototype.speedUpReplay = function () { if (!core.isPlaying() || !core.isReplaying()) return; @@ -1585,10 +1560,10 @@ control.prototype.stopReplay = function (force) { core.status.replay.speed = 1.0; core.status.replay.steps = 0; core.status.replay.save = []; - core.setFlag('replayValve', null); core.deleteCanvas('replay'); core.updateStatusBar(false, true); core.drawTip("停止播放并恢复游戏"); + core.setToolbarButton('normal'); } ////// 回退 ////// @@ -1741,11 +1716,6 @@ control.prototype.replay = function (force) { || core.status.replay.animate || core.status.event.id || core.status.replay.failed) return; if (core.status.replay.pausing && !force) return; - const valve = core.getFlag('replayValve', -1); - if (!main.replayChecking && core.status.route.length === valve) { - core.pauseReplay(); // 非线上录像验证时,截停录像。 - core.drawFailTip('录像已运行到指定的暂停点第' + valve + '步,自动暂停。'); - } this._replay_drawProgress(); if (core.status.replay.toReplay.length == 0) return this._replay_finished(); @@ -3244,45 +3214,17 @@ control.prototype.updateStatusBar_update = function () { core.control.noAutoEvents = true; } +/** 切换replay/pause 并刷新工具栏图标的完成度 */ control.prototype._updateStatusBar_setToolboxIcon = function () { if (core.isReplaying()) { - core.statusBar.image.book.src = core.status.replay.pausing ? core.statusBar.icons.play.src : core.statusBar.icons.pause.src; - core.statusBar.image.book.style.opacity = 1; - core.statusBar.image.fly.src = core.statusBar.icons.stop.src; - core.statusBar.image.fly.style.opacity = 1; - core.statusBar.image.toolbox.src = core.statusBar.icons.rewind.src; - core.statusBar.image.keyboard.src = core.statusBar.icons.book.src; - core.statusBar.image.shop.src = core.statusBar.icons.floor.src; - core.statusBar.image.save.src = core.statusBar.icons.speedDown.src; - core.statusBar.image.save.style.opacity = 1; - core.statusBar.image.load.src = core.statusBar.icons.speedUp.src; - core.statusBar.image.settings.src = core.statusBar.icons.save.src; - core.statusBar.image.rollback.src = core.statusBar.icons.single.src; - core.statusBar.image.undoRollback.src = core.statusBar.icons.valve.src; - } - else { - core.statusBar.image.book.src = core.statusBar.icons.book.src; - core.statusBar.image.book.style.opacity = core.hasItem('book') ? 1 : 0.3; - if (!core.flags.equipboxButton) { - core.statusBar.image.fly.src = core.statusBar.icons.fly.src; - core.statusBar.image.fly.style.opacity = core.hasItem('fly') ? 1 : 0.3; - } - else { - core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src; - core.statusBar.image.fly.style.opacity = 1; - } - core.statusBar.image.undoRollback.style.opacity = (core.saves.autosave.data != null - && core.saves.autosave.now < core.saves.autosave.data.length) ? 1 : 0.3; - core.statusBar.image.toolbox.src = core.statusBar.icons.toolbox.src; - core.statusBar.image.keyboard.src = core.statusBar.icons.keyboard.src; - core.statusBar.image.shop.src = core.statusBar.icons.shop.src; - core.statusBar.image.save.src = core.statusBar.icons.save.src; - core.statusBar.image.save.style.opacity = core.hasFlag('__forbidSave__') ? 0.3 : 1; - core.statusBar.image.load.src = core.statusBar.icons.load.src; - core.statusBar.image.settings.src = core.statusBar.icons.settings.src; - core.statusBar.image.rollback.src = core.statusBar.icons.rollback.src; - core.statusBar.image.undoRollback.src = core.statusBar.icons.undoRollback.src; + main.statusBar.image.play.src = core.status.replay.pausing ? core.statusBar.icons.play.src : core.statusBar.icons.pause.src; } + core.statusBar.image.book.style.opacity = core.hasItem('book') ? 1 : 0.3; + core.statusBar.image.fly.style.opacity = core.hasItem('fly') ? 1 : 0.3; + core.statusBar.image.undoRollback.style.opacity = + (core.saves.autosave.data != null && core.saves.autosave.now < core.saves.autosave.data.length) ? 1 : 0.3; + core.statusBar.image.save.style.opacity = core.hasFlag('__forbidSave__') ? 0.3 : 1; + } control.prototype.showStatusBar = function () { @@ -3294,7 +3236,8 @@ control.prototype.showStatusBar = function () { // 显示 for (var i = 0; i < statusItems.length; ++i) statusItems[i].style.opacity = 1; - this.setToolbarButton(false); + core.setToolbarButton(core.domStyle.toolbarBtn); + // this.setToolbarButton(false); core.dom.tools.hard.style.display = 'block'; core.dom.toolBar.style.display = 'block'; } @@ -3314,13 +3257,14 @@ control.prototype.hideStatusBar = function (showToolbox) { // 隐藏 for (var i = 0; i < statusItems.length; ++i) statusItems[i].style.opacity = 0; - if ((!core.domStyle.isVertical && !core.flags.extendToolbar) || !showToolbox) { - for (var i = 0; i < toolItems.length; ++i) - toolItems[i].style.display = 'none'; - } - if (!core.domStyle.isVertical && !core.flags.extendToolbar) { - core.dom.toolBar.style.display = 'none'; - } + if (!showToolbox) core.setToolbarButton('hide'); + // if ((!core.domStyle.isVertical && !core.flags.extendToolbar) || !showToolbox) { + // for (var i = 0; i < toolItems.length; ++i) + // toolItems[i].style.display = 'none'; + // } + // if (!core.domStyle.isVertical && !core.flags.extendToolbar) { + // core.dom.toolBar.style.display = 'none'; + // } } ////// 更新状态栏的勇士图标 ////// @@ -3345,62 +3289,62 @@ control.prototype.updateHeroIcon = function (name) { } ////// 改变工具栏为按钮1-8 ////// -control.prototype.setToolbarButton = function (useButton) { - if (!core.domStyle.showStatusBar) { - // 隐藏状态栏时检查竖屏 - if (!core.domStyle.isVertical && !core.flags.extendToolbar) { - for (var i = 0; i < core.dom.tools.length; ++i) - core.dom.tools[i].style.display = 'none'; - return; - } - if (!core.hasFlag('showToolbox')) return; - else core.dom.tools.hard.style.display = 'block'; - } +// control.prototype.setToolbarButton = function (useButton) { +// if (!core.domStyle.showStatusBar) { +// // 隐藏状态栏时检查竖屏 +// if (!core.domStyle.isVertical && !core.flags.extendToolbar) { +// for (var i = 0; i < core.dom.tools.length; ++i) +// core.dom.tools[i].style.display = 'none'; +// return; +// } +// if (!core.hasFlag('showToolbox')) return; +// else core.dom.tools.hard.style.display = 'block'; +// } - if (useButton == null) useButton = core.domStyle.toolbarBtn; - if ((!core.domStyle.isVertical && !core.flags.extendToolbar) || core.isReplaying()) useButton = false; - core.domStyle.toolbarBtn = useButton; +// if (useButton == null) useButton = core.domStyle.toolbarBtn; +// if ((!core.domStyle.isVertical && !core.flags.extendToolbar) || core.isReplaying()) useButton = false; +// core.domStyle.toolbarBtn = useButton; - if (useButton) { - ["book", "fly", "toolbox", "keyboard", "shop", "save", "load", "settings"].forEach(function (t) { - core.statusBar.image[t].style.display = 'none'; - }); - ["rollback", "undoRollback"].forEach(function (t) { - core.statusBar.image[t].style.display = 'none'; - }); - ["btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btnAlt"].forEach(function (t) { - core.statusBar.image[t].style.display = 'block'; - }) - if (!core.flags.showHard) { - ["btn8", "btn9"].forEach(function (t) { - core.statusBar.image[t].style.display = 'block'; - }); - } - main.statusBar.image.btnAlt.style.filter = core.getLocalStorage('altKey') ? 'sepia(1) contrast(1.5)' : ''; - } - else { - ["btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btnAlt"].forEach(function (t) { - core.statusBar.image[t].style.display = 'none'; - }); - ["btn8", "btn9"].forEach(function (t) { - core.statusBar.image[t].style.display = 'none'; - }); - ["book", "fly", "toolbox", "save", "load", "settings"].forEach(function (t) { - core.statusBar.image[t].style.display = 'block'; - }); - if (core.domStyle.isVertical || core.flags.extendToolbar || !core.flags.showHard) { - core.statusBar.image.shop.style.display = "block"; - } - else core.statusBar.image.shop.style.display = "none"; +// if (useButton) { +// ["book", "fly", "toolbox", "keyboard", "shop", "save", "load", "settings"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'none'; +// }); +// ["rollback", "undoRollback"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'none'; +// }); +// ["btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btnAlt"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'block'; +// }) +// if (!core.flags.showHard) { +// ["btn8", "btn9"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'block'; +// }); +// } +// main.statusBar.image.btnAlt.style.filter = core.getLocalStorage('altKey') ? 'sepia(1) contrast(1.5)' : ''; +// } +// else { +// ["btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btnAlt"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'none'; +// }); +// ["btn8", "btn9"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'none'; +// }); +// ["book", "fly", "toolbox", "save", "load", "settings"].forEach(function (t) { +// core.statusBar.image[t].style.display = 'block'; +// }); +// if (core.domStyle.isVertical || core.flags.extendToolbar || !core.flags.showHard) { +// core.statusBar.image.shop.style.display = "block"; +// } +// else core.statusBar.image.shop.style.display = "none"; - ["rollback", "undoRollback"].forEach(function (t) { - core.statusBar.image[t].style.display = core.flags.showHard ? "none" : "block"; - }); +// ["rollback", "undoRollback"].forEach(function (t) { +// core.statusBar.image[t].style.display = core.flags.showHard ? "none" : "block"; +// }); - core.statusBar.image.keyboard.style.display - = core.domStyle.isVertical || core.flags.extendToolbar ? "block" : "none"; - } -} +// core.statusBar.image.keyboard.style.display +// = core.domStyle.isVertical || core.flags.extendToolbar ? "block" : "none"; +// } +// } ////// ------ resize处理 ------ // @@ -3452,6 +3396,7 @@ control.prototype.unregisterResize = function (name) { this.resizes = this.resizes.filter(function (b) { return b.name != name; }); } +/** 执行所有resize函数 */ control.prototype._doResize = function (obj) { for (var i in this.resizes) { try { @@ -3465,8 +3410,22 @@ control.prototype._doResize = function (obj) { return false; } +/** 执行单个特定名称的resize函数 */ +control.prototype._doOneResize = function (obj, type) { + try { + const currEvent = this.resizes.find((resizeEvent) => resizeEvent.name === type); + if (!currEvent) return; + if (core.doFunc(currEvent.func, this, obj)) return true; + } catch (e) { + console.error(e); + console.error("ERROR in resizes[" + this.resizes[type].name + "]:已自动注销该项。"); + this.unregisterResize(this.resizes[type].name); + } + return false; +} + ////// 屏幕分辨率改变后重新自适应 ////// -control.prototype.resize = function () { +control.prototype.resize = function (type) { if (main.mode == 'editor') return; var clientWidth = main.dom.body.clientWidth, clientHeight = main.dom.body.clientHeight; var CANVAS_WIDTH = core.__PIXELS__, BAR_WIDTH = Math.round(core.__PIXELS__ * 0.31); @@ -3525,16 +3484,12 @@ control.prototype.resize = function () { is15x15: core.__SIZE__ == 15 }; - // 横屏且非底部工具栏,则商店调整到回退按键之前 - if (!core.domStyle.isVertical && !core.flags.extendsToolBar) { - if (core.statusBar.image.shop.nextElementSibling !== core.statusBar.image.rollback) - core.dom.toolBar.insertBefore(core.statusBar.image.shop, core.statusBar.image.rollback); + if (type != null) { + if (type instanceof Array) type.forEach((oneType) => this._doOneResize(obj, oneType)); + else this._doOneResize(obj, type); } - else if (core.statusBar.image.shop.nextElementSibling !== core.statusBar.image.save) - core.dom.toolBar.insertBefore(core.statusBar.image.shop, core.statusBar.image.save); - - this._doResize(obj); - this.setToolbarButton(); + else this._doResize(obj); + // this.setToolbarButton(); core.updateStatusBar(); } @@ -3700,8 +3655,8 @@ control.prototype._resize_status = function (obj) { } } +/** toolBar的样式 */ control.prototype._resize_toolBar = function (obj) { - // toolBar var toolBar = core.dom.toolBar; if (core.domStyle.isVertical) { toolBar.style.left = 0; @@ -3732,6 +3687,7 @@ control.prototype._resize_toolBar = function (obj) { toolBar.style.borderRight = toolBar.style.borderBottom = core.domStyle.isVertical || obj.extendToolbar ? obj.border : ''; toolBar.style.fontSize = 16 * core.domStyle.scale + "px"; + // 本项控制toolBar本身的显示与隐藏 if (!core.domStyle.showStatusBar && !core.domStyle.isVertical && !obj.extendToolbar) { toolBar.style.display = 'none'; } else { @@ -3739,6 +3695,7 @@ control.prototype._resize_toolBar = function (obj) { } } +/** toolBar中各个tools的样式 */ control.prototype._resize_tools = function (obj) { var toolsHeight = 32 * core.domStyle.scale * ((core.domStyle.isVertical || obj.extendToolbar) && !obj.is15x15 ? 0.95 : 1); var toolsMarginLeft; @@ -3754,9 +3711,15 @@ control.prototype._resize_tools = function (obj) { } core.dom.hard.style.lineHeight = toolsHeight + "px"; if (core.domStyle.isVertical || obj.extendToolbar) { - if (core.flags.showHard) core.dom.hard.style.width = obj.outerSize - 9 * toolsMarginLeft - 8.5 * toolsHeight - 22 + "px"; - else { - core.dom.hard.style.width = "15px"; + const toolsCount = core.domStyle.toolsCount; + if (toolsCount <= 8) { + core.dom.hard.style.width = obj.outerSize - (toolsCount + 1) * toolsMarginLeft - (toolsCount + 0.5) * toolsHeight - 22 + "px"; + } + else if (toolsCount === 9) { + core.dom.hard.style.width = obj.outerSize - (toolsCount + 1) * toolsMarginLeft - toolsCount * toolsHeight - 22 + "px"; + } + else { // toolsCount is 10 + core.dom.hard.style.width = obj.outerSize - (toolsCount + 1) * toolsMarginLeft - toolsCount * toolsHeight - 13 + "px"; core.dom.hard.style.marginLeft = "1px"; } } diff --git a/libs/core.js b/libs/core.js index 0fb6e5e8..9f5b3fa5 100644 --- a/libs/core.js +++ b/libs/core.js @@ -97,7 +97,8 @@ function core() { availableScale: [], isVertical: false, showStatusBar: true, - toolbarBtn: false, + toolbarBtn: "normal", + toolsCount: 7, } this.bigmap = { canvas: ["bg", "event", "event2", "fg", "damage"], diff --git a/main.js b/main.js index ed4ca6b3..c1bb2ebf 100644 --- a/main.js +++ b/main.js @@ -109,11 +109,14 @@ function main () { 'book': document.getElementById("img-book"), 'fly': document.getElementById("img-fly"), 'toolbox': document.getElementById("img-toolbox"), + 'equipbox': document.getElementById("img-equipbox"), 'keyboard': document.getElementById("img-keyboard"), 'shop': document.getElementById('img-shop'), 'save': document.getElementById("img-save"), 'load': document.getElementById("img-load"), 'settings': document.getElementById("img-settings"), + 'rollback': document.getElementById("img-rollback"), + 'undoRollback': document.getElementById("img-undoRollback"), 'btn1': document.getElementById("img-btn1"), 'btn2': document.getElementById("img-btn2"), 'btn3': document.getElementById("img-btn3"), @@ -124,10 +127,14 @@ function main () { 'btn8': document.getElementById("img-btn8"), 'btn9': document.getElementById("img-btn9"), 'btnAlt': document.getElementById("img-btnAlt"), - 'rollback': document.getElementById("img-rollback"), - 'undoRollback': document.getElementById("img-undoRollback"), + 'play': document.getElementById("img-play"), + 'pause': document.getElementById("img-pause"), + 'stop': document.getElementById("img-stop"), + 'rewind': document.getElementById("img-rewind"), + 'speedDown': document.getElementById("img-speedDown"), + 'speedUp': document.getElementById("img-speedUp"), 'single': document.getElementById("img-single"), - 'valve': document.getElementById("img-valve"), + 'view': document.getElementById("img-view"), }, 'icons': { 'floor': 0, @@ -171,7 +178,7 @@ function main () { 'rollback': 37, 'undoRollback': 38, 'single': 39, - 'valve': 40, + 'view': 40, }, 'floor': document.getElementById('floor'), 'name': document.getElementById('name'), @@ -633,184 +640,111 @@ main.prototype.listen = function () { console.error(e); } } - + // #region 图标点击事件-常规模式 ////// 点击状态栏中的怪物手册时 ////// main.statusBar.image.book.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.triggerReplay(); - return; - } - - if (main.core.isPlaying()) - main.core.openBook(true); + if (core.isReplaying()) core.control._replay_book(); + else if (main.core.isPlaying()) main.core.openBook(true); } - ////// 点击状态栏中的楼层传送器/装备栏时 ////// + ////// 点击状态栏中的楼层传送器时 ////// main.statusBar.image.fly.onclick = function (e) { e.stopPropagation(); - - // 播放录像时 - if (core.isReplaying()) { - core.stopReplay(); - return; - } - - if (main.core.isPlaying()) { - if (!main.core.flags.equipboxButton) { - main.core.useFly(true); - } - else { - main.core.openEquipbox(true) - } - } + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.useFly(true); } ////// 点击状态栏中的工具箱时 ////// main.statusBar.image.toolbox.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.rewindReplay(); - return; - } - - if (main.core.isPlaying()) { - main.core.openToolbox(core.status.event.id != 'equipbox'); - } + if (core.isReplaying()) core.control._replay_toolbox(); + else if (main.core.isPlaying()) main.core.openToolbox(core.status.event.id != 'equipbox'); } ////// 双击状态栏中的工具箱时 ////// main.statusBar.image.toolbox.ondblclick = function (e) { e.stopPropagation(); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.openEquipbox(true); + } - if (core.isReplaying()) { - return; - } - - if (main.core.isPlaying()) - main.core.openEquipbox(true); - + ////// 点击状态栏中的装备栏图标时 ////// + main.statusBar.image.toolbox.onclick = function (e) { + e.stopPropagation(); + if (core.isReplaying()) core.control._replay_equipbox(); + else if (main.core.isPlaying()) main.core.openEquipbox(core.status.event.id != 'equipbox'); } ////// 点击状态栏中的虚拟键盘时 ////// main.statusBar.image.keyboard.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.control._replay_book(); - return; - } - - if (main.core.isPlaying()) - main.core.openKeyBoard(true); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.openKeyBoard(true); } ////// 点击状态栏中的快捷商店时 ////// main.statusBar.image.shop.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.control._replay_viewMap(); - return; - } - - if (main.core.isPlaying()) - main.core.openQuickShop(true); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.openQuickShop(true); } ////// 点击金币时也可以开启快捷商店 ////// main.statusBar.image.money.onclick = function (e) { e.stopPropagation(); - - if (main.core.isPlaying()) - main.core.openQuickShop(true); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.openQuickShop(true); } - ////// 点击楼梯图标也可以浏览地图 ////// - main.statusBar.image.floor.onclick = function (e) { + ////// 楼梯图标代表浏览地图 ////// + main.statusBar.image.view.onclick = function (e) { e.stopPropagation(); - - if (main.core && main.core.isPlaying() && !core.isMoving() && !core.status.lockControl) { - core.ui._drawViewMaps(); + if (main.core && !core.isMoving() && !core.status.lockControl) { + if (core.isReplaying()) core.control._replay_viewMap(); + else if (main.core.isPlaying()) core.ui._drawViewMaps(); } } ////// 点击状态栏中的存档按钮时 ////// main.statusBar.image.save.onclick = function (e) { e.stopPropagation(); - if (core.isReplaying()) { - core.speedDownReplay(); + core.control._replay_SL(); return; } - - if (main.core.isPlaying()) - main.core.save(true); + if (main.core.isPlaying()) main.core.save(true); } ////// 点击状态栏中的读档按钮时 ////// main.statusBar.image.load.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.speedUpReplay(); - return; - } - - if (main.core.isPlaying()) - main.core.load(true); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) main.core.load(true); } - ////// 点击状态栏中的系统菜单时 ////// + ////// 点击状态栏中的系统设置菜单时 ////// main.statusBar.image.settings.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.control._replay_SL(); - return; - } - - if (main.core.isPlaying()) - main.core.openSettings(true); + if (core.isReplaying()) return; + if (main.core.isPlaying()) main.core.openSettings(true); } ////// 点击状态栏中的回退菜单时 ////// main.statusBar.image.rollback.onclick = function (e) { e.stopPropagation(); - - // 单步播放录像 - if (core.isReplaying()) { - core.control.stepReplay(); - return; - } - - if (main.core.isPlaying()) - core.doSL("autoSave", "load"); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) core.doSL("autoSave", "load"); } ////// 点击状态栏中的取消回退菜单时 ////// main.statusBar.image.undoRollback.onclick = function (e) { e.stopPropagation(); - - if (core.isReplaying()) { - core.control.interceptReplay(); - return; - } - - if (main.core.isPlaying()) - core.doSL("autoSave", "reload"); + if (core.isReplaying()) return; + else if (main.core.isPlaying()) core.doSL("autoSave", "reload"); } - ////// 点击工具栏时 ////// - main.dom.hard.onclick = function () { - if (core.isReplaying()) - return; - main.core.control.setToolbarButton(!core.domStyle.toolbarBtn); - } - - ////// 手机端的按钮1-7 ////// + // #region 图标点击事件-数字按钮模式 main.statusBar.image.btn1.onclick = function (e) { e.stopPropagation(); main.core.onkeyUp({ "keyCode": 49, "altKey": core.getLocalStorage('altKey') }); @@ -869,6 +803,59 @@ main.prototype.listen = function () { main.statusBar.image.btnAlt.style.filter = 'sepia(1) contrast(1.5)'; } }; + // #endregion + + // #region 图标点击事件-录像模式 + // 录像播放/暂停按钮(同一个) + // play和pause是一体的,根据core.status.replay.pausing决定 + main.statusBar.image.play.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.triggerReplay(); + } + + // 录像停止按钮 + main.statusBar.image.stop.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.stopReplay(); + } + + // 录像回退按钮 + main.statusBar.image.rewind.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.rewindReplay(); + } + + // 录像减速按钮 + main.statusBar.image.speedDown.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.speedDownReplay(); + } + + // 录像加速按钮 + main.statusBar.image.speedUp.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.speedUpReplay(); + } + + // 录像单步播放按钮 + main.statusBar.image.single.onclick = function (e) { + e.stopPropagation(); + if (!core.isReplaying()) return; + core.control.stepReplay(); + } + // #endregion + + ////// 点击工具栏的难度时 ////// + main.dom.hard.onclick = function () { + if (core.isReplaying()) return; + if (core.domStyle.toolbarBtn === 'normal') main.core.setToolbarButton('num'); + else if (core.domStyle.toolbarBtn === 'num') main.core.setToolbarButton('normal'); + } ////// 点击“开始游戏”时 ////// main.dom.playGame.onclick = function () { diff --git a/project/functions.js b/project/functions.js index 88be9a90..182e325e 100644 --- a/project/functions.js +++ b/project/functions.js @@ -58,9 +58,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.plugin.checkSkipFuncs(); // 清空自绘道具栏的缓存 core.plugin.clearItemBoxCache(); - - // 清空录像暂停点 - core.setFlag('replayValve', null); + // 设置一次工具栏,统计出元素数量 + core.setToolbarButton('normal'); }, "win": function (reason, norank, noexit) { // 游戏获胜事件 diff --git a/project/materials/icons.png b/project/materials/icons.png index 4c9b08f1..88feaec1 100644 Binary files a/project/materials/icons.png and b/project/materials/icons.png differ diff --git a/project/plugins.js b/project/plugins.js index 46ce7522..cd4221c1 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -3770,6 +3770,70 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }) } }, + "customizableToolBar": function () { + // 自定义工具栏显示项 + // 本插件需要配合main.js, control.js等的修改 + // 新的逻辑如下: + // 函数_updateStatusBar_setToolboxIcon在updateStatusBar中调用,仅用于切换录像replay/pause,和计算几个图标的透明度 + // setToolbarButton根据输入的类型重新向状态栏填入元素 + // resize添加一个只刷新工具栏的模式,此外,resize不调用setToolbarButton,相反,setToolbarButton后调用resize + // 以下地方调用setToolbarButton: hard的点击事件,回放录像的进入/退出事件 + // 要注意一点, floor是不能作为toolBar元素的,statuBar具有同id元素,样式会相互冲突 复制了一个外形一样的图标叫view,作为浏览地图按钮 + + /** + * PC 默认6个键且不需要切入数字键的模式 最多9个键 手机 默认9个键 最多10个键 + * normal:普通模式 num:按下数字键切换到的模式 replay:录像模式 opacity:透明度 + */ + const defaultConfig = { + normal: () => isVertical() ? ['book', 'fly', 'toolbox', 'keyboard', 'shop', 'save', 'load', 'settings', 'rollback'] : + ['book', 'fly', 'toolbox', 'save', 'load', 'settings'], + num: () => ['btn1', 'btn2', 'btn3', 'btn4', 'btn5', 'btn6', 'btn7', 'btn8', 'btnAlt'], + replay: () => isVertical() ? ['play', 'stop', 'rewind', 'book', 'view', 'speedDown', 'speedUp', 'single'] : + ['play', 'stop', 'rewind', 'speedDown', 'speedUp', 'book'], + hide: () => [], + }; + + function isVertical() { + return core.domStyle.isVertical || core.flags.extendToolbar; + } + + function getToolBarConfig(type) { + return core.getLocalStorage('toorBarConfig' + type, defaultConfig[type]()); + } + this.getToolBarConfig = getToolBarConfig; + + this.setToolBarConfig = function (type, index, value) { + const toolBarConfig = getToolBarConfig(); + if (value == null) toolBarConfig[type].splice(index, 1); + core.setLocalStorage('toorBarConfig', toolBarConfig); + } + + /** + * + * @param {'normal'|'num'|'replay'|'hide'} type + */ + function setToolbarButton(type) { + const currList = getToolBarConfig(type); + if (!currList) return; + const fragment = document.createDocumentFragment(); + for (let i = 0, l = currList.length; i < l; i++) { + const iconId = currList[i]; + const currEle = core.statusBar.image[iconId]; + if (!currEle) continue; + currEle.style.display = 'block'; + fragment.appendChild(currEle); + } + if (type !== "hide") { + core.domStyle.toolbarBtn = type; + } + core.domStyle.toolsCount = currList.length; + fragment.appendChild(core.dom.hard); // 难度一定会显示 因为难度所在位置要用于切换常规模式和数字模式 难度的尺寸是动态决定的 + core.dom.toolBar.innerHTML = ''; + core.dom.toolBar.appendChild(fragment); + core.control.resize('tools'); // 在这里计算难度的尺寸 + } + this.setToolbarButton = setToolbarButton; + }, "setting": function () { // 自绘设置界面 // 请保持本插件在所有插件的最下方 diff --git a/runtime.d.ts b/runtime.d.ts index f077094b..94af9723 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -973,8 +973,10 @@ interface control { /** 注销一个resize函数 */ unregisterResize(name: string): void - /** 屏幕分辨率改变后重新自适应 */ - resize(): void + /** 屏幕分辨率改变后重新自适应 + * @param type 重新设置指定类型的已注册resize事件 + */ + resize(type?:string): void } /**@file events.js将处理所有和事件相关的操作。 */ @@ -3231,7 +3233,8 @@ type CoreMixin = { scale: number, isVertical: boolean, showStatusBar: boolean, - toolbarBtn: boolean, + toolbarBtn: 'normal' | 'num' | 'replay' | 'hide', + toolsCount: number, } readonly bigmap: { canvas: string[], @@ -3256,6 +3259,7 @@ type CoreMixin = { max: number storage: true time: number + now: number updated: boolean } favorite: []