previewUI

This commit is contained in:
oc 2019-05-28 00:04:45 +08:00
parent 414dd86c81
commit dc205877de
3 changed files with 34 additions and 15 deletions

View File

@ -612,7 +612,19 @@ function omitedcheckUpdateFunction(event) {
editor_blockly.doubleClickBlock = function (blockId) { editor_blockly.doubleClickBlock = function (blockId) {
var b = editor_blockly.workspace.getBlockById(blockId); var b = editor_blockly.workspace.getBlockById(blockId);
//console.log(b); // console.log(Blockly.JavaScript.blockToCode(b));
if (b && b.type == 'previewUI_s') { // previewUI
try {
var code = "[" + Blockly.JavaScript.blockToCode(b).replace(/\\i/g, '\\\\i') + "]";
eval("var obj="+code);
// console.log(obj);
if (obj.length > 0 && obj[0].type == 'previewUI') {
uievent.previewUI(obj[0].action);
}
} catch (e) {main.log(e);}
return;
}
var textStringDict = { var textStringDict = {
'text_0_s': 'EvalString_0', 'text_0_s': 'EvalString_0',
'text_1_s': 'EvalString_2', 'text_1_s': 'EvalString_2',

View File

@ -285,6 +285,15 @@ editor.constructor.prototype.listen=function () {
var shortcut = core.getLocalStorage('shortcut',{48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0}); var shortcut = core.getLocalStorage('shortcut',{48: 0, 49: 0, 50: 0, 51: 0, 52: 0, 53: 0, 54: 0, 55: 0, 56: 0, 57: 0});
document.body.onkeydown = function (e) { document.body.onkeydown = function (e) {
// UI预览 & 地图选点
if (uievent && uievent.isOpen) {
e.preventDefault();
if (e.keyCode == 27) uievent.close();
if (e.keyCode == 13) uievent.confirm();
// TODOWASD平移大地图
return;
}
// 监听Ctrl+S保存 // 监听Ctrl+S保存
if (e.ctrlKey && e.keyCode == 83) { if (e.ctrlKey && e.keyCode == 83) {
e.preventDefault(); e.preventDefault();

View File

@ -371,38 +371,36 @@ selectBox.isSelected=function(value){
uievent = {}; uievent = {};
uievent.uieventDiv = document.getElementById('uieventDiv'); uievent.div = document.getElementById('uieventDiv');
uievent.title = document.getElementById('uieventTitle');
uievent.selectPoint = document.getElementById('selectPoint');
uievent.yes = document.getElementById('uieventYes');
uievent.no = document.getElementById('uieventNo');
uievent.uieventNo = document.getElementById('uieventNo'); uievent.confirm = function () {
uievent.uieventNo.onclick = function () {
uievent.close();
}
uievent.uieventYes = document.getElementById('uieventYes');
uievent.uieventYes.onclick = function () {
uievent.close(); uievent.close();
if (uievent.callback) { if (uievent.callback) {
uievent.callback(uievent.floorId, uievent.x, uievent.y); uievent.callback(uievent.floorId, uievent.x, uievent.y);
} }
delete uievent.callback; delete uievent.callback;
} }
uievent.yes.onclick = uievent.confirm;
uievent.title = document.getElementById('uieventTitle');
uievent.selectPoint = document.getElementById('selectPoint');
uievent.close = function () { uievent.close = function () {
uievent.isOpen = false; uievent.isOpen = false;
uievent.uieventDiv.style.display = 'none'; uievent.div.style.display = 'none';
} }
uievent.no.onclick = uievent.close;
uievent.previewUI = function (list) { uievent.previewUI = function (list) {
uievent.isOpen = true; uievent.isOpen = true;
uievent.uieventDiv.style.display = 'block'; uievent.div.style.display = 'block';
uievent.mode = 'previewUI'; uievent.mode = 'previewUI';
uievent.selectPoint.style.display = 'none'; uievent.selectPoint.style.display = 'none';
uievent.uieventYes.style.display = 'none'; uievent.yes.style.display = 'none';
uievent.title.innerText = 'UI绘制预览'; uievent.title.innerText = 'UI绘制预览';
core.setAlpha('uievent', 1);
core.clearMap('uievent'); core.clearMap('uievent');
// 绘制UI // 绘制UI