editor_file
This commit is contained in:
parent
cb10654e58
commit
4e102eba6c
@ -42,8 +42,6 @@ editor.util.guid()//产生一个可以作为id的长随机字符串
|
||||
|
||||
提供了以下函数进行楼层`map`数组相关的操作
|
||||
```javascript
|
||||
editor.file.getFloorFileList
|
||||
editor.file.loadFloorFile
|
||||
editor.file.saveFloorFile
|
||||
editor.file.saveFloorFileAs
|
||||
```
|
||||
|
||||
@ -53,6 +53,7 @@ editor.prototype.init = function (callback) {
|
||||
editor_file_wrapper(editor);
|
||||
editor_table_wrapper(editor);
|
||||
editor_unsorted_1_wrapper(editor);
|
||||
editor.printe=printe;
|
||||
afterMainInit();
|
||||
});
|
||||
|
||||
|
||||
@ -7,23 +7,6 @@ editor_file = function (editor, callback) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
editor.file.getFloorFileList = function (callback) {
|
||||
checkCallback(callback);
|
||||
/* var fs = editor.fs;
|
||||
fs.readdir('project/floors',function(err, data){
|
||||
callback([data,err]);
|
||||
}); */
|
||||
callback([editor.core.floorIds, null]);
|
||||
}
|
||||
//callback([Array<String>,err:String])
|
||||
editor.file.loadFloorFile = function (filename, callback) {
|
||||
//filename不含'/'不含'.js'
|
||||
checkCallback(callback);
|
||||
|
||||
editor.currentFloorId = editor.core.status.floorId;
|
||||
editor.currentFloorData = editor.core.floors[editor.currentFloorId];
|
||||
}
|
||||
//callback(err:String)
|
||||
editor.file.saveFloorFile = function (callback) {
|
||||
checkCallback(callback);
|
||||
/* if (!isset(editor.currentFloorId) || !isset(editor.currentFloorData)) {
|
||||
|
||||
@ -5,7 +5,10 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
this.replacerRecord = {}
|
||||
}
|
||||
|
||||
|
||||
//////////////////// 修改数据相关 ////////////////////
|
||||
// 三个 replacer 和 replacerRecord 暂时放在此处
|
||||
|
||||
editor_game.prototype.replacerForLoading = function (_key, value) {
|
||||
var rmap = editor.game.replacerRecord;
|
||||
if (value instanceof Function) {
|
||||
@ -29,7 +32,7 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
return value
|
||||
}
|
||||
|
||||
editor_game.prototype.getValue = function(field){
|
||||
editor_game.prototype.getValue = function (field) {
|
||||
var rmap = editor.game.replacerRecord;
|
||||
var value = eval(field)
|
||||
if (rmap.hasOwnProperty(oldval)) {
|
||||
@ -39,13 +42,13 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
}
|
||||
}
|
||||
|
||||
editor_game.prototype.setValue = function(field,value){
|
||||
editor_game.prototype.setValue = function (field, value) {
|
||||
var rmap = editor.game.replacerRecord;
|
||||
var oldval = eval(field)
|
||||
if (rmap.hasOwnProperty(oldval)) {
|
||||
rmap[value]=eval(value)
|
||||
rmap[value] = eval(value)
|
||||
} else {
|
||||
eval(field+'='+value)
|
||||
eval(field + '=' + value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +65,9 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = JSON.parse(JSON.stringify(data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d, rf));
|
||||
}
|
||||
|
||||
//////////////////// 加载游戏数据相关 ////////////////////
|
||||
|
||||
// 初始化数字与地图图块的对应
|
||||
editor_game.prototype.idsInit = function (maps, icons) {
|
||||
editor.ids = [0];
|
||||
editor.indexs = [];
|
||||
@ -125,6 +131,7 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前地图
|
||||
editor_game.prototype.fetchMapFromCore = function () {
|
||||
var mapArray = core.maps.saveMap(core.status.floorId);
|
||||
editor.map = mapArray.map(function (v) {
|
||||
@ -158,6 +165,16 @@ editor_game_wrapper = function (editor, main, core) {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取地图列表
|
||||
editor_game.prototype.getFloorFileList = function (callback) {
|
||||
// callback([Array<String>,err:String])
|
||||
editor.util.checkCallback(callback);
|
||||
/* editor.fs.readdir('project/floors',function(err, data){
|
||||
callback([data,err]);
|
||||
}); */
|
||||
callback([editor.core.floorIds, null]);
|
||||
}
|
||||
|
||||
editor.constructor.prototype.game = new editor_game();
|
||||
}
|
||||
//editor_game_wrapper(editor);
|
||||
@ -37,7 +37,7 @@ editor_unsorted_2_wrapper=function(editor_mode){
|
||||
}
|
||||
|
||||
var selectFloor = document.getElementById('selectFloor');
|
||||
editor.file.getFloorFileList(function (floors) {
|
||||
editor.game.getFloorFileList(function (floors) {
|
||||
var outstr = [];
|
||||
floors[0].forEach(function (floor) {
|
||||
outstr.push(["<option value='", floor, "'>", floor, '</option>\n'].join(''));
|
||||
|
||||
@ -157,6 +157,17 @@ editor_util_wrapper = function (editor) {
|
||||
}).join(''))
|
||||
}
|
||||
|
||||
editor_util.prototype.isset = function (val) {
|
||||
return val != null && !(typeof val == 'number' && isNaN(val));
|
||||
}
|
||||
|
||||
editor_util.prototype.checkCallback=function(callback){
|
||||
if (!editor.util.isset(callback)) {
|
||||
editor.printe('未设置callback');
|
||||
throw('未设置callback')
|
||||
}
|
||||
}
|
||||
|
||||
editor.constructor.prototype.util = new editor_util();
|
||||
}
|
||||
//editor_util_wrapper(editor);
|
||||
@ -10,9 +10,9 @@
|
||||
+ [ ] editor_blockly 图块化事件编辑器
|
||||
+ [ ] editor_multi 多行文本编辑器
|
||||
+ [x] editor_table 处理表格的生成, 及其响应的事件, 从原editor\_mode中分离
|
||||
+ [ ] editor_file 调用fs.js编辑文件, 把原editor\_file模块化
|
||||
+ [ ] editor_game 处理来自core的数据, 导入为editor的数据, 从原editor中分离. **只有此文件允许`\s(main|core)`形式的调用**(以及其初始化`editor_game_wrapper(editor, main, core);`)
|
||||
+ [x] editor_util 生成guid等函数, 从editor分离
|
||||
+ [ ] editor_file 调用fs.js编辑文件, 把原editor\_file模块化, 并且只负责文件写入
|
||||
+ [ ] editor_game 处理游戏数据, 导入为editor的数据, 编辑数据, 从原editor和editor_file中抽离. **只有此文件允许`\s(main|core)`形式的调用**(以及其初始化`editor_game_wrapper(editor, main, core);`)
|
||||
+ [x] editor_util 生成guid/处理颜色 等函数, 从editor分离
|
||||
+ [ ] editor 执行初始化流程加组合各组件
|
||||
+ [ ] 原editor_mode 移除
|
||||
+ [x] 原vm 移除
|
||||
|
||||
Loading…
Reference in New Issue
Block a user