commit
3a1d068308
@ -54,7 +54,7 @@ body {
|
||||
height: 630px;
|
||||
}
|
||||
|
||||
#editArea {
|
||||
#mapEditArea {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
@ -107,7 +107,7 @@ body {
|
||||
top: 530px;
|
||||
}
|
||||
|
||||
#editArea p {
|
||||
#mapEditArea p {
|
||||
margin: 10px;
|
||||
display: block;
|
||||
width: 70%;
|
||||
|
||||
@ -37,7 +37,7 @@ body {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#editArea {
|
||||
#mapEditArea {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 70%;
|
||||
@ -64,7 +64,7 @@ body {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#editArea p {
|
||||
#mapEditArea p {
|
||||
margin: 10px;
|
||||
display: block;
|
||||
width: 70%;
|
||||
|
||||
@ -573,9 +573,9 @@ editor.prototype.setSelectBoxFromInfo=function(thisevent){
|
||||
dataSelection.style.left = pos.x * 32 + 'px';
|
||||
dataSelection.style.top = pos.y * ysize + 'px';
|
||||
dataSelection.style.height = ysize - 6 + 'px';
|
||||
setTimeout(function(){selectBox.isSelected = true;});
|
||||
setTimeout(function(){selectBox.isSelected(true);});
|
||||
editor.info = JSON.parse(JSON.stringify(thisevent));
|
||||
tip.infos = JSON.parse(JSON.stringify(thisevent));
|
||||
tip.infos(JSON.parse(JSON.stringify(thisevent)));
|
||||
editor.pos=pos;
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('enemyitem');
|
||||
@ -617,7 +617,7 @@ editor.prototype.listen = function () {
|
||||
}
|
||||
if (unselect) {
|
||||
if (clickpath.indexOf('eui') === -1) {
|
||||
if (selectBox.isSelected) {
|
||||
if (selectBox.isSelected()) {
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
@ -627,7 +627,7 @@ editor.prototype.listen = function () {
|
||||
;printf('地图保存成功');
|
||||
});
|
||||
}
|
||||
selectBox.isSelected = false;
|
||||
selectBox.isSelected(false);
|
||||
editor.info = {};
|
||||
}
|
||||
}
|
||||
@ -705,13 +705,13 @@ editor.prototype.listen = function () {
|
||||
editor.showMidMenu(e.clientX,e.clientY);
|
||||
return;
|
||||
}
|
||||
if (!selectBox.isSelected) {
|
||||
if (!selectBox.isSelected()) {
|
||||
var loc = eToLoc(e);
|
||||
var pos = locToPos(loc,true);
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('loc');
|
||||
//editor_mode.loc();
|
||||
//tip.whichShow = 1;
|
||||
//tip.whichShow(1);
|
||||
if(editor.isMobile)editor.showMidMenu(e.clientX,e.clientY);
|
||||
return;
|
||||
}
|
||||
@ -730,8 +730,8 @@ editor.prototype.listen = function () {
|
||||
}
|
||||
|
||||
eui.onmousemove = function (e) {
|
||||
if (!selectBox.isSelected) {
|
||||
//tip.whichShow = 1;
|
||||
if (!selectBox.isSelected()) {
|
||||
//tip.whichShow(1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -761,8 +761,8 @@ editor.prototype.listen = function () {
|
||||
}
|
||||
|
||||
eui.onmouseup = function (e) {
|
||||
if (!selectBox.isSelected) {
|
||||
//tip.whichShow = 1;
|
||||
if (!selectBox.isSelected()) {
|
||||
//tip.whichShow(1);
|
||||
return;
|
||||
}
|
||||
holdingPath = 0;
|
||||
@ -892,7 +892,7 @@ editor.prototype.listen = function () {
|
||||
if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1)
|
||||
e.preventDefault();
|
||||
//Ctrl+z 撤销上一步undo
|
||||
if (e.keyCode == 90 && e.ctrlKey && editor.preMapData && currDrawData.pos.length && selectBox.isSelected) {
|
||||
if (e.keyCode == 90 && e.ctrlKey && editor.preMapData && currDrawData.pos.length && selectBox.isSelected()) {
|
||||
editor.map = JSON.parse(JSON.stringify(editor.preMapData.map));
|
||||
editor.fgmap = JSON.parse(JSON.stringify(editor.preMapData.fgmap));
|
||||
editor.bgmap = JSON.parse(JSON.stringify(editor.preMapData.bgmap));
|
||||
@ -902,7 +902,7 @@ editor.prototype.listen = function () {
|
||||
editor.preMapData = null;
|
||||
}
|
||||
//Ctrl+y 重做一步redo
|
||||
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected) {
|
||||
if (e.keyCode == 89 && e.ctrlKey && reDo && reDo.pos.length && selectBox.isSelected()) {
|
||||
editor.preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
||||
for (var j = 0; j < reDo.pos.length; j++)
|
||||
editor.map[reDo.pos[j].y][reDo.pos[j].x] = JSON.parse(JSON.stringify(reDo.info));
|
||||
@ -1024,7 +1024,7 @@ editor.prototype.listen = function () {
|
||||
} else if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
|
||||
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 1;
|
||||
|
||||
selectBox.isSelected = true;
|
||||
selectBox.isSelected(true);
|
||||
// console.log(pos,core.material.images[pos.images].height)
|
||||
dataSelection.style.left = pos.x * 32 + 'px';
|
||||
dataSelection.style.top = pos.y * ysize + 'px';
|
||||
@ -1055,7 +1055,7 @@ editor.prototype.listen = function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
tip.infos = JSON.parse(JSON.stringify(editor.info));
|
||||
tip.infos(JSON.parse(JSON.stringify(editor.info)));
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('enemyitem');
|
||||
//editor_mode.enemyitem();
|
||||
@ -1127,12 +1127,12 @@ editor.prototype.listen = function () {
|
||||
chooseThis.onmousedown = function(e){
|
||||
editor.hideMidMenu();
|
||||
e.stopPropagation();
|
||||
selectBox.isSelected = false;
|
||||
selectBox.isSelected(false);
|
||||
|
||||
editor_mode.onmode('nextChange');
|
||||
editor_mode.onmode('loc');
|
||||
//editor_mode.loc();
|
||||
//tip.whichShow = 1;
|
||||
//tip.whichShow(1);
|
||||
if(editor.isMobile)editor.showdataarea(false);
|
||||
}
|
||||
|
||||
|
||||
@ -513,7 +513,7 @@ function omitedcheckUpdateFunction(event) {
|
||||
|
||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||
editor_blockly.show = function () {
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected(false);
|
||||
document.getElementById('left6').style = '';
|
||||
for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) {
|
||||
node.style.zIndex = 201;
|
||||
|
||||
@ -414,7 +414,7 @@ editor_mode = function (editor) {
|
||||
if (editor_mode[mode]) editor_mode[mode]();
|
||||
document.getElementById('editModeSelect').value = mode;
|
||||
var tips = tip_in_showMode;
|
||||
if (!selectBox.isSelected) printf('tips: ' + tips[~~(tips.length * Math.random())]);
|
||||
if (!selectBox.isSelected()) printf('tips: ' + tips[~~(tips.length * Math.random())]);
|
||||
}
|
||||
|
||||
editor_mode.prototype.loc = function (callback) {
|
||||
|
||||
@ -39,7 +39,7 @@ editor_multi = function () {
|
||||
editor_multi.lintAutocomplete = false;
|
||||
|
||||
editor_multi.show = function () {
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected(false);
|
||||
var valueNow = codeEditor.getValue();
|
||||
//try{eval('function _asdygakufyg_() { return '+valueNow+'\n}');editor_multi.lintAutocomplete=true;}catch(ee){}
|
||||
if (valueNow.slice(0, 8) === 'function') editor_multi.lintAutocomplete = true;
|
||||
|
||||
606
_server/vm.js
606
_server/vm.js
@ -1,226 +1,205 @@
|
||||
// vue 相关处理
|
||||
|
||||
var exportMap = new Vue({
|
||||
el: '#exportMap',
|
||||
data: {
|
||||
isExport: false,
|
||||
},
|
||||
methods: {
|
||||
exportMap: function () {
|
||||
editor.updateMap();
|
||||
var sx=editor.map.length-1,sy=editor.map[0].length-1;
|
||||
var exportMap = document.getElementById('exportMap')
|
||||
exportMap.isExport=false
|
||||
exportMap.onclick=function(){
|
||||
editor.updateMap();
|
||||
var sx=editor.map.length-1,sy=editor.map[0].length-1;
|
||||
|
||||
var filestr = '';
|
||||
for (var yy = 0; yy <= sy; yy++) {
|
||||
filestr += '['
|
||||
for (var xx = 0; xx <= sx; xx++) {
|
||||
var mapxy = editor.map[yy][xx];
|
||||
if (typeof(mapxy) == typeof({})) {
|
||||
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
||||
else {
|
||||
// mapxy='!!?';
|
||||
tip.whichShow = 3;
|
||||
return;
|
||||
}
|
||||
} else if (typeof(mapxy) == 'undefined') {
|
||||
tip.whichShow = 3;
|
||||
return;
|
||||
}
|
||||
mapxy = String(mapxy);
|
||||
mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy;
|
||||
filestr += mapxy + (xx == sx ? '' : ',')
|
||||
var filestr = '';
|
||||
for (var yy = 0; yy <= sy; yy++) {
|
||||
filestr += '['
|
||||
for (var xx = 0; xx <= sx; xx++) {
|
||||
var mapxy = editor.map[yy][xx];
|
||||
if (typeof(mapxy) == typeof({})) {
|
||||
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
||||
else {
|
||||
// mapxy='!!?';
|
||||
tip.whichShow(3);
|
||||
return;
|
||||
}
|
||||
|
||||
filestr += ']' + (yy == sy ? '' : ',\n');
|
||||
}
|
||||
pout.value = filestr;
|
||||
editArea.mapArr = filestr;
|
||||
this.isExport = true;
|
||||
editArea.error = 0;
|
||||
tip.whichShow = 2;
|
||||
}
|
||||
}
|
||||
})
|
||||
var editArea = new Vue({
|
||||
el: '#editArea',
|
||||
data: {
|
||||
mapArr: '',
|
||||
errors: [ // 编号1,2,3,4
|
||||
"格式错误!请使用正确格式(请使用地图生成器进行生成,且需要和本地图宽高完全一致)",
|
||||
"当前有未定义ID(在地图区域显示红块),请修改ID或者到icons.js和maps.js中进行定义!",
|
||||
"ID越界(在地图区域显示红块),当前编辑器暂时支持编号小于400,请修改编号!",
|
||||
// "发生错误!",
|
||||
],
|
||||
error: 0,
|
||||
formatTimer: null,
|
||||
},
|
||||
watch: {
|
||||
mapArr: function (val, oldval) {
|
||||
var that = this;
|
||||
if (val == '') return;
|
||||
if (exportMap.isExport) {
|
||||
exportMap.isExport = false;
|
||||
} else if (typeof(mapxy) == 'undefined') {
|
||||
tip.whichShow(3);
|
||||
return;
|
||||
}
|
||||
if (that.formatArr()) {
|
||||
that.error = 0;
|
||||
|
||||
setTimeout(function () {
|
||||
that.mapArr = that.formatArr();
|
||||
that.drawMap();
|
||||
tip.whichShow = 8
|
||||
}, 1000);
|
||||
that.formatTimer = setTimeout(function () {
|
||||
pout.value = that.formatArr();
|
||||
}, 5000); //5s后再格式化,不然光标跳到最后很烦
|
||||
} else {
|
||||
that.error = 1;
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
// console.log(editArea.mapArr);
|
||||
if (this.error>0)
|
||||
printe(this.errors[this.error-1])
|
||||
mapxy = String(mapxy);
|
||||
mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy;
|
||||
filestr += mapxy + (xx == sx ? '' : ',')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
drawMap: function () {
|
||||
var that = this;
|
||||
|
||||
// var mapArray = that.mapArr.split(/\D+/).join(' ').trim().split(' ');
|
||||
var mapArray = JSON.parse('[' + that.mapArr + ']');
|
||||
var sy=editor.map.length,sx=editor.map[0].length;
|
||||
for (var y = 0; y < sy; y++)
|
||||
for (var x = 0; x < sx; x++) {
|
||||
var num = mapArray[y][x];
|
||||
if (num == 0)
|
||||
editor.map[y][x] = 0;
|
||||
else if (typeof(editor.indexs[num][0]) == 'undefined') {
|
||||
that.error = 2;
|
||||
editor.map[y][x] = undefined;
|
||||
} else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
||||
}
|
||||
|
||||
editor.updateMap();
|
||||
|
||||
},
|
||||
formatArr: function () {
|
||||
var formatArrStr = '';
|
||||
var that = this;
|
||||
clearTimeout(that.formatTimer);
|
||||
var si=editor.map.length,sk=editor.map[0].length;
|
||||
if (this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != si*sk) return false;
|
||||
var arr = this.mapArr.replace(/\s+/g, '').split('],[');
|
||||
|
||||
if (arr.length != si) return;
|
||||
for (var i = 0; i < si; i++) {
|
||||
var a = [];
|
||||
formatArrStr += '[';
|
||||
if (i == 0 || i == si-1) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
else a = arr[i].split(/\D+/);
|
||||
if (a.length != sk) {
|
||||
formatArrStr = '';
|
||||
return;
|
||||
}
|
||||
|
||||
for (var k = 0; k < sk; k++) {
|
||||
var num = parseInt(a[k]);
|
||||
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == sk-1 ? '' : ',');
|
||||
}
|
||||
formatArrStr += ']' + (i == si-1 ? '' : ',\n');
|
||||
}
|
||||
return formatArrStr;
|
||||
}
|
||||
filestr += ']' + (yy == sy ? '' : ',\n');
|
||||
}
|
||||
});
|
||||
var copyMap = new Vue({
|
||||
el: '#copyMap',
|
||||
data: {
|
||||
err: ''
|
||||
},
|
||||
methods: {
|
||||
copyMap: function () {
|
||||
pout.value = filestr;
|
||||
mapEditArea.mapArr(filestr);
|
||||
exportMap.isExport = true;
|
||||
mapEditArea.error(0);
|
||||
tip.whichShow(2);
|
||||
}
|
||||
var mapEditArea = document.getElementById('mapEditArea')
|
||||
mapEditArea.errors=[ // 编号1,2
|
||||
"格式错误!请使用正确格式(请使用地图生成器进行生成,且需要和本地图宽高完全一致)",
|
||||
"当前有未定义ID(在地图区域显示红块),请修改ID或者到icons.js和maps.js中进行定义!"
|
||||
]
|
||||
mapEditArea.formatTimer=null
|
||||
mapEditArea._mapArr=''
|
||||
mapEditArea.mapArr=function(value){
|
||||
if(value!=null){
|
||||
var val=value
|
||||
var oldval=mapEditArea._mapArr
|
||||
if (val==oldval) return;
|
||||
|
||||
tip.whichShow = 0;
|
||||
if (pout.value.trim() != '') {
|
||||
if (editArea.error) {
|
||||
this.err = editArea.errors[editArea.error - 1];
|
||||
tip.whichShow = 5
|
||||
return;
|
||||
}
|
||||
try {
|
||||
pout.focus();
|
||||
pout.setSelectionRange(0, pout.value.length);
|
||||
document.execCommand("Copy");
|
||||
tip.whichShow = 6;
|
||||
} catch (e) {
|
||||
this.err = e;
|
||||
tip.whichShow = 5;
|
||||
}
|
||||
} else {
|
||||
tip.whichShow = 7;
|
||||
}
|
||||
if (exportMap.isExport) {
|
||||
exportMap.isExport = false;
|
||||
return;
|
||||
}
|
||||
},
|
||||
})
|
||||
var clearMap = new Vue({
|
||||
el: '#clearMap',
|
||||
if (mapEditArea.formatArr()) {
|
||||
mapEditArea.error(0);
|
||||
|
||||
methods: {
|
||||
clearMap: function () {
|
||||
editor.mapInit();
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
;printf('地图清除成功');
|
||||
});
|
||||
editor.updateMap();
|
||||
clearTimeout(editArea.formatTimer);
|
||||
clearTimeout(tip.timer);
|
||||
pout.value = '';
|
||||
editArea.mapArr = '';
|
||||
tip.whichShow = 4;
|
||||
editArea.error = 0;
|
||||
setTimeout(function () {
|
||||
if (mapEditArea.formatArr())mapEditArea.mapArr(mapEditArea.formatArr());
|
||||
mapEditArea.drawMap();
|
||||
tip.whichShow(8)
|
||||
}, 1000);
|
||||
clearTimeout(mapEditArea.formatTimer);
|
||||
mapEditArea.formatTimer = setTimeout(function () {
|
||||
pout.value = mapEditArea.formatArr();
|
||||
}, 5000); //5s后再格式化,不然光标跳到最后很烦
|
||||
} else {
|
||||
mapEditArea.error(1);
|
||||
}
|
||||
|
||||
mapEditArea._mapArr=value
|
||||
}
|
||||
})
|
||||
var deleteMap = new Vue({
|
||||
el: '#deleteMap',
|
||||
methods: {
|
||||
deleteMap: function () {
|
||||
editor_mode.onmode('');
|
||||
var index = core.floorIds.indexOf(editor.currentFloorId);
|
||||
if (index>=0) {
|
||||
core.floorIds.splice(index,1);
|
||||
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printe('删除成功,请F5刷新编辑器生效');
|
||||
});
|
||||
}
|
||||
else printe('删除成功,请F5刷新编辑器生效');
|
||||
return mapEditArea._mapArr
|
||||
}
|
||||
pout.oninput=function(){
|
||||
mapEditArea.mapArr(pout.value)
|
||||
}
|
||||
mapEditArea._error=0
|
||||
mapEditArea.error=function(value){
|
||||
if(value!=null){
|
||||
mapEditArea._error=value
|
||||
if (value>0)
|
||||
printe(mapEditArea.errors[value-1])
|
||||
}
|
||||
return mapEditArea._error
|
||||
}
|
||||
mapEditArea.drawMap= function () {
|
||||
// var mapArray = mapEditArea.mapArr().split(/\D+/).join(' ').trim().split(' ');
|
||||
var mapArray = JSON.parse('[' + mapEditArea.mapArr() + ']');
|
||||
var sy=editor.map.length,sx=editor.map[0].length;
|
||||
for (var y = 0; y < sy; y++)
|
||||
for (var x = 0; x < sx; x++) {
|
||||
var num = mapArray[y][x];
|
||||
if (num == 0)
|
||||
editor.map[y][x] = 0;
|
||||
else if (typeof(editor.indexs[num][0]) == 'undefined') {
|
||||
mapEditArea.error(2);
|
||||
editor.map[y][x] = undefined;
|
||||
} else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
||||
}
|
||||
|
||||
editor.updateMap();
|
||||
|
||||
}
|
||||
mapEditArea.formatArr= function () {
|
||||
var formatArrStr = '';
|
||||
console.log(1)
|
||||
|
||||
var si=editor.map.length,sk=editor.map[0].length;
|
||||
if (mapEditArea.mapArr().split(/\D+/).join(' ').trim().split(' ').length != si*sk) return false;
|
||||
var arr = mapEditArea.mapArr().replace(/\s+/g, '').split('],[');
|
||||
|
||||
if (arr.length != si) return;
|
||||
for (var i = 0; i < si; i++) {
|
||||
var a = [];
|
||||
formatArrStr += '[';
|
||||
if (i == 0 || i == si-1) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||
else a = arr[i].split(/\D+/);
|
||||
if (a.length != sk) {
|
||||
formatArrStr = '';
|
||||
return;
|
||||
}
|
||||
|
||||
for (var k = 0; k < sk; k++) {
|
||||
var num = parseInt(a[k]);
|
||||
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == sk-1 ? '' : ',');
|
||||
}
|
||||
formatArrStr += ']' + (i == si-1 ? '' : ',\n');
|
||||
}
|
||||
})
|
||||
printf = function (str_, type) {
|
||||
selectBox.isSelected = false;
|
||||
if (!type) {
|
||||
tip.whichShow = 11;
|
||||
return formatArrStr;
|
||||
}
|
||||
var copyMap=document.getElementById('copyMap')
|
||||
copyMap.err=''
|
||||
copyMap.onclick=function(){
|
||||
tip.whichShow(0);
|
||||
if (pout.value.trim() != '') {
|
||||
if (mapEditArea.error()) {
|
||||
copyMap.err = mapEditArea.errors[mapEditArea.error() - 1];
|
||||
tip.whichShow(5)
|
||||
return;
|
||||
}
|
||||
try {
|
||||
pout.focus();
|
||||
pout.setSelectionRange(0, pout.value.length);
|
||||
document.execCommand("Copy");
|
||||
tip.whichShow(6);
|
||||
} catch (e) {
|
||||
copyMap.err = e;
|
||||
tip.whichShow(5);
|
||||
}
|
||||
} else {
|
||||
tip.whichShow = 12;
|
||||
tip.whichShow(7);
|
||||
}
|
||||
}
|
||||
var clearMapButton=document.getElementById('clearMapButton')
|
||||
clearMapButton.onclick=function () {
|
||||
editor.mapInit();
|
||||
editor_mode.onmode('');
|
||||
editor.file.saveFloorFile(function (err) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw(err)
|
||||
}
|
||||
;printf('地图清除成功');
|
||||
});
|
||||
editor.updateMap();
|
||||
clearTimeout(mapEditArea.formatTimer);
|
||||
clearTimeout(tip.timer);
|
||||
pout.value = '';
|
||||
mapEditArea.mapArr('');
|
||||
tip.whichShow(4);
|
||||
mapEditArea.error(0);
|
||||
}
|
||||
var deleteMap=document.getElementById('deleteMap')
|
||||
deleteMap.onclick=function () {
|
||||
editor_mode.onmode('');
|
||||
var index = core.floorIds.indexOf(editor.currentFloorId);
|
||||
if (index>=0) {
|
||||
core.floorIds.splice(index,1);
|
||||
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {//console.log(objs_);
|
||||
if (objs_.slice(-1)[0] != null) {
|
||||
printe(objs_.slice(-1)[0]);
|
||||
throw(objs_.slice(-1)[0])
|
||||
}
|
||||
;printe('删除成功,请F5刷新编辑器生效');
|
||||
});
|
||||
}
|
||||
else printe('删除成功,请F5刷新编辑器生效');
|
||||
}
|
||||
printf = function (str_, type) {
|
||||
selectBox.isSelected(false);
|
||||
if (!type) {
|
||||
tip.whichShow(11);
|
||||
} else {
|
||||
tip.whichShow(12);
|
||||
}
|
||||
setTimeout(function () {
|
||||
if (!type) {
|
||||
tip.msgs[11] = String(str_);
|
||||
tip.whichShow = 12;
|
||||
tip.whichShow(12);
|
||||
} else {
|
||||
tip.msgs[10] = String(str_);
|
||||
tip.whichShow = 11;
|
||||
tip.whichShow(11);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
@ -233,87 +212,158 @@ tip_in_showMode = [
|
||||
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
|
||||
"画出的地图要点击\"保存地图\"才会写入到文件中",
|
||||
];
|
||||
var tip = new Vue({
|
||||
el: '#tip',
|
||||
data: {
|
||||
infos: {},
|
||||
hasId: true,
|
||||
isAutotile: false,
|
||||
isSelectedBlock: false,
|
||||
isClearBlock: false,
|
||||
isAirwall: false,
|
||||
geneMapSuccess: false,
|
||||
timer: null,
|
||||
msgs: [ //分别编号1,2,3,4,5,6,7,8,9,10;奇数警告,偶数成功
|
||||
"当前未选择任何图块,请先在右边选择要画的图块!",
|
||||
"生成地图成功!可点击复制按钮复制地图数组到剪切板",
|
||||
"生成失败! 地图中有未定义的图块,建议先用其他有效图块覆盖或点击清除地图!",
|
||||
"地图清除成功!",
|
||||
"复制失败!",
|
||||
"复制成功!可直接粘贴到楼层文件的地图数组中。",
|
||||
"复制失败!当前还没有数据",
|
||||
"修改成功!可点击复制按钮复制地图数组到剪切板",
|
||||
"选择背景图片失败!文件名格式错误或图片不存在!",
|
||||
"更新背景图片成功!",
|
||||
"11:警告",
|
||||
"12:成功"
|
||||
],
|
||||
mapMsg: '',
|
||||
whichShow: 0,
|
||||
},
|
||||
watch: {
|
||||
infos: {
|
||||
handler: function (val, oldval) {
|
||||
this.isClearBlock = false;
|
||||
this.isAirwall = false;
|
||||
if (typeof(val) != 'undefined') {
|
||||
if (val == 0) {
|
||||
this.isClearBlock = true;
|
||||
return;
|
||||
}
|
||||
if ('id' in val) {
|
||||
if (val.idnum == 17) {
|
||||
this.isAirwall = true;
|
||||
return;
|
||||
}
|
||||
this.hasId = true;
|
||||
} else {
|
||||
this.hasId = false;
|
||||
}
|
||||
this.isAutotile = false;
|
||||
if (val.images == "autotile" && this.hasId) this.isAutotile = true;
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
var tip=document.getElementById('tip')
|
||||
tip._infos= {}
|
||||
tip.infos=function(value){
|
||||
if(value!=null){
|
||||
var val=value
|
||||
var oldval=tip._infos
|
||||
|
||||
whichShow: function () {
|
||||
var that = this;
|
||||
that.mapMsg = '';
|
||||
that.msgs[4] = "复制失败!" + editTip.err;
|
||||
clearTimeout(that.timer);
|
||||
if (that.whichShow) {
|
||||
that.mapMsg = that.msgs[that.whichShow - 1];
|
||||
that.timer = setTimeout(function () {
|
||||
if (!(that.whichShow % 2))
|
||||
that.whichShow = 0;
|
||||
}, 5000); //5秒后自动清除success,warn不清除
|
||||
tip.isClearBlock(false);
|
||||
tip.isAirwall(false);
|
||||
if (typeof(val) != 'undefined') {
|
||||
if (val == 0) {
|
||||
tip.isClearBlock(true);
|
||||
return;
|
||||
}
|
||||
if ('id' in val) {
|
||||
if (val.idnum == 17) {
|
||||
tip.isAirwall(true);
|
||||
return;
|
||||
}
|
||||
tip.hasId = true;
|
||||
} else {
|
||||
tip.hasId = false;
|
||||
}
|
||||
tip.isAutotile = false;
|
||||
if (val.images == "autotile" && tip.hasId) tip.isAutotile = true;
|
||||
document.getElementById('isAirwall-else').innerHTML=(tip.hasId?`<p>图块编号:<span class="infoText">${ value['idnum'] }</span></p>
|
||||
<p>图块ID:<span class="infoText">${ value['id'] }</span></p>`:`
|
||||
<p class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>`)+`
|
||||
<p>图块所在素材:<span class="infoText">${ value['images'] + (tip.isAutotile ? '( '+infos['id']+' )' : '') }</span>
|
||||
</p>
|
||||
<p>图块索引:<span class="infoText">${ value['y'] }</span></p>`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var selectBox = new Vue({
|
||||
el: '#selectBox',
|
||||
data: {
|
||||
isSelected: false
|
||||
},
|
||||
watch: {
|
||||
isSelected: function () {
|
||||
tip.isSelectedBlock = this.isSelected;
|
||||
tip.whichShow = 0;
|
||||
clearTimeout(tip.timer);
|
||||
tip._infos=value
|
||||
}
|
||||
return tip._infos
|
||||
}
|
||||
tip.hasId= true
|
||||
tip.isAutotile= false
|
||||
tip._isSelectedBlock= false
|
||||
tip.isSelectedBlock=function(value){
|
||||
if(value!=null){
|
||||
var dshow=document.getElementById('isSelectedBlock-if')
|
||||
var dhide=document.getElementById('isSelectedBlock-else')
|
||||
if(!value){
|
||||
var dtemp=dshow
|
||||
dshow=dhide
|
||||
dhide=dtemp
|
||||
}
|
||||
dshow.style.display=''
|
||||
dhide.style.display='none'
|
||||
tip._isSelectedBlock=value
|
||||
}
|
||||
})
|
||||
return tip._isSelectedBlock
|
||||
}
|
||||
tip._isClearBlock= false
|
||||
tip.isClearBlock=function(value){
|
||||
if(value!=null){
|
||||
var dshow=document.getElementById('isClearBlock-if')
|
||||
var dhide=document.getElementById('isClearBlock-else')
|
||||
if(!value){
|
||||
var dtemp=dshow
|
||||
dshow=dhide
|
||||
dhide=dtemp
|
||||
}
|
||||
dshow.style.display=''
|
||||
dhide.style.display='none'
|
||||
tip._isClearBlock=value
|
||||
}
|
||||
return tip._isClearBlock
|
||||
}
|
||||
tip._isAirwall= false
|
||||
tip.isAirwall=function(value){
|
||||
if(value!=null){
|
||||
var dshow=document.getElementById('isAirwall-if')
|
||||
var dhide=document.getElementById('isAirwall-else')
|
||||
if(!value){
|
||||
var dtemp=dshow
|
||||
dshow=dhide
|
||||
dhide=dtemp
|
||||
}
|
||||
dshow.style.display=''
|
||||
dhide.style.display='none'
|
||||
tip._isAirwall=value
|
||||
}
|
||||
return tip._isAirwall
|
||||
}
|
||||
tip.geneMapSuccess= false
|
||||
tip.timer= null
|
||||
tip.msgs= [ //分别编号1,2,3,4,5,6,7,8,9,10;奇数警告,偶数成功
|
||||
"当前未选择任何图块,请先在右边选择要画的图块!",
|
||||
"生成地图成功!可点击复制按钮复制地图数组到剪切板",
|
||||
"生成失败! 地图中有未定义的图块,建议先用其他有效图块覆盖或点击清除地图!",
|
||||
"地图清除成功!",
|
||||
"复制失败!",
|
||||
"复制成功!可直接粘贴到楼层文件的地图数组中。",
|
||||
"复制失败!当前还没有数据",
|
||||
"修改成功!可点击复制按钮复制地图数组到剪切板",
|
||||
"选择背景图片失败!文件名格式错误或图片不存在!",
|
||||
"更新背景图片成功!",
|
||||
"11:警告",
|
||||
"12:成功"
|
||||
]
|
||||
tip._mapMsg= ''
|
||||
tip.mapMsg=function(value){
|
||||
if(value!=null){
|
||||
document.getElementById('whichShow-if').innerText=value
|
||||
tip._mapMsg=value
|
||||
}
|
||||
return tip._mapMsg
|
||||
}
|
||||
tip._whichShow= 0
|
||||
tip.whichShow=function(value){
|
||||
if(value!=null){
|
||||
|
||||
var dshow=document.getElementById('whichShow-if')
|
||||
var dhide=null
|
||||
if(!value){
|
||||
var dtemp=dshow
|
||||
dshow=dhide
|
||||
dhide=dtemp
|
||||
}
|
||||
if(dshow)dshow.style.display=''
|
||||
if(dhide)dhide.style.display='none'
|
||||
|
||||
if(dshow)dshow.setAttribute('class',(value%2) ? 'warnText' : 'successText')
|
||||
|
||||
tip.mapMsg('');
|
||||
tip.msgs[4] = "复制失败!" + editTip.err;
|
||||
clearTimeout(tip.timer);
|
||||
if (value) {
|
||||
tip.mapMsg(tip.msgs[value - 1]);
|
||||
tip.timer = setTimeout(function () {
|
||||
if (!(value % 2))
|
||||
value = 0;
|
||||
}, 5000); //5秒后自动清除success,warn不清除
|
||||
}
|
||||
tip._whichShow=value
|
||||
}
|
||||
return tip._whichShow
|
||||
}
|
||||
var selectBox=document.getElementById('selectBox')
|
||||
var dataSelection=document.getElementById('dataSelection')
|
||||
selectBox._isSelected=false
|
||||
selectBox.isSelected=function(value){
|
||||
if(value!=null){
|
||||
selectBox._isSelected=value;
|
||||
tip.isSelectedBlock(value);
|
||||
tip.whichShow(0);
|
||||
clearTimeout(tip.timer);
|
||||
dataSelection.style.display=value?'':'none'
|
||||
}
|
||||
return selectBox._isSelected
|
||||
}
|
||||
|
||||
|
||||
@ -18,9 +18,8 @@
|
||||
<div id="arrEditor">
|
||||
<table class="col" id='arrColMark'></table>
|
||||
<table class="row" id='arrRowMark'></table>
|
||||
<div id="editArea" v-cloak>
|
||||
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
||||
<!-- <p class="warnText" v-if="error">{{ errors[error-1] }}</p> -->
|
||||
<div id="mapEditArea">
|
||||
<textarea cols="10" rows="10" id="pout"></textarea>
|
||||
</div>
|
||||
<div id="editTip">
|
||||
<input id='newFileName' placeholder="新楼层id" style="width: 100px"/>
|
||||
@ -34,10 +33,10 @@
|
||||
<input type="button" value="新建空白地图" id='newMap'/>
|
||||
</div>
|
||||
<div id='editBtns'>
|
||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||
<input type="button" value="导出地图" id="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMapButton'/>
|
||||
<input type="button" value="删除地图" id="deleteMap"/>
|
||||
</div>
|
||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||
<div id='newFloors' style='display:none'>
|
||||
@ -294,28 +293,23 @@
|
||||
<div id="iconLib">
|
||||
<div id="iconImages"></div>
|
||||
<div id="selectBox">
|
||||
<div id='dataSelection' v-show="isSelected" v-cloak></div>
|
||||
<div id='dataSelection' style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="down">
|
||||
<div style="margin:0.5rem">
|
||||
<div class="tools">
|
||||
<div id="tip" v-cloak>
|
||||
<div v-if="isSelectedBlock">
|
||||
<p v-if="isClearBlock" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||
<p v-if="isAirwall" class="infoText">当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图</p>
|
||||
<div v-else>
|
||||
<p v-if="hasId">图块编号:<span class="infoText">{{ infos['idnum'] }}</span></p>
|
||||
<p v-if="hasId">图块ID:<span class="infoText">{{ infos['id'] }}</span></p>
|
||||
<p v-else class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>
|
||||
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span>
|
||||
</p>
|
||||
<p>图块索引:<span class="infoText">{{ infos['y'] }}</span></p>
|
||||
</div>
|
||||
<div id="tip">
|
||||
<div id="isSelectedBlock-if" style="display:none">
|
||||
<p id="isClearBlock-if" style="display:none" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||
<div id="isClearBlock-else"><p id="isAirwall-if" style="display:none" class="infoText">当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图</p>
|
||||
<div id="isAirwall-else">
|
||||
|
||||
</div></div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p v-if="whichShow" v-bind:class="[ (whichShow%2) ? 'warnText' : 'successText']">{{ mapMsg }}</p>
|
||||
<div id="isSelectedBlock-else">
|
||||
<p id="whichShow-if" style="display:none"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -540,8 +534,8 @@ if (location.protocol.indexOf("http")!=0) {
|
||||
<script>
|
||||
//所有全局量
|
||||
__all__ = ['Vue', 'fs', 'editor_file', 'editor_mode', 'main', 'core', 'hasOwnProp', 'printf', 'printe', 'editor', 'converter', 'ActionParser', 'MotaActionFunctions', 'MotaActionBlocks'];
|
||||
__id__ = ['editArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||
__Vue__ = ['editArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||
__id__ = ['mapEditArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||
__Vue__ = ['mapEditArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||
//var event = document.getElementById('event');
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
42
editor.html
42
editor.html
@ -17,9 +17,8 @@
|
||||
<div id="arrEditor">
|
||||
<table class="col" id='arrColMark'></table>
|
||||
<table class="row" id='arrRowMark'></table>
|
||||
<div id="editArea" v-cloak>
|
||||
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
||||
<!-- <p class="warnText" v-if="error">{{ errors[error-1] }}</p> -->
|
||||
<div id="mapEditArea">
|
||||
<textarea cols="10" rows="10" id="pout"></textarea>
|
||||
</div>
|
||||
<div id="editTip">
|
||||
<input type="button" value="新建空白地图" id='newMap'/>
|
||||
@ -32,10 +31,10 @@
|
||||
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
||||
</div>
|
||||
<div id="editBtns">
|
||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||
<input type="button" value="导出地图" id="exportMap"/>
|
||||
<input type="button" value="复制地图" id="copyMap"/>
|
||||
<input type="button" value="清除地图" id='clearMapButton'/>
|
||||
<input type="button" value="删除地图" id="deleteMap"/>
|
||||
</div>
|
||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||
<div id='newFloors' style='display:none'>
|
||||
@ -285,21 +284,16 @@
|
||||
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<div id="tip" v-cloak>
|
||||
<div v-if="isSelectedBlock">
|
||||
<p v-if="isClearBlock" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||
<p v-else-if="isAirwall" class="infoText">当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图</p>
|
||||
<div v-else>
|
||||
<p v-if="hasId">图块编号:<span class="infoText">{{ infos['idnum'] }}</span></p>
|
||||
<p v-if="hasId">图块ID:<span class="infoText">{{ infos['id'] }}</span></p>
|
||||
<p v-else class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>
|
||||
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span>
|
||||
</p>
|
||||
<p>图块索引:<span class="infoText">{{ infos['y'] }}</span></p>
|
||||
</div>
|
||||
<div id="tip">
|
||||
<div id="isSelectedBlock-if" style="display:none">
|
||||
<p id="isClearBlock-if" style="display:none" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||
<div id="isClearBlock-else"><p id="isAirwall-if" style="display:none" class="infoText">当前选择为空气墙, 在编辑器中可视, 在游戏中隐藏的墙, 用来配合前景/背景的贴图</p>
|
||||
<div id="isAirwall-else">
|
||||
|
||||
</div></div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p v-if="whichShow" v-bind:class="[ (whichShow%2) ? 'warnText' : 'successText']">{{ mapMsg }}</p>
|
||||
<div id="isSelectedBlock-else">
|
||||
<p id="whichShow-if" style="display:none"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -343,7 +337,7 @@
|
||||
<div id="iconLib">
|
||||
<div id="iconImages"></div>
|
||||
<div id="selectBox">
|
||||
<div id='dataSelection' v-show="isSelected" v-cloak></div>
|
||||
<div id='dataSelection' style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -523,8 +517,8 @@ if (location.protocol.indexOf("http")!=0) {
|
||||
<script>
|
||||
//所有全局量
|
||||
__all__ = ['Vue', 'fs', 'editor_file', 'editor_mode', 'main', 'core', 'hasOwnProp', 'printf', 'printe', 'editor', 'converter', 'ActionParser', 'MotaActionFunctions', 'MotaActionBlocks'];
|
||||
__id__ = ['editArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||
__Vue__ = ['editArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||
__id__ = ['mapEditArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||
__Vue__ = ['mapEditArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||
//var event = document.getElementById('event');
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user