选层 & 搜索

This commit is contained in:
ckcz123 2021-08-24 15:28:33 +08:00
parent a95cc8c615
commit 654567fdd7
6 changed files with 105 additions and 2 deletions

View File

@ -57,6 +57,7 @@ function editor() {
showMovable: document.getElementById('showMovable'), showMovable: document.getElementById('showMovable'),
gameInject: document.getElementById('gameInject'), gameInject: document.getElementById('gameInject'),
undoFloor: document.getElementById('undoFloor'), undoFloor: document.getElementById('undoFloor'),
selectFloorBtn: document.getElementById('selectFloorBtn'),
editorTheme: document.getElementById('editorTheme'), editorTheme: document.getElementById('editorTheme'),
bigmapBtn : document.getElementById('bigmapBtn'), bigmapBtn : document.getElementById('bigmapBtn'),
mapRowMark: document.getElementById('mapRowMark'), mapRowMark: document.getElementById('mapRowMark'),

View File

@ -37,6 +37,7 @@ editor_listen_wrapper = function (editor) {
editor.dom.clearEvent.onmouseup = editor.uifunctions.clearEvent_click editor.dom.clearEvent.onmouseup = editor.uifunctions.clearEvent_click
editor.dom.clearLoc.onmouseup = editor.uifunctions.clearLoc_click editor.dom.clearLoc.onmouseup = editor.uifunctions.clearLoc_click
editor.dom.undoFloor.onclick = editor.uifunctions.undoFloor_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.editorTheme.onchange = editor.uifunctions.editorTheme_onchange
editor.dom.lastUsed.onmouseup = editor.uifunctions.lastUsed_click; editor.dom.lastUsed.onmouseup = editor.uifunctions.lastUsed_click;

View File

@ -452,6 +452,23 @@ editor_mappanel_wrapper = function (editor) {
editor.changeFloor(toId); 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 () { editor.uifunctions.editorTheme_onchange = function () {
var theme = editor.dom.editorTheme.value; var theme = editor.dom.editorTheme.value;
editor.config.set('theme', theme); editor.config.set('theme', theme);

View File

@ -787,6 +787,88 @@ editor_ui_wrapper = function (editor) {
return list; 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 = "<p style='margin-left: 10px; line-height: 25px'>";
html += "搜索楼层:<input type='text' oninput='editor.uievent._selectFloor_update(this.value)' "
html += "placeholder='楼层ID或楼层名...' style='vertical-align:text-bottom'><br/>"
html += '<span id="selectFloor_floorList"></span>';
html += "</p>";
uievent.elements.extraBody.innerHTML = html;
uievent._selectFloor_update();
}
uievent._selectFloor_update = function (value) {
value = value || '';
var floorList = document.getElementById('selectFloor_floorList');
var html = '';
core.floorIds.forEach(function (one) {
var checked = one == uievent.values.floorId;
var floor = core.floors[one];
if (floor == null) return;
if (!one.includes(value) && !(floor.title||"").includes(value) && !(floor.name||"").includes(value)) return;
html += "<input type='radio' name='uievent_selectFloor' onchange='editor.uievent.values.floorId=\""+one+"\"'" + (checked ? ' checked' : '') + ">";
html += "<span onclick='this.previousElementSibling.checked=true;editor.uievent.values.floorId=\""+one+"\"' style='cursor: default'>"
+ one + '' + floor.title + '' + "</span>";
html += "<button onclick='editor.uievent._selectFloor_preview(this)' style='margin-left: 10px'>预览</button>";
html += "<span style='display:none;' key='"+one+"'></span>";
html += '<br/>';
});
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) { uievent.selectMaterial = function (value, title, directory, transform, callback) {
var one = directory.split(':'); var one = directory.split(':');

View File

@ -381,8 +381,9 @@
<input type="button" id="bigmapBtn" value="大地图" style="margin-left: 5px"/> <input type="button" id="bigmapBtn" value="大地图" style="margin-left: 5px"/>
</div> </div>
<select id="selectFloor" style="clear:left"></select> <select id="selectFloor" style="clear:left"></select>
<input type="button" value="选层" id='selectFloorBtn'/>
<input type="button" value="保存地图" id='saveFloor'/> <input type="button" value="保存地图" id='saveFloor'/>
<input type="button" value="后退" id="undoFloor" /> <input type="button" value="后退" id="undoFloor" style="display: none;"/>
<input type="button" value="帮助文档" id="openDoc" /> <input type="button" value="帮助文档" id="openDoc" />
<span id='mobileeditdata' style="display:none"> <span id='mobileeditdata' style="display:none">
<input type="button" value="编辑"/> <input type="button" value="编辑"/>

View File

@ -344,8 +344,9 @@
<input type="button" id='bigmapBtn' value="大地图" style="margin-left: 5px"/> <input type="button" id='bigmapBtn' value="大地图" style="margin-left: 5px"/>
</div> </div>
<select id="selectFloor" style="margin-bottom: 5px;"></select> <select id="selectFloor" style="margin-bottom: 5px;"></select>
<input type="button" value="选层" id='selectFloorBtn'/>
<input type="button" value="保存地图" id='saveFloor'/> <input type="button" value="保存地图" id='saveFloor'/>
<input type="button" value="后退" id="undoFloor" /> <input type="button" value="后退" id="undoFloor" style="display: none;" />
<input type="button" value="帮助文档" id="openDoc" /> <input type="button" value="帮助文档" id="openDoc" />
<input type="button" value="前往游戏" onclick="window.open('./index.html', '_blank')"/> <input type="button" value="前往游戏" onclick="window.open('./index.html', '_blank')"/>
</div> </div>