step1:buttons
This commit is contained in:
parent
69e4215e03
commit
4fa318a6b4
189
_server/vm.js
189
_server/vm.js
@ -1,46 +1,39 @@
|
|||||||
// vue 相关处理
|
|
||||||
|
|
||||||
var exportMap = new Vue({
|
var exportMap = document.getElementById('exportMap')
|
||||||
el: '#exportMap',
|
exportMap.isExport=false
|
||||||
data: {
|
exportMap.onclick=function(){
|
||||||
isExport: false,
|
editor.updateMap();
|
||||||
},
|
var sx=editor.map.length-1,sy=editor.map[0].length-1;
|
||||||
methods: {
|
|
||||||
exportMap: function () {
|
|
||||||
editor.updateMap();
|
|
||||||
var sx=editor.map.length-1,sy=editor.map[0].length-1;
|
|
||||||
|
|
||||||
var filestr = '';
|
var filestr = '';
|
||||||
for (var yy = 0; yy <= sy; yy++) {
|
for (var yy = 0; yy <= sy; yy++) {
|
||||||
filestr += '['
|
filestr += '['
|
||||||
for (var xx = 0; xx <= sx; xx++) {
|
for (var xx = 0; xx <= sx; xx++) {
|
||||||
var mapxy = editor.map[yy][xx];
|
var mapxy = editor.map[yy][xx];
|
||||||
if (typeof(mapxy) == typeof({})) {
|
if (typeof(mapxy) == typeof({})) {
|
||||||
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
||||||
else {
|
else {
|
||||||
// mapxy='!!?';
|
// mapxy='!!?';
|
||||||
tip.whichShow = 3;
|
tip.whichShow = 3;
|
||||||
return;
|
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 ? '' : ',')
|
|
||||||
}
|
}
|
||||||
|
} else if (typeof(mapxy) == 'undefined') {
|
||||||
filestr += ']' + (yy == sy ? '' : ',\n');
|
tip.whichShow = 3;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
pout.value = filestr;
|
mapxy = String(mapxy);
|
||||||
editArea.mapArr = filestr;
|
mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy;
|
||||||
this.isExport = true;
|
filestr += mapxy + (xx == sx ? '' : ',')
|
||||||
editArea.error = 0;
|
|
||||||
tip.whichShow = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filestr += ']' + (yy == sy ? '' : ',\n');
|
||||||
}
|
}
|
||||||
})
|
pout.value = filestr;
|
||||||
|
editArea.mapArr = filestr;
|
||||||
|
exportMap.isExport = true;
|
||||||
|
editArea.error = 0;
|
||||||
|
tip.whichShow = 2;
|
||||||
|
}
|
||||||
var editArea = new Vue({
|
var editArea = new Vue({
|
||||||
el: '#editArea',
|
el: '#editArea',
|
||||||
data: {
|
data: {
|
||||||
@ -133,80 +126,64 @@ var editArea = new Vue({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var copyMap = new Vue({
|
var copyMap=document.getElementById('copyMap')
|
||||||
el: '#copyMap',
|
copyMap.err=''
|
||||||
data: {
|
copyMap.onclick=function(){
|
||||||
err: ''
|
tip.whichShow = 0;
|
||||||
},
|
if (pout.value.trim() != '') {
|
||||||
methods: {
|
if (editArea.error) {
|
||||||
copyMap: function () {
|
copyMap.err = editArea.errors[editArea.error - 1];
|
||||||
|
tip.whichShow = 5
|
||||||
tip.whichShow = 0;
|
return;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
try {
|
||||||
})
|
pout.focus();
|
||||||
var clearMap = new Vue({
|
pout.setSelectionRange(0, pout.value.length);
|
||||||
el: '#clearMap',
|
document.execCommand("Copy");
|
||||||
|
tip.whichShow = 6;
|
||||||
methods: {
|
} catch (e) {
|
||||||
clearMap: function () {
|
copyMap.err = e;
|
||||||
editor.mapInit();
|
tip.whichShow = 5;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tip.whichShow = 7;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
var deleteMap = new Vue({
|
var clearMapButton=document.getElementById('clearMapButton')
|
||||||
el: '#deleteMap',
|
clearMapButton.onclick=function () {
|
||||||
methods: {
|
editor.mapInit();
|
||||||
deleteMap: function () {
|
editor_mode.onmode('');
|
||||||
editor_mode.onmode('');
|
editor.file.saveFloorFile(function (err) {
|
||||||
var index = core.floorIds.indexOf(editor.currentFloorId);
|
if (err) {
|
||||||
if (index>=0) {
|
printe(err);
|
||||||
core.floorIds.splice(index,1);
|
throw(err)
|
||||||
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('地图清除成功');
|
||||||
|
});
|
||||||
|
editor.updateMap();
|
||||||
|
clearTimeout(editArea.formatTimer);
|
||||||
|
clearTimeout(tip.timer);
|
||||||
|
pout.value = '';
|
||||||
|
editArea.mapArr = '';
|
||||||
|
tip.whichShow = 4;
|
||||||
|
editArea.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) {
|
printf = function (str_, type) {
|
||||||
selectBox.isSelected = false;
|
selectBox.isSelected = false;
|
||||||
if (!type) {
|
if (!type) {
|
||||||
|
|||||||
@ -34,10 +34,10 @@
|
|||||||
<input type="button" value="新建空白地图" id='newMap'/>
|
<input type="button" value="新建空白地图" id='newMap'/>
|
||||||
</div>
|
</div>
|
||||||
<div id='editBtns'>
|
<div id='editBtns'>
|
||||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
<input type="button" value="导出地图" id="exportMap"/>
|
||||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
<input type="button" value="复制地图" id="copyMap"/>
|
||||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
<input type="button" value="清除地图" id='clearMapButton'/>
|
||||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
<input type="button" value="删除地图" id="deleteMap"/>
|
||||||
</div>
|
</div>
|
||||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||||
<div id='newFloors' style='display:none'>
|
<div id='newFloors' style='display:none'>
|
||||||
|
|||||||
@ -32,10 +32,10 @@
|
|||||||
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
<span style='vertical-align: bottom; margin-left: -4px'>保留楼层属性</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="editBtns">
|
<div id="editBtns">
|
||||||
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
<input type="button" value="导出地图" id="exportMap"/>
|
||||||
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
<input type="button" value="复制地图" id="copyMap"/>
|
||||||
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
<input type="button" value="清除地图" id='clearMapButton'/>
|
||||||
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
<input type="button" value="删除地图" id="deleteMap"/>
|
||||||
</div>
|
</div>
|
||||||
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
<input type="button" value="批量创建空白地图 ↓" id='newMaps'/>
|
||||||
<div id='newFloors' style='display:none'>
|
<div id='newFloors' style='display:none'>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user