From e97693194998a34a86ba24a531be2ff474ca2fde Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Sat, 8 Mar 2025 16:54:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A5=BC=E4=BC=A0=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=A2=9D=E5=A4=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/actions.js | 45 +++++++++++++++++++++++++++++++++++++++++++-- libs/ui.js | 19 ++++++++++++++++++- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index f49cbd67..ca36790a 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1284,6 +1284,30 @@ actions.prototype._clickBookDetail = function () { core.status.event.id = 'book'; } +function _hideFly(floorId) { + const hideFloors = core.getFlag('hideFloors', {}); + if (hideFloors.hasOwnProperty(floorId)) { + delete hideFloors[floorId]; + core.setFlag('hideFloors', hideFloors); + } + else { + if (Object.keys(hideFloors).length <= 1) { + core.drawFailTip('当前无法执行隐藏操作!'); + return; + } + hideFloors[floorId] = true; + } + core.setFlag('hideFloors', hideFloors); +} + +function _hideFlyMode() { + core.setFlag('noHideFly', !core.hasFlag('noHideFly')); +} + +function _isFloorHided(floorId) { + return !core.hasFlag('noHideFly') && core.getFlag('hideFloors', {}).hasOwnProperty(floorId); +} + ////// 楼层传送器界面时的点击操作 ////// actions.prototype._clickFly = function (x, y) { if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE + 3) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-1)); } @@ -1291,8 +1315,24 @@ actions.prototype._clickFly = function (x, y) { if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE + 4) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(-10)); } if ((x == this.SIZE - 2 || x == this.SIZE - 3) && y == this.HSIZE - 2) { core.playSound('光标移动'); core.ui.drawFly(this._getNextFlyFloor(10)); } if (x >= this.HSIZE - 1 && x <= this.HSIZE + 1 && y == this.LAST) { core.playSound('取消'); core.ui.closePanel(); } + const floorId = core.floorIds[core.status.event.data]; if (x >= 0 && x <= this.HSIZE + 3 && y >= 3 && y <= this.LAST - 1) - core.flyTo(core.floorIds[core.status.event.data]); + core.flyTo(floorId); + if (x >= 1 && x <= 2 && y === 2) _hideFly(floorId); + if (x >= 3 && x <= 6 && y === 2) _hideFlyMode(); + if (x >= 7 && x <= 8 && y === 2) { + core.myprompt("请输入一段笔记,字数不要过多。", null, function (data) { + if (data) { + const flyNotes = core.getFlag('flyNotes', {}); + flyNotes[floorId] = data; + core.setFlag('flyNotes', flyNotes); + core.ui.drawFly(core.status.event.data); + core.drawSuccessTip("楼层笔记新增成功!"); + } else { + core.ui.closePanel(); + } + }, () => { }); + } return; } @@ -1315,7 +1355,8 @@ actions.prototype._getNextFlyFloor = function (delta, index) { index += sign; if (index < 0 || index >= core.floorIds.length) break; var floorId = core.floorIds[index]; - if (core.status.maps[floorId].canFlyTo && core.hasVisitedFloor(floorId)) { + if (core.status.maps[floorId].canFlyTo && core.hasVisitedFloor(floorId) + && !_isFloorHided(floorId)) { delta--; ans = index; } diff --git a/libs/ui.js b/libs/ui.js index 1e178ef4..90666698 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2553,13 +2553,20 @@ ui.prototype.drawFly = function (page) { core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000'); core.setAlpha('ui', 1); core.setTextAlign('ui', 'center'); - core.fillText('ui', '楼层跳跃', this.HPIXEL, 60, '#FFFFFF', this._buildFont(28, true)); + core.fillText('ui', '楼层跳跃', this.HPIXEL, 40, '#FFFFFF', this._buildFont(28, true)); core.fillText('ui', '返回游戏', this.HPIXEL, this.PIXEL - 13, null, this._buildFont(15, true)) core.setTextAlign('ui', 'right'); core.fillText('ui', '浏览地图时也', this.PIXEL - 10, this.PIXEL - 23, '#aaaaaa', this._buildFont(10, false)); core.fillText('ui', '可楼层跳跃!', this.PIXEL - 10, this.PIXEL - 11, null, this._buildFont(10, false)); core.setTextAlign('ui', 'center'); + const isHide = core.getFlag('hideFloors', {}).hasOwnProperty(floorId); + const noHideFly = core.hasFlag('noHideFly'); + + core.fillText('ui', isHide ? '[显示本层]' : '[隐藏本层]', 60, 80, '#EEEEEE', this._buildFont(12, false)); + core.fillText('ui', '[显示隐藏层:' + noHideFly ? 'ON' : 'OFF' + ']', 160, 80, '#EEEEEE', this._buildFont(12, false)); + core.fillText('ui', '[楼层笔记]', 260, 80, '#EEEEEE', this._buildFont(12, false)); + var middle = this.HPIXEL + 39; // 换行 @@ -2583,8 +2590,18 @@ ui.prototype.drawFly = function (page) { core.fillText('ui', '▼', this.PIXEL - 60, middle + 96 + 7); } var size = this.PIXEL - 143; + core.strokeRect('ui', 20, 100, size, size, '#FFFFFF', 2); + if (isHide) core.setAlpha('ui', 0.8); core.drawThumbnail(floorId, null, { ctx: 'ui', x: 20, y: 100, size: size, damage: true }); + if (isHide) core.setAlpha('ui', 1); + + const flyNotes = core.getFlag('flyNotes', {}); + if (flyNotes.hasOwnProperty(floorId)) { + core.ui.drawTextContent('ui', flyNotes[floorId], { + left: 50, top: 120, color: 'white', align: 'center', fontSize: 12, maxWidth: size - 50, + }); + } } ////// 绘制中心对称飞行器