diff --git a/project/icons.js b/project/icons.js index 73914d5..ff4ef13 100644 --- a/project/icons.js +++ b/project/icons.js @@ -118,7 +118,8 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "T362": 86, "T363": 87, "T364": 88, - "T365": 89 + "T365": 89, + "T397": 90 }, "animates": { "star": 0, diff --git a/project/maps.js b/project/maps.js index d1b42f0..3085125 100644 --- a/project/maps.js +++ b/project/maps.js @@ -295,6 +295,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "394": {"cls":"terrains","id":"T394"}, "395": {"cls":"terrains","id":"T395"}, "396": {"cls":"items","id":"I396"}, + "397": {"cls":"terrains","id":"T397"}, "20034": {"cls":"tileset","id":"X20034","canPass":true}, "20154": {"cls":"tileset","id":"X20154","canPass":true}, "20216": {"cls":"tileset","id":"X20216","canPass":true}, diff --git a/project/materials/terrains.png b/project/materials/terrains.png index fd82855..1676124 100644 Binary files a/project/materials/terrains.png and b/project/materials/terrains.png differ diff --git a/project/plugins.js b/project/plugins.js index 459d53a..72f7a53 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -2736,7 +2736,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = main.dom.boss7.style.height = obj.totalHeight + 3 + "px"; main.dom.boss8.style.width = obj.totalWidth + 3 + "px"; main.dom.boss8.style.height = obj.totalHeight + 3 + "px"; - + main.dom.saveLoad.style.height = obj.totalHeight + 3 + "px"; main.dom.boss.style.width = obj.totalWidth + 3 + "px"; main.dom.boss.style.height = obj.totalHeight + 3 + "px"; @@ -2907,6 +2907,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.ui.cgText.update(); if (main.dom.boss1 && main.dom.boss1.style.display === "block") core.ui.boss.update(); + + if (main.dom.saveLoad && main.dom.saveLoad.style.display === "block") + core.saveLoad.update(); }; class StatusBar { @@ -21131,88 +21134,87 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }, "开局选项悬停": function () { - // 在此增加新插件 + // 在此增加新插件 + main.dom.playGame.addEventListener("mouseenter", () => { + core.dom.playGame.style.backgroundColor = "#808080"; + }); + main.dom.playGame.addEventListener("mouseleave", () => { + core.dom.playGame.style.backgroundColor = "transparent"; + }); + main.dom.playGame.addEventListener("touchmove", () => { + core.dom.playGame.style.backgroundColor = "#808080"; + }); + main.dom.playGame.addEventListener("touchend", () => { + core.dom.playGame.style.backgroundColor = "transparent"; + }); + main.dom.playGame.addEventListener("touchcancel", () => { + core.dom.playGame.style.backgroundColor = "transparent"; + }); - main.dom.playGame.addEventListener("mouseenter", () => { - core.dom.playGame.style.backgroundColor = "#808080"; - }); - main.dom.playGame.addEventListener("mouseleave", () => { - core.dom.playGame.style.backgroundColor = "transparent"; - }); - main.dom.playGame.addEventListener("touchmove", () => { - core.dom.playGame.style.backgroundColor = "#808080"; - }); - main.dom.playGame.addEventListener("touchend", () => { - core.dom.playGame.style.backgroundColor = "transparent"; - }); - main.dom.playGame.addEventListener("touchcancel", () => { - core.dom.playGame.style.backgroundColor = "transparent"; - }); + main.dom.loadGame.addEventListener("mouseenter", () => { + core.dom.loadGame.style.backgroundColor = "#808080"; + }); + main.dom.loadGame.addEventListener("mouseleave", () => { + core.dom.loadGame.style.backgroundColor = "transparent"; + }); + main.dom.loadGame.addEventListener("touchmove", () => { + core.dom.loadGame.style.backgroundColor = "#808080"; + }); + main.dom.loadGame.addEventListener("touchend", () => { + core.dom.loadGame.style.backgroundColor = "transparent"; + }); + main.dom.loadGame.addEventListener("touchcancel", () => { + core.dom.loadGame.style.backgroundColor = "transparent"; + }); - main.dom.loadGame.addEventListener("mouseenter", () => { - core.dom.loadGame.style.backgroundColor = "#808080"; - }); - main.dom.loadGame.addEventListener("mouseleave", () => { - core.dom.loadGame.style.backgroundColor = "transparent"; - }); - main.dom.loadGame.addEventListener("touchmove", () => { - core.dom.loadGame.style.backgroundColor = "#808080"; - }); - main.dom.loadGame.addEventListener("touchend", () => { - core.dom.loadGame.style.backgroundColor = "transparent"; - }); - main.dom.loadGame.addEventListener("touchcancel", () => { - core.dom.loadGame.style.backgroundColor = "transparent"; - }); + main.dom.CGMode.addEventListener("mouseenter", () => { + core.dom.CGMode.style.backgroundColor = "#808080"; + }); + main.dom.CGMode.addEventListener("mouseleave", () => { + core.dom.CGMode.style.backgroundColor = "transparent"; + }); + main.dom.CGMode.addEventListener("touchmove", () => { + core.dom.CGMode.style.backgroundColor = "#808080"; + }); + main.dom.CGMode.addEventListener("touchend", () => { + core.dom.CGMode.style.backgroundColor = "transparent"; + }); + main.dom.CGMode.addEventListener("touchcancel", () => { + core.dom.CGMode.style.backgroundColor = "transparent"; + }); - main.dom.CGMode.addEventListener("mouseenter", () => { - core.dom.CGMode.style.backgroundColor = "#808080"; - }); - main.dom.CGMode.addEventListener("mouseleave", () => { - core.dom.CGMode.style.backgroundColor = "transparent"; - }); - main.dom.CGMode.addEventListener("touchmove", () => { - core.dom.CGMode.style.backgroundColor = "#808080"; - }); - main.dom.CGMode.addEventListener("touchend", () => { - core.dom.CGMode.style.backgroundColor = "transparent"; - }); - main.dom.CGMode.addEventListener("touchcancel", () => { - core.dom.CGMode.style.backgroundColor = "transparent"; - }); + main.dom.musicMode.addEventListener("mouseenter", () => { + core.dom.musicMode.style.backgroundColor = "#808080"; + }); + main.dom.musicMode.addEventListener("mouseleave", () => { + core.dom.musicMode.style.backgroundColor = "transparent"; + }); + main.dom.musicMode.addEventListener("touchmove", () => { + core.dom.musicMode.style.backgroundColor = "#808080"; + }); + main.dom.musicMode.addEventListener("touchend", () => { + core.dom.musicMode.style.backgroundColor = "transparent"; + }); + main.dom.musicMode.addEventListener("touchcancel", () => { + core.dom.musicMode.style.backgroundColor = "transparent"; + }); - main.dom.musicMode.addEventListener("mouseenter", () => { - core.dom.musicMode.style.backgroundColor = "#808080"; - }); - main.dom.musicMode.addEventListener("mouseleave", () => { - core.dom.musicMode.style.backgroundColor = "transparent"; - }); - main.dom.musicMode.addEventListener("touchmove", () => { - core.dom.musicMode.style.backgroundColor = "#808080"; - }); - main.dom.musicMode.addEventListener("touchend", () => { - core.dom.musicMode.style.backgroundColor = "transparent"; - }); - main.dom.musicMode.addEventListener("touchcancel", () => { - core.dom.musicMode.style.backgroundColor = "transparent"; - }); - - main.dom.replayGame.addEventListener("mouseenter", () => { - core.dom.replayGame.style.backgroundColor = "#808080"; - }); - main.dom.replayGame.addEventListener("mouseleave", () => { - core.dom.replayGame.style.backgroundColor = "transparent"; - }); - main.dom.replayGame.addEventListener("touchmove", () => { - core.dom.replayGame.style.backgroundColor = "#808080"; - }); - main.dom.replayGame.addEventListener("touchend", () => { - core.dom.replayGame.style.backgroundColor = "transparent"; - }); - main.dom.replayGame.addEventListener("touchcancel", () => { - core.dom.replayGame.style.backgroundColor = "transparent"; - }); - }, + main.dom.replayGame.addEventListener("mouseenter", () => { + core.dom.replayGame.style.backgroundColor = "#808080"; + }); + main.dom.replayGame.addEventListener("mouseleave", () => { + core.dom.replayGame.style.backgroundColor = "transparent"; + }); + main.dom.replayGame.addEventListener("touchmove", () => { + core.dom.replayGame.style.backgroundColor = "#808080"; + }); + main.dom.replayGame.addEventListener("touchend", () => { + core.dom.replayGame.style.backgroundColor = "transparent"; + }); + main.dom.replayGame.addEventListener("touchcancel", () => { + core.dom.replayGame.style.backgroundColor = "transparent"; + }); +}, "天气叠加": function () { //使用方法:使用core.setWeather(天气,等级)来增加天气,使用core.setWeather()来清空天气 // 天气叠加功能 @@ -21899,34 +21901,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ctx.lineTo(enemynow - 5, 110); ctx.closePath(); ctx.fill(); + core.drawIcon(ctx, 'T367', enemynow - 16, 74, 32, 32) - if (enemyInfo.cls === "enemys") { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 32, - 32, - 32, - enemynow - 16, - 74, - 32, - 32 - ); - } else { - core.drawImage( - ctx, - core.getBlockInfo(enemyInfo.id).image, - 32, - core.getBlockInfo(enemyInfo.id).posY * 48, - 32, - 48, - enemynow - 16, - 58, - 32, - 48 - ); - } core.drawLine(ctx, 100, 125, 315, 125, "#FFFFFF", 5); equipInfo.forEach(function (v) { if (!attack && !onAttack) v.now += v.speed; @@ -23681,5 +23657,488 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = ctx.restore(); //恢复变换前的坐标,否则将连续转置 } +}, + "存读档": function () { + // 在此增加新插件 + const saveLoad = document.createElement("canvas"); //创建存读档画布 + saveLoad.style.position = "absolute"; + saveLoad.style.zIndex = 390; + saveLoad.style.display = "none"; + saveLoad.id = "saveLoad"; + main.dom.gameGroup.insertAdjacentElement("afterend", saveLoad); + saveLoad.style.top = "50%"; + saveLoad.style.left = "50%"; + saveLoad.style.transform = "translate(-50%,-50%)"; + const ctx = saveLoad.getContext("2d"); + main.dom.saveLoad = saveLoad + //////存读档界面更新 + class SL { + constructor() { + this.index = -1; + this.refresh = false + } + update() {} + set() {} + } + core.saveLoad = new SL() + ////// 绘制存档/读档界面 ////// + ui.prototype._drawSLPanel = function (index, refresh) { + core.control._loadFavoriteSaves(); + if (index == null) index = 1; + if (index < 0) index = 0; + + var page = parseInt(index / 10), + offset = index % 10; + var max_page = main.savePages || 30; + if (core.status.event.data && core.status.event.data.mode == 'fav') + max_page = Math.ceil((core.saves.favorite || []).length / 5); + if (page >= max_page) page = max_page - 1; + if (offset > 5) offset = 5; + if (core.status.event.data && core.status.event.data.mode == 'fav' && page == max_page - 1) { + offset = Math.min(offset, (core.saves.favorite || []).length - 5 * page); + } + + var last_page = -1; + var mode = 'all'; + if (core.status.event.data) { + last_page = core.status.event.data.page; + mode = core.status.event.data.mode; + } + core.status.event.data = { 'page': page, 'offset': offset, 'mode': mode }; + core.status.event.ui = core.status.event.ui || []; + if (refresh || page != last_page) { + core.status.event.ui = []; + this._drawSLPanel_loadSave(page, function () { + core.ui._drawSLPanel_draw(page, max_page); + }); + } else this._drawSLPanel_draw(page, max_page); + } + + ui.prototype._drawSLPanel_draw = function (page, max_page) { + // --- 绘制背景 + this._drawSLPanel_drawBackground(); + // --- 绘制文字 + core.ui.drawPagination(page + 1, max_page); + core.setTextAlign('ui', 'center'); + var bottom = core._PY_ - 13; + core.fillText('ui', '返回游戏', core._PX_ - 48, bottom, '#DDDDDD', this._buildFont(15, true)); + + if (core.status.event.selection) + core.setFillStyle('ui', '#FF6A6A'); + if (core.status.event.id == 'save') + core.fillText('ui', '删除模式', 48, bottom); + else { + if (core.status.event.data.mode == 'all') { + core.fillText('ui', '[E]显示收藏', 52, bottom); + } else { + core.fillText('ui', '[E]显示全部', 52, bottom); + } + } + // --- 绘制记录 + this._drawSLPanel_drawRecords(); + } + + ui.prototype._drawSLPanel_drawBackground = function () { + core.clearMap('ui'); + core.setAlpha('ui', 0.85); + core.fillRect('ui', 0, 0, core._PX_, core._PY_, '#000000'); // 可改成背景图 + core.setAlpha('ui', 1); + } + + ui.prototype._drawSLPanel_loadSave = function (page, callback) { + var ids = [0]; + for (var i = 1; i <= 5; ++i) { + var id = 5 * page + i; + if (core.status.event.data.mode == 'fav') + id = core.saves.favorite[id - 1]; // 因为favorite第一个不是自动存档 所以要偏移1 + ids.push(id); + } + core.getSaves(ids, function (data) { + for (var i = 1; i < ids.length; ++i) + core.status.event.ui[i] = data[i]; + core.status.event.ui[0] = data[0] == null ? null : data[0][core.saves.autosave.now - 1]; + callback(); + }); + } + + // 在以x为中心轴 y为顶坐标 的位置绘制一条宽为size的记录 cho表示是否被选中 选中会加粗 highlight表示高亮标题 ✐ + ui.prototype._drawSLPanel_drawRecord = function (title, data, x, y, size, cho, highLight) { + var globalAttribute = core.status.globalAttribute || core.initStatus.globalAttribute; + var strokeColor = globalAttribute.selectColor; + if (core.status.event.selection) strokeColor = '#FF6A6A'; + if (!data || !data.floorId) highLight = false; + if (data && data.__toReplay__) title = '[R]' + title; + var w = size * core._PX_, + h = size * core._PY_; + core.fillText('ui', title, x, y, highLight ? globalAttribute.selectColor : '#FFFFFF', this._buildFont(17, true)); + core.strokeRect('ui', x - w / 2, y + 15, w, h, cho ? strokeColor : '#FFFFFF', cho ? 3 : 1); + if (data && data.floorId) { + core.setTextAlign('ui', "center"); + var map = core.maps.loadMap(data.maps, data.floorId); + core.extractBlocksForUI(map, data.hero.flags); + core.drawThumbnail(data.floorId, map.blocks, { + heroLoc: data.hero.loc, + heroIcon: data.hero.image, + flags: data.hero.flags, + ctx: 'ui', + x: x - w / 2, + y: y + 15, + size: size, + centerX: data.hero.loc.x, + centerY: data.hero.loc.y, + noHD: true + }); + if (core.isPlaying() && core.getFlag("hard") != data.hero.flags.hard) { + core.fillRect('ui', x - w / 2, y + 15, w, h, [0, 0, 0, 0.4]); + core.fillText('ui', data.hard, x, parseInt(y + 22 + h / 2), data.hero.flags.__hardColor__ || 'white', this._buildFont(30, true)); + } + // 绘制存档笔记 + if (data.hero.notes && data.hero.notes.length > 0) { + core.setTextAlign('ui', 'left'); + if (data.hero.notes.length >= 2) { + core.fillRect('ui', x - w / 2, y + 15, w, 28, [0, 0, 0, 0.3]); + core.fillBoldText('ui', data.hero.notes.length - 1 + ". " + data.hero.notes[data.hero.notes.length - 2].substring(0, 10), + x - w / 2 + 2, y + 15 + 12, '#FFFFFF', null, this._buildFont(10, false)); + core.fillBoldText('ui', data.hero.notes.length + ". " + data.hero.notes[data.hero.notes.length - 1].substring(0, 10), + x - w / 2 + 2, y + 15 + 24); + } else { + core.fillRect('ui', x - w / 2, y + 15, w, 16, [0, 0, 0, 0.3]); + core.fillBoldText('ui', data.hero.notes.length + ". " + data.hero.notes[data.hero.notes.length - 1].substring(0, 10), + x - w / 2 + 2, y + 15 + 12, '#FFFFFF', null, this._buildFont(10, false)); + } + } + core.setTextAlign('ui', "center"); + var v = core.formatBigNumber(data.hero.hp, true) + "/" + core.formatBigNumber(data.hero.atk, true) + "/" + core.formatBigNumber(data.hero.def, true); + var v2 = "/" + core.formatBigNumber(data.hero.mdef, true); + if (core.calWidth('ui', v + v2, this._buildFont(10, false)) <= w) v += v2; + core.fillText('ui', v, x, y + 30 + h, globalAttribute.selectColor); + core.fillText('ui', core.formatDate(new Date(data.time)), x, y + 43 + h, data.hero.flags.debug ? '#FF6A6A' : '#FFFFFF'); + } else { + core.fillRect('ui', x - w / 2, y + 15, w, h, '#333333'); + core.fillText('ui', '空', x, parseInt(y + 22 + h / 2), '#FFFFFF', this._buildFont(30, true)); + } + } + + ui.prototype._drawSLPanel_drawRecords = function (n) { + var page = core.status.event.data.page; + var offset = core.status.event.data.offset; + var u = Math.floor(core._PX_ / 6), + size = 0.3; + var name = core.status.event.id == 'save' ? "存档" : core.status.event.id == 'load' ? "读档" : "回放"; + + for (var i = 0; i < (n || 6); i++) { + var data = core.status.event.ui[i]; + var id = 5 * page + i; + var highLight = (i > 0 && core.saves.favorite.indexOf(id) >= 0) || core.status.event.data.mode == 'fav'; + var title = (highLight ? '★ ' : '☆ ') + (core.saves.favoriteName[id] || (name + id)); + if (i != 0 && core.status.event.data.mode == 'fav') { + if (!data) break; + var real_id = core.saves.favorite[id - 1]; + title = (core.saves.favoriteName[real_id] || (name + real_id)) + ' ✐'; + } + var charSize = 32; // 字体占用像素范围 + var topSpan = parseInt((core._PY_ - charSize - 2 * (charSize * 2 + size * core._PY_)) / 3); // Margin + var yTop1 = topSpan + parseInt(charSize / 2) + 8; // 文字的中心 + var yTop2 = yTop1 + charSize * 2 + size * core._PY_ + topSpan; + if (i < 3) { + this._drawSLPanel_drawRecord(i == 0 ? "自动存档" : title, data, (2 * i + 1) * u, yTop1, size, i == offset, highLight); + } else { + this._drawSLPanel_drawRecord(title, data, (2 * i - 5) * u, yTop2, size, i == offset, highLight); + } + } + }; + ////// 点击保存按钮时的打开操作 ////// + events.prototype.save = function (fromUserAction) { + if (core.isReplaying()) return; + if (core.hasFlag("__forbidSave__")) { + core.playSound("操作失败"); + core.drawTip("当前禁止存档"); + 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.playSound("打开界面"); + 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.status.event = { id: "load", data: null }; + core.status.lockControl = true; + core.playSound("打开界面"); + 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.playSound("打开界面"); + core.ui._drawSLPanel(10 * page + offset); + }; + ////// 回放时存档 ////// + control.prototype._replay_SL = 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("请等待当前事件的处理结束"); + } + if (core.hasFlag("__forbidSave__")) { + core.playSound("操作失败"); + return core.drawTip("当前禁止存档"); + } + this._replay_hideProgress(); + + core.lockControl(); + core.status.event.id = "save"; + var saveIndex = core.saves.saveIndex; + var page = parseInt((saveIndex - 1) / 5), + offset = saveIndex - 5 * page; + + core.ui._drawSLPanel(10 * page + offset); + }; + + ////// 存读档界面时的点击操作 ////// + actions.prototype._clickSL = function (x, y) { + var page = core.status.event.data.page, + offset = core.status.event.data.offset; + var index = page * 10 + offset; + + // 上一页 + if ((x == this._HX_ - 2 || x == this._HX_ - 3) && y === core._HEIGHT_ - 1) { + core.playSound('光标移动'); + core.ui._drawSLPanel(10 * (page - 1) + offset); + return; + } + // 下一页 + if ((x == this._HX_ + 2 || x == this._HX_ + 3) && y === core._HEIGHT_ - 1) { + core.playSound('光标移动'); + core.ui._drawSLPanel(10 * (page + 1) + offset); + return; + } + // 返回 + if (x >= this.LAST - 2 && y === core._HEIGHT_ - 1) { + core.playSound('取消'); + if (core.events.recoverEvents(core.status.event.interval)) + return; + core.ui.closePanel(); + delete core.status.tempRoute; + if (!core.isPlaying()) + core.showStartAnimate(true); + return; + } + // 删除 + if (x >= 0 && x <= 2 && y === core._HEIGHT_ - 1) { + if (core.status.event.id == 'save') { + core.status.event.selection = !core.status.event.selection; + core.ui._drawSLPanel(index); + } else { // 显示收藏 + core.status.event.data.mode = core.status.event.data.mode == 'all' ? 'fav' : 'all'; + if (core.status.event.data.mode == 'fav') + core.ui._drawSLPanel(1, true); + else { + page = parseInt((core.saves.saveIndex - 1) / 5); + offset = core.saves.saveIndex - 5 * page; + core.ui._drawSLPanel(10 * page + offset, true); + } + } + return; + } + // 点存档名 + var xLeft = parseInt(core._WIDTH_ / 3), + xRight = parseInt(core._WIDTH_ * 2 / 3); + var topY1 = 0, + topY2 = this._HY_; + if (y >= topY1 && y <= topY1 + 1) { + if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 1); + if (x >= xRight) return this._clickSL_favorite(page, 2); + } + if (y >= topY2 && y <= topY2 + 1) { + if (x < xLeft) return this._clickSL_favorite(page, 3); + if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 4); + if (x >= xRight) return this._clickSL_favorite(page, 5); + } + + var id = null; + if (y >= topY1 + 2 && y < this._HY_ - 1) { + if (x < xLeft) id = "autoSave"; + if (x >= xLeft && x < xRight) id = 5 * page + 1; + if (x >= xRight) id = 5 * page + 2; + } + if (y >= topY2 + 2 && y < core._HEIGHT_ - 1) { + if (x < xLeft) id = 5 * page + 3; + if (x >= xLeft && x < xRight) id = 5 * page + 4; + if (x >= xRight) id = 5 * page + 5; + } + if (id != null) { + if (core.status.event.selection) { + if (id == 'autoSave') { + core.playSound('操作失败'); + core.drawTip("无法删除自动存档!"); + } else { + core.removeSave(id, function () { + core.ui._drawSLPanel(index, true); + }); + } + } else { + if (core.status.event.data.mode == 'fav' && id != 'autoSave') + id = core.saves.favorite[id - 1]; + core.doSL(id, core.status.event.id); + } + } + } + + actions.prototype._clickSL_favorite = function (page, offset) { + if (offset == 0) return; + var index = 5 * page + offset; + if (core.status.event.data.mode == 'fav') { // 收藏模式下点击的下标直接对应favorite + index = core.saves.favorite[index - 1]; + core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (value) { + if (value && value.length <= 5) { + core.saves.favoriteName[index] = value; + core.control._updateFavoriteSaves(); + core.ui._drawSLPanel(10 * page + offset); + } else if (value) { + alert("无效的输入!"); + } + }); + } else { + var v = core.saves.favorite.indexOf(index); + core.playSound('确定'); + if (v >= 0) { // 已经处于收藏状态:取消收藏 + core.saves.favorite.splice(v, 1); + delete core.saves.favoriteName[index]; + } else if (core.hasSave(index)) { // 存在存档则进行收藏 + core.saves.favorite.push(index); + core.saves.favorite = core.saves.favorite.sort(function (a, b) { return a - b; }); // 保证有序 + core.drawTip("收藏成功!"); + } + core.control._updateFavoriteSaves(); + core.ui._drawSLPanel(10 * page + offset); + } + } + + ////// 存读档界面时,按下某个键的操作 ////// + actions.prototype._keyDownSL = function (keycode) { + + var page = core.status.event.data.page, + offset = core.status.event.data.offset; + var index = page * 10 + offset; + + if (keycode == 37) { // left + core.playSound('光标移动'); + if (offset == 0) { + core.ui._drawSLPanel(10 * (page - 1) + 5); + } else { + core.ui._drawSLPanel(index - 1); + } + return; + } + if (keycode == 38) { // up + core.playSound('光标移动'); + if (offset < 3) { + core.ui._drawSLPanel(10 * (page - 1) + offset + 3); + } else { + core.ui._drawSLPanel(index - 3); + } + return; + } + if (keycode == 39) { // right + core.playSound('光标移动'); + if (offset == 5) { + core.ui._drawSLPanel(10 * (page + 1) + 1); + } else { + core.ui._drawSLPanel(index + 1); + } + return; + } + if (keycode == 40) { // down + core.playSound('光标移动'); + if (offset >= 3) { + core.ui._drawSLPanel(10 * (page + 1) + offset - 3); + } else { + core.ui._drawSLPanel(index + 3); + } + return; + } + if (keycode == 33) { // PAGEUP + core.playSound('光标移动'); + core.ui._drawSLPanel(10 * (page - 1) + offset); + return; + } + if (keycode == 34) { // PAGEDOWN + core.playSound('光标移动'); + core.ui._drawSLPanel(10 * (page + 1) + offset); + return; + } + } + + ////// 存读档界面时,放开某个键的操作 ////// + actions.prototype._keyUpSL = function (keycode) { + var page = core.status.event.data.page, + offset = core.status.event.data.offset; + var index = page * 10 + offset; + + if (keycode == 27 || keycode == 88 || (core.status.event.id == 'save' && keycode == 83) || (core.status.event.id == 'load' && keycode == 68)) { + this._clickSL(core._WIDTH_ - 1, core._HEIGHT_ - 1); + return; + } + if (keycode >= 48 && keycode <= 57) { + if (keycode == 48) keycode = 58; + core.ui._drawSLPanel((keycode - 49) * 1000 + 1); + return; + } + if (keycode == 13 || keycode == 32 || keycode == 67) { + if (offset == 0) + core.doSL("autoSave", core.status.event.id); + else { + var id = 5 * page + offset; + if (core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1]; + core.doSL(id, core.status.event.id); + } + return; + } + if (keycode == 69 && core.status.event.id != 'save') { // E 收藏切换 + this._clickSL(0, core._HEIGHT_ - 1); + return; + } + if (keycode == 46) { + if (offset == 0) { + core.playSound('操作失败'); + core.drawTip("无法删除自动存档!"); + } else { + var id = 5 * page + offset; + if (core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1]; + core.removeSave(id, function () { + core.ui._drawSLPanel(index, true); + }); + } + } + if (keycode == 70 && core.status.event.data.mode == 'all') { // F + this._clickSL_favorite(page, offset); + } + } } } \ No newline at end of file