From 654567fdd742ede34b2115a4710d562e8eb62114 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 24 Aug 2021 15:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=89=E5=B1=82=20&=20=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 1 + _server/editor_listen.js | 1 + _server/editor_mappanel.js | 17 ++++++++ _server/editor_ui.js | 82 ++++++++++++++++++++++++++++++++++++++ editor-mobile.html | 3 +- editor.html | 3 +- 6 files changed, 105 insertions(+), 2 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 5afe7a24..9036c0d2 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -57,6 +57,7 @@ function editor() { showMovable: document.getElementById('showMovable'), gameInject: document.getElementById('gameInject'), undoFloor: document.getElementById('undoFloor'), + selectFloorBtn: document.getElementById('selectFloorBtn'), editorTheme: document.getElementById('editorTheme'), bigmapBtn : document.getElementById('bigmapBtn'), mapRowMark: document.getElementById('mapRowMark'), diff --git a/_server/editor_listen.js b/_server/editor_listen.js index 5f876bad..474c10cd 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -37,6 +37,7 @@ editor_listen_wrapper = function (editor) { editor.dom.clearEvent.onmouseup = editor.uifunctions.clearEvent_click editor.dom.clearLoc.onmouseup = editor.uifunctions.clearLoc_click editor.dom.undoFloor.onclick = editor.uifunctions.undoFloor_click + editor.dom.selectFloorBtn.onclick = editor.uifunctions.selectFloorBtn_click editor.dom.editorTheme.onchange = editor.uifunctions.editorTheme_onchange editor.dom.lastUsed.onmouseup = editor.uifunctions.lastUsed_click; diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index 2adb4cac..d451d3c7 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -452,6 +452,23 @@ editor_mappanel_wrapper = function (editor) { editor.changeFloor(toId); } + editor.uifunctions.selectFloorBtn_click = function () { + editor.uievent.selectFloor(null, '选择楼层', function (floorId) { + if (!floorId || floorId == editor.currentFloorId) return; + + var saveFloor = document.getElementById('saveFloor'); + if (saveFloor && saveFloor.classList.contains('highlight')) { + printe('请先保存地图!'); + return; + } + + editor_mode.onmode('nextChange'); + editor_mode.onmode('floor'); + editor.dom.selectFloor.value = floorId; + editor.changeFloor(floorId); + }) + } + editor.uifunctions.editorTheme_onchange = function () { var theme = editor.dom.editorTheme.value; editor.config.set('theme', theme); diff --git a/_server/editor_ui.js b/_server/editor_ui.js index 20b4d436..fc960d86 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -787,6 +787,88 @@ editor_ui_wrapper = function (editor) { return list; } + // ------ 选择楼层 ------ // + uievent.selectFloor = function (floorId, title, callback) { + uievent.isOpen = true; + uievent.elements.div.style.display = 'block'; + uievent.mode = 'selectFloor'; + uievent.elements.selectPoint.style.display = 'none'; + uievent.elements.yes.style.display = 'block'; + uievent.elements.title.innerText = title; + uievent.elements.selectBackground.style.display = 'none'; + uievent.elements.selectFloor.style.display = 'none'; + uievent.elements.selectPointBox.style.display = 'none'; + uievent.elements.canvas.style.display = 'none'; + uievent.elements.usedFlags.style.display = 'none'; + uievent.elements.extraBody.style.display = 'block'; + uievent.elements.body.style.overflow = "auto"; + + uievent.elements.yes.onclick = function () { + var floorId = uievent.values.floorId; + uievent.close(); + if (callback) callback(floorId); + } + + if (floorId instanceof Array) floorId = floorId[0]; + if (!floorId) floorId = editor.currentFloorId; + uievent.values.floorId = floorId; + + var html = "

"; + html += "搜索楼层:"; + html += "" + + one + '(' + floor.title + ')' + ""; + html += ""; + html += ""; + html += '
'; + }); + floorList.innerHTML = html; + } + + uievent._selectFloor_preview = function (button) { + var span = button.nextElementSibling; + while (span.firstChild) span.removeChild(span.lastChild); + var floorId = span.getAttribute('key'); + + if (span.style.display == 'none') { + button.innerText = '收起'; + span.style.display = 'inline'; + if (!uievent.values.dom) { + var canvas = document.createElement('canvas'); + canvas.style.position = 'relative'; + canvas.style.marginLeft = "-10px"; + canvas.style.marginTop = '5px'; + canvas.style.width = "100%" + canvas.width = canvas.height = core.__PIXELS__; + uievent.values.dom = canvas; + uievent.values.ctx = canvas.getContext('2d'); + } + span.appendChild(uievent.values.dom); + core.clearMap(uievent.values.ctx); + core.drawThumbnail(floorId, null, {ctx: uievent.values.ctx}); + } else { + button.innerText = '预览'; + span.style.display = 'none'; + } + } + // ------ 素材选择框 ------ // uievent.selectMaterial = function (value, title, directory, transform, callback) { var one = directory.split(':'); diff --git a/editor-mobile.html b/editor-mobile.html index 0356e7c5..2c117bd3 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -381,8 +381,9 @@ + - +