Merge pull request #64 from zhaouv/v2.0-editor-20180304

调整 editor.file & editor.mode
This commit is contained in:
Zhang Chen 2018-03-04 12:54:07 +08:00 committed by GitHub
commit fcc71dcf7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 94 additions and 80 deletions

View File

@ -59,38 +59,38 @@ editor.file.saveFloorFileAs
``` ```
5个编辑模式有关的查询 5个编辑模式有关的查询
```javascript ```javascript
editor.file.editItem(editor,'redJewel',[],function(a){console.log(a)}); editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor.file.editEnemy(editor,'redBat',[],function(a){console.log(a)}); editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor.file.editLoc(editor,2,0,[],function(a){console.log(a)}); editor.file.editLoc(2,0,[],function(a){console.log(a)});
editor.file.editFloor(editor,[],function(a){console.log(a)}); editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower(editor,[],function(a){console.log(a)}); editor.file.editTower([],function(a){console.log(a)});
``` ```
5个编辑模式有关的编辑 5个编辑模式有关的编辑
```javascript ```javascript
editor.info={images: "terrains", y: 9}; editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)}); editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor.file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor.file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)}); editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor.file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor.file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)}); editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
``` ```
### editor_mode.js ### editor_mode.js
4个生成表格并绑定事件的函数 4个生成表格并绑定事件的函数
```javascript ```javascript
editor_mode.loc(); editor.mode.loc();
editor_mode.emenyitem(); editor.mode.emenyitem();
editor_mode.floor(); editor.mode.floor();
editor_mode.tower(); editor.mode.tower();
``` ```
切换模式 切换模式
```javascript ```javascript
editor_mode.onmode(''); editor.mode.onmode('');
editor_mode.onmode('loc'); editor.mode.onmode('loc');
editor_mode.onmode('emenyitem'); editor.mode.onmode('emenyitem');
editor_mode.onmode('floor'); editor.mode.onmode('floor');
editor_mode.onmode('tower'); editor.mode.onmode('tower');
``` ```
在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动 在切换模式时,改动才会保存到文件,并且需要刷新页面使得`editor`能看到改动

View File

@ -24,7 +24,10 @@ editor.prototype.init = function(callback){
editor.main=main; editor.main=main;
editor.core=core; editor.core=core;
editor.fs=fs; editor.fs=fs;
editor_file = editor_file(editor);
editor.file=editor_file; editor.file=editor_file;
editor_mode = editor_mode(editor);
editor.mode=editor_mode;
editor.material.images=core.material.images; editor.material.images=core.material.images;
editor.listen(); // 开始监听事件 editor.listen(); // 开始监听事件
var hard = 'Hard'; var hard = 'Hard';
@ -308,6 +311,13 @@ editor.prototype.changeFloor = function(floorId,callback) {
}); });
} }
editor.prototype.guid = function() {
return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
editor.prototype.listen = function() { editor.prototype.listen = function() {
var uc = eui.getContext('2d'); var uc = eui.getContext('2d');

View File

@ -1,6 +1,6 @@
(function(){ editor_file = function(editor){
editor_file = {}; var editor_file = {};
(function(){ (function(){
var script = document.createElement('script'); var script = document.createElement('script');
@ -28,7 +28,7 @@
})(); })();
editor_file.getFloorFileList = function(editor,callback){ editor_file.getFloorFileList = function(callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* var fs = editor.fs; /* var fs = editor.fs;
fs.readdir('project/floors',function(err, data){ fs.readdir('project/floors',function(err, data){
@ -37,7 +37,7 @@
callback([editor.core.floorIds,null]); callback([editor.core.floorIds,null]);
} }
//callback([Array<String>,err:String]) //callback([Array<String>,err:String])
editor_file.loadFloorFile = function(editor,filename,callback){ editor_file.loadFloorFile = function(filename,callback){
//filename不含'/'不含'.js' //filename不含'/'不含'.js'
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* var fs = editor.fs; /* var fs = editor.fs;
@ -63,7 +63,7 @@
editor.currentFloorData = editor.core.floors[editor.currentFloorId]; editor.currentFloorData = editor.core.floors[editor.currentFloorId];
} }
//callback(err:String) //callback(err:String)
editor_file.saveFloorFile = function(editor,callback){ editor_file.saveFloorFile = function(callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) { /* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
callback('未选中文件或无数据'); callback('未选中文件或无数据');
@ -85,7 +85,7 @@
}); });
} }
//callback(err:String) //callback(err:String)
editor_file.saveFloorFileAs = function(editor,saveAsFilename,callback){ editor_file.saveFloorFileAs = function(saveAsFilename,callback){
//saveAsFilename不含'/'不含'.js' //saveAsFilename不含'/'不含'.js'
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
if (!isset(editor.currentFloorData)) { if (!isset(editor.currentFloorData)) {
@ -95,13 +95,13 @@
editor.currentFloorData=JSON.parse(JSON.stringify(editor.currentFloorData)); editor.currentFloorData=JSON.parse(JSON.stringify(editor.currentFloorData));
editor.currentFloorData.floorId=saveAsFilename; editor.currentFloorData.floorId=saveAsFilename;
editor.currentFloorId=saveAsFilename; editor.currentFloorId=saveAsFilename;
editor_file.saveFloorFile(editor,callback); editor_file.saveFloorFile(callback);
} }
//callback(err:String) //callback(err:String)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
editor_file.changeIdAndIdnum = function(editor,id,idnum,info,callback){ editor_file.changeIdAndIdnum = function(id,idnum,info,callback){
if (!isset(callback)) {printe('未设置callback');throw('未设置callback')}; if (!isset(callback)) {printe('未设置callback');throw('未设置callback')};
//检查maps中是否有重复的idnum或id //检查maps中是否有重复的idnum或id
var change = -1; var change = -1;
@ -159,7 +159,7 @@
callback(null); callback(null);
} }
//callback(err:String) //callback(err:String)
editor_file.editItem = function(editor,id,actionList,callback){ editor_file.editItem = function(id,actionList,callback){
/*actionList:[ /*actionList:[
["change","['items']['name']","红宝石的新名字"], ["change","['items']['name']","红宝石的新名字"],
["add","['items']['新的和name同级的属性']",123], ["add","['items']['新的和name同级的属性']",123],
@ -208,7 +208,7 @@
//只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items //只有items.cls是items的才有itemEffect和itemEffectTip,keys和constants和tools只有items
} }
//callback([obj,commentObj,err:String]) //callback([obj,commentObj,err:String])
editor_file.editEnemy = function(editor,id,actionList,callback){ editor_file.editEnemy = function(id,actionList,callback){
/*actionList:[ /*actionList:[
["change","['name']","初级巫师的新名字"], ["change","['name']","初级巫师的新名字"],
["add","['新的和name同级的属性']",123], ["add","['新的和name同级的属性']",123],
@ -256,7 +256,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
editor_file.editLoc = function(editor,x,y,actionList,callback){ editor_file.editLoc = function(x,y,actionList,callback){
/*actionList:[ /*actionList:[
["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值可参见样板中初级巫师的写法。"]], ["change","['events']",["\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值可参见样板中初级巫师的写法。"]],
["change","['afterBattle']",null], ["change","['afterBattle']",null],
@ -304,7 +304,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
editor_file.editFloor = function(editor,actionList,callback){ editor_file.editFloor = function(actionList,callback){
/*actionList:[ /*actionList:[
["change","['title']",'样板 3 层'], ["change","['title']",'样板 3 层'],
["change","['color']",null], ["change","['color']",null],
@ -348,7 +348,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
editor_file.editTower = function(editor,actionList,callback){ editor_file.editTower = function(actionList,callback){
/*actionList:[ /*actionList:[
["change","['firstData']['version']",'Ver 1.0.1 (Beta)'], ["change","['firstData']['version']",'Ver 1.0.1 (Beta)'],
["change","['values']['lavaDamage']",200], ["change","['values']['lavaDamage']",200],
@ -489,7 +489,7 @@
if (value[0]!='change')return; if (value[0]!='change')return;
eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2])); eval("editor.currentFloorData"+value[1]+'='+JSON.stringify(value[2]));
}); });
editor_file.saveFloorFile(editor,callback); editor_file.saveFloorFile(callback);
return; return;
} }
callback('出错了,要设置的文件名不识别'); callback('出错了,要设置的文件名不识别');
@ -523,5 +523,6 @@
// ] // ]
*/ */
return editor_file;
})(); }
//editor_file = editor_file(editor);

View File

@ -11,31 +11,32 @@
pout.innerHTML='waiting\nwaiting waiting'; pout.innerHTML='waiting\nwaiting waiting';
var editor={}; var editor={};
editor.fs=fs; editor.fs=fs;
editor_file = editor_file(editor);
editor.file=editor_file; editor.file=editor_file;
//代码复制到 http://127.0.0.1:1055/drawMapGUI.html 的console中进行测试 //代码复制到 http://127.0.0.1:1055/drawMapGUI.html 的console中进行测试
/* editor.file.loadFloorFile(editor,'sample0',function(err){console.log(err); /* editor.file.loadFloorFile('sample0',function(err){console.log(err);
editor.file.saveFloorFileAs(editor,'aaa',function(err){console.log(err)}); editor.file.saveFloorFileAs('aaa',function(err){console.log(err)});
}); */ }); */
//查询 //查询
/* /*
editor_file.editItem(editor,'redJewel',[],function(a){console.log(a)}); editor.file.editItem('redJewel',[],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[],function(a){console.log(a)}); editor.file.editEnemy('redBat',[],function(a){console.log(a)});
editor_file.editLoc(editor,2,6,[],function(a){console.log(a)}); editor.file.editLoc(2,6,[],function(a){console.log(a)});
editor_file.editFloor(editor,[],function(a){console.log(a)}); editor.file.editFloor([],function(a){console.log(a)});
editor.file.editTower(editor,[],function(a){console.log(a)}); editor.file.editTower([],function(a){console.log(a)});
*/ */
//编辑 //编辑
/* /*
editor.info={images: "terrains", y: 9}; editor.info={images: "terrains", y: 9};
editor.file.changeIdAndIdnum(editor,'yellowWall2',16,editor.info,function(a){console.log(a)}); editor.file.changeIdAndIdnum('yellowWall2',16,editor.info,function(a){console.log(a)});
editor_file.editItem(editor,'book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)}); editor.file.editItem('book',[["change","['items']['name']","怪物手册的新名字"]],function(a){console.log(a)});
editor_file.editEnemy(editor,'redBat',[['change',"['atk']",20]],function(a){console.log(a)}); editor.file.editEnemy('redBat',[['change',"['atk']",20]],function(a){console.log(a)});
editor_file.editLoc(editor,2,6,[["change","['afterBattle']",null]],function(a){console.log(a)}); editor.file.editLoc(2,6,[["change","['afterBattle']",null]],function(a){console.log(a)});
editor_file.editFloor(editor,[["change","['title']",'样板 33 层']],function(a){console.log(a)}); editor.file.editFloor([["change","['title']",'样板 33 层']],function(a){console.log(a)});
editor.file.editTower(editor,[["change","['values']['lavaDamage']",200]],function(a){console.log(a)}); editor.file.editTower([["change","['values']['lavaDamage']",200]],function(a){console.log(a)});
*/ */
pout.innerHTML='succeed\nsucceed succeed'; pout.innerHTML='succeed\nsucceed succeed';

View File

@ -1,3 +1,5 @@
editor_mode = function(editor){
function editor_mode(){ function editor_mode(){
this.ids={ this.ids={
'loc':'left2', 'loc':'left2',
@ -12,8 +14,11 @@ function editor_mode(){
this.info={}; this.info={};
this.appendPic={}; this.appendPic={};
} }
editor_mode.prototype.init = function(callback){ editor_mode.prototype.init = function(callback){
if (Boolean(callback))callback();
}
editor_mode.prototype.init_dom_ids = function(callback){
Object.keys(editor_mode.ids).forEach(function(v){ Object.keys(editor_mode.ids).forEach(function(v){
editor_mode.dom[v]=document.getElementById(editor_mode.ids[v]); editor_mode.dom[v]=document.getElementById(editor_mode.ids[v]);
@ -90,7 +95,7 @@ editor_mode.prototype.checkIsLeaf = function(obj,commentObj,field){
} }
editor_mode.prototype.objToTr = function(obj,commentObj,field){ editor_mode.prototype.objToTr = function(obj,commentObj,field){
var guid = editor_mode.guid(); var guid = editor.guid();
var thiseval = eval('obj'+field); var thiseval = eval('obj'+field);
var comment = ''; var comment = '';
try { try {
@ -131,13 +136,6 @@ editor_mode.prototype.objToTd = function(thiseval,comment){
} }
} }
editor_mode.prototype.guid = function() {
return 'id_'+'xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
editor_mode.prototype.addAction = function(action){ editor_mode.prototype.addAction = function(action){
editor_mode.actionList.push(action); editor_mode.actionList.push(action);
} }
@ -147,23 +145,23 @@ editor_mode.prototype.doActionList = function(mode,actionList){
switch (mode) { switch (mode) {
case 'loc': case 'loc':
editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break; break;
case 'emenyitem': case 'emenyitem':
if (editor_mode.info.images=='enemys'){ if (editor_mode.info.images=='enemys'){
editor_file.editEnemy(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); editor.file.editEnemy(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
} else if (editor_mode.info.images=='items'){ } else if (editor_mode.info.images=='items'){
editor_file.editItem(editor,editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); editor.file.editItem(editor_mode.info.id,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
} }
break; break;
case 'floor': case 'floor':
editor_file.editFloor(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); editor.file.editFloor(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break; break;
case 'tower': case 'tower':
editor.file.editTower(editor,actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')}); editor.file.editTower(actionList,function(objs_){console.log(objs_);if(objs_.slice(-1)[0]!=null){printe(objs_.slice(-1)[0]);throw(objs_.slice(-1)[0])};printf('修改成功')});
break; break;
default: default:
break; break;
@ -186,7 +184,7 @@ editor_mode.prototype.loc = function(callback){
document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText=editor_mode.pos.x+','+editor_mode.pos.y; document.getElementById('pos_a6771a78_a099_417c_828f_0a24851ebfce').innerText=editor_mode.pos.x+','+editor_mode.pos.y;
var objs=[]; var objs=[];
editor_file.editLoc(editor,editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)}); editor.file.editLoc(editor_mode.pos.x,editor_mode.pos.y,[],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写 //只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]); var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML=tableinfo.HTML; document.getElementById('table_3d846fc4_7644_44d1_aa04_433d266a73df').innerHTML=tableinfo.HTML;
@ -209,9 +207,9 @@ editor_mode.prototype.emenyitem = function(callback){
var objs=[]; var objs=[];
if (editor_mode.info.images=='enemys'){ if (editor_mode.info.images=='enemys'){
editor_file.editEnemy(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); editor.file.editEnemy(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
} else if (editor_mode.info.images=='items'){ } else if (editor_mode.info.images=='items'){
editor_file.editItem(editor,editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)}); editor.file.editItem(editor_mode.info.id,[],function(objs_){objs=objs_;console.log(objs_)});
} else { } else {
document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML=''; document.getElementById('table_a3f03d4c_55b8_4ef6_b362_b345783acd72').innerHTML='';
return; return;
@ -226,7 +224,7 @@ editor_mode.prototype.emenyitem = function(callback){
editor_mode.prototype.floor = function(callback){ editor_mode.prototype.floor = function(callback){
var objs=[]; var objs=[];
editor_file.editFloor(editor,[],function(objs_){objs=objs_;console.log(objs_)}); editor.file.editFloor([],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写 //只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]); var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML=tableinfo.HTML; document.getElementById('table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74').innerHTML=tableinfo.HTML;
@ -236,7 +234,7 @@ editor_mode.prototype.floor = function(callback){
editor_mode.prototype.tower = function(callback){ editor_mode.prototype.tower = function(callback){
var objs=[]; var objs=[];
editor.file.editTower(editor,[],function(objs_){objs=objs_;console.log(objs_)}); editor.file.editTower([],function(objs_){objs=objs_;console.log(objs_)});
//只查询不修改时,内部实现不是异步的,所以可以这么写 //只查询不修改时,内部实现不是异步的,所以可以这么写
var tableinfo=editor_mode.objToTable(objs[0],objs[1]); var tableinfo=editor_mode.objToTable(objs[0],objs[1]);
document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML=tableinfo.HTML; document.getElementById('table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5').innerHTML=tableinfo.HTML;
@ -253,7 +251,7 @@ editor_mode.prototype.listen = function(callback){
if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){ if (newIdIdnum.children[0].value && newIdIdnum.children[1].value){
var id = newIdIdnum.children[0].value; var id = newIdIdnum.children[0].value;
var idnum = parseInt(newIdIdnum.children[1].value); var idnum = parseInt(newIdIdnum.children[1].value);
editor_file.changeIdAndIdnum(editor,id,idnum,editor_mode.info,function(err){ editor.file.changeIdAndIdnum(id,idnum,editor_mode.info,function(err){
if(err){printe(err);throw(err)} if(err){printe(err);throw(err)}
printe('添加id的idnum成功,请F5刷新编辑器'); printe('添加id的idnum成功,请F5刷新编辑器');
}); });
@ -261,7 +259,7 @@ editor_mode.prototype.listen = function(callback){
} }
var selectFloor = document.getElementById('selectFloor'); var selectFloor = document.getElementById('selectFloor');
editor_file.getFloorFileList(editor,function(floors){ editor.file.getFloorFileList(function(floors){
var outstr=[]; var outstr=[];
floors[0].forEach(function(floor){ floors[0].forEach(function(floor){
outstr.push(["<option value='",floor,"'>",floor,'</option>\n'].join('')); outstr.push(["<option value='",floor,"'>",floor,'</option>\n'].join(''));
@ -277,7 +275,7 @@ editor_mode.prototype.listen = function(callback){
var saveFloor = document.getElementById('saveFloor'); var saveFloor = document.getElementById('saveFloor');
saveFloor.onclick = function(){ saveFloor.onclick = function(){
editor_mode.onmode(''); editor_mode.onmode('');
editor_file.saveFloorFile(editor,function(err){if(err){printe(err);throw(err)}}); editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)}});
} }
var saveFloorAs = document.getElementById('saveFloorAs'); var saveFloorAs = document.getElementById('saveFloorAs');
@ -285,10 +283,10 @@ editor_mode.prototype.listen = function(callback){
saveFloorAs.onclick = function(){ saveFloorAs.onclick = function(){
if (!saveAsName.value)return; if (!saveAsName.value)return;
editor_mode.onmode(''); editor_mode.onmode('');
editor_file.saveFloorFileAs(editor,saveAsName.value,function(err){ editor.file.saveFloorFileAs(saveAsName.value,function(err){
if(err){printe(err);throw(err)} if(err){printe(err);throw(err)}
core.floorIds.push(saveAsName.value); core.floorIds.push(saveAsName.value);
editor.file.editTower(editor,[['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])}}); 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])}});
}); });
} }
@ -436,5 +434,9 @@ editor_mode.prototype.listen = function(callback){
if (Boolean(callback))callback(); if (Boolean(callback))callback();
} }
editor_mode = new editor_mode(); var editor_mode = new editor_mode();
editor_mode.init(); editor_mode.init_dom_ids();
return editor_mode;
}
//editor_mode = editor_mode(editor);

View File

@ -324,12 +324,12 @@ function hasOwnProp (obj, key) {
main.init('editor'); main.init('editor');
editor.init(function(){ editor.init(function(){
editor.pos={x: 0, y: 0}; editor.pos={x: 0, y: 0};
editor_mode.loc(); editor.mode.loc();
editor.info=editor.ids[editor.indexs[201]]; editor.info=editor.ids[editor.indexs[201]];
editor_mode.emenyitem(); editor.mode.emenyitem();
editor_mode.floor(); editor.mode.floor();
editor_mode.tower(); editor.mode.tower();
editor_mode.listen(); editor.mode.listen();
editor_blockly=editor_blockly(); editor_blockly=editor_blockly();
}); });